MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / zEntHangable_SetMatrix

Function zEntHangable_SetMatrix

src/SB/Game/zEntHangable.cpp:320–427  ·  view source on GitHub ↗

Equivalent: scheduling.

Source from the content-addressed store, hash-verified

318
319// Equivalent: scheduling.
320void zEntHangable_SetMatrix(zEntHangable* ent, F32 dt)
321{
322 xMat4x3 spinMat;
323 xMat3x3 tmpMat;
324 S32 moving;
325 xVec3* opos;
326 xVec3* pos;
327 xVec3* orot;
328 xVec3 rot;
329
330 xVec3Sub(&spinMat.up, &ent->pivot, &ent->endpos);
331 xVec3Normalize(&spinMat.up, &spinMat.up);
332
333 opos = &spinMat.at;
334 opos->x = 0.0f;
335 opos->y = 0.0f;
336 opos->z = 1.0f;
337
338 xVec3Cross(&spinMat.right, &spinMat.up, opos);
339 xVec3Normalize(&spinMat.right, &spinMat.right);
340 xMat3x3RotC(&tmpMat, spinMat.up.x, spinMat.up.y, spinMat.up.z, ent->spin);
341 xMat3x3RMulVec(&spinMat.right, &tmpMat, &spinMat.right);
342 xVec3Cross(opos, &spinMat.right, &spinMat.up);
343
344 spinMat.pos.x = 0.0f;
345 spinMat.pos.y = -ent->hangInfo->pivotOffset;
346 spinMat.pos.z = 0.0f;
347
348 xMat3x3RMulVec(&spinMat.pos, &spinMat, &spinMat.pos);
349
350 spinMat.pos.x += ent->pivot.x;
351 spinMat.pos.y += ent->pivot.y;
352 spinMat.pos.z += ent->pivot.z;
353 spinMat.flags = 0;
354
355 *(xMat4x3*)(ent->model->Mat) = *(xMat4x3*)(&spinMat);
356
357 opos = &ent->frame->oldmat.pos;
358 orot = &ent->frame->oldrot.axis;
359 pos = (xVec3 *)&ent->model->Mat->pos;
360 xMat3x3GetEuler((xMat3x3*)ent->model->Mat, &rot);
361
362 if
363 (
364 (opos->x != pos->x) || (opos->y != pos->y) || (opos->z != pos->z) ||
365 (orot->x != rot.x) || (orot->y != rot.y) || (orot->z != rot.z)
366 )
367 {
368 moving = 1;
369 if (ent->moving != 1)
370 {
371 zEntEvent((xBase *)ent, eEventStartMoving);
372 }
373 }
374 else
375 {
376 moving = 0;
377 if (ent->moving != 0)

Callers 1

zEntHangable_UpdateFunction · 0.70

Calls 9

xVec3SubFunction · 0.85
xVec3CrossFunction · 0.85
HangableIsMovingTooMuchFunction · 0.85
xurandFunction · 0.85
xVec3NormalizeFunction · 0.50
xMat3x3RotCFunction · 0.50
xMat3x3RMulVecFunction · 0.50
xMat3x3GetEulerFunction · 0.50
zEntEventFunction · 0.50

Tested by

no test coverage detected