Skip to content

Commit 8f3e9ad

Browse files
committed
Fix Prefab duplicate not correctly copying UID
1 parent f7df599 commit 8f3e9ad

File tree

8 files changed

+55
-44
lines changed

8 files changed

+55
-44
lines changed

Diff for: Editor.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Root>
22
<Object class="EditorOptions">
3-
<Property type="Uint32" name="m_uid" flags="Debug|Hexadecimal" value="0"/>
3+
<Property type="Uint32" name="m_uid" flags="Debug|Hexadecimal" value="3465924071"/>
4+
<Property type="Uint32" name="m_originalUID" flags="Debug|Hexadecimal" value="0"/>
45
<Property type="String" name="m_name" flags="NotVisible" value="Editor Options"/>
56
<Property type="EnumFlagsU32" name="m_objectFlags" flags="Debug|Bitfield" value=""/>
67
<Property type="EnumU8" name="m_theme" value="VimontGames_Dark"/>

Diff for: data/Scenes/Aiguelongue.scene

+29-23
Original file line numberDiff line numberDiff line change
@@ -2296,7 +2296,7 @@
22962296
<Property type="Uint32" name="m_uid" flags="Debug|Hexadecimal" value="1638339078"/>
22972297
<Property type="Uint32" name="m_originalUID" flags="Debug|Hexadecimal" value="0"/>
22982298
<Property type="String" name="m_name" value="Ennemies"/>
2299-
<Property type="EnumFlagsU32" name="m_objectFlags" flags="Debug|Bitfield" value=""/>
2299+
<Property type="EnumFlagsU32" name="m_objectFlags" flags="Debug|Bitfield" value="Opened"/>
23002300
<Property type="EnumFlagsU32" name="m_flags" flags="Bitfield" value="Enabled"/>
23012301
<Property type="Float4" name="m_color" flags="Color" x="1" y="1" z="1" w="1"/>
23022302
<Property type="Float4x4" name="m_local" Ix="1" Iy="0" Iz="0" Iw="0" Jx="0" Jy="1" Jz="0" Jw="0" Kx="0" Ky="0" Kz="1" Kw="0" Tx="0" Ty="0" Tz="0" Tw="1"/>
@@ -2305,7 +2305,7 @@
23052305
<Object class="PrefabGameObject">
23062306
<Property type="Uint32" name="m_uid" flags="Debug|Hexadecimal" value="1553459387"/>
23072307
<Property type="Uint32" name="m_originalUID" flags="Debug|Hexadecimal" value="0"/>
2308-
<Property type="String" name="m_name" value="GJ"/>
2308+
<Property type="String" name="m_name" value="GJ_Red_Prefab"/>
23092309
<Property type="EnumFlagsU32" name="m_objectFlags" flags="Debug|Bitfield" value="Opened|Prefab"/>
23102310
<Property type="EnumFlagsU32" name="m_flags" flags="Bitfield" value="Enabled"/>
23112311
<Property type="Float4" name="m_color" flags="Color" x="1" y="1" z="1" w="1"/>
@@ -2334,39 +2334,45 @@
23342334
<Property type="String" name="m_name" flags="NotVisible" value="m_color"/>
23352335
<Property type="EnumFlagsU32" name="m_objectFlags" flags="Debug|Bitfield" value=""/>
23362336
<Property type="Bool" name="m_enable" value="true"/>
2337-
<Property type="Float4" name="m_value" x="1" y="0.57740581" z="0" w="1"/>
2337+
<Property type="Float4" name="m_value" x="0.97071129" y="0.056861762" z="0.24039628" w="0"/>
23382338
</Object>
23392339
</Property>
23402340
</Object>
2341-
<Object class="DynamicPropertyList">
2342-
<Property type="Uint32" name="m_uid" flags="Debug|Hexadecimal" value="2637626638"/>
2343-
<Property type="Uint32" name="m_originalUID" flags="Debug|Hexadecimal" value="0"/>
2344-
<Property type="String" name="m_name" flags="NotVisible" value="CapsuleShapeDesc #8"/>
2341+
</Property>
2342+
</Object>
2343+
<Object class="PrefabGameObject">
2344+
<Property type="Uint32" name="m_uid" flags="Debug|Hexadecimal" value="3094291699"/>
2345+
<Property type="Uint32" name="m_originalUID" flags="Debug|Hexadecimal" value="1553459387"/>
2346+
<Property type="String" name="m_name" value="GJ_Blue_Prefab"/>
2347+
<Property type="EnumFlagsU32" name="m_objectFlags" flags="Debug|Bitfield" value="Opened|Prefab"/>
2348+
<Property type="EnumFlagsU32" name="m_flags" flags="Bitfield" value="Enabled"/>
2349+
<Property type="Float4" name="m_color" flags="Color" x="1" y="1" z="1" w="1"/>
2350+
<Property type="Float4x4" name="m_local" Ix="0.0008334259" Iy="-0.99999958" Iz="0" Iw="0" Jx="0.99999958" Jy="0.0008334259" Jz="0" Jw="0" Kx="0" Ky="0" Kz="1" Kw="0" Tx="11.5" Ty="0" Tz="0" Tw="1"/>
2351+
<Property type="ObjectPtrVector" name="m_components"/>
2352+
<Property type="ObjectPtrVector" name="m_children" flags="NotVisible"/>
2353+
<Property type="Resource" name="m_prefabResource" flags="Resource">
2354+
<Object class="PrefabResource">
2355+
<Property type="Uint32" name="m_uid" flags="Debug|Hexadecimal" value="704174967"/>
2356+
<Property type="Uint32" name="m_originalUID" flags="Debug|Hexadecimal" value="2010269170"/>
2357+
<Property type="String" name="m_name" flags="NotVisible" value=""/>
23452358
<Property type="EnumFlagsU32" name="m_objectFlags" flags="Debug|Bitfield" value=""/>
2346-
<Property type="ObjectPtrVector" name="m_properties">
2347-
<Object class="DynamicPropertyFloat">
2348-
<Property type="Uint32" name="m_uid" flags="Debug|Hexadecimal" value="2613471442"/>
2349-
<Property type="Uint32" name="m_originalUID" flags="Debug|Hexadecimal" value="0"/>
2350-
<Property type="String" name="m_name" flags="NotVisible" value="m_radius"/>
2351-
<Property type="EnumFlagsU32" name="m_objectFlags" flags="Debug|Bitfield" value=""/>
2352-
<Property type="Bool" name="m_enable" value="false"/>
2353-
<Property type="Float" name="m_value" value="1"/>
2354-
</Object>
2355-
</Property>
2359+
<Property type="String" name="m_resourcePath" flags="NotVisible" value="data/Prefabs/GJ.prefab"/>
23562360
</Object>
2361+
</Property>
2362+
<Property type="ObjectPtrVector" name="m_dynamicProperties" flags="Debug">
23572363
<Object class="DynamicPropertyList">
2358-
<Property type="Uint32" name="m_uid" flags="Debug|Hexadecimal" value="4120299909"/>
2364+
<Property type="Uint32" name="m_uid" flags="Debug|Hexadecimal" value="3525072167"/>
23592365
<Property type="Uint32" name="m_originalUID" flags="Debug|Hexadecimal" value="0"/>
2360-
<Property type="String" name="m_name" flags="NotVisible" value="MeshComponent #37"/>
2366+
<Property type="String" name="m_name" flags="NotVisible" value="GJ"/>
23612367
<Property type="EnumFlagsU32" name="m_objectFlags" flags="Debug|Bitfield" value=""/>
23622368
<Property type="ObjectPtrVector" name="m_properties">
2363-
<Object class="DynamicPropertyBool">
2369+
<Object class="DynamicPropertyFloat4">
23642370
<Property type="Uint32" name="m_uid" flags="Debug|Hexadecimal" value="0"/>
2365-
<Property type="Uint32" name="m_originalUID" flags="Debug|Hexadecimal" value="0"/>
2366-
<Property type="String" name="m_name" flags="NotVisible" value="m_displayBones"/>
2371+
<Property type="Uint32" name="m_originalUID" flags="Debug|Hexadecimal" value="977322677"/>
2372+
<Property type="String" name="m_name" flags="NotVisible" value="m_color"/>
23672373
<Property type="EnumFlagsU32" name="m_objectFlags" flags="Debug|Bitfield" value=""/>
23682374
<Property type="Bool" name="m_enable" value="true"/>
2369-
<Property type="Bool" name="m_value" value="true"/>
2375+
<Property type="Float4" name="m_value" x="0" y="0.058577538" z="1" w="0"/>
23702376
</Object>
23712377
</Property>
23722378
</Object>

