CLight: Make use of in-class initializers where applicable

Same behavior, less code.
This commit is contained in:
Lioncash 2020-06-14 19:02:38 -04:00
parent f942ad6551
commit b439e4bba1
2 changed files with 14 additions and 24 deletions

View File

@ -4,17 +4,11 @@
#include <cmath> #include <cmath>
#include <float.h> #include <float.h>
#define CLIGHT_NO_RADIUS 0x40 constexpr uint32_t CLIGHT_NO_RADIUS = 0x40;
#define CLIGHT_NO_INTENSITY 0x80 constexpr uint32_t CLIGHT_NO_INTENSITY = 0x80;
CLight::CLight() CLight::CLight()
: mPosition(skDefaultLightPos) : mDirtyFlags(CLIGHT_NO_RADIUS | CLIGHT_NO_INTENSITY)
, mDirection(skDefaultLightDir)
, mDistAttenCoefficients(0.f, 1.f, 0.f)
, mAngleAttenCoefficients(0.f, 1.f, 0.f)
, mCachedRadius(0.f)
, mCachedIntensity(0.f)
, mDirtyFlags(CLIGHT_NO_RADIUS | CLIGHT_NO_INTENSITY)
{ {
} }
@ -289,7 +283,3 @@ CLight CLight::BuildCustom(const CVector3f& rkPosition, const CVector3f& rkDirec
pLight.mAngleAttenCoefficients.Z = AngleAttenC * AngleAttenC; pLight.mAngleAttenCoefficients.Z = AngleAttenC * AngleAttenC;
return pLight; return pLight;
} }
// ************ CONSTANTS ************
const CVector3f CLight::skDefaultLightPos(0.f, 0.f, 0.f);
const CVector3f CLight::skDefaultLightDir(0.f,-1.f, 0.f);

View File

@ -19,17 +19,17 @@ enum class ELightType
class CLight class CLight
{ {
ELightType mType; ELightType mType{};
uint32 mLayerIndex; uint32 mLayerIndex = 0;
CVector3f mPosition; CVector3f mPosition{skDefaultLightPos};
CVector3f mDirection; CVector3f mDirection{skDefaultLightDir};
CColor mColor; CColor mColor;
float mSpotCutoff; float mSpotCutoff = 0.0f;
CVector3f mDistAttenCoefficients; CVector3f mDistAttenCoefficients{0.f, 1.f, 0.f};
CVector3f mAngleAttenCoefficients; CVector3f mAngleAttenCoefficients{0.f, 1.f, 0.f};
mutable float mCachedRadius; mutable float mCachedRadius = 0.0f;
mutable float mCachedIntensity; mutable float mCachedIntensity = 0.0f;
mutable uint8 mDirtyFlags; mutable uint8 mDirtyFlags;
public: public:
@ -77,8 +77,8 @@ public:
float AngleAttenA, float AngleAttenB, float AngleAttenC); float AngleAttenA, float AngleAttenB, float AngleAttenC);
// Constants // Constants
static const CVector3f skDefaultLightPos; static constexpr CVector3f skDefaultLightPos{0.f, 0.f, 0.f};
static const CVector3f skDefaultLightDir; static constexpr CVector3f skDefaultLightDir{0.f, -1.f, 0.f};
}; };
#endif // CLIGHT_H #endif // CLIGHT_H