2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-10 09:47:43 +00:00

CLight: Mark caching member variables as mutable

Member variables acting as caches is one of the areas where marking
variables as mutable makes sense.

We can do this to allow for the elimination of const_cast in some member
functions.
This commit is contained in:
Lioncash
2020-03-17 20:45:49 -04:00
parent 9483b64c91
commit e821f736de
2 changed files with 10 additions and 10 deletions

View File

@@ -27,20 +27,20 @@ float CLight::CalculateLightRadius() const {
float CLight::GetIntensity() const {
if (x4c_24_intensityDirty) {
const_cast<CLight*>(this)->x4c_24_intensityDirty = false;
x4c_24_intensityDirty = false;
float coef = 1.f;
if (x1c_type == ELightType::Custom)
if (x1c_type == ELightType::Custom) {
coef = x30_angleC;
const_cast<CLight*>(this)->x48_cachedIntensity =
coef * std::max(x18_color.r(), std::max(x18_color.g(), x18_color.b()));
}
x48_cachedIntensity = coef * std::max(x18_color.r(), std::max(x18_color.g(), x18_color.b()));
}
return x48_cachedIntensity;
}
float CLight::GetRadius() const {
if (x4c_25_radiusDirty) {
const_cast<CLight*>(this)->x44_cachedRadius = CalculateLightRadius();
const_cast<CLight*>(this)->x4c_25_radiusDirty = false;
x44_cachedRadius = CalculateLightRadius();
x4c_25_radiusDirty = false;
}
return x44_cachedRadius;
}