Diff for: src/core/IObject.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ namespace vg::core
3636
virtual bool HasValidUID () const = 0;
3737

3838
virtual UID GetUID (bool _mustBeValid = true) const = 0;
39-
virtual void SetUID (UID _uid) = 0;
39+
virtual void SetUID (UID _uid) = 0;
40+
virtual bool CanCopyUID () const = 0;
4041

4142
virtual UID GetOriginalUID (bool _mustBeValid = true) const = 0;
4243
virtual void SetOriginalUID (UID _uid) = 0;

Diff for: src/core/Object/DynamicProperties/DynamicPropertyList.h

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace vg::core
1414
~DynamicPropertyList();
1515

1616
bool RegisterUID();
17+
bool CanCopyUID() const final override { return true; }
1718
const IDynamicProperty * GetProperty(const IProperty * _prop) const override;
1819

1920
core::vector<DynamicProperty*> m_properties;

Diff for: src/core/Object/DynamicProperties/DynamicPropertyList.hpp

+3-15
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,16 @@ namespace vg::core
99
{
1010
super::registerProperties(_desc);
1111

12-
//registerProperty(DynamicPropertyList, m_uid, "UID");
13-
//registerProperty(DynamicPropertyList, m_name, "Name");
14-
1512
registerPropertyObjectPtrVector(DynamicPropertyList, m_properties, "Properties");
1613

1714
return true;
1815
}
1916

