CCompoundTargetReticle: Brace statements where applicable

This commit is contained in:
Lioncash 2020-04-13 17:03:38 -04:00
parent 85f930ef2e
commit 2c7d10c4b4
1 changed files with 315 additions and 212 deletions

View File

@ -97,12 +97,13 @@ CCompoundTargetReticle::EReticleState CCompoundTargetReticle::GetDesiredReticleS
} }
void CCompoundTargetReticle::Update(float dt, const CStateManager& mgr) { void CCompoundTargetReticle::Update(float dt, const CStateManager& mgr) {
float angle = x10_laggingOrientation.angleFrom(x0_leadingOrientation).asDegrees(); const float angle = x10_laggingOrientation.angleFrom(x0_leadingOrientation).asDegrees();
float t; float t;
if (angle < 0.1f || angle > 45.f) if (angle < 0.1f || angle > 45.f) {
t = 1.f; t = 1.f;
else } else {
t = std::min(1.f, g_tweakTargeting->GetAngularLagSpeed() * dt / angle); t = std::min(1.f, g_tweakTargeting->GetAngularLagSpeed() * dt / angle);
}
x10_laggingOrientation = x10_laggingOrientation =
t == 1.f ? x0_leadingOrientation : zeus::CQuaternion::slerp(x10_laggingOrientation, x0_leadingOrientation, t); t == 1.f ? x0_leadingOrientation : zeus::CQuaternion::slerp(x10_laggingOrientation, x0_leadingOrientation, t);
xf4_targetPos = CalculateOrbitZoneReticlePosition(mgr, false); xf4_targetPos = CalculateOrbitZoneReticlePosition(mgr, false);
@ -110,7 +111,7 @@ void CCompoundTargetReticle::Update(float dt, const CStateManager& mgr) {
UpdateCurrLockOnGroup(dt, mgr); UpdateCurrLockOnGroup(dt, mgr);
UpdateNextLockOnGroup(dt, mgr); UpdateNextLockOnGroup(dt, mgr);
UpdateOrbitZoneGroup(dt, mgr); UpdateOrbitZoneGroup(dt, mgr);
EReticleState desiredState = GetDesiredReticleState(mgr); const EReticleState desiredState = GetDesiredReticleState(mgr);
if (desiredState != x20_prevState && x20_prevState == x24_nextState) { if (desiredState != x20_prevState && x20_prevState == x24_nextState) {
x24_nextState = desiredState; x24_nextState = desiredState;
x28_noDrawTicks = 2; x28_noDrawTicks = 2;
@ -137,90 +138,110 @@ void CCompoundTargetReticle::Update(float dt, const CStateManager& mgr) {
default: default:
break; break;
} }
if (combat) if (combat) {
x40_seeker.Lock(); x40_seeker.Lock();
else } else {
x40_seeker.Unlock(); x40_seeker.Unlock();
if (combat) }
if (combat) {
x4c_lockConfirm.Lock(); x4c_lockConfirm.Lock();
else } else {
x4c_lockConfirm.Unlock(); x4c_lockConfirm.Unlock();
if (combat) }
if (combat) {
x58_targetFlower.Lock(); x58_targetFlower.Lock();
else } else {
x58_targetFlower.Unlock(); x58_targetFlower.Unlock();
if (combat) }
if (combat) {
x64_missileBracket.Lock(); x64_missileBracket.Lock();
else } else {
x64_missileBracket.Unlock(); x64_missileBracket.Unlock();
if (combat) }
if (combat) {
x70_innerBeamIcon.Lock(); x70_innerBeamIcon.Lock();
else } else {
x70_innerBeamIcon.Unlock(); x70_innerBeamIcon.Unlock();
if (combat) }
if (combat) {
x7c_lockFire.Lock(); x7c_lockFire.Lock();
else } else {
x7c_lockFire.Unlock(); x7c_lockFire.Unlock();
if (combat) }
if (combat) {
x88_lockDagger.Lock(); x88_lockDagger.Lock();
else } else {
x88_lockDagger.Unlock(); x88_lockDagger.Unlock();
if (combat) }
if (combat) {
xa0_chargeTickFirst.Lock(); xa0_chargeTickFirst.Lock();
else } else {
xa0_chargeTickFirst.Unlock(); xa0_chargeTickFirst.Unlock();
if (xray) }
if (xray) {
xac_xrayRetRing.Lock(); xac_xrayRetRing.Lock();
else } else {
xac_xrayRetRing.Unlock(); xac_xrayRetRing.Unlock();
if (thermal) }
if (thermal) {
xb8_thermalReticle.Lock(); xb8_thermalReticle.Lock();
else } else {
xb8_thermalReticle.Unlock(); xb8_thermalReticle.Unlock();
if (combat) }
if (combat) {
xc4_chargeGauge.x0_model.Lock(); xc4_chargeGauge.x0_model.Lock();
else } else {
xc4_chargeGauge.x0_model.Unlock(); xc4_chargeGauge.x0_model.Unlock();
if (!scan) }
if (!scan) {
x94_grapple.Lock(); x94_grapple.Lock();
else } else {
x94_grapple.Unlock(); x94_grapple.Unlock();
}
for (SOuterItemInfo& info : xe0_outerBeamIconSquares) { for (SOuterItemInfo& info : xe0_outerBeamIconSquares) {
if (combat) if (combat) {
info.x0_model.Lock(); info.x0_model.Lock();
else } else {
info.x0_model.Unlock(); info.x0_model.Unlock();
}
} }
} }
CPlayerGun* gun = mgr.GetPlayer().GetPlayerGun();
bool fullyCharged = (gun->IsCharging() ? gun->GetChargeBeamFactor() : 0.f) >= 1.f; const CPlayerGun* gun = mgr.GetPlayer().GetPlayerGun();
if (fullyCharged != x21a_fullyCharged) const bool fullyCharged = (gun->IsCharging() ? gun->GetChargeBeamFactor() : 0.f) >= 1.f;
if (fullyCharged != x21a_fullyCharged) {
x21a_fullyCharged = fullyCharged; x21a_fullyCharged = fullyCharged;
if (x21a_fullyCharged) }
if (x21a_fullyCharged) {
x214_fullChargeFadeTimer = std::min(dt / g_tweakTargeting->GetFullChargeFadeDuration() + x214_fullChargeFadeTimer, x214_fullChargeFadeTimer = std::min(dt / g_tweakTargeting->GetFullChargeFadeDuration() + x214_fullChargeFadeTimer,
g_tweakTargeting->GetFullChargeFadeDuration()); g_tweakTargeting->GetFullChargeFadeDuration());
else } else {
x214_fullChargeFadeTimer = x214_fullChargeFadeTimer =
std::max(x214_fullChargeFadeTimer - dt / g_tweakTargeting->GetFullChargeFadeDuration(), 0.f); std::max(x214_fullChargeFadeTimer - dt / g_tweakTargeting->GetFullChargeFadeDuration(), 0.f);
bool missileActive = gun->GetMissleMode() == CPlayerGun::EMissleMode::Active; }
const bool missileActive = gun->GetMissleMode() == CPlayerGun::EMissleMode::Active;
if (missileActive != x1f4_missileActive) { if (missileActive != x1f4_missileActive) {
if (x1f8_missileBracketTimer != 0.f) if (x1f8_missileBracketTimer != 0.f) {
x1f8_missileBracketTimer = FLT_EPSILON - x1f8_missileBracketTimer; x1f8_missileBracketTimer = FLT_EPSILON - x1f8_missileBracketTimer;
else } else {
x1f8_missileBracketTimer = FLT_EPSILON; x1f8_missileBracketTimer = FLT_EPSILON;
}
x1f4_missileActive = missileActive; x1f4_missileActive = missileActive;
} }
CPlayerState::EBeamId beam = gun->GetCurrentBeam();
const CPlayerState::EBeamId beam = gun->GetCurrentBeam();
if (beam != x200_beam) { if (beam != x200_beam) {
x204_chargeGaugeOvershootTimer = g_tweakTargeting->GetChargeGaugeOvershootDuration(); x204_chargeGaugeOvershootTimer = g_tweakTargeting->GetChargeGaugeOvershootDuration();
for (int i = 0; i < 9; ++i) { for (size_t i = 0; i < xe0_outerBeamIconSquares.size(); ++i) {
zeus::CRelAngle baseAngle = g_tweakTargeting->GetOuterBeamSquareAngles(int(beam))[i]; zeus::CRelAngle baseAngle = g_tweakTargeting->GetOuterBeamSquareAngles(int(beam))[i];
baseAngle.makeRel(); baseAngle.makeRel();
SOuterItemInfo& icon = xe0_outerBeamIconSquares[i]; SOuterItemInfo& icon = xe0_outerBeamIconSquares[i];
zeus::CRelAngle offshootAngleDelta = baseAngle.asRadians() - icon.x10_rotAng; zeus::CRelAngle offshootAngleDelta = baseAngle.asRadians() - icon.x10_rotAng;
if ((i & 0x1) == 1) if ((i & 0x1) == 1) {
offshootAngleDelta = offshootAngleDelta =
(baseAngle > 0.f) ? zeus::CRelAngle(-2.f * M_PIF - baseAngle) : zeus::CRelAngle(2.f * M_PIF + baseAngle); (baseAngle > 0.f) ? zeus::CRelAngle(-2.f * M_PIF - baseAngle) : zeus::CRelAngle(2.f * M_PIF + baseAngle);
}
icon.xc_offshootBaseAngle = icon.x10_rotAng; icon.xc_offshootBaseAngle = icon.x10_rotAng;
icon.x18_offshootAngleDelta = offshootAngleDelta; icon.x18_offshootAngleDelta = offshootAngleDelta;
icon.x14_baseAngle = baseAngle; icon.x14_baseAngle = baseAngle;
@ -228,36 +249,43 @@ void CCompoundTargetReticle::Update(float dt, const CStateManager& mgr) {
zeus::CRelAngle baseAngle = g_tweakTargeting->GetChargeGaugeAngle(int(beam)); zeus::CRelAngle baseAngle = g_tweakTargeting->GetChargeGaugeAngle(int(beam));
baseAngle.makeRel(); baseAngle.makeRel();
float offshootAngleDelta = baseAngle.asRadians() - xc4_chargeGauge.x10_rotAng; float offshootAngleDelta = baseAngle.asRadians() - xc4_chargeGauge.x10_rotAng;
if ((rand() & 0x1) == 1) if ((rand() & 0x1) == 1) {
offshootAngleDelta = offshootAngleDelta =
(offshootAngleDelta > 0.f) ? -2.f * M_PIF - offshootAngleDelta : 2.f * M_PIF + offshootAngleDelta; (offshootAngleDelta > 0.f) ? -2.f * M_PIF - offshootAngleDelta : 2.f * M_PIF + offshootAngleDelta;
}
xc4_chargeGauge.xc_offshootBaseAngle = xc4_chargeGauge.x10_rotAng; xc4_chargeGauge.xc_offshootBaseAngle = xc4_chargeGauge.x10_rotAng;
xc4_chargeGauge.x18_offshootAngleDelta = offshootAngleDelta; xc4_chargeGauge.x18_offshootAngleDelta = offshootAngleDelta;
xc4_chargeGauge.x14_baseAngle = baseAngle; xc4_chargeGauge.x14_baseAngle = baseAngle;
x200_beam = beam; x200_beam = beam;
x208_lockonTimer = 0.f; x208_lockonTimer = 0.f;
} }
if (gun->GetLastFireButtonStates() & 0x1) {
if (!x218_beamShot) if ((gun->GetLastFireButtonStates() & 0x1) != 0) {
if (!x218_beamShot) {
x210_lockFireTimer = g_tweakTargeting->GetLockFireDuration(); x210_lockFireTimer = g_tweakTargeting->GetLockFireDuration();
}
x218_beamShot = true; x218_beamShot = true;
} else { } else {
x218_beamShot = false; x218_beamShot = false;
} }
if (gun->GetLastFireButtonStates() & 0x2) {
if (!x219_missileShot) if ((gun->GetLastFireButtonStates() & 0x2) != 0) {
if (!x219_missileShot) {
x1fc_missileBracketScaleTimer = g_tweakTargeting->GetMissileBracketScaleDuration(); x1fc_missileBracketScaleTimer = g_tweakTargeting->GetMissileBracketScaleDuration();
}
x219_missileShot = true; x219_missileShot = true;
} else { } else {
x219_missileShot = false; x219_missileShot = false;
} }
if (TCastToConstPtr<CScriptGrapplePoint> point = mgr.GetObjectById(xf2_nextTargetId)) {
if (const TCastToConstPtr<CScriptGrapplePoint> point = mgr.GetObjectById(xf2_nextTargetId)) {
if (point->GetUniqueId() != x1dc_grapplePoint0) { if (point->GetUniqueId() != x1dc_grapplePoint0) {
float tmp; float tmp;
if (point->GetUniqueId() == x1de_grapplePoint1) if (point->GetUniqueId() == x1de_grapplePoint1) {
tmp = std::max(FLT_EPSILON, x1e4_grapplePoint1T); tmp = std::max(FLT_EPSILON, x1e4_grapplePoint1T);
else } else {
tmp = FLT_EPSILON; tmp = FLT_EPSILON;
}
x1de_grapplePoint1 = x1dc_grapplePoint0; x1de_grapplePoint1 = x1dc_grapplePoint0;
x1e4_grapplePoint1T = x1e0_grapplePoint0T; x1e4_grapplePoint1T = x1e0_grapplePoint0T;
x1e0_grapplePoint0T = tmp; x1e0_grapplePoint0T = tmp;
@ -269,13 +297,18 @@ void CCompoundTargetReticle::Update(float dt, const CStateManager& mgr) {
x1e0_grapplePoint0T = 0.f; x1e0_grapplePoint0T = 0.f;
x1dc_grapplePoint0 = kInvalidUniqueId; x1dc_grapplePoint0 = kInvalidUniqueId;
} }
if (x1e0_grapplePoint0T > 0.f)
if (x1e0_grapplePoint0T > 0.f) {
x1e0_grapplePoint0T = std::min(dt / 0.5f + x1e0_grapplePoint0T, 1.f); x1e0_grapplePoint0T = std::min(dt / 0.5f + x1e0_grapplePoint0T, 1.f);
}
if (x1e4_grapplePoint1T > 0.f) { if (x1e4_grapplePoint1T > 0.f) {
x1e4_grapplePoint1T = std::max(0.f, x1e4_grapplePoint1T - dt / 0.5f); x1e4_grapplePoint1T = std::max(0.f, x1e4_grapplePoint1T - dt / 0.5f);
if (x1e4_grapplePoint1T == 0.f) if (x1e4_grapplePoint1T == 0.f) {
x1de_grapplePoint1 = kInvalidUniqueId; x1de_grapplePoint1 = kInvalidUniqueId;
}
} }
x1f0_xrayRetAngle = x1f0_xrayRetAngle =
zeus::CRelAngle(zeus::degToRad(g_tweakTargeting->GetXRayRetAngleSpeed() * dt) + x1f0_xrayRetAngle).asRel(); zeus::CRelAngle(zeus::degToRad(g_tweakTargeting->GetXRayRetAngleSpeed() * dt) + x1f0_xrayRetAngle).asRel();
x1ec_seekerAngle = zeus::CRelAngle(zeus::degToRad(g_tweakTargeting->GetSeekerAngleSpeed() * dt) + x1ec_seekerAngle). x1ec_seekerAngle = zeus::CRelAngle(zeus::degToRad(g_tweakTargeting->GetSeekerAngleSpeed() * dt) + x1ec_seekerAngle).
@ -285,18 +318,19 @@ void CCompoundTargetReticle::Update(float dt, const CStateManager& mgr) {
void CTargetReticleRenderState::InterpolateWithClamp(const CTargetReticleRenderState& a, CTargetReticleRenderState& out, void CTargetReticleRenderState::InterpolateWithClamp(const CTargetReticleRenderState& a, CTargetReticleRenderState& out,
const CTargetReticleRenderState& b, float t) { const CTargetReticleRenderState& b, float t) {
t = zeus::clamp(0.f, t, 1.f); t = zeus::clamp(0.f, t, 1.f);
float omt = 1.f - t; const float omt = 1.f - t;
out.x4_radiusWorld = omt * a.x4_radiusWorld + t * b.x4_radiusWorld; out.x4_radiusWorld = omt * a.x4_radiusWorld + t * b.x4_radiusWorld;
out.x14_factor = omt * a.x14_factor + t * b.x14_factor; out.x14_factor = omt * a.x14_factor + t * b.x14_factor;
out.x18_minVpClampScale = omt * a.x18_minVpClampScale + t * b.x18_minVpClampScale; out.x18_minVpClampScale = omt * a.x18_minVpClampScale + t * b.x18_minVpClampScale;
out.x8_positionWorld = zeus::CVector3f::lerp(a.x8_positionWorld, b.x8_positionWorld, t); out.x8_positionWorld = zeus::CVector3f::lerp(a.x8_positionWorld, b.x8_positionWorld, t);
if (t == 1.f) if (t == 1.f) {
out.x0_target = b.x0_target; out.x0_target = b.x0_target;
else if (t == 0.f) } else if (t == 0.f) {
out.x0_target = a.x0_target; out.x0_target = a.x0_target;
else } else {
out.x0_target = kInvalidUniqueId; out.x0_target = kInvalidUniqueId;
}
} }
static bool IsDamageOrbit(CPlayer::EPlayerOrbitRequest req) { static bool IsDamageOrbit(CPlayer::EPlayerOrbitRequest req) {
@ -313,13 +347,14 @@ static bool IsDamageOrbit(CPlayer::EPlayerOrbitRequest req) {
} }
void CCompoundTargetReticle::UpdateCurrLockOnGroup(float dt, const CStateManager& mgr) { void CCompoundTargetReticle::UpdateCurrLockOnGroup(float dt, const CStateManager& mgr) {
TUniqueId targetId = mgr.GetPlayer().GetOrbitTargetId(); const TUniqueId targetId = mgr.GetPlayer().GetOrbitTargetId();
if (targetId != xf0_targetId) { if (targetId != xf0_targetId) {
if (targetId != kInvalidUniqueId) { if (targetId != kInvalidUniqueId) {
if (TCastToConstPtr<CScriptGrapplePoint> point = mgr.GetObjectById(targetId)) if (const TCastToConstPtr<CScriptGrapplePoint> point = mgr.GetObjectById(targetId)) {
CSfxManager::SfxStart(SFXui_lockon_grapple, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); CSfxManager::SfxStart(SFXui_lockon_grapple, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
else } else {
CSfxManager::SfxStart(SFXui_lockon_poi, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); CSfxManager::SfxStart(SFXui_lockon_poi, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
} }
if (targetId == kInvalidUniqueId) { if (targetId == kInvalidUniqueId) {
@ -329,17 +364,20 @@ void CCompoundTargetReticle::UpdateCurrLockOnGroup(float dt, const CStateManager
IsDamageOrbit(mgr.GetPlayer().GetOrbitRequest()) ? 0.65f : g_tweakTargeting->GetCurrLockOnEnterDuration(); IsDamageOrbit(mgr.GetPlayer().GetOrbitRequest()) ? 0.65f : g_tweakTargeting->GetCurrLockOnEnterDuration();
} else { } else {
x12c_currGroupA = x10c_currGroupInterp; x12c_currGroupA = x10c_currGroupInterp;
if (xf0_targetId == kInvalidUniqueId) if (xf0_targetId == kInvalidUniqueId) {
x12c_currGroupA.SetTargetId(targetId); x12c_currGroupA.SetTargetId(targetId);
}
x14c_currGroupB = CTargetReticleRenderState( x14c_currGroupB = CTargetReticleRenderState(
targetId, 1.f, zeus::skZero3f, 1.f, targetId, 1.f, zeus::skZero3f, 1.f,
IsGrappleTarget(targetId, mgr) ? g_tweakTargeting->GetGrappleMinClampScale() : 1.f, false); IsGrappleTarget(targetId, mgr) ? g_tweakTargeting->GetGrappleMinClampScale() : 1.f, false);
x16c_currGroupDur = xf0_targetId == kInvalidUniqueId ? g_tweakTargeting->GetCurrLockOnExitDuration() x16c_currGroupDur = xf0_targetId == kInvalidUniqueId ? g_tweakTargeting->GetCurrLockOnExitDuration()
: g_tweakTargeting->GetCurrLockOnSwitchDuration(); : g_tweakTargeting->GetCurrLockOnSwitchDuration();
} }
x170_currGroupTimer = x16c_currGroupDur; x170_currGroupTimer = x16c_currGroupDur;
xf0_targetId = targetId; xf0_targetId = targetId;
} }
if (x170_currGroupTimer > 0.f) { if (x170_currGroupTimer > 0.f) {
UpdateTargetParameters(x12c_currGroupA, mgr); UpdateTargetParameters(x12c_currGroupA, mgr);
UpdateTargetParameters(x14c_currGroupB, mgr); UpdateTargetParameters(x14c_currGroupB, mgr);
@ -349,46 +387,54 @@ void CCompoundTargetReticle::UpdateCurrLockOnGroup(float dt, const CStateManager
} else { } else {
UpdateTargetParameters(x10c_currGroupInterp, mgr); UpdateTargetParameters(x10c_currGroupInterp, mgr);
} }
if (x1f8_missileBracketTimer != 0.f && x1f8_missileBracketTimer < g_tweakTargeting->GetMissileBracketDuration()) { if (x1f8_missileBracketTimer != 0.f && x1f8_missileBracketTimer < g_tweakTargeting->GetMissileBracketDuration()) {
if (x1f8_missileBracketTimer < 0.f) if (x1f8_missileBracketTimer < 0.f) {
x1f8_missileBracketTimer = std::min(0.f, x1f8_missileBracketTimer + dt); x1f8_missileBracketTimer = std::min(0.f, x1f8_missileBracketTimer + dt);
else } else {
x1f8_missileBracketTimer = std::min(g_tweakTargeting->GetMissileBracketDuration(), x1f8_missileBracketTimer + dt); x1f8_missileBracketTimer = std::min(g_tweakTargeting->GetMissileBracketDuration(), x1f8_missileBracketTimer + dt);
}
} }
if (x204_chargeGaugeOvershootTimer > 0.f) { if (x204_chargeGaugeOvershootTimer > 0.f) {
x204_chargeGaugeOvershootTimer = std::max(0.f, x204_chargeGaugeOvershootTimer - dt); x204_chargeGaugeOvershootTimer = std::max(0.f, x204_chargeGaugeOvershootTimer - dt);
if (x204_chargeGaugeOvershootTimer == 0.f) { if (x204_chargeGaugeOvershootTimer == 0.f) {
for (int i = 0; i < 9; ++i) for (auto& iconSquare : xe0_outerBeamIconSquares) {
xe0_outerBeamIconSquares[i].x10_rotAng = xe0_outerBeamIconSquares[i].x14_baseAngle; iconSquare.x10_rotAng = iconSquare.x14_baseAngle;
}
xc4_chargeGauge.x10_rotAng = xc4_chargeGauge.x14_baseAngle; xc4_chargeGauge.x10_rotAng = xc4_chargeGauge.x14_baseAngle;
x208_lockonTimer = FLT_EPSILON; x208_lockonTimer = FLT_EPSILON;
} else { } else {
float offshoot = const float offshoot =
offshoot_func(x2c_overshootOffsetHalf, x30_premultOvershootOffset, offshoot_func(x2c_overshootOffsetHalf, x30_premultOvershootOffset,
1.f - x204_chargeGaugeOvershootTimer / g_tweakTargeting->GetChargeGaugeOvershootDuration()); 1.f - x204_chargeGaugeOvershootTimer / g_tweakTargeting->GetChargeGaugeOvershootDuration());
for (int i = 0; i < 9; ++i) { for (auto& item : xe0_outerBeamIconSquares) {
SOuterItemInfo& item = xe0_outerBeamIconSquares[i]; item.x10_rotAng = zeus::CRelAngle(item.x18_offshootAngleDelta * offshoot + item.xc_offshootBaseAngle).asRel();
item.x10_rotAng = zeus::CRelAngle(item.x18_offshootAngleDelta * offshoot + item.xc_offshootBaseAngle).
asRel();
} }
xc4_chargeGauge.x10_rotAng = xc4_chargeGauge.x10_rotAng =
zeus::CRelAngle(xc4_chargeGauge.x18_offshootAngleDelta * offshoot + xc4_chargeGauge.xc_offshootBaseAngle). zeus::CRelAngle(xc4_chargeGauge.x18_offshootAngleDelta * offshoot + xc4_chargeGauge.xc_offshootBaseAngle).
asRel(); asRel();
} }
} }
if (x208_lockonTimer > 0.f && x208_lockonTimer < g_tweakTargeting->GetLockonDuration())
if (x208_lockonTimer > 0.f && x208_lockonTimer < g_tweakTargeting->GetLockonDuration()) {
x208_lockonTimer = std::min(g_tweakTargeting->GetLockonDuration(), x208_lockonTimer + dt); x208_lockonTimer = std::min(g_tweakTargeting->GetLockonDuration(), x208_lockonTimer + dt);
if (x210_lockFireTimer > 0.f) }
if (x210_lockFireTimer > 0.f) {
x210_lockFireTimer = std::max(0.f, x210_lockFireTimer - dt); x210_lockFireTimer = std::max(0.f, x210_lockFireTimer - dt);
if (x1fc_missileBracketScaleTimer > 0.f) }
if (x1fc_missileBracketScaleTimer > 0.f) {
x1fc_missileBracketScaleTimer = std::max(0.f, x1fc_missileBracketScaleTimer - dt); x1fc_missileBracketScaleTimer = std::max(0.f, x1fc_missileBracketScaleTimer - dt);
}
} }
void CCompoundTargetReticle::UpdateNextLockOnGroup(float dt, const CStateManager& mgr) { void CCompoundTargetReticle::UpdateNextLockOnGroup(float dt, const CStateManager& mgr) {
TUniqueId nextTargetId = mgr.GetPlayer().GetOrbitNextTargetId(); TUniqueId nextTargetId = mgr.GetPlayer().GetOrbitNextTargetId();
if (mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan && if (mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan &&
mgr.GetPlayer().GetOrbitTargetId() != kInvalidUniqueId) mgr.GetPlayer().GetOrbitTargetId() != kInvalidUniqueId) {
nextTargetId = mgr.GetPlayer().GetOrbitTargetId(); nextTargetId = mgr.GetPlayer().GetOrbitTargetId();
}
if (nextTargetId != xf2_nextTargetId) { if (nextTargetId != xf2_nextTargetId) {
if (nextTargetId == kInvalidUniqueId) { if (nextTargetId == kInvalidUniqueId) {
x194_nextGroupA = x174_nextGroupInterp; x194_nextGroupA = x174_nextGroupInterp;
@ -410,6 +456,7 @@ void CCompoundTargetReticle::UpdateNextLockOnGroup(float dt, const CStateManager
xf2_nextTargetId = nextTargetId; xf2_nextTargetId = nextTargetId;
} }
} }
if (x1d8_nextGroupTimer > 0.f) { if (x1d8_nextGroupTimer > 0.f) {
UpdateTargetParameters(x194_nextGroupA, mgr); UpdateTargetParameters(x194_nextGroupA, mgr);
UpdateTargetParameters(x1b4_nextGroupB, mgr); UpdateTargetParameters(x1b4_nextGroupB, mgr);
@ -422,22 +469,25 @@ void CCompoundTargetReticle::UpdateNextLockOnGroup(float dt, const CStateManager
} }
void CCompoundTargetReticle::UpdateOrbitZoneGroup(float dt, const CStateManager& mgr) { void CCompoundTargetReticle::UpdateOrbitZoneGroup(float dt, const CStateManager& mgr) {
if (xf0_targetId == kInvalidUniqueId && xf2_nextTargetId != kInvalidUniqueId) if (xf0_targetId == kInvalidUniqueId && xf2_nextTargetId != kInvalidUniqueId) {
x20c_ = std::min(1.f, 2.f * dt + x20c_); x20c_ = std::min(1.f, 2.f * dt + x20c_);
else } else {
x20c_ = std::max(0.f, x20c_ - 2.f * dt); x20c_ = std::max(0.f, x20c_ - 2.f * dt);
}
if (mgr.GetPlayer().IsShowingCrosshairs() && if (mgr.GetPlayer().IsShowingCrosshairs() &&
mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::EPlayerVisor::Scan) mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::EPlayerVisor::Scan) {
x1e8_crosshairsScale = std::min(1.f, dt / g_tweakTargeting->GetCrosshairsScaleDuration() + x1e8_crosshairsScale); x1e8_crosshairsScale = std::min(1.f, dt / g_tweakTargeting->GetCrosshairsScaleDuration() + x1e8_crosshairsScale);
else } else {
x1e8_crosshairsScale = std::max(0.f, x1e8_crosshairsScale - dt / g_tweakTargeting->GetCrosshairsScaleDuration()); x1e8_crosshairsScale = std::max(0.f, x1e8_crosshairsScale - dt / g_tweakTargeting->GetCrosshairsScaleDuration());
}
} }
void CCompoundTargetReticle::Draw(const CStateManager& mgr, bool hideLockon) { void CCompoundTargetReticle::Draw(const CStateManager& mgr, bool hideLockon) {
if (mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed && if (mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed &&
!mgr.GetCameraManager()->IsInCinematicCamera()) { !mgr.GetCameraManager()->IsInCinematicCamera()) {
SCOPED_GRAPHICS_DEBUG_GROUP("CCompoundTargetReticle::Draw", zeus::skCyan); SCOPED_GRAPHICS_DEBUG_GROUP("CCompoundTargetReticle::Draw", zeus::skCyan);
zeus::CTransform camXf = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr); const zeus::CTransform camXf = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr);
CGraphics::SetViewPointMatrix(camXf); CGraphics::SetViewPointMatrix(camXf);
if (!hideLockon) { if (!hideLockon) {
DrawCurrLockOnGroup(camXf.basis, mgr); DrawCurrLockOnGroup(camXf.basis, mgr);
@ -446,18 +496,23 @@ void CCompoundTargetReticle::Draw(const CStateManager& mgr, bool hideLockon) {
} }
DrawGrappleGroup(camXf.basis, mgr, hideLockon); DrawGrappleGroup(camXf.basis, mgr, hideLockon);
} }
if (x28_noDrawTicks > 0)
if (x28_noDrawTicks > 0) {
--x28_noDrawTicks; --x28_noDrawTicks;
}
} }
void CCompoundTargetReticle::DrawGrapplePoint(const CScriptGrapplePoint& point, float t, const CStateManager& mgr, void CCompoundTargetReticle::DrawGrapplePoint(const CScriptGrapplePoint& point, float t, const CStateManager& mgr,
const zeus::CMatrix3f& rot, bool zEqual) const { const zeus::CMatrix3f& rot, bool zEqual) const {
zeus::CVector3f orbitPos = point.GetOrbitPosition(mgr); zeus::CVector3f orbitPos = point.GetOrbitPosition(mgr);
zeus::CColor color; zeus::CColor color;
if (point.GetGrappleParameters().GetLockSwingTurn())
if (point.GetGrappleParameters().GetLockSwingTurn()) {
color = g_tweakTargeting->GetLockedGrapplePointSelectColor(); color = g_tweakTargeting->GetLockedGrapplePointSelectColor();
else } else {
color = g_tweakTargeting->GetGrapplePointSelectColor(); color = g_tweakTargeting->GetGrapplePointSelectColor();
}
color = zeus::CColor::lerp(g_tweakTargeting->GetGrapplePointColor(), color, t); color = zeus::CColor::lerp(g_tweakTargeting->GetGrapplePointColor(), color, t);
zeus::CMatrix3f scale( zeus::CMatrix3f scale(
CalculateClampedScale(orbitPos, 1.f, g_tweakTargeting->GetGrappleClampMin(), CalculateClampedScale(orbitPos, 1.f, g_tweakTargeting->GetGrappleClampMin(),
@ -471,8 +526,9 @@ void CCompoundTargetReticle::DrawGrapplePoint(const CScriptGrapplePoint& point,
void CCompoundTargetReticle::DrawGrappleGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr, void CCompoundTargetReticle::DrawGrappleGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr,
bool hideLockon) const { bool hideLockon) const {
if (x28_noDrawTicks > 0) if (x28_noDrawTicks > 0) {
return; return;
}
if (mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::GrappleBeam) && x94_grapple.IsLoaded() && if (mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::GrappleBeam) && x94_grapple.IsLoaded() &&
x20_prevState != EReticleState::Scan) { x20_prevState != EReticleState::Scan) {
@ -482,39 +538,45 @@ void CCompoundTargetReticle::DrawGrappleGroup(const zeus::CMatrix3f& rot, const
if (point->GetActive()) { if (point->GetActive()) {
if (point->GetAreaIdAlways() != kInvalidAreaId) { if (point->GetAreaIdAlways() != kInvalidAreaId) {
const CGameArea* area = mgr.GetWorld()->GetAreaAlways(point->GetAreaIdAlways()); const CGameArea* area = mgr.GetWorld()->GetAreaAlways(point->GetAreaIdAlways());
CGameArea::EOcclusionState occState = const auto occState =
area->IsPostConstructed() ? area->GetOcclusionState() : CGameArea::EOcclusionState::Occluded; area->IsPostConstructed() ? area->GetOcclusionState() : CGameArea::EOcclusionState::Occluded;
if (occState != CGameArea::EOcclusionState::Visible) if (occState != CGameArea::EOcclusionState::Visible) {
continue; continue;
}
} }
float t = 0.f; float t = 0.f;
if (point->GetUniqueId() == x1dc_grapplePoint0) if (point->GetUniqueId() == x1dc_grapplePoint0) {
t = x1e0_grapplePoint0T; t = x1e0_grapplePoint0T;
else if (point->GetUniqueId() == x1de_grapplePoint1) } else if (point->GetUniqueId() == x1de_grapplePoint1) {
t = x1e4_grapplePoint1T; t = x1e4_grapplePoint1T;
if (std::fabs(t) < 0.00001f) }
if (std::fabs(t) < 0.00001f) {
DrawGrapplePoint(*point, t, mgr, rot, true); DrawGrapplePoint(*point, t, mgr, rot, true);
}
} }
} }
} }
} else { } else {
TCastToConstPtr<CScriptGrapplePoint> point0 = mgr.GetObjectById(x1dc_grapplePoint0); const TCastToConstPtr<CScriptGrapplePoint> point0 = mgr.GetObjectById(x1dc_grapplePoint0);
TCastToConstPtr<CScriptGrapplePoint> point1 = mgr.GetObjectById(x1de_grapplePoint1); const TCastToConstPtr<CScriptGrapplePoint> point1 = mgr.GetObjectById(x1de_grapplePoint1);
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
const CScriptGrapplePoint* point = i == 0 ? point0.GetPtr() : point1.GetPtr(); const CScriptGrapplePoint* point = i == 0 ? point0.GetPtr() : point1.GetPtr();
float t = i == 0 ? x1e0_grapplePoint0T : x1e4_grapplePoint1T; const float t = i == 0 ? x1e0_grapplePoint0T : x1e4_grapplePoint1T;
if (point) if (point) {
DrawGrapplePoint(*point, t, mgr, rot, false); DrawGrapplePoint(*point, t, mgr, rot, false);
}
} }
} }
} }
} }
void CCompoundTargetReticle::DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr) const { void CCompoundTargetReticle::DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr) const {
if (x28_noDrawTicks > 0) if (x28_noDrawTicks > 0) {
return; return;
if (x1e0_grapplePoint0T + x1e4_grapplePoint1T > 0 || x10c_currGroupInterp.GetFactor() == 0.f) }
if (x1e0_grapplePoint0T + x1e4_grapplePoint1T > 0 || x10c_currGroupInterp.GetFactor() == 0.f) {
return; return;
}
float lockBreakAlpha = x10c_currGroupInterp.GetFactor(); float lockBreakAlpha = x10c_currGroupInterp.GetFactor();
float visorFactor = mgr.GetPlayerState()->GetVisorTransitionFactor(); float visorFactor = mgr.GetPlayerState()->GetVisorTransitionFactor();
@ -537,79 +599,83 @@ void CCompoundTargetReticle::DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, con
if (IsDamageOrbit(mgr.GetPlayer().GetOrbitRequest()) && x14c_currGroupB.GetFactor() == 0.f) { if (IsDamageOrbit(mgr.GetPlayer().GetOrbitRequest()) && x14c_currGroupB.GetFactor() == 0.f) {
zeus::CMatrix3f lockBreakRM; zeus::CMatrix3f lockBreakRM;
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
int a = rand() % 9; const int a = rand() % 9;
auto b = std::div(a, 3); const auto b = std::div(a, 3);
lockBreakRM[b.rem][b.quot] += rand() / float(RAND_MAX) - 0.5f; lockBreakRM[b.rem][b.quot] += rand() / float(RAND_MAX) - 0.5f;
} }
lockBreakXf = lockBreakRM.transposed(); lockBreakXf = lockBreakRM.transposed();
if (x10c_currGroupInterp.GetFactor() > 0.8f) if (x10c_currGroupInterp.GetFactor() > 0.8f) {
lockBreakColor = zeus::CColor(1.f, (x10c_currGroupInterp.GetFactor() - 0.8f) * 0.3f / 0.2f); lockBreakColor = zeus::CColor(1.f, (x10c_currGroupInterp.GetFactor() - 0.8f) * 0.3f / 0.2f);
}
lockBreakAlpha = x10c_currGroupInterp.GetFactor() > 0.75f lockBreakAlpha = x10c_currGroupInterp.GetFactor() > 0.75f
? 1.f ? 1.f
: std::max(0.f, (x10c_currGroupInterp.GetFactor() - 0.55f) / 0.2f); : std::max(0.f, (x10c_currGroupInterp.GetFactor() - 0.55f) / 0.2f);
} }
if (lockConfirm && x4c_lockConfirm.IsLoaded()) { if (lockConfirm && x4c_lockConfirm.IsLoaded()) {
zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(), const zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(),
x10c_currGroupInterp.GetRadiusWorld(), x10c_currGroupInterp.GetRadiusWorld(),
x10c_currGroupInterp.GetMinViewportClampScale() * x10c_currGroupInterp.GetMinViewportClampScale() *
g_tweakTargeting->GetLockConfirmClampMin(), g_tweakTargeting->GetLockConfirmClampMin(),
g_tweakTargeting->GetLockConfirmClampMax(), mgr) * g_tweakTargeting->GetLockConfirmClampMax(), mgr) *
g_tweakTargeting->GetLockConfirmScale() / x10c_currGroupInterp.GetFactor()); g_tweakTargeting->GetLockConfirmScale() / x10c_currGroupInterp.GetFactor());
zeus::CTransform modelXf(lockBreakXf * (rot * zeus::CMatrix3f::RotateY(x1ec_seekerAngle) * scale), const zeus::CTransform modelXf(lockBreakXf * (rot * zeus::CMatrix3f::RotateY(x1ec_seekerAngle) * scale),
x10c_currGroupInterp.GetTargetPositionWorld()); x10c_currGroupInterp.GetTargetPositionWorld());
CGraphics::SetModelMatrix(modelXf); CGraphics::SetModelMatrix(modelXf);
zeus::CColor color = g_tweakTargeting->GetLockConfirmColor(); zeus::CColor color = g_tweakTargeting->GetLockConfirmColor();
color.a() *= lockBreakAlpha; color.a() *= lockBreakAlpha;
CModelFlags flags(7, 0, 0, lockBreakColor + color); const CModelFlags flags(7, 0, 0, lockBreakColor + color);
x4c_lockConfirm->Draw(flags); x4c_lockConfirm->Draw(flags);
} }
if (lockReticule) { if (lockReticule) {
if (x58_targetFlower.IsLoaded()) { if (x58_targetFlower.IsLoaded()) {
zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(), const zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(),
x10c_currGroupInterp.GetRadiusWorld(), x10c_currGroupInterp.GetRadiusWorld(),
x10c_currGroupInterp.GetMinViewportClampScale() * x10c_currGroupInterp.GetMinViewportClampScale() *
g_tweakTargeting->GetTargetFlowerClampMin(), g_tweakTargeting->GetTargetFlowerClampMin(),
g_tweakTargeting->GetTargetFlowerClampMax(), mgr) * g_tweakTargeting->GetTargetFlowerClampMax(), mgr) *
g_tweakTargeting->GetTargetFlowerScale() / lockBreakAlpha); g_tweakTargeting->GetTargetFlowerScale() / lockBreakAlpha);
zeus::CTransform modelXf(lockBreakXf * (rot * zeus::CMatrix3f::RotateY(x1f0_xrayRetAngle) * scale), const zeus::CTransform modelXf(lockBreakXf * (rot * zeus::CMatrix3f::RotateY(x1f0_xrayRetAngle) * scale),
x10c_currGroupInterp.GetTargetPositionWorld()); x10c_currGroupInterp.GetTargetPositionWorld());
CGraphics::SetModelMatrix(modelXf); CGraphics::SetModelMatrix(modelXf);
zeus::CColor color = g_tweakTargeting->GetTargetFlowerColor(); zeus::CColor color = g_tweakTargeting->GetTargetFlowerColor();
color.a() *= lockBreakAlpha * visorFactor; color.a() *= lockBreakAlpha * visorFactor;
CModelFlags flags(7, 0, 0, lockBreakColor + color); const CModelFlags flags(7, 0, 0, lockBreakColor + color);
x58_targetFlower->Draw(flags); x58_targetFlower->Draw(flags);
} }
if (x1f8_missileBracketTimer != 0.f && x64_missileBracket.IsLoaded()) { if (x1f8_missileBracketTimer != 0.f && x64_missileBracket.IsLoaded()) {
float t = std::fabs((x1fc_missileBracketScaleTimer - 0.5f * g_tweakTargeting->GetMissileBracketScaleDuration()) / const float t =
0.5f * g_tweakTargeting->GetMissileBracketScaleDuration()); std::fabs((x1fc_missileBracketScaleTimer - 0.5f * g_tweakTargeting->GetMissileBracketScaleDuration()) / 0.5f *
float tscale = ((1.f - t) * g_tweakTargeting->GetMissileBracketScaleEnd() + g_tweakTargeting->GetMissileBracketScaleDuration());
t * g_tweakTargeting->GetMissileBracketScaleStart()); const float tscale = ((1.f - t) * g_tweakTargeting->GetMissileBracketScaleEnd() +
zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(), t * g_tweakTargeting->GetMissileBracketScaleStart());
x10c_currGroupInterp.GetRadiusWorld(), const zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(),
x10c_currGroupInterp.GetMinViewportClampScale() * x10c_currGroupInterp.GetRadiusWorld(),
g_tweakTargeting->GetMissileBracketClampMin(), x10c_currGroupInterp.GetMinViewportClampScale() *
g_tweakTargeting->GetMissileBracketClampMax(), mgr) * g_tweakTargeting->GetMissileBracketClampMin(),
std::fabs(x1f8_missileBracketTimer) / g_tweakTargeting->GetMissileBracketDuration() * g_tweakTargeting->GetMissileBracketClampMax(), mgr) *
tscale / x10c_currGroupInterp.GetFactor()); std::fabs(x1f8_missileBracketTimer) / g_tweakTargeting->GetMissileBracketDuration() *
tscale / x10c_currGroupInterp.GetFactor());
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
zeus::CTransform modelXf( const zeus::CTransform modelXf(
lockBreakXf * rot * zeus::CMatrix3f(zeus::CVector3f{i < 2 ? 1.f : -1.f, 1.f, i & 0x1 ? 1.f : -1.f}) * scale, lockBreakXf * rot * zeus::CMatrix3f(zeus::CVector3f{i < 2 ? 1.f : -1.f, 1.f, i & 0x1 ? 1.f : -1.f}) * scale,
x10c_currGroupInterp.GetTargetPositionWorld()); x10c_currGroupInterp.GetTargetPositionWorld());
CGraphics::SetModelMatrix(modelXf); CGraphics::SetModelMatrix(modelXf);
zeus::CColor color = g_tweakTargeting->GetMissileBracketColor(); zeus::CColor color = g_tweakTargeting->GetMissileBracketColor();
color.a() *= lockBreakAlpha * visorFactor; color.a() *= lockBreakAlpha * visorFactor;
CModelFlags flags(7, 0, 0, lockBreakColor + color); const CModelFlags flags(7, 0, 0, lockBreakColor + color);
x64_missileBracket->Draw(flags); x64_missileBracket->Draw(flags);
} }
} }
zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(),
x10c_currGroupInterp.GetRadiusWorld(), const zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(),
x10c_currGroupInterp.GetMinViewportClampScale() * x10c_currGroupInterp.GetRadiusWorld(),
g_tweakTargeting->GetChargeGaugeClampMin(), x10c_currGroupInterp.GetMinViewportClampScale() *
g_tweakTargeting->GetChargeGaugeClampMax(), mgr) * g_tweakTargeting->GetChargeGaugeClampMin(),
1.f / x10c_currGroupInterp.GetFactor() * g_tweakTargeting->GetOuterBeamSquaresScale()); g_tweakTargeting->GetChargeGaugeClampMax(), mgr) *
1.f / x10c_currGroupInterp.GetFactor() * g_tweakTargeting->GetOuterBeamSquaresScale());
zeus::CMatrix3f outerBeamXf = rot * scale; zeus::CMatrix3f outerBeamXf = rot * scale;
for (int i = 0; i < 9; ++i) { for (int i = 0; i < 9; ++i) {
const SOuterItemInfo& info = xe0_outerBeamIconSquares[i]; const SOuterItemInfo& info = xe0_outerBeamIconSquares[i];
@ -623,16 +689,18 @@ void CCompoundTargetReticle::DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, con
info.x0_model->Draw(flags); info.x0_model->Draw(flags);
} }
} }
if (xc4_chargeGauge.x0_model.IsLoaded()) { if (xc4_chargeGauge.x0_model.IsLoaded()) {
zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(), const zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(),
x10c_currGroupInterp.GetRadiusWorld(), x10c_currGroupInterp.GetRadiusWorld(),
x10c_currGroupInterp.GetMinViewportClampScale() * x10c_currGroupInterp.GetMinViewportClampScale() *
g_tweakTargeting->GetChargeGaugeClampMin(), g_tweakTargeting->GetChargeGaugeClampMin(),
g_tweakTargeting->GetChargeGaugeClampMax(), mgr) * g_tweakTargeting->GetChargeGaugeClampMax(), mgr) *
g_tweakTargeting->GetChargeGaugeScale() / x10c_currGroupInterp.GetFactor()); g_tweakTargeting->GetChargeGaugeScale() / x10c_currGroupInterp.GetFactor());
zeus::CMatrix3f chargeGaugeXf = rot * scale * zeus::CMatrix3f::RotateY(xc4_chargeGauge.x10_rotAng); const zeus::CMatrix3f chargeGaugeXf = rot * scale * zeus::CMatrix3f::RotateY(xc4_chargeGauge.x10_rotAng);
float pulseT = std::fabs(std::fmod(CGraphics::GetSecondsMod900(), g_tweakTargeting->GetChargeGaugePulsePeriod())); const float pulseT =
zeus::CColor gaugeColor = std::fabs(std::fmod(CGraphics::GetSecondsMod900(), g_tweakTargeting->GetChargeGaugePulsePeriod()));
const zeus::CColor gaugeColor =
zeus::CColor::lerp(g_tweakTargeting->GetChargeGaugeNonFullColor(), zeus::CColor::lerp(g_tweakTargeting->GetChargeGaugeNonFullColor(),
zeus::CColor::lerp(g_tweakTargeting->GetChargeGaugePulseColorHigh(), zeus::CColor::lerp(g_tweakTargeting->GetChargeGaugePulseColorHigh(),
g_tweakTargeting->GetChargeGaugePulseColorLow(), g_tweakTargeting->GetChargeGaugePulseColorLow(),
@ -645,21 +713,22 @@ void CCompoundTargetReticle::DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, con
CGraphics::SetModelMatrix(modelXf); CGraphics::SetModelMatrix(modelXf);
zeus::CColor color = gaugeColor; zeus::CColor color = gaugeColor;
color.a() *= lockBreakAlpha * visorFactor; color.a() *= lockBreakAlpha * visorFactor;
CModelFlags flags(7, 0, 0, lockBreakColor + color); const CModelFlags flags(7, 0, 0, lockBreakColor + color);
xc4_chargeGauge.x0_model->Draw(flags); xc4_chargeGauge.x0_model->Draw(flags);
if (xa0_chargeTickFirst.IsLoaded()) { if (xa0_chargeTickFirst.IsLoaded()) {
const CPlayerGun* gun = mgr.GetPlayer().GetPlayerGun(); const CPlayerGun* gun = mgr.GetPlayer().GetPlayerGun();
int numTicks = const int numTicks =
int(g_tweakTargeting->GetChargeTickCount() * (gun->IsCharging() ? gun->GetChargeBeamFactor() : 0.f)); int(g_tweakTargeting->GetChargeTickCount() * (gun->IsCharging() ? gun->GetChargeBeamFactor() : 0.f));
for (int i = 0; i < numTicks; ++i) { for (int i = 0; i < numTicks; ++i) {
CModelFlags flags(7, 0, 0, lockBreakColor + color); const CModelFlags tickFlags(7, 0, 0, lockBreakColor + color);
xa0_chargeTickFirst->Draw(flags); xa0_chargeTickFirst->Draw(tickFlags);
modelXf.rotateLocalY(g_tweakTargeting->GetChargeTickAnglePitch()); modelXf.rotateLocalY(g_tweakTargeting->GetChargeTickAnglePitch());
CGraphics::SetModelMatrix(modelXf); CGraphics::SetModelMatrix(modelXf);
} }
} }
} }
if (x208_lockonTimer > 0.f && x70_innerBeamIcon.IsLoaded()) { if (x208_lockonTimer > 0.f && x70_innerBeamIcon.IsLoaded()) {
const zeus::CColor* iconColor; const zeus::CColor* iconColor;
switch (x200_beam) { switch (x200_beam) {
@ -676,41 +745,44 @@ void CCompoundTargetReticle::DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, con
iconColor = &g_tweakTargeting->GetInnerBeamColorPlasma(); iconColor = &g_tweakTargeting->GetInnerBeamColorPlasma();
break; break;
} }
zeus::CMatrix3f scale(
const zeus::CMatrix3f scale(
CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(), x10c_currGroupInterp.GetRadiusWorld(), CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(), x10c_currGroupInterp.GetRadiusWorld(),
x10c_currGroupInterp.GetMinViewportClampScale() * x10c_currGroupInterp.GetMinViewportClampScale() *
g_tweakTargeting->GetInnerBeamClampMin(), g_tweakTargeting->GetInnerBeamClampMin(),
g_tweakTargeting->GetInnerBeamClampMax(), mgr) * g_tweakTargeting->GetInnerBeamClampMax(), mgr) *
g_tweakTargeting->GetInnerBeamScale() * (x208_lockonTimer / g_tweakTargeting->GetLockonDuration()) / g_tweakTargeting->GetInnerBeamScale() * (x208_lockonTimer / g_tweakTargeting->GetLockonDuration()) /
x10c_currGroupInterp.GetFactor()); x10c_currGroupInterp.GetFactor());
zeus::CTransform modelXf(lockBreakXf * rot * scale, x10c_currGroupInterp.GetTargetPositionWorld()); const zeus::CTransform modelXf(lockBreakXf * rot * scale, x10c_currGroupInterp.GetTargetPositionWorld());
CGraphics::SetModelMatrix(modelXf); CGraphics::SetModelMatrix(modelXf);
zeus::CColor color = *iconColor; zeus::CColor color = *iconColor;
color.a() *= lockBreakAlpha * visorFactor; color.a() *= lockBreakAlpha * visorFactor;
CModelFlags flags(7, 0, 0, lockBreakColor + color); const CModelFlags flags(7, 0, 0, lockBreakColor + color);
x70_innerBeamIcon->Draw(flags); x70_innerBeamIcon->Draw(flags);
} }
if (x210_lockFireTimer > 0.f && x7c_lockFire.IsLoaded()) { if (x210_lockFireTimer > 0.f && x7c_lockFire.IsLoaded()) {
zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(), const zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(),
x10c_currGroupInterp.GetRadiusWorld(), x10c_currGroupInterp.GetRadiusWorld(),
x10c_currGroupInterp.GetMinViewportClampScale() * x10c_currGroupInterp.GetMinViewportClampScale() *
g_tweakTargeting->GetLockFireClampMin(), g_tweakTargeting->GetLockFireClampMin(),
g_tweakTargeting->GetLockFireClampMax(), mgr) * g_tweakTargeting->GetLockFireClampMax(), mgr) *
g_tweakTargeting->GetLockFireScale() / x10c_currGroupInterp.GetFactor()); g_tweakTargeting->GetLockFireScale() / x10c_currGroupInterp.GetFactor());
zeus::CTransform modelXf(lockBreakXf * rot * scale * zeus::CMatrix3f::RotateY(x1f0_xrayRetAngle), const zeus::CTransform modelXf(lockBreakXf * rot * scale * zeus::CMatrix3f::RotateY(x1f0_xrayRetAngle),
x10c_currGroupInterp.GetTargetPositionWorld()); x10c_currGroupInterp.GetTargetPositionWorld());
CGraphics::SetModelMatrix(modelXf); CGraphics::SetModelMatrix(modelXf);
zeus::CColor color = g_tweakTargeting->GetLockFireColor(); zeus::CColor color = g_tweakTargeting->GetLockFireColor();
color.a() *= visorFactor * lockBreakAlpha * (x210_lockFireTimer / g_tweakTargeting->GetLockFireDuration()); color.a() *= visorFactor * lockBreakAlpha * (x210_lockFireTimer / g_tweakTargeting->GetLockFireDuration());
CModelFlags flags(7, 0, 0, lockBreakColor + color); const CModelFlags flags(7, 0, 0, lockBreakColor + color);
x7c_lockFire->Draw(flags); x7c_lockFire->Draw(flags);
} }
if (x208_lockonTimer > 0.f && x88_lockDagger.IsLoaded()) { if (x208_lockonTimer > 0.f && x88_lockDagger.IsLoaded()) {
float t = std::fabs((x210_lockFireTimer - 0.5f * g_tweakTargeting->GetLockFireDuration()) / 0.5f * const float t = std::fabs((x210_lockFireTimer - 0.5f * g_tweakTargeting->GetLockFireDuration()) / 0.5f *
g_tweakTargeting->GetLockFireDuration()); g_tweakTargeting->GetLockFireDuration());
float tscale = const float tscale =
((1.f - t) * g_tweakTargeting->GetLockDaggerScaleEnd() + t * g_tweakTargeting->GetLockDaggerScaleStart()); ((1.f - t) * g_tweakTargeting->GetLockDaggerScaleEnd() + t * g_tweakTargeting->GetLockDaggerScaleStart());
zeus::CMatrix3f scale( const zeus::CMatrix3f scale(
CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(), x10c_currGroupInterp.GetRadiusWorld(), CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(), x10c_currGroupInterp.GetRadiusWorld(),
x10c_currGroupInterp.GetMinViewportClampScale() * x10c_currGroupInterp.GetMinViewportClampScale() *
g_tweakTargeting->GetLockDaggerClampMin(), g_tweakTargeting->GetLockDaggerClampMin(),
@ -730,12 +802,12 @@ void CCompoundTargetReticle::DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, con
ang = g_tweakTargeting->GetLockDaggerAngle2(); ang = g_tweakTargeting->GetLockDaggerAngle2();
break; break;
} }
zeus::CTransform modelXf(lockBreakXf * lockDaggerXf * zeus::CMatrix3f::RotateY(ang), const zeus::CTransform modelXf(lockBreakXf * lockDaggerXf * zeus::CMatrix3f::RotateY(ang),
x10c_currGroupInterp.GetTargetPositionWorld()); x10c_currGroupInterp.GetTargetPositionWorld());
CGraphics::SetModelMatrix(modelXf); CGraphics::SetModelMatrix(modelXf);
zeus::CColor color = g_tweakTargeting->GetLockDaggerColor(); zeus::CColor color = g_tweakTargeting->GetLockDaggerColor();
color.a() *= visorFactor * lockBreakAlpha; color.a() *= visorFactor * lockBreakAlpha;
CModelFlags flags(7, 0, 0, lockBreakColor + color); const CModelFlags flags(7, 0, 0, lockBreakColor + color);
x88_lockDagger->Draw(flags); x88_lockDagger->Draw(flags);
} }
} }
@ -768,64 +840,64 @@ void CCompoundTargetReticle::DrawNextLockOnGroup(const zeus::CMatrix3f& rot, con
} }
if (!xrayRet && x174_nextGroupInterp.GetFactor() > 0.f && x40_seeker.IsLoaded()) { if (!xrayRet && x174_nextGroupInterp.GetFactor() > 0.f && x40_seeker.IsLoaded()) {
zeus::CMatrix3f scale( const zeus::CMatrix3f scale(
CalculateClampedScale(position, x174_nextGroupInterp.GetRadiusWorld(), CalculateClampedScale(position, x174_nextGroupInterp.GetRadiusWorld(),
x174_nextGroupInterp.GetMinViewportClampScale() * g_tweakTargeting->GetSeekerClampMin(), x174_nextGroupInterp.GetMinViewportClampScale() * g_tweakTargeting->GetSeekerClampMin(),
g_tweakTargeting->GetSeekerClampMax(), mgr) * g_tweakTargeting->GetSeekerClampMax(), mgr) *
g_tweakTargeting->GetSeekerScale()); g_tweakTargeting->GetSeekerScale());
zeus::CTransform modelXf(rot * zeus::CMatrix3f::RotateY(x1ec_seekerAngle) * scale, const zeus::CTransform modelXf(rot * zeus::CMatrix3f::RotateY(x1ec_seekerAngle) * scale,
x174_nextGroupInterp.GetTargetPositionWorld()); x174_nextGroupInterp.GetTargetPositionWorld());
CGraphics::SetModelMatrix(modelXf); CGraphics::SetModelMatrix(modelXf);
zeus::CColor color = g_tweakTargeting->GetSeekerColor(); zeus::CColor color = g_tweakTargeting->GetSeekerColor();
color.a() *= x174_nextGroupInterp.GetFactor(); color.a() *= x174_nextGroupInterp.GetFactor();
CModelFlags flags(7, 0, 0, color); const CModelFlags flags(7, 0, 0, color);
x40_seeker->Draw(flags); x40_seeker->Draw(flags);
} }
if (xrayRet && xac_xrayRetRing.IsLoaded()) { if (xrayRet && xac_xrayRetRing.IsLoaded()) {
zeus::CMatrix3f scale( const zeus::CMatrix3f scale(
CalculateClampedScale(position, x174_nextGroupInterp.GetRadiusWorld(), CalculateClampedScale(position, x174_nextGroupInterp.GetRadiusWorld(),
x174_nextGroupInterp.GetMinViewportClampScale() * g_tweakTargeting->GetReticuleClampMin(), x174_nextGroupInterp.GetMinViewportClampScale() * g_tweakTargeting->GetReticuleClampMin(),
g_tweakTargeting->GetReticuleClampMax(), mgr) * g_tweakTargeting->GetReticuleClampMax(), mgr) *
g_tweakTargeting->GetReticuleScale()); g_tweakTargeting->GetReticuleScale());
zeus::CTransform modelXf(rot * scale * zeus::CMatrix3f::RotateY(x1f0_xrayRetAngle), const zeus::CTransform modelXf(rot * scale * zeus::CMatrix3f::RotateY(x1f0_xrayRetAngle),
x174_nextGroupInterp.GetTargetPositionWorld()); x174_nextGroupInterp.GetTargetPositionWorld());
CGraphics::SetModelMatrix(modelXf); CGraphics::SetModelMatrix(modelXf);
zeus::CColor color = g_tweakTargeting->GetXRayRetRingColor(); zeus::CColor color = g_tweakTargeting->GetXRayRetRingColor();
color.a() *= visorFactor; color.a() *= visorFactor;
CModelFlags flags(7, 0, 0, color); const CModelFlags flags(7, 0, 0, color);
xac_xrayRetRing->Draw(flags); xac_xrayRetRing->Draw(flags);
} }
if (thermalRet && xb8_thermalReticle.IsLoaded()) { if (thermalRet && xb8_thermalReticle.IsLoaded()) {
zeus::CMatrix3f scale( const zeus::CMatrix3f scale(
CalculateClampedScale(position, x174_nextGroupInterp.GetRadiusWorld(), CalculateClampedScale(position, x174_nextGroupInterp.GetRadiusWorld(),
x174_nextGroupInterp.GetMinViewportClampScale() * g_tweakTargeting->GetReticuleClampMin(), x174_nextGroupInterp.GetMinViewportClampScale() * g_tweakTargeting->GetReticuleClampMin(),
g_tweakTargeting->GetReticuleClampMax(), mgr) * g_tweakTargeting->GetReticuleClampMax(), mgr) *
g_tweakTargeting->GetReticuleScale()); g_tweakTargeting->GetReticuleScale());
zeus::CTransform modelXf(rot * scale, x174_nextGroupInterp.GetTargetPositionWorld()); const zeus::CTransform modelXf(rot * scale, x174_nextGroupInterp.GetTargetPositionWorld());
CGraphics::SetModelMatrix(modelXf); CGraphics::SetModelMatrix(modelXf);
zeus::CColor color = g_tweakTargeting->GetThermalReticuleColor(); zeus::CColor color = g_tweakTargeting->GetThermalReticuleColor();
color.a() *= visorFactor; color.a() *= visorFactor;
CModelFlags flags(7, 0, 0, color); const CModelFlags flags(7, 0, 0, color);
xb8_thermalReticle->Draw(flags); xb8_thermalReticle->Draw(flags);
} }
if (scanRet && visorFactor > 0.f) { if (scanRet && visorFactor > 0.f) {
float factor = visorFactor * x174_nextGroupInterp.GetFactor(); float factor = visorFactor * x174_nextGroupInterp.GetFactor();
zeus::CMatrix3f scale(CalculateClampedScale(position, x174_nextGroupInterp.GetRadiusWorld(), const zeus::CMatrix3f scale(CalculateClampedScale(position, x174_nextGroupInterp.GetRadiusWorld(),
x174_nextGroupInterp.GetMinViewportClampScale() * x174_nextGroupInterp.GetMinViewportClampScale() *
g_tweakTargeting->GetScanTargetClampMin(), g_tweakTargeting->GetScanTargetClampMin(),
g_tweakTargeting->GetScanTargetClampMax(), mgr) * g_tweakTargeting->GetScanTargetClampMax(), mgr) *
(1.f / factor)); (1.f / factor));
zeus::CTransform modelXf(rot * scale, x174_nextGroupInterp.GetTargetPositionWorld()); const zeus::CTransform modelXf(rot * scale, x174_nextGroupInterp.GetTargetPositionWorld());
CGraphics::SetModelMatrix(modelXf); CGraphics::SetModelMatrix(modelXf);
// compare, GX_LESS, no update // compare, GX_LESS, no update
float alpha = 0.5f * factor; float alpha = 0.5f * factor;
zeus::CColor color = g_tweakGuiColors->GetScanReticuleColor(); zeus::CColor color = g_tweakGuiColors->GetScanReticuleColor();
color.a() *= alpha; color.a() *= alpha;
for (size_t i = 0; i < m_scanRetRenderer.m_lineRenderers.size(); ++i) { for (size_t i = 0; i < m_scanRetRenderer.m_lineRenderers.size(); ++i) {
float lineWidth = i != 0 ? 2.5f : 1.f; const float lineWidth = i != 0 ? 2.5f : 1.f;
auto& rend = *m_scanRetRenderer.m_lineRenderers[i]; auto& rend = *m_scanRetRenderer.m_lineRenderers[i];
rend.Reset(); rend.Reset();
rend.AddVertex({-0.5f, 0.f, 0.f}, color, lineWidth); rend.AddVertex({-0.5f, 0.f, 0.f}, color, lineWidth);
@ -839,8 +911,8 @@ void CCompoundTargetReticle::DrawNextLockOnGroup(const zeus::CMatrix3f& rot, con
rend.Render(); rend.Render();
for (size_t j = 0; j < m_scanRetRenderer.m_stripRenderers[i].size(); ++j) { for (size_t j = 0; j < m_scanRetRenderer.m_stripRenderers[i].size(); ++j) {
float xSign = j < 2 ? -1.f : 1.f; const float xSign = j < 2 ? -1.f : 1.f;
float zSign = (j & 0x1) != 0 ? -1.f : 1.f; const float zSign = (j & 0x1) != 0 ? -1.f : 1.f;
// begin line strip // begin line strip
auto& stripRend = *m_scanRetRenderer.m_stripRenderers[i][j]; auto& stripRend = *m_scanRetRenderer.m_stripRenderers[i][j];
stripRend.Reset(); stripRend.Reset();
@ -855,20 +927,21 @@ void CCompoundTargetReticle::DrawNextLockOnGroup(const zeus::CMatrix3f& rot, con
} }
void CCompoundTargetReticle::DrawOrbitZoneGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr) const { void CCompoundTargetReticle::DrawOrbitZoneGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr) const {
if (x28_noDrawTicks > 0) if (x28_noDrawTicks > 0) {
return; return;
}
if (x1e8_crosshairsScale > 0.f && x34_crosshairs.IsLoaded()) { if (x1e8_crosshairsScale > 0.f && x34_crosshairs.IsLoaded()) {
CGraphics::SetModelMatrix(zeus::CTransform(rot, xf4_targetPos) * zeus::CTransform::Scale(x1e8_crosshairsScale)); CGraphics::SetModelMatrix(zeus::CTransform(rot, xf4_targetPos) * zeus::CTransform::Scale(x1e8_crosshairsScale));
zeus::CColor color = g_tweakTargeting->GetCrosshairsColor(); zeus::CColor color = g_tweakTargeting->GetCrosshairsColor();
color.a() *= x1e8_crosshairsScale; color.a() *= x1e8_crosshairsScale;
CModelFlags flags(7, 0, 0, color); const CModelFlags flags(7, 0, 0, color);
x34_crosshairs->Draw(flags); x34_crosshairs->Draw(flags);
} }
} }
void CCompoundTargetReticle::UpdateTargetParameters(CTargetReticleRenderState& state, const CStateManager& mgr) { void CCompoundTargetReticle::UpdateTargetParameters(CTargetReticleRenderState& state, const CStateManager& mgr) {
if (auto act = TCastToConstPtr<CActor>(mgr.GetAllObjectList().GetObjectById(state.GetTargetId()))) { if (const auto act = TCastToConstPtr<CActor>(mgr.GetAllObjectList().GetObjectById(state.GetTargetId()))) {
state.SetRadiusWorld(CalculateRadiusWorld(*act, mgr)); state.SetRadiusWorld(CalculateRadiusWorld(*act, mgr));
state.SetTargetPositionWorld(CalculatePositionWorld(*act, mgr)); state.SetTargetPositionWorld(CalculatePositionWorld(*act, mgr));
} else if (state.GetIsOrbitZoneIdlePosition()) { } else if (state.GetIsOrbitZoneIdlePosition()) {
@ -880,11 +953,11 @@ void CCompoundTargetReticle::UpdateTargetParameters(CTargetReticleRenderState& s
} }
float CCompoundTargetReticle::CalculateRadiusWorld(const CActor& act, const CStateManager& mgr) const { float CCompoundTargetReticle::CalculateRadiusWorld(const CActor& act, const CStateManager& mgr) const {
auto tb = act.GetTouchBounds(); const auto tb = act.GetTouchBounds();
zeus::CAABox aabb = tb ? *tb : zeus::CAABox(act.GetAimPosition(mgr, 0.f), act.GetAimPosition(mgr, 0.f)); const zeus::CAABox aabb = tb ? *tb : zeus::CAABox(act.GetAimPosition(mgr, 0.f), act.GetAimPosition(mgr, 0.f));
float radius; float radius;
zeus::CVector3f delta = aabb.max - aabb.min; const zeus::CVector3f delta = aabb.max - aabb.min;
switch (g_tweakTargeting->GetTargetRadiusMode()) { switch (g_tweakTargeting->GetTargetRadiusMode()) {
case 0: { case 0: {
radius = std::min(delta.x(), std::min(delta.y(), delta.z())) * 0.5f; radius = std::min(delta.x(), std::min(delta.y(), delta.z())) * 0.5f;
@ -904,19 +977,21 @@ float CCompoundTargetReticle::CalculateRadiusWorld(const CActor& act, const CSta
} }
zeus::CVector3f CCompoundTargetReticle::CalculatePositionWorld(const CActor& act, const CStateManager& mgr) const { zeus::CVector3f CCompoundTargetReticle::CalculatePositionWorld(const CActor& act, const CStateManager& mgr) const {
if (x20_prevState == EReticleState::Scan) if (x20_prevState == EReticleState::Scan) {
return act.GetOrbitPosition(mgr); return act.GetOrbitPosition(mgr);
}
return act.GetAimPosition(mgr, 0.f); return act.GetAimPosition(mgr, 0.f);
} }
zeus::CVector3f CCompoundTargetReticle::CalculateOrbitZoneReticlePosition(const CStateManager& mgr, bool lag) const { zeus::CVector3f CCompoundTargetReticle::CalculateOrbitZoneReticlePosition(const CStateManager& mgr, bool lag) const {
const CGameCamera* curCam = mgr.GetCameraManager()->GetCurrentCamera(mgr); const CGameCamera* curCam = mgr.GetCameraManager()->GetCurrentCamera(mgr);
float distMul = const float distMul =
224.f / float(g_tweakPlayer->GetOrbitScreenBoxHalfExtentY(0)) / std::tan(zeus::degToRad(0.5f * curCam->GetFov())); 224.f / float(g_tweakPlayer->GetOrbitScreenBoxHalfExtentY(0)) / std::tan(zeus::degToRad(0.5f * curCam->GetFov()));
zeus::CTransform camXf = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr); const zeus::CTransform camXf = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr);
zeus::CVector3f lookDir = camXf.basis[1]; zeus::CVector3f lookDir = camXf.basis[1];
if (lag) if (lag) {
lookDir = x10_laggingOrientation.transform(lookDir); lookDir = x10_laggingOrientation.transform(lookDir);
}
return lookDir * distMul + camXf.origin; return lookDir * distMul + camXf.origin;
} }
@ -930,42 +1005,70 @@ float CCompoundTargetReticle::CalculateClampedScale(const zeus::CVector3f& pos,
mgr.GetCameraManager()->GetCurrentCameraTransform(mgr); mgr.GetCameraManager()->GetCurrentCameraTransform(mgr);
zeus::CVector3f viewPos = cam->GetTransform().transposeRotate(pos - cam->GetTransform().origin); zeus::CVector3f viewPos = cam->GetTransform().transposeRotate(pos - cam->GetTransform().origin);
viewPos = zeus::CVector3f(viewPos.x(), viewPos.z(), -viewPos.y()); viewPos = zeus::CVector3f(viewPos.x(), viewPos.z(), -viewPos.y());
float realX = cam->GetPerspectiveMatrix().multiplyOneOverW(viewPos).x(); const float realX = cam->GetPerspectiveMatrix().multiplyOneOverW(viewPos).x();
float offsetX = cam->GetPerspectiveMatrix().multiplyOneOverW(viewPos + zeus::CVector3f(scale, 0.f, 0.f)).x(); const float offsetX = cam->GetPerspectiveMatrix().multiplyOneOverW(viewPos + zeus::CVector3f(scale, 0.f, 0.f)).x();
float unclampedX = (offsetX - realX) * 640; const float unclampedX = (offsetX - realX) * 640;
return zeus::clamp(clampMin, unclampedX, clampMax) / unclampedX * scale; return zeus::clamp(clampMin, unclampedX, clampMax) / unclampedX * scale;
} }
void CCompoundTargetReticle::Touch() { void CCompoundTargetReticle::Touch() {
if (x34_crosshairs.IsLoaded()) if (x34_crosshairs.IsLoaded()) {
x34_crosshairs->Touch(0); x34_crosshairs->Touch(0);
if (x40_seeker.IsLoaded()) }
if (x40_seeker.IsLoaded()) {
x40_seeker->Touch(0); x40_seeker->Touch(0);
if (x4c_lockConfirm.IsLoaded()) }
if (x4c_lockConfirm.IsLoaded()) {
x4c_lockConfirm->Touch(0); x4c_lockConfirm->Touch(0);
if (x58_targetFlower.IsLoaded()) }
if (x58_targetFlower.IsLoaded()) {
x58_targetFlower->Touch(0); x58_targetFlower->Touch(0);
if (x64_missileBracket.IsLoaded()) }
if (x64_missileBracket.IsLoaded()) {
x64_missileBracket->Touch(0); x64_missileBracket->Touch(0);
if (x70_innerBeamIcon.IsLoaded()) }
if (x70_innerBeamIcon.IsLoaded()) {
x70_innerBeamIcon->Touch(0); x70_innerBeamIcon->Touch(0);
if (x7c_lockFire.IsLoaded()) }
if (x7c_lockFire.IsLoaded()) {
x7c_lockFire->Touch(0); x7c_lockFire->Touch(0);
if (x88_lockDagger.IsLoaded()) }
if (x88_lockDagger.IsLoaded()) {
x88_lockDagger->Touch(0); x88_lockDagger->Touch(0);
if (x94_grapple.IsLoaded()) }
if (x94_grapple.IsLoaded()) {
x94_grapple->Touch(0); x94_grapple->Touch(0);
if (xa0_chargeTickFirst.IsLoaded()) }
if (xa0_chargeTickFirst.IsLoaded()) {
xa0_chargeTickFirst->Touch(0); xa0_chargeTickFirst->Touch(0);
if (xac_xrayRetRing.IsLoaded()) }
if (xac_xrayRetRing.IsLoaded()) {
xac_xrayRetRing->Touch(0); xac_xrayRetRing->Touch(0);
if (xb8_thermalReticle.IsLoaded()) }
if (xb8_thermalReticle.IsLoaded()) {
xb8_thermalReticle->Touch(0); xb8_thermalReticle->Touch(0);
if (xc4_chargeGauge.x0_model.IsLoaded()) }
if (xc4_chargeGauge.x0_model.IsLoaded()) {
xc4_chargeGauge.x0_model->Touch(0); xc4_chargeGauge.x0_model->Touch(0);
for (SOuterItemInfo& info : xe0_outerBeamIconSquares) }
if (info.x0_model.IsLoaded())
for (SOuterItemInfo& info : xe0_outerBeamIconSquares) {
if (info.x0_model.IsLoaded()) {
info.x0_model->Touch(0); info.x0_model->Touch(0);
}
}
} }
} // namespace urde } // namespace urde