From f2201ca03c8327b155dbf0c682f2bd8251fd4a51 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 14 Jun 2020 19:05:26 -0400 Subject: [PATCH] CLight: Make CalculateSpotAngleAtten() const This member function doesn't modify internal member state. --- src/Core/Resource/CLight.cpp | 11 ++++++----- src/Core/Resource/CLight.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Core/Resource/CLight.cpp b/src/Core/Resource/CLight.cpp index 2f6b3939..fff46caf 100644 --- a/src/Core/Resource/CLight.cpp +++ b/src/Core/Resource/CLight.cpp @@ -82,13 +82,14 @@ float CLight::CalculateIntensity() const } // As is this one... partly -CVector3f CLight::CalculateSpotAngleAtten() +CVector3f CLight::CalculateSpotAngleAtten() const { - if (mType != ELightType::Spot) return CVector3f(1.f, 0.f, 0.f); + if (mType != ELightType::Spot) + return CVector3f(1.f, 0.f, 0.f); - float RadianCutoff = mSpotCutoff * (3.1415927f / 180.f); - float RadianCosine = cosf(RadianCutoff); - float InvCosine = 1.f - RadianCosine; + const float RadianCutoff = mSpotCutoff * (3.1415927f / 180.f); + const float RadianCosine = cosf(RadianCutoff); + const float InvCosine = 1.f - RadianCosine; return CVector3f(0.f, -RadianCosine / InvCosine, 1.f / InvCosine); } diff --git a/src/Core/Resource/CLight.h b/src/Core/Resource/CLight.h index ce1635ce..349ac42d 100644 --- a/src/Core/Resource/CLight.h +++ b/src/Core/Resource/CLight.h @@ -39,7 +39,7 @@ private: // Data Manipulation float CalculateRadius() const; float CalculateIntensity() const; - CVector3f CalculateSpotAngleAtten(); + CVector3f CalculateSpotAngleAtten() const; public: // Accessors