2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-04-18 01:58:13 +00:00
|
|
|
|
|
|
|
#include "RetroTypes.hpp"
|
|
|
|
#include "zeus/CColor.hpp"
|
2016-08-31 00:33:59 +00:00
|
|
|
#include "Character/CActorLights.hpp"
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
|
|
|
|
|
|
|
class CLightParameters {
|
|
|
|
friend class CActor;
|
2016-04-18 01:58:13 +00:00
|
|
|
|
2016-08-31 00:33:59 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EShadowTesselation { Zero };
|
2016-08-31 00:33:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EWorldLightingOptions { Zero, NormalWorld, NoShadowCast, DisableWorld };
|
2016-08-31 00:33:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class ELightRecalculationOptions { LargeFrameCount, EightFrames, FourFrames, OneFrame };
|
2016-08-31 00:33:59 +00:00
|
|
|
|
|
|
|
private:
|
2018-12-08 05:30:43 +00:00
|
|
|
bool x4_a = false;
|
|
|
|
float x8_b = 0.f;
|
|
|
|
EShadowTesselation xc_shadowTesselation = EShadowTesselation::Zero;
|
|
|
|
float x10_d = 0.f;
|
|
|
|
float x14_e = 0.f;
|
|
|
|
zeus::CColor x18_noLightsAmbient;
|
|
|
|
bool x1c_makeLights = false;
|
|
|
|
bool x1d_ambientChannelOverflow = false;
|
|
|
|
EWorldLightingOptions x20_worldLightingOptions = EWorldLightingOptions::Zero;
|
|
|
|
ELightRecalculationOptions x24_lightRecalcOpts = ELightRecalculationOptions::EightFrames;
|
|
|
|
s32 x28_layerIdx = 0;
|
|
|
|
zeus::CVector3f x2c_actorPosBias;
|
|
|
|
s32 x38_maxDynamicLights = 4;
|
|
|
|
s32 x3c_maxAreaLights = 4;
|
|
|
|
|
2016-04-18 01:58:13 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CLightParameters() = default;
|
|
|
|
CLightParameters(bool a, float b, EShadowTesselation shadowTess, float d, float e,
|
|
|
|
const zeus::CColor& noLightsAmbient, bool makeLights, EWorldLightingOptions lightingOpts,
|
|
|
|
ELightRecalculationOptions lightRecalcOpts, const zeus::CVector3f& actorPosBias,
|
|
|
|
s32 maxDynamicLights, s32 maxAreaLights, bool ambChannelOverflow, s32 layerIdx)
|
|
|
|
: x4_a(a)
|
|
|
|
, x8_b(b)
|
|
|
|
, xc_shadowTesselation(shadowTess)
|
|
|
|
, x10_d(d)
|
|
|
|
, x14_e(e)
|
|
|
|
, x18_noLightsAmbient(noLightsAmbient)
|
|
|
|
, x1c_makeLights(makeLights)
|
|
|
|
, x1d_ambientChannelOverflow(ambChannelOverflow)
|
|
|
|
, x20_worldLightingOptions(lightingOpts)
|
|
|
|
, x24_lightRecalcOpts(lightRecalcOpts)
|
|
|
|
, x28_layerIdx(layerIdx)
|
|
|
|
, x2c_actorPosBias(actorPosBias)
|
|
|
|
, x38_maxDynamicLights(maxDynamicLights)
|
|
|
|
, x3c_maxAreaLights(maxAreaLights) {
|
|
|
|
if (x38_maxDynamicLights > 4 || x38_maxDynamicLights == -1)
|
|
|
|
x38_maxDynamicLights = 4;
|
|
|
|
if (x3c_maxAreaLights > 4 || x3c_maxAreaLights == -1)
|
|
|
|
x3c_maxAreaLights = 4;
|
|
|
|
}
|
|
|
|
static CLightParameters None() { return CLightParameters(); }
|
2016-08-31 00:33:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static u32 GetFramesBetweenRecalculation(ELightRecalculationOptions opts) {
|
|
|
|
if (opts == ELightRecalculationOptions::LargeFrameCount)
|
|
|
|
return 0x3FFFFFFF;
|
|
|
|
else if (opts == ELightRecalculationOptions::EightFrames)
|
|
|
|
return 8;
|
|
|
|
else if (opts == ELightRecalculationOptions::FourFrames)
|
|
|
|
return 4;
|
|
|
|
else if (opts == ELightRecalculationOptions::OneFrame)
|
|
|
|
return 1;
|
|
|
|
return 8;
|
|
|
|
}
|
2016-08-31 00:33:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
std::unique_ptr<CActorLights> MakeActorLights() const {
|
|
|
|
if (!x1c_makeLights)
|
|
|
|
return {};
|
2016-08-31 00:33:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
u32 updateFrames = GetFramesBetweenRecalculation(x24_lightRecalcOpts);
|
|
|
|
CActorLights* lights = new CActorLights(updateFrames, x2c_actorPosBias, x38_maxDynamicLights, x3c_maxAreaLights,
|
|
|
|
x1d_ambientChannelOverflow, x28_layerIdx == 1,
|
|
|
|
x20_worldLightingOptions == EWorldLightingOptions::DisableWorld, 0.1f);
|
|
|
|
if (x20_worldLightingOptions == EWorldLightingOptions::NoShadowCast)
|
|
|
|
lights->SetCastShadows(false);
|
|
|
|
if (x3c_maxAreaLights == 0)
|
|
|
|
lights->SetAmbientColor(x18_noLightsAmbient);
|
|
|
|
return std::unique_ptr<CActorLights>(lights);
|
|
|
|
}
|
|
|
|
const zeus::CColor& GetNoLightsAmbient() const { return x18_noLightsAmbient; }
|
2016-04-18 01:58:13 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|