mirror of https://github.com/AxioDL/metaforce.git
CProjectileInfo: Initialize result variable to false within PredictInterceptPos()
GM8E v0 sets this to false before performing any further calculations. This also prevents accidental uninitialized usages from occurring if this is ever changed in the future. While we're in the same area we can make bracing consistent.
This commit is contained in:
parent
4daa8ac374
commit
27fb2008dc
|
@ -18,9 +18,10 @@ CProjectileInfo::CProjectileInfo(CAssetId proj, const CDamageInfo& dInfo)
|
||||||
zeus::CVector3f CProjectileInfo::PredictInterceptPos(const zeus::CVector3f& gunPos, const zeus::CVector3f& aimPos,
|
zeus::CVector3f CProjectileInfo::PredictInterceptPos(const zeus::CVector3f& gunPos, const zeus::CVector3f& aimPos,
|
||||||
const CPlayer& player, bool gravity, float speed, float dt) {
|
const CPlayer& player, bool gravity, float speed, float dt) {
|
||||||
zeus::CVector3f ret;
|
zeus::CVector3f ret;
|
||||||
zeus::CVector3f playerVel = player.GetDampedClampedVelocityWR();
|
const zeus::CVector3f playerVel = player.GetDampedClampedVelocityWR();
|
||||||
zeus::CVector3f gravVec(0.f, 0.f, player.GetGravity());
|
const zeus::CVector3f gravVec(0.f, 0.f, player.GetGravity());
|
||||||
bool result;
|
bool result = false;
|
||||||
|
|
||||||
switch (player.GetOrbitState()) {
|
switch (player.GetOrbitState()) {
|
||||||
case CPlayer::EPlayerOrbitState::OrbitObject:
|
case CPlayer::EPlayerOrbitState::OrbitObject:
|
||||||
case CPlayer::EPlayerOrbitState::OrbitPoint:
|
case CPlayer::EPlayerOrbitState::OrbitPoint:
|
||||||
|
@ -33,22 +34,28 @@ zeus::CVector3f CProjectileInfo::PredictInterceptPos(const zeus::CVector3f& gunP
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
zeus::CVector3f vel;
|
zeus::CVector3f vel;
|
||||||
if (playerVel.canBeNormalized())
|
if (playerVel.canBeNormalized()) {
|
||||||
vel = playerVel.normalized() * player.GetAverageSpeed();
|
vel = playerVel.normalized() * player.GetAverageSpeed();
|
||||||
else
|
} else {
|
||||||
vel = playerVel;
|
vel = playerVel;
|
||||||
|
}
|
||||||
result = CSteeringBehaviors::ProjectOrbitalIntersection(gunPos, speed, dt, aimPos, vel,
|
result = CSteeringBehaviors::ProjectOrbitalIntersection(gunPos, speed, dt, aimPos, vel,
|
||||||
player.GetOrbitPoint(), ret);
|
player.GetOrbitPoint(), ret);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CPlayer::EPlayerOrbitState::NoOrbit:
|
case CPlayer::EPlayerOrbitState::NoOrbit:
|
||||||
if (gravity && player.GetPlayerMovementState() == CPlayer::EPlayerMovementState::ApplyJump)
|
if (gravity && player.GetPlayerMovementState() == CPlayer::EPlayerMovementState::ApplyJump) {
|
||||||
result = CSteeringBehaviors::ProjectLinearIntersection(gunPos, speed, aimPos, playerVel, gravVec, ret);
|
result = CSteeringBehaviors::ProjectLinearIntersection(gunPos, speed, aimPos, playerVel, gravVec, ret);
|
||||||
else
|
} else {
|
||||||
result = CSteeringBehaviors::ProjectLinearIntersection(gunPos, speed, aimPos, playerVel, ret);
|
result = CSteeringBehaviors::ProjectLinearIntersection(gunPos, speed, aimPos, playerVel, ret);
|
||||||
}
|
}
|
||||||
if (!result)
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
ret = playerVel * 1.5f + aimPos;
|
ret = playerVel * 1.5f + aimPos;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue