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

Function TurnToFace

src/SB/Game/zEntPlayer.cpp:492–518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

490}
491
492static void TurnToFace(xEnt* ent, const xVec3* target, F32 speedLimit, F32 dt)
493{
494 xVec3 currentFacing = ent->frame->mat.at;
495 xVec3Normalize(&currentFacing, &currentFacing);
496
497 F32 angle = xVec3Dot(&currentFacing, target);
498 const F32 maxAngle = 0.9999f;
499 if (angle < maxAngle)
500 {
501 xVec3Cross(&ent->frame->drot.axis, &currentFacing, target);
502 xVec3Normalize(&ent->frame->drot.axis, &ent->frame->drot.axis);
503
504 angle = xacos(angle);
505 if (angle > speedLimit * dt)
506 {
507 angle = speedLimit * dt;
508 }
509
510 if (ent->frame->drot.axis.y < 0.0f)
511 {
512 angle = -angle;
513 }
514
515 ent->frame->drot.angle = angle;
516 ent->frame->mode |= 0x20;
517 }
518}
519
520void PlayerArrive(xEnt* ent, xBase* base)
521{

Callers

nothing calls this directly

Calls 3

xVec3CrossFunction · 0.85
xacosFunction · 0.85
xVec3NormalizeFunction · 0.50

Tested by

no test coverage detected