-
Notifications
You must be signed in to change notification settings - Fork 4
/
dummy.cpp
103 lines (89 loc) · 2.76 KB
/
dummy.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include "dummy.h"
#include "environment.h"
CDummy::CDummy()
{
_objectType=ik_objecttype_dummy;
_objectName="dummy";
_targetDummyHandle=-1;
_linkedDummyHandle_old=-1; // backward compatibility
}
CDummy::~CDummy()
{
}
bool CDummy::announceSceneObjectWillBeErased(int objectHandle)
{
announceSceneObjectWillBeErasedMain(objectHandle);
if (_targetDummyHandle==objectHandle)
_targetDummyHandle=-1;
// backward compatibility:
if (_linkedDummyHandle_old==objectHandle)
setLinkedDummyHandle_old(-1,false);
return(false);
}
void CDummy::announceIkGroupWillBeErased(int ikGroupHandle)
{
announceIkGroupWillBeErasedMain(ikGroupHandle);
}
void CDummy::performSceneObjectLoadingMapping(const std::vector<int>* map)
{
performSceneObjectLoadingMappingMain(map);
_linkedDummyHandle_old=_getLoadingMapping(map,_linkedDummyHandle_old); // backward compatibility
_targetDummyHandle=_getLoadingMapping(map,_targetDummyHandle);
}
void CDummy::serialize(CSerialization& ar)
{
serializeMain(ar);
if (ar.isWriting())
{
ar.writeInt(_targetDummyHandle);
ar.writeInt(_targetDummyHandle); // previously link type
}
else
{
_targetDummyHandle=ar.readInt();
ar.readInt(); // previously link type
}
}
CSceneObject* CDummy::copyYourself() const
{
CDummy* duplicate=(CDummy*)CSceneObject::copyYourself();
duplicate->_linkedDummyHandle_old=_linkedDummyHandle_old; // backward compatibility
duplicate->_targetDummyHandle=_targetDummyHandle;
return(duplicate);
}
int CDummy::getTargetDummyHandle() const
{
return(_targetDummyHandle);
}
void CDummy::setTargetDummyHandle(int theHandle)
{
if (_targetDummyHandle!=theHandle)
_targetDummyHandle=theHandle;
}
int CDummy::getLinkedDummyHandle_old() const
{ // backward compatibility
return(_linkedDummyHandle_old);
}
void CDummy::setLinkedDummyHandle_old(int theHandle,bool setDirectly)
{ // backward compatibility
if (_linkedDummyHandle_old!=theHandle)
{
if (setDirectly)
_linkedDummyHandle_old=theHandle;
else
{
CDummy* oldLinkedDummy=CEnvironment::currentEnvironment->objectContainer->getDummy(_linkedDummyHandle_old);
if (oldLinkedDummy!=nullptr)
oldLinkedDummy->setLinkedDummyHandle_old(-1,true);
CDummy* newLinkedDummy=CEnvironment::currentEnvironment->objectContainer->getDummy(theHandle);
if (newLinkedDummy!=nullptr)
{
newLinkedDummy->setLinkedDummyHandle_old(-1,false);
_linkedDummyHandle_old=theHandle;
newLinkedDummy->setLinkedDummyHandle_old(_objectHandle,true);
}
else
_linkedDummyHandle_old=-1;
}
}
}