From d5e57b534870303b7c156fa89f6545b46977324b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 12 Apr 2020 04:19:48 -0400 Subject: [PATCH] CCompoundTargetReticle: Make skZeroRenderState constexpr Allows eliding runtime initializers where applicable. Particularly for the static data. --- Runtime/GuiSys/CCompoundTargetReticle.cpp | 4 ++-- Runtime/GuiSys/CCompoundTargetReticle.hpp | 28 +++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Runtime/GuiSys/CCompoundTargetReticle.cpp b/Runtime/GuiSys/CCompoundTargetReticle.cpp index c54dc531a..af9e138d1 100644 --- a/Runtime/GuiSys/CCompoundTargetReticle.cpp +++ b/Runtime/GuiSys/CCompoundTargetReticle.cpp @@ -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)); } } // Anonymous namespace -const CTargetReticleRenderState CTargetReticleRenderState::skZeroRenderState(kInvalidUniqueId, 1.f, - zeus::skZero3f, 0.f, 1.f, true); +constexpr CTargetReticleRenderState CTargetReticleRenderState::skZeroRenderState(kInvalidUniqueId, 1.f, zeus::skZero3f, + 0.f, 1.f, true); CCompoundTargetReticle::SOuterItemInfo::SOuterItemInfo(std::string_view res) : x0_model(g_SimplePool->GetObj(res)) {} diff --git a/Runtime/GuiSys/CCompoundTargetReticle.hpp b/Runtime/GuiSys/CCompoundTargetReticle.hpp index 7d8f20a53..6a6b4da8b 100644 --- a/Runtime/GuiSys/CCompoundTargetReticle.hpp +++ b/Runtime/GuiSys/CCompoundTargetReticle.hpp @@ -27,26 +27,26 @@ class CTargetReticleRenderState { public: static const CTargetReticleRenderState skZeroRenderState; - CTargetReticleRenderState(TUniqueId target, float radiusWorld, const zeus::CVector3f& positionWorld, float factor, - float minVpClampScale, bool orbitZoneIdlePosition) + constexpr CTargetReticleRenderState(TUniqueId target, float radiusWorld, const zeus::CVector3f& positionWorld, + float factor, float minVpClampScale, bool orbitZoneIdlePosition) : x0_target(target) , x4_radiusWorld(radiusWorld) , x8_positionWorld(positionWorld) , x14_factor(factor) , x18_minVpClampScale(minVpClampScale) , x1c_orbitZoneIdlePosition(orbitZoneIdlePosition) {} - void SetTargetId(TUniqueId id) { x0_target = id; } - void SetFactor(float f) { x14_factor = f; } - void SetIsOrbitZoneIdlePosition(bool b) { x1c_orbitZoneIdlePosition = b; } - float GetMinViewportClampScale() const { return x18_minVpClampScale; } - float GetFactor() const { return x14_factor; } - float GetRadiusWorld() const { return x4_radiusWorld; } - const zeus::CVector3f& GetTargetPositionWorld() const { return x8_positionWorld; } - bool GetIsOrbitZoneIdlePosition() const { return x1c_orbitZoneIdlePosition; } - void SetTargetPositionWorld(const zeus::CVector3f& pos) { x8_positionWorld = pos; } - void SetRadiusWorld(float r) { x4_radiusWorld = r; } - TUniqueId GetTargetId() const { return x0_target; } - void SetMinViewportClampScale(float s) { x18_minVpClampScale = s; } + constexpr void SetTargetId(TUniqueId id) { x0_target = id; } + constexpr void SetFactor(float factor) { x14_factor = factor; } + constexpr void SetIsOrbitZoneIdlePosition(bool orbit) { x1c_orbitZoneIdlePosition = orbit; } + constexpr float GetMinViewportClampScale() const { return x18_minVpClampScale; } + constexpr float GetFactor() const { return x14_factor; } + constexpr float GetRadiusWorld() const { return x4_radiusWorld; } + constexpr const zeus::CVector3f& GetTargetPositionWorld() const { return x8_positionWorld; } + constexpr bool GetIsOrbitZoneIdlePosition() const { return x1c_orbitZoneIdlePosition; } + constexpr void SetTargetPositionWorld(const zeus::CVector3f& position) { x8_positionWorld = position; } + constexpr void SetRadiusWorld(float radius) { x4_radiusWorld = radius; } + constexpr TUniqueId GetTargetId() const { return x0_target; } + constexpr void SetMinViewportClampScale(float scale) { x18_minVpClampScale = scale; } static void InterpolateWithClamp(const CTargetReticleRenderState& a, CTargetReticleRenderState& out, const CTargetReticleRenderState& b, float t); };