MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / UpdateItemAnimations

Method UpdateItemAnimations

TombEngine/Renderer/RendererHelper.cpp:161–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159 }
160
161 void Renderer::UpdateItemAnimations(int itemNumber, bool force)
162 {
163 auto* itemToDraw = &_items[itemNumber];
164 auto* nativeItem = &g_Level.Items[itemNumber];
165
166 // TODO: hack for fixing a bug, check again if needed
167 itemToDraw->ItemNumber = itemNumber;
168
169 // Lara has her own routine
170 if (nativeItem->ObjectNumber == ID_LARA)
171 return;
172
173 // Has been already done?
174 if (!force && itemToDraw->DoneAnimations)
175 return;
176
177 itemToDraw->DoneAnimations = true;
178
179 auto* obj = &Objects[nativeItem->ObjectNumber];
180
181 if (!obj->loaded)
182 {
183 TENLog("Attempted to animate nonexistent object " + GetObjectName((GAME_OBJECT_ID)nativeItem->ObjectNumber), LogLevel::Error);
184 return;
185 }
186
187 auto& moveableObj = *_moveableObjects[nativeItem->ObjectNumber];
188
189 // Copy meshswaps
190 itemToDraw->MeshIndex = nativeItem->Model.MeshIndex;
191 itemToDraw->SkinIndex = nativeItem->Model.SkinIndex;
192
193 if (obj->Animations.empty())
194 return;
195
196 // Apply extra rotations
197 int lastJoint = 0;
198 for (int j = 0; j < moveableObj.LinearizedBones.size(); j++)
199 {
200 auto* currentBone = moveableObj.LinearizedBones[j];
201
202 auto prevRotation = currentBone->ExtraRotation;
203 currentBone->ExtraRotation = Quaternion::Identity;
204
205 nativeItem->Data.apply(
206 [&j, &currentBone](QuadBikeInfo& quadBike)
207 {
208 if (j == 3 || j == 4)
209 {
210 currentBone->ExtraRotation = EulerAngles(quadBike.RearRot, 0, 0).ToQuaternion();
211 }
212 else if (j == 6 || j == 7)
213 {
214 currentBone->ExtraRotation = EulerAngles(quadBike.FrontRot, quadBike.TurnRate * 2, 0).ToQuaternion();
215 }
216 },
217 [&j, &currentBone](JeepInfo& jeep)
218 {

Callers 1

AnimateItemFunction · 0.80

Calls 9

TENLogFunction · 0.85
ANGLEFunction · 0.85
FROM_RADFunction · 0.85
GetFrameInterpDataFunction · 0.85
EulerAnglesClass · 0.70
emptyMethod · 0.45
sizeMethod · 0.45
applyMethod · 0.45
ToQuaternionMethod · 0.45

Tested by

no test coverage detected