2017
//--------------------------------------------------------------------------------------
21-
DynamicPropertyList::DynamicPropertyList(const core::string & _name, core::IObject * _parent)
18+
DynamicPropertyList::DynamicPropertyList(const core::string & _name, core::IObject * _parent) :
19+
super(_name, _parent)
2220
{
23-
21+
2422
}
2523

2624
//--------------------------------------------------------------------------------------
@@ -50,16 +48,6 @@ namespace vg::core
5048
}
5149
}
5250

53-
//for (uint i = 0; i < m_properties.size(); ++i)
54-
//{
55-
// const auto & prop = m_properties[i];
56-
//
57-
// if (prop->getType() == IProperty::Type::Resource)
58-
// {
59-
//
60-
// }
61-
//}
62-
6351
return nullptr;
6452
}
6553
}

Diff for: src/core/Object/Factory.cpp

+16-4
Original file line numberDiff line numberDiff line change
@@ -441,17 +441,29 @@ namespace vg::core
441441

442442
if (!strcmp(_srcProp->getName(), "m_uid"))
443443
{
444+
// In case of DynamicPropertyList the UID must be copied (TODO: use explicit member for different usage?)
445+
const bool canCopyUID = _srcObj->CanCopyUID();
446+
444447
if (_srcObj->HasValidUID())
445448
{
446-
_dstObj->SetOriginalUID(_srcObj->GetUID());
447-
_dstObj->RegisterUID();
449+
if (!canCopyUID)
450+
{
451+
if (_srcObj->GetOriginalUID(false)) // equivalent to HasValidOriginalUID
452+
_dstObj->SetOriginalUID(_srcObj->GetOriginalUID());
453+
else
454+
_dstObj->SetOriginalUID(_srcObj->GetUID());
455+
456+
_dstObj->RegisterUID();
457+
}
448458
}
449-
return true;
459+
460+
if (!canCopyUID)
461+
return true;
450462
}
451463
else if(!strcmp(_srcProp->getName(), "m_originalUID"))
452464
{
453465
return false;
454-
}
466+
}
455467

456468
switch (srcPropType)
457469
{

Diff for: src/core/Object/Object.h

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ namespace vg::core
5353

5454
UID GetUID (bool _mustBeValid = true) const final override;
5555
void SetUID (UID _uid) override;
56+
bool CanCopyUID () const override { return false; }
5657

5758
UID GetOriginalUID (bool _mustBeValid = true) const final override;
5859
void SetOriginalUID (UID _uid) final override;

Diff for: src/engine/GameObject/Prefab/PrefabGameObject.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ namespace vg::engine
105105
// TODO : dedicated ctor?
106106
newPropList = new DynamicPropertyList(_object->getName(), nullptr);
107107
newPropList->SetUID(_object->GetOriginalUID());
108+
newPropList->SetOriginalUID(0x0);
108109
newPropList->setName(_object->getName());
109110

110111
return newPropList;

0 commit comments

Comments
 (0)