CCompoundTargetReticle: Make skZeroRenderState constexpr

Allows eliding runtime initializers where applicable. Particularly for
the static data.
This commit is contained in:
Lioncash 2020-04-12 04:19:48 -04:00
parent 32134990c3
commit d5e57b5348
2 changed files with 16 additions and 16 deletions

View File

@ -36,8 +36,8 @@ float offshoot_func(float f1, float f2, float f3) { return (f1 * 0.5f) + std::si
float calculate_premultiplied_overshoot_offset(float f1) { return 2.f * (M_PIF - std::asin(1.f / f1)); } float calculate_premultiplied_overshoot_offset(float f1) { return 2.f * (M_PIF - std::asin(1.f / f1)); }
} // Anonymous namespace } // Anonymous namespace
const CTargetReticleRenderState CTargetReticleRenderState::skZeroRenderState(kInvalidUniqueId, 1.f, constexpr CTargetReticleRenderState CTargetReticleRenderState::skZeroRenderState(kInvalidUniqueId, 1.f, zeus::skZero3f,
zeus::skZero3f, 0.f, 1.f, true); 0.f, 1.f, true);
CCompoundTargetReticle::SOuterItemInfo::SOuterItemInfo(std::string_view res) : x0_model(g_SimplePool->GetObj(res)) {} CCompoundTargetReticle::SOuterItemInfo::SOuterItemInfo(std::string_view res) : x0_model(g_SimplePool->GetObj(res)) {}

View File

@ -27,26 +27,26 @@ class CTargetReticleRenderState {
public: public:
static const CTargetReticleRenderState skZeroRenderState; static const CTargetReticleRenderState skZeroRenderState;
CTargetReticleRenderState(TUniqueId target, float radiusWorld, const zeus::CVector3f& positionWorld, float factor, constexpr CTargetReticleRenderState(TUniqueId target, float radiusWorld, const zeus::CVector3f& positionWorld,
float minVpClampScale, bool orbitZoneIdlePosition) float factor, float minVpClampScale, bool orbitZoneIdlePosition)
: x0_target(target) : x0_target(target)
, x4_radiusWorld(radiusWorld) , x4_radiusWorld(radiusWorld)
, x8_positionWorld(positionWorld) , x8_positionWorld(positionWorld)
, x14_factor(factor) , x14_factor(factor)
, x18_minVpClampScale(minVpClampScale) , x18_minVpClampScale(minVpClampScale)
, x1c_orbitZoneIdlePosition(orbitZoneIdlePosition) {} , x1c_orbitZoneIdlePosition(orbitZoneIdlePosition) {}
void SetTargetId(TUniqueId id) { x0_target = id; } constexpr void SetTargetId(TUniqueId id) { x0_target = id; }
void SetFactor(float f) { x14_factor = f; } constexpr void SetFactor(float factor) { x14_factor = factor; }
void SetIsOrbitZoneIdlePosition(bool b) { x1c_orbitZoneIdlePosition = b; } constexpr void SetIsOrbitZoneIdlePosition(bool orbit) { x1c_orbitZoneIdlePosition = orbit; }
float GetMinViewportClampScale() const { return x18_minVpClampScale; } constexpr float GetMinViewportClampScale() const { return x18_minVpClampScale; }
float GetFactor() const { return x14_factor; } constexpr float GetFactor() const { return x14_factor; }
float GetRadiusWorld() const { return x4_radiusWorld; } constexpr float GetRadiusWorld() const { return x4_radiusWorld; }
const zeus::CVector3f& GetTargetPositionWorld() const { return x8_positionWorld; } constexpr const zeus::CVector3f& GetTargetPositionWorld() const { return x8_positionWorld; }
bool GetIsOrbitZoneIdlePosition() const { return x1c_orbitZoneIdlePosition; } constexpr bool GetIsOrbitZoneIdlePosition() const { return x1c_orbitZoneIdlePosition; }
void SetTargetPositionWorld(const zeus::CVector3f& pos) { x8_positionWorld = pos; } constexpr void SetTargetPositionWorld(const zeus::CVector3f& position) { x8_positionWorld = position; }
void SetRadiusWorld(float r) { x4_radiusWorld = r; } constexpr void SetRadiusWorld(float radius) { x4_radiusWorld = radius; }
TUniqueId GetTargetId() const { return x0_target; } constexpr TUniqueId GetTargetId() const { return x0_target; }
void SetMinViewportClampScale(float s) { x18_minVpClampScale = s; } constexpr void SetMinViewportClampScale(float scale) { x18_minVpClampScale = scale; }
static void InterpolateWithClamp(const CTargetReticleRenderState& a, CTargetReticleRenderState& out, static void InterpolateWithClamp(const CTargetReticleRenderState& a, CTargetReticleRenderState& out,
const CTargetReticleRenderState& b, float t); const CTargetReticleRenderState& b, float t);
}; };