Isle
Loading...
Searching...
No Matches
legohideanimpresenter.cpp
Go to the documentation of this file.
2
3#include "anim/legoanim.h"
4#include "legomain.h"
5#include "legoworld.h"
6#include "misc.h"
7
10
11// FUNCTION: LEGO1 0x1006d7e0
13{
14 Init();
15}
16
17// FUNCTION: LEGO1 0x1006d9f0
19{
21}
22
23// FUNCTION: LEGO1 0x1006da50
24void LegoHideAnimPresenter::Init()
25{
26 m_boundaryMap = NULL;
27}
28
29// FUNCTION: LEGO1 0x1006da60
30void LegoHideAnimPresenter::Destroy(MxBool p_fromDestructor)
31{
33
34 if (m_boundaryMap) {
35 delete[] m_boundaryMap;
36 }
37 Init();
38
40
41 // This appears to be a bug, since it results in an endless loop
42 if (!p_fromDestructor) {
44 }
45}
46
47// FUNCTION: LEGO1 0x1006dab0
49{
51}
52
53// FUNCTION: LEGO1 0x1006dac0
55{
57}
58
59// FUNCTION: LEGO1 0x1006dad0
61{
62}
63
64// FUNCTION: LEGO1 0x1006dae0
65// FUNCTION: BETA10 0x100530f4
67{
69
70 if (m_currentWorld) {
73 }
74
75 m_currentWorld->Add(this);
76 }
77}
78
79// FUNCTION: LEGO1 0x1006db20
80// FUNCTION: BETA10 0x1005316b
82{
84
86 FUN_1006dc10();
87 FUN_1006db40(0);
88 }
89}
90
91// FUNCTION: LEGO1 0x1006db40
92// FUNCTION: BETA10 0x100531ab
94{
95 FUN_1006db60(m_anim->GetRoot(), p_time);
96}
97
98// FUNCTION: LEGO1 0x1006db60
99// FUNCTION: BETA10 0x100531de
100void LegoHideAnimPresenter::FUN_1006db60(LegoTreeNode* p_node, LegoTime p_time)
101{
102 LegoAnimNodeData* data = (LegoAnimNodeData*) p_node->GetData();
103 MxBool newB = FALSE;
104 MxBool previousB = FALSE;
105
106 if (m_roiMap != NULL) {
107 LegoROI* roi = m_roiMap[data->GetUnknown0x20()];
108
109 if (roi != NULL) {
110 newB = data->FUN_100a0990(p_time);
111 previousB = roi->GetVisibility();
112 roi->SetVisibility(newB);
113 }
114 }
115
116 if (m_boundaryMap != NULL) {
117 LegoPathBoundary* boundary = m_boundaryMap[data->GetUnknown0x22()];
118
119 if (boundary != NULL) {
120 newB = data->FUN_100a0990(p_time);
121 previousB = boundary->GetFlag0x10();
122 boundary->SetFlag0x10(newB);
123 }
124 }
125
126 for (MxS32 i = 0; i < p_node->GetNumChildren(); i++) {
127 FUN_1006db60(p_node->GetChild(i), p_time);
128 }
129}
130
131// FUNCTION: LEGO1 0x1006dc10
132// FUNCTION: BETA10 0x100532fd
133void LegoHideAnimPresenter::FUN_1006dc10()
134{
136
137 FUN_1006e3f0(anims, m_anim->GetRoot());
138
139 if (m_boundaryMap != NULL) {
140 delete[] m_boundaryMap;
141 }
142
143 m_boundaryMap = new LegoPathBoundary*[anims.size() + 1];
144 m_boundaryMap[0] = NULL;
145
146 for (LegoHideAnimStructMap::iterator it = anims.begin(); !(it == anims.end()); it++) {
147 m_boundaryMap[(*it).second.m_index] = (*it).second.m_boundary;
148 delete[] const_cast<char*>((*it).first);
149 }
150}
151
152// FUNCTION: LEGO1 0x1006e3f0
153// FUNCTION: BETA10 0x1005345e
154void LegoHideAnimPresenter::FUN_1006e3f0(LegoHideAnimStructMap& p_map, LegoTreeNode* p_node)
155{
156 LegoAnimNodeData* data = (LegoAnimNodeData*) p_node->GetData();
157 const char* name = data->GetName();
158
159 if (name != NULL) {
161
162 if (boundary != NULL) {
163 FUN_1006e470(p_map, data, name, boundary);
164 }
165 else {
166 data->SetUnknown0x22(0);
167 }
168 }
169
170 MxS32 count = p_node->GetNumChildren();
171 for (MxS32 i = 0; i < count; i++) {
172 FUN_1006e3f0(p_map, p_node->GetChild(i));
173 }
174}
175
176// FUNCTION: LEGO1 0x1006e470
177// FUNCTION: BETA10 0x10053520
178void LegoHideAnimPresenter::FUN_1006e470(
180 LegoAnimNodeData* p_data,
181 const char* p_name,
182 LegoPathBoundary* p_boundary
183)
184{
185 LegoHideAnimStructMap::iterator it;
186
187 it = p_map.find(p_name);
188 if (it == p_map.end()) {
189 LegoHideAnimStruct animStruct;
190 animStruct.m_index = p_map.size() + 1;
191 animStruct.m_boundary = p_boundary;
192
193 p_data->SetUnknown0x22(animStruct.m_index);
194
195 char* name = new char[strlen(p_name) + 1];
196 strcpy(name, p_name);
197
198 p_map[name] = animStruct;
199 }
200 else {
201 p_data->SetUnknown0x22((*it).second.m_index);
202 }
203}
204
205// FUNCTION: LEGO1 0x1006e9e0
206// FUNCTION: BETA10 0x100535ef
208{
209 if (m_action) {
211
212 if (m_currentWorld) {
213 m_currentWorld->Remove(this);
214 }
215 }
216}
[AI] Holds per-node animation data for a model's animation tree.
Definition: legoanim.h:144
void SetUnknown0x22(LegoU16 p_unk0x22)
[AI] Sets unknown parameter (possibly camera/scene state).
Definition: legoanim.h:201
LegoBool FUN_100a0990(LegoFloat p_time)
[AI] Evaluates morph keys at the given animation time and returns result (typically affects mesh shap...
Definition: legoanim.cpp:923
LegoU16 GetUnknown0x20()
[AI] Unknown, used in scene/camera calculations (purpose unclear).
Definition: legoanim.h:180
LegoChar * GetName()
[AI] Name of this animation node (used for lookup/mapping to scene graph).
Definition: legoanim.h:163
LegoU16 GetUnknown0x22()
[AI] Unknown, used in scene/camera calculations (purpose unclear).
Definition: legoanim.h:181
void StartingTickle() override
[AI] Called at the "Starting" tickle state.
LegoAnim * m_anim
[AI] Animation resource currently being played back.
void ReadyTickle() override
[AI] Called when the presenter is in the "Ready" tickle state.
LegoROI ** m_roiMap
[AI] Lookup array to map animation node indices to scene ROIs (1-based index).
MxResult AddToManager() override
[AI] Adds this presenter instance to the relevant presenter/notification manager.
LegoWorld * m_currentWorld
[AI] Reference to the world in which this presenter is currently placed/active.
[AI] Presenter class responsible for controlling animations that hide or show actors based on animati...
void StartingTickle() override
[AI] Called during the Starting state tick; if streaming state is reached, prepares boundary mappings...
~LegoHideAnimPresenter() override
[AI] Destructor. Destroys presenter and cleans up boundary mapping.
void ReadyTickle() override
[AI] Called when presenter is in the Ready state; maps boundaries to animation nodes and adds present...
void EndAction() override
[AI] Called when the associated DSAction has ended, cleans up and removes presenter from the world.
void PutFrame() override
[AI] Advances the animation by one frame (no-op here; implemented in other presenter classes).
MxResult AddToManager() override
[AI] Adds the presenter to the tickle manager; delegates to base animation presenter registration.
void Destroy() override
[AI] Destroys the presenter, optionally from destructor; cleans up resources and removes from world.
void FUN_1006db40(LegoTime p_time)
[AI] Traverses the animation node hierarchy starting at the root and synchronizes visibility flags fo...
[AI] Represents a path segment or boundary in the navigation network for actors (vehicles,...
[AI] Represents a Real-time Object Instance enriched with LEGO-specific functionality.
Definition: legoroi.h:43
[AI] Represents a node within a general, N-ary tree structure.
Definition: legotree.h:44
LegoTreeNodeData * GetData()
[AI] Returns the data payload stored at this node (may be nullptr). [AI]
Definition: legotree.h:54
LegoU32 GetNumChildren()
[AI] Returns the number of direct children of this node. [AI]
Definition: legotree.h:63
LegoTreeNode * GetChild(LegoU32 p_i)
[AI] Gets the child node at the specified index (no bounds checking).
Definition: legotree.h:72
LegoTreeNode * GetRoot()
[AI] Returns a pointer to the root node of the tree. [AI]
Definition: legotree.h:112
LegoU32 GetFlag0x10()
Returns TRUE if the 'disabled' flag is not set, otherwise FALSE.
Definition: legowegedge.h:57
void SetFlag0x10(LegoU32 p_disable)
[AI] Sets the enabled/disabled flag for this edge.
Definition: legowegedge.h:85
void Remove(MxCore *p_object)
Removes an object from all relevant world-managed lists or sets, and also detaches if needed.
Definition: legoworld.cpp:508
virtual void Add(MxCore *p_object)
Adds an object (entity, presenter, ROI, etc.) to the appropriate world-managed list or set.
Definition: legoworld.cpp:418
LegoPathBoundary * FindPathBoundary(const char *p_name)
Finds a path boundary in all path controllers by name.
Definition: legoworld.cpp:385
void Enter()
[AI] Acquires/gains entry to the critical section or mutex, blocking if not available.
void Leave()
[AI] Releases/leaves the critical section or mutex.
MxDSAction * m_action
[AI] The associated action currently being presented by this presenter.
Definition: mxpresenter.h:211
TickleState m_currentTickleState
[AI] Current state in the tickle lifecycle.
Definition: mxpresenter.h:199
@ e_starting
[AI] In the process of starting playback/presentation.
Definition: mxpresenter.h:26
@ e_streaming
[AI] Streaming or rendering actively.
Definition: mxpresenter.h:27
MxCriticalSection m_criticalSection
[AI] Thread synchronization for presenter state and data.
Definition: mxpresenter.h:214
MxCompositePresenter * m_compositePresenter
[AI] Owner composite presenter, if any.
Definition: mxpresenter.h:217
void SendToCompositePresenter(MxOmni *p_omni)
[AI] Notifies a composite presenter (if one exists) that this presenter wishes to join a group.
void EndAction() override
Signals the end of the current playback action.
unsigned char GetVisibility()
[AI] Returns the visibility flag; true if visible, false if hidden.
Definition: roi.h:228
void SetVisibility(unsigned char p_visible)
[AI] Sets the visibility flag to the provided value.
Definition: roi.h:235
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
map< const char *, LegoHideAnimStruct, LegoHideAnimStructComparator > LegoHideAnimStructMap
[AI] Map associating string (name) keys to LegoHideAnimStruct, using custom comparator for C strings.
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
LegoS32 LegoTime
[AI] Time value, typically used for tick counts, durations, or timing; defined as a signed 32-bit int...
Definition: legotypes.h:95
LegoOmni * Lego()
[AI] Retrieves the global LegoOmni singleton instance, providing access to core subsystems.
Definition: misc.cpp:16
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
signed int MxS32
[AI]
Definition: mxtypes.h:38
[AI] Structure associating a path boundary with an index.
LegoPathBoundary * m_boundary
[AI] Pointer to a LegoPathBoundary found by name from animation node
MxU32 m_index
[AI] Index assigned to this boundary in the map and used for node-to-boundary association