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

Method face_camera

src/SB/Game/zEntCruiseBubble.cpp:2747–2780  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2745 }
2746
2747 void cruise_bubble::state_player_aim::face_camera(F32 dt)
2748 {
2749 xMat4x3* mat = &globals.camera.mat;
2750
2751 F32 new_yaw;
2752 if (mat->at.x >= -0.00001f && mat->at.x <= 0.00001f && mat->at.z >= -0.00001f &&
2753 mat->at.z <= 0.00001f)
2754 {
2755 new_yaw = this->yaw;
2756 }
2757 else
2758 {
2759 new_yaw = xatan2(mat->at.x, mat->at.z);
2760 }
2761
2762 F32 diff = new_yaw - this->yaw;
2763 if (diff > PI)
2764 {
2765 diff -= PI * 2;
2766 }
2767 else if (diff < -PI)
2768 {
2769 diff += PI * 2;
2770 }
2771 F32 tspeed = current_tweak->player.aim.turn_speed * xexp(dt);
2772 if (tspeed > 1.0f)
2773 {
2774 tspeed = 1.0f;
2775 }
2776 tspeed = diff * tspeed;
2777 this->yaw_vel = tspeed / dt;
2778 this->yaw = this->yaw + tspeed;
2779 this->yaw = xrmod(this->yaw);
2780 }
2781
2782 void cruise_bubble::state_player_fire::start()
2783 {

Callers 1

updateMethod · 0.95

Calls 3

xatan2Function · 0.85
xexpFunction · 0.85
xrmodFunction · 0.50

Tested by

no test coverage detected