mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-06 16:05:53 +00:00
CEyeball: Eliminate unnecessary runtime initialzer in Think()
We can just fold the result into the constant directly, which allows us to avoid the need for a static runtime initializer. This is bit-exact with what the result would be, so this is fine.
This commit is contained in:
parent
2f9dd38bbe
commit
c3809162bf
@ -83,17 +83,22 @@ void CEyeball::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMa
|
|||||||
CPatterned::AcceptScriptMsg(msg, uid, mgr);
|
CPatterned::AcceptScriptMsg(msg, uid, mgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float kMinAngle = std::cos(zeus::degToRad(45.f));
|
|
||||||
void CEyeball::Think(float dt, CStateManager& mgr) {
|
void CEyeball::Think(float dt, CStateManager& mgr) {
|
||||||
CPatterned::Think(dt, mgr);
|
CPatterned::Think(dt, mgr);
|
||||||
if (!GetActive())
|
|
||||||
return;
|
|
||||||
|
|
||||||
CPlayer& player = mgr.GetPlayer();
|
if (!GetActive()) {
|
||||||
zeus::CVector3f direction = (player.GetTranslation() - GetTranslation()).normalized();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CPlayer& player = mgr.GetPlayer();
|
||||||
|
const zeus::CVector3f direction = (player.GetTranslation() - GetTranslation()).normalized();
|
||||||
|
|
||||||
|
// Used to be directly calculated as std::cos(zeus::degToRad(45.f));
|
||||||
|
// but was converted into the exact constant to avoid unnecessary runtime initialization.
|
||||||
|
constexpr float minAngle = 0.707106769f;
|
||||||
|
|
||||||
x60c_25_playerInRange = (player.GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed &&
|
x60c_25_playerInRange = (player.GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed &&
|
||||||
direction.dot(GetTransform().frontVector()) > kMinAngle);
|
direction.dot(GetTransform().frontVector()) > minAngle);
|
||||||
|
|
||||||
if (x60c_25_playerInRange) {
|
if (x60c_25_playerInRange) {
|
||||||
x570_boneTracking.SetActive(true);
|
x570_boneTracking.SetActive(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user