Fix MP3 SAVW support, code cleanup, and more stubs

This commit is contained in:
Phillip Stephens 2016-08-30 17:33:59 -07:00
parent 0aaeed2aeb
commit c35106c907
25 changed files with 404 additions and 173 deletions

View File

@ -14,8 +14,8 @@ struct ThermalHeatFader : IScriptObject
DECL_YAML DECL_YAML
String<-1> name; String<-1> name;
Value<bool> active; Value<bool> active;
Value<float> fadedHeatLevel; Value<float> fadedLevel;
Value<float> initialHeatLevel; Value<float> initialLevel;
}; };
} }
} }

View File

@ -13,7 +13,7 @@ struct WorldLightFader : IScriptObject
{ {
DECL_YAML DECL_YAML
String<-1> name; String<-1> name;
Value<bool> activated; Value<bool> active;
Value<float> fadedLevel; Value<float> fadedLevel;
Value<float> intialLevel; Value<float> intialLevel;
}; };

View File

@ -21,7 +21,7 @@ struct CTweakGui : ITweakGui
Value<float> x20_; Value<float> x20_;
Value<float> x24_; Value<float> x24_;
Value<float> x28_; Value<float> x28_;
Value<atUint32> x2c_ = 0; atUint32 x2c_ = 0;
Value<float> x30_; Value<float> x30_;
Value<float> x34_; Value<float> x34_;
Value<float> x38_; Value<float> x38_;

View File

@ -35,8 +35,6 @@ struct SAVW : BigYAML
Vector<SavedState, DNA_COUNT(skippableCutsceneCount)> skippableCutscenes; Vector<SavedState, DNA_COUNT(skippableCutsceneCount)> skippableCutscenes;
Value<atUint32> relayCount; Value<atUint32> relayCount;
Vector<SavedState, DNA_COUNT(relayCount)> relays; Vector<SavedState, DNA_COUNT(relayCount)> relays;
Value<atUint32> layerCount;
Vector<SAVWCommon::Layer, DNA_COUNT(layerCount)> layers;
Value<atUint32> doorCount; Value<atUint32> doorCount;
Vector<SavedState, DNA_COUNT(doorCount)> doors; Vector<SavedState, DNA_COUNT(doorCount)> doors;
Value<atUint32> scanCount; Value<atUint32> scanCount;

View File

@ -4,7 +4,8 @@
namespace urde namespace urde
{ {
CActorLights::CActorLights(u32 unk, const zeus::CVector3f& vec, int a, int b, int c, int d, int e, float f1) s32 CActorLights::sFrameSchedulerCount = 0;
CActorLights::CActorLights(u32 unk, const zeus::CVector3f& vec, int a, int b, bool c, int d, int e, float f1)
: x2a8_(unk), x2ac_(vec), x2b8_b(b), x2bc_a(a), x2cc_(f1 * f1) : x2a8_(unk), x2ac_(vec), x2b8_b(b), x2bc_a(a), x2cc_(f1 * f1)
{ {
x298_24_ = true; x298_24_ = true;
@ -15,6 +16,9 @@ CActorLights::CActorLights(u32 unk, const zeus::CVector3f& vec, int a, int b, in
x298_30_ = d; x298_30_ = d;
x298_31_ = e; x298_31_ = e;
x299_24_ = true; x299_24_ = true;
sFrameSchedulerCount++;
sFrameSchedulerCount &= 7;
} }
void CActorLights::BuildConstantAmbientLighting() void CActorLights::BuildConstantAmbientLighting()

View File

@ -15,6 +15,7 @@ class CGameArea;
class CActorLights class CActorLights
{ {
static s32 sFrameSchedulerCount;
std::vector<CLight> x0_areaLights; std::vector<CLight> x0_areaLights;
std::vector<CLight> x144_dynamicLights; std::vector<CLight> x144_dynamicLights;
zeus::CColor x288_ambientColor; zeus::CColor x288_ambientColor;
@ -54,7 +55,7 @@ class CActorLights
u32 x2dc_overrideDist = 0; u32 x2dc_overrideDist = 0;
public: public:
CActorLights(u32, const zeus::CVector3f& vec, int, int, int, int, int, float); CActorLights(u32, const zeus::CVector3f& vec, int, int, bool, int, int, float);
void BuildConstantAmbientLighting(); void BuildConstantAmbientLighting();
void BuildConstantAmbientLighting(const zeus::CColor& color); void BuildConstantAmbientLighting(const zeus::CColor& color);

View File

@ -45,6 +45,7 @@ void CAnimTreeSequence::VGetWeightedReaders
SAdvancementResults CAnimTreeSequence::VAdvanceView(const CCharAnimTime& a) SAdvancementResults CAnimTreeSequence::VAdvanceView(const CCharAnimTime& a)
{ {
return {};
} }
CCharAnimTime CAnimTreeSequence::VGetTimeRemaining() const CCharAnimTime CAnimTreeSequence::VGetTimeRemaining() const

View File

@ -35,6 +35,7 @@ CSequenceHelper::CSequenceHelper(const std::vector<std::shared_ptr<IMetaAnim>>&
CSequenceFundamentals CSequenceHelper::ComputeSequenceFundamentals() CSequenceFundamentals CSequenceHelper::ComputeSequenceFundamentals()
{ {
return {};
} }
} }

View File

@ -21,6 +21,9 @@ class CSequenceFundamentals
std::vector<CParticlePOINode> x38_particleNodes; std::vector<CParticlePOINode> x38_particleNodes;
std::vector<CSoundPOINode> x48_soundNodes; std::vector<CSoundPOINode> x48_soundNodes;
public: public:
/* HACK: Remove this default constructor */
CSequenceFundamentals() = default;
CSequenceFundamentals(const CSteadyStateAnimInfo& ssInfo, CSequenceFundamentals(const CSteadyStateAnimInfo& ssInfo,
const std::vector<CBoolPOINode>& boolNodes, const std::vector<CBoolPOINode>& boolNodes,
const std::vector<CInt32POINode>& int32Nodes, const std::vector<CInt32POINode>& int32Nodes,
@ -40,6 +43,8 @@ class CSequenceHelper
std::vector<std::shared_ptr<CAnimTreeNode>> x10_treeNodes; std::vector<std::shared_ptr<CAnimTreeNode>> x10_treeNodes;
std::vector<bool> x20_; std::vector<bool> x20_;
public: public:
/* HACK: Remove this default constructor */
CSequenceHelper() = default;
CSequenceHelper(const std::shared_ptr<CAnimTreeNode>& a, CSequenceHelper(const std::shared_ptr<CAnimTreeNode>& a,
const std::shared_ptr<CAnimTreeNode>& b, const std::shared_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animCtx); const CAnimSysContext& animCtx);

View File

@ -37,6 +37,8 @@ class CSteadyStateAnimInfo
bool x14_looping = false; bool x14_looping = false;
public: public:
/* HACK: Remove this default constructor */
CSteadyStateAnimInfo() = default;
CSteadyStateAnimInfo(bool looping, const CCharAnimTime& duration, const zeus::CVector3f& offset) CSteadyStateAnimInfo(bool looping, const CCharAnimTime& duration, const zeus::CVector3f& offset)
: x0_duration(duration), x8_offset(offset), x14_looping(looping) {} : x0_duration(duration), x8_offset(offset), x14_looping(looping) {}

View File

@ -43,6 +43,7 @@ set(GRAPHICS_SOURCES
CPVSBounds.hpp CPVSBounds.cpp CPVSBounds.hpp CPVSBounds.cpp
CPVSAreaSet.hpp CPVSAreaSet.cpp CPVSAreaSet.hpp CPVSAreaSet.cpp
CGraphics.hpp CGraphics.cpp CGraphics.hpp CGraphics.cpp
CSimpleShadow.hpp CSimpleShadow.cpp
Shaders/TShader.hpp Shaders/TMultiBlendShader.hpp Shaders/TShaderDecl.hpp Shaders/TMultiBlendShaderDecl.hpp Shaders/TShader.hpp Shaders/TMultiBlendShader.hpp Shaders/TShaderDecl.hpp Shaders/TMultiBlendShaderDecl.hpp
Shaders/CLineRendererShaders.hpp Shaders/CLineRendererShaders.cpp Shaders/CLineRendererShadersGLSL.cpp Shaders/CLineRendererShaders.hpp Shaders/CLineRendererShaders.cpp Shaders/CLineRendererShadersGLSL.cpp
Shaders/CTexturedQuadFilter.hpp Shaders/CTexturedQuadFilter.cpp Shaders/CTexturedQuadFilterGLSL.cpp Shaders/CTexturedQuadFilter.hpp Shaders/CTexturedQuadFilter.cpp Shaders/CTexturedQuadFilterGLSL.cpp

View File

@ -0,0 +1,9 @@
#include "CSimpleShadow.hpp"
namespace urde
{
CSimpleShadow::CSimpleShadow(float, float, float, float)
{
}
}

View File

@ -0,0 +1,14 @@
#ifndef __URDE_CSIMPLESHADOW_HPP__
#define __URDE_CSIMPLESHADOW_HPP__
namespace urde
{
class CSimpleShadow
{
public:
CSimpleShadow() = default;
CSimpleShadow(float, float, float, float);
};
}
#endif // __URDE_CSIMPLESHADOW_HPP__

View File

@ -164,7 +164,7 @@ CTweakGui::CTweakGui(CInputStream& in)
x278_(in.readFloatBig()), x278_(in.readFloatBig()),
x27c_(ReadUnknownValx27c(in)), x27c_(ReadUnknownValx27c(in)),
x280_(in.readFloatBig()), x280_(in.readFloatBig()),
x284_(in.readUint32Big()), x284_(in.readFloatBig()),
x288_(in.readVec4fBig()), x288_(in.readVec4fBig()),
x28c_(in.readFloatBig()), x28c_(in.readFloatBig()),
x290_(in.readVec4fBig()), x290_(in.readVec4fBig()),

View File

@ -91,11 +91,56 @@ void CActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMana
CEntity::AcceptScriptMsg(msg, uid, mgr); CEntity::AcceptScriptMsg(msg, uid, mgr);
} }
zeus::CVector3f CActor::GetOrbitPosition(const CStateManager&) zeus::CAABox CActor::CalculateRenderBounds()
{
return {};
}
const CHealthInfo* CActor::GetHealthInfo() const
{
return nullptr;
}
const CDamageVulnerability* CActor::GetDamageVulnerability() const
{
return nullptr;
}
const CDamageVulnerability* CActor::GetDamageVulnerability(const zeus::CVector3f &, const zeus::CVector3f &, const CDamageInfo &) const
{
return nullptr;
}
rstl::optional_object<zeus::CAABox> CActor::GetTouchBounds() const
{
return {} ;
}
void CActor::Touch(CActor &, CStateManager &)
{
}
zeus::CVector3f CActor::GetOrbitPosition(const CStateManager&) const
{ {
return x34_transform.origin; return x34_transform.origin;
} }
zeus::CVector3f CActor::GetAimPosition(const CStateManager &, float) const
{
return x34_transform.origin;
}
zeus::CVector3f CActor::GetHomingPosition(const CStateManager& mgr, float f) const
{
return GetAimPosition(mgr, f);
}
zeus::CVector3f CActor::GetScanObjectIndicatorPosition(const CStateManager &)
{
return {};
}
void CActor::RemoveEmitter() void CActor::RemoveEmitter()
{ {
if (x8c_sfxHandle) if (x8c_sfxHandle)
@ -112,6 +157,31 @@ EWeaponCollisionResponseTypes CActor::GetCollisionResponseType(const zeus::CVect
return EWeaponCollisionResponseTypes::Unknown13; return EWeaponCollisionResponseTypes::Unknown13;
} }
void CActor::FluidFXThink(CActor::EFluidState, CScriptWater &, CStateManager &)
{
}
void CActor::OnScanStateChanged(EScanState state, CStateManager& mgr)
{
if (state == EScanState::Zero)
SendScriptMsgs(EScriptObjectState::UNKS7, mgr, EScriptObjectMessage::None);
else if (state == EScanState::One)
SendScriptMsgs(EScriptObjectState::UNKS8, mgr, EScriptObjectMessage::None);
else if (state == EScanState::Two)
SendScriptMsgs(EScriptObjectState::ScanDone, mgr, EScriptObjectMessage::None);
}
zeus::CAABox CActor::GetSortingBounds(const zeus::CTransform &) const
{
return {};
}
void CActor::DoUserAnimEvent(CStateManager &, CInt32POINode &, EUserEventType)
{
}
void CActor::RemoveMaterial(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, CStateManager& mgr) void CActor::RemoveMaterial(EMaterialTypes t1, EMaterialTypes t2, EMaterialTypes t3, EMaterialTypes t4, CStateManager& mgr)
{ {
x68_material.Remove(t1); x68_material.Remove(t1);
@ -223,15 +293,4 @@ void CActor::SetSfxPitchBend(s32 val)
CSfxManager::PitchBend(*x8c_sfxHandle.get(), val); CSfxManager::PitchBend(*x8c_sfxHandle.get(), val);
} }
void CActor::OnScanStateChanged(EScanState state, CStateManager& mgr)
{
if (state == EScanState::Zero)
SendScriptMsgs(EScriptObjectState::UNKS7, mgr, EScriptObjectMessage::None);
else if (state == EScanState::One)
SendScriptMsgs(EScriptObjectState::UNKS8, mgr, EScriptObjectMessage::None);
else if (state == EScanState::Two)
SendScriptMsgs(EScriptObjectState::ScanDone, mgr, EScriptObjectMessage::None);
}
} }

View File

@ -3,10 +3,12 @@
#include "CEntity.hpp" #include "CEntity.hpp"
#include "Graphics/CGraphics.hpp" #include "Graphics/CGraphics.hpp"
#include "Graphics/CSimpleShadow.hpp"
#include "Audio/CSfxHandle.hpp" #include "Audio/CSfxHandle.hpp"
#include "zeus/zeus.hpp" #include "zeus/zeus.hpp"
#include "Collision/CMaterialFilter.hpp" #include "Collision/CMaterialFilter.hpp"
#include "Character/CModelData.hpp" #include "Character/CModelData.hpp"
#include "Character/CActorLights.hpp"
#include "Collision/CCollisionResponseData.hpp" #include "Collision/CCollisionResponseData.hpp"
namespace urde namespace urde
@ -15,8 +17,11 @@ namespace urde
class CActorParameters; class CActorParameters;
class CWeaponMode; class CWeaponMode;
class CHealthInfo; class CHealthInfo;
class CDamageInfo;
class CDamageVulnerability; class CDamageVulnerability;
class CLightParameters; class CLightParameters;
class CScannableObjectInfo;
class CScriptWater;
class CSfxHandle; class CSfxHandle;
class CSimpleShadow; class CSimpleShadow;
@ -29,14 +34,23 @@ protected:
CMaterialFilter x70_; CMaterialFilter x70_;
s16 x88_sfxId = -1; s16 x88_sfxId = -1;
std::unique_ptr<CSfxHandle> x8c_sfxHandle; std::unique_ptr<CSfxHandle> x8c_sfxHandle;
//std::unique_ptr<CSimpleShadow> x94_simpleShadow; std::unique_ptr<CActorLights> x90_actorLights;
std::unique_ptr<CSimpleShadow> x94_simpleShadow;
std::unique_ptr<TToken<CScannableObjectInfo>> x98_scanObjectInfo;
zeus::CAABox x9c_aabox; zeus::CAABox x9c_aabox;
u32 xb8_ = 0; u8 xb4_ = 0;
u8 xb5_ = 0;
u16 xb6_ = 3;
zeus::CColor xb8_ = zeus::CColor::skWhite;
float xbc_time = 0.f; float xbc_time = 0.f;
s32 xc0_ = 0; s32 xc0_ = 0;
TUniqueId xc4_fluidId = kInvalidUniqueId; TUniqueId xc4_fluidId = kInvalidUniqueId;
TUniqueId xc6_ = kInvalidUniqueId; TUniqueId xc6_ = kInvalidUniqueId;
s32 xc8_ = -1;
s32 xcc_ = -1;
float xd0_;
u8 xd4_ = 0x7F; u8 xd4_ = 0x7F;
u32 xd8_ = 2;
union union
{ {
struct struct
@ -71,10 +85,6 @@ public:
const zeus::CTransform&, CModelData&&, const CMaterialList&, const zeus::CTransform&, CModelData&&, const CMaterialList&,
const CActorParameters&, TUniqueId); const CActorParameters&, TUniqueId);
const zeus::CTransform& GetTransform() const {return x34_transform;}
virtual void AddToRenderer(const zeus::CFrustum&, CStateManager&) {}
virtual void Render(CStateManager&) {}
virtual void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); virtual void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
virtual void SetActive(bool active) virtual void SetActive(bool active)
{ {
@ -84,20 +94,30 @@ public:
xe7_29_ = true; xe7_29_ = true;
CEntity::SetActive(active); CEntity::SetActive(active);
} }
virtual void PreRender(const zeus::CFrustum&, const CStateManager&) {}
virtual zeus::CVector3f GetAimPosition(const CStateManager&, float) virtual void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const {}
{ return x34_transform.origin; } virtual void Render(const CStateManager&) const {}
virtual bool CanRenderUnsorted(const CStateManager&) const { return false; }
virtual bool ValidAimTarget() { return true; } virtual zeus::CAABox CalculateRenderBounds();
virtual bool ValidOrbitTarget() { return true; } virtual const CHealthInfo* GetHealthInfo() const;
virtual bool GetOrbitDistanceCheck() { return true; } virtual const CDamageVulnerability* GetDamageVulnerability() const;
virtual zeus::CVector3f GetOrbitPosition(const CStateManager&); virtual const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f&, const zeus::CVector3f&, const CDamageInfo&) const;
virtual rstl::optional_object<zeus::CAABox> GetTouchBounds() const;
void RemoveEmitter(); virtual void Touch(CActor&, CStateManager&);
virtual zeus::CVector3f GetOrbitPosition(const CStateManager&) const;
virtual rstl::optional_object<zeus::CAABox> GetTouchBounds() const { return {} ; } virtual zeus::CVector3f GetAimPosition(const CStateManager&, float) const;
virtual zeus::CVector3f GetHomingPosition(const CStateManager&, float) const;
virtual zeus::CVector3f GetScanObjectIndicatorPosition(const CStateManager&);
virtual EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, virtual EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&,
CWeaponMode&, int); CWeaponMode&, int);
virtual void FluidFXThink(EFluidState, CScriptWater&, CStateManager&);
virtual void OnScanStateChanged(EScanState, CStateManager&);
virtual zeus::CAABox GetSortingBounds(const zeus::CTransform&) const;
virtual void DoUserAnimEvent(CStateManager&, CInt32POINode&, EUserEventType);
void RemoveEmitter();
const zeus::CTransform& GetTransform() const {return x34_transform;}
void RemoveMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&); void RemoveMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&);
void RemoveMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&); void RemoveMaterial(EMaterialTypes, EMaterialTypes, EMaterialTypes, CStateManager&);
@ -110,24 +130,15 @@ public:
void AddMaterial(EMaterialTypes, CStateManager&); void AddMaterial(EMaterialTypes, CStateManager&);
void SetCallTouch(bool callTouch); void SetCallTouch(bool callTouch);
bool GetCallTouch() const; bool GetCallTouch() const;
void SetUseInSortedList(bool use); void SetUseInSortedList(bool use);
bool GetUseInSortedLists() const; bool GetUseInSortedLists() const;
const CMaterialFilter& GetMaterialFilter() const { return x70_; } const CMaterialFilter& GetMaterialFilter() const { return x70_; }
void SetInFluid(bool in, TUniqueId uid); void SetInFluid(bool in, TUniqueId uid);
bool HasModelData() const; bool HasModelData() const;
const CSfxHandle* GetSfxHandle() const; const CSfxHandle* GetSfxHandle() const;
void SetSfxPitchBend(s32); void SetSfxPitchBend(s32);
virtual void OnScanStateChanged(EScanState, CStateManager&);
}; };
} }
#endif // __URDE_CACTOR_HPP__ #endif // __URDE_CACTOR_HPP__

View File

@ -20,6 +20,9 @@ class CActorParameters
bool b2 : 1; bool b2 : 1;
bool b3 : 1; bool b3 : 1;
bool b4 : 1; bool b4 : 1;
float x5c_;
float x60_;
float x64_;
public: public:
CActorParameters() CActorParameters()
: b1(true), b2(false), b3(false), b4(false) {} : b1(true), b2(false), b3(false), b4(false) {}

View File

@ -58,8 +58,9 @@ public:
virtual void PreThink(float, CStateManager&) {} virtual void PreThink(float, CStateManager&) {}
virtual void Think(float, CStateManager&) {} virtual void Think(float, CStateManager&) {}
virtual void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr); virtual void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr);
bool GetActive() const {return x30_24_active;}
virtual void SetActive(bool active) {x30_24_active = active;} virtual void SetActive(bool active) {x30_24_active = active;}
bool GetActive() const {return x30_24_active;}
void ToggleActive() void ToggleActive()
{ {
x30_24_active ^= 1; x30_24_active ^= 1;

View File

@ -3,32 +3,71 @@
#include "RetroTypes.hpp" #include "RetroTypes.hpp"
#include "zeus/CColor.hpp" #include "zeus/CColor.hpp"
#include "Character/CActorLights.hpp"
static inline u32 count_1bits(u32 x)
{
x = x - ((x >> 1) & 0x55555555);
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
x = x + (x >> 8);
x = x + (x >> 16);
return x & 0x0000003F;
}
static inline u32 count_0bits(u32 x)
{
return 32 - count_1bits(x);
}
namespace urde namespace urde
{ {
class CLightParameters class CLightParameters
{ {
public:
enum class EShadowTesselation
{
Zero
};
enum class EWorldLightingOptions
{
Zero,
NormalWorld,
Two,
DisableWorld
};
enum class ELightRecalculationOptions
{
Zero,
One,
Two,
Three
};
private:
bool x4_a = false; bool x4_a = false;
float x8_b = 0.f; float x8_b = 0.f;
u32 xc_c = 0; EShadowTesselation xc_shadowTesselation = EShadowTesselation::Zero;
float x10_d = 0.f; float x10_d = 0.f;
float x14_e = 0.f; float x14_e = 0.f;
zeus::CColor x18_f; zeus::CColor x18_f;
bool x1c_g = false; bool x1c_noLights = false;
bool x1d_h = false; bool x1d_h = false;
u32 x20_i = 0; EWorldLightingOptions x20_worldLightingOptions = EWorldLightingOptions::Zero;
u32 x24_j = 1; ELightRecalculationOptions x24_lightRecalcOpts = ELightRecalculationOptions::One;
u32 x28_k = 0; s32 x28_k = 0;
zeus::CVector3f x2c_l; zeus::CVector3f x2c_l;
u32 x38_m = 4; s32 x38_m = 4;
u32 x3c_n = 4; s32 x3c_n = 4;
public: public:
CLightParameters() = default; CLightParameters() = default;
CLightParameters(bool a, float b, u32 c, float d, float e, const zeus::CColor& f, CLightParameters(bool a, float b, EShadowTesselation shadowTess, float d, float e, const zeus::CColor& f,
bool g, u32 i, u32 j, const zeus::CVector3f& l, u32 m, u32 n, bool h, u32 k) bool noLights, EWorldLightingOptions lightingOpts, ELightRecalculationOptions lightRecalcOpts,
: x4_a(a), x8_b(b), xc_c(c), x10_d(d), x14_e(e), x18_f(f), x1c_g(g), x1d_h(h), x20_i(i), const zeus::CVector3f& l, s32 m, s32 n, bool h, s32 k)
x24_j(j), x28_k(k), x2c_l(l), x38_m(m), x3c_n(n) : x4_a(a), x8_b(b), xc_shadowTesselation(shadowTess), x10_d(d), x14_e(e), x18_f(f), x1c_noLights(noLights), x1d_h(h),
x20_worldLightingOptions(lightingOpts), x24_lightRecalcOpts(lightRecalcOpts), x28_k(k), x2c_l(l), x38_m(m), x3c_n(n)
{ {
if (x38_m > 4 || x38_m == -1) if (x38_m > 4 || x38_m == -1)
x38_m = 4; x38_m = 4;
@ -36,6 +75,32 @@ public:
x3c_n = 4; x3c_n = 4;
} }
static CLightParameters None() {return CLightParameters();} static CLightParameters None() {return CLightParameters();}
static u32 GetFramesBetweenRecalculation(ELightRecalculationOptions opts)
{
if (opts == ELightRecalculationOptions::Zero)
return 0x3FFFFFFF;
else if (opts == ELightRecalculationOptions::One)
return 8;
else if (opts == ELightRecalculationOptions::Two)
return 4;
else if (opts == ELightRecalculationOptions::Three)
return 1;
return 8;
}
std::unique_ptr<CActorLights> MakeActorLights() const
{
if (x1c_noLights == false)
return {};
u32 updateFrames = GetFramesBetweenRecalculation(x24_lightRecalcOpts);
CActorLights* lights = new CActorLights(updateFrames, x2c_l, x1d_h, x3c_n, x38_m,
count_0bits(x28_k - 1) / 32,
count_0bits(u32(x20_worldLightingOptions) - 3) / 32,
0.1f);
return std::unique_ptr<CActorLights>(std::move(lights));
}
}; };
} }

View File

@ -11,9 +11,106 @@ CPhysicsActor::CPhysicsActor(TUniqueId uid, bool active, const std::string& name
{ {
} }
void CPhysicsActor::Render(const CStateManager &mgr)
{
CActor::Render(mgr);
}
zeus::CVector3f CPhysicsActor::GetOrbitPosition(const CStateManager &)
{
return GetBoundingBox().center();
}
zeus::CVector3f CPhysicsActor::GetAimPosition(const CStateManager &, float val)
{
if (val <= 0.0)
return GetBoundingBox().center();
//zeus::CVector3f delta = PredictMotion(val);
return zeus::CVector3f();
}
void CPhysicsActor::CollidedWith(const TUniqueId &, const CCollisionInfoList &, CStateManager &)
{
}
const CCollisionPrimitive& CPhysicsActor::GetCollisionPrimitive() const
{
return x1c0_collisionPrimitive;
}
zeus::CTransform CPhysicsActor::GetPrimitiveTransform()
{
return zeus::CTransform();
}
float CPhysicsActor::GetStepUpHeight()
{
return x23c_stepUpHeight;
}
float CPhysicsActor::GetStepDownHeight()
{
return x240_stepDownHeight;
}
float CPhysicsActor::GetWeight()
{
return 24.525002f * xe8_mass;
}
void CPhysicsActor::SetPrimitiveOffset(const zeus::CVector2f &offset)
{
x1e8_primitiveOffset = offset;
}
zeus::CVector3f CPhysicsActor::GetPrimitiveOffset()
{
return x1e8_primitiveOffset;
}
void CPhysicsActor::MoveCollisionPrimitive(const zeus::CVector3f &offset)
{
x1e8_primitiveOffset = offset;
}
void CPhysicsActor::SetBoundingBox(const zeus::CAABox &box)
{
x1a4_baseBoundingBox = box;
MoveCollisionPrimitive(zeus::CVector3f::skZero);
}
zeus::CAABox CPhysicsActor::GetMotionVolume()
{
return {};
}
zeus::CAABox CPhysicsActor::GetBoundingBox() zeus::CAABox CPhysicsActor::GetBoundingBox()
{ {
return {}; return {};
} }
const zeus::CAABox &CPhysicsActor::GetBaseBoundingBox() const
{
return x1a4_baseBoundingBox;
}
void CPhysicsActor::SetInertiaTensorScalar(float tensor)
{
if (tensor <= 0.0f)
tensor = 1.0f;
xf0_inertialTensor = tensor;
xf4_inertialTensorRecip = 1.0f / tensor;
}
void CPhysicsActor::SetMass(float mass)
{
xe8_mass = mass;
float tensor = 1.0f;
if (mass > 0.0f)
tensor = 1.0f / mass;
xec_massRecip = tensor;
SetInertiaTensorScalar(mass * tensor);
}
} }

View File

@ -2,7 +2,7 @@
#define __URDE_CPHYSICSACTOR_HPP__ #define __URDE_CPHYSICSACTOR_HPP__
#include "CActor.hpp" #include "CActor.hpp"
#include "Collision/CCollisionPrimitive.hpp" #include "Collision/CCollidableAABox.hpp"
namespace urde namespace urde
{ {
@ -11,13 +11,18 @@ struct SMoverData;
struct SMoverData struct SMoverData
{ {
zeus::CVector3f x0_; zeus::CVector3f x0_velocity;
zeus::CAxisAngle xc_; zeus::CAxisAngle xc_angularVelocity;
zeus::CVector3f x18_; zeus::CVector3f x18_;
zeus::CAxisAngle x24_; zeus::CAxisAngle x24_;
float x30_; float x30_mass;
SMoverData(float a) : x30_(a) {} SMoverData(float mass) : x30_mass(mass) {}
};
struct CMotionState
{
CMotionState(const zeus::CVector3f&, const zeus::CNUQuaternion&, const zeus::CVector3f&, const zeus::CAxisAngle&);
}; };
class CPhysicsActor : public CActor class CPhysicsActor : public CActor
@ -27,114 +32,59 @@ protected:
float xec_massRecip; float xec_massRecip;
float xf0_inertialTensor; float xf0_inertialTensor;
float xf4_inertialTensorRecip; float xf4_inertialTensorRecip;
bool xf8_;
bool xf9_;
zeus::CVector3f xfc_;
zeus::CAxisAngle x108_;
zeus::CMatrix3f x114_;
zeus::CVector3f x138_;
zeus::CAxisAngle x144_;
zeus::CVector3f x150_;
zeus::CVector3f x15c_;
zeus::CVector3f x168_;
zeus::CAxisAngle x174_;
zeus::CAxisAngle x180_;
zeus::CVector3f x18c_;
zeus::CAxisAngle x198_;
zeus::CAABox x1a4_baseBoundingBox; zeus::CAABox x1a4_baseBoundingBox;
std::unique_ptr<CCollisionPrimitive> x1c0_collisionPrimitive; CCollidableAABox x1c0_collisionPrimitive;
zeus::CVector3f x1e8_primitiveOffset; zeus::CVector3f x1e8_primitiveOffset;
zeus::CQuaternion x200_;
zeus::CVector3f x210_;
zeus::CVector3f x21c_;
bool x234_;
float x238_ = 1000000.0f;
float x23c_stepUpHeight; float x23c_stepUpHeight;
float x240_stepDownHeight; float x240_stepDownHeight;
float x244_restitutionCoefModifier; float x244_restitutionCoefModifier;
float x248_collisionAccuracyModifier; float x248_collisionAccuracyModifier;
u32 x24c_;
u32 x250_;
public: public:
CPhysicsActor(TUniqueId, bool, const std::string&, const CEntityInfo&, CPhysicsActor(TUniqueId, bool, const std::string&, const CEntityInfo&,
const zeus::CTransform&, CModelData&&, const CMaterialList&, const zeus::CTransform&, CModelData&&, const CMaterialList&,
const zeus::CAABox&, const SMoverData&, const CActorParameters&, const zeus::CAABox&, const SMoverData&, const CActorParameters&,
float, float); float, float);
void AddToRenderer(const zeus::CFrustum &, CStateManager &){} void Render(const CStateManager& mgr);
void Render(CStateManager& mgr) { CActor::Render(mgr); } zeus::CVector3f GetOrbitPosition(const CStateManager&);
zeus::CVector3f GetAimPosition(const CStateManager&, float val);
float GetCollisionAccuracyModifier() virtual const CCollisionPrimitive& GetCollisionPrimitive() const;
{ return x248_collisionAccuracyModifier; } virtual zeus::CTransform GetPrimitiveTransform();
virtual void CollidedWith(const TUniqueId&, const CCollisionInfoList&, CStateManager&);
void SetCollisionAccuracyModifier(float modifier) virtual float GetStepUpHeight();
{ x248_collisionAccuracyModifier = modifier; } virtual float GetStepDownHeight();
virtual float GetWeight();
float GetCoefficientOfRestitutionModifier()
{ return x244_restitutionCoefModifier; }
void SetCoefficientOfRestitutionModifier(float modifier)
{ x244_restitutionCoefModifier = modifier;}
void DrawCollisionPrimitive()
{ }
void Render(const CStateManager&)
{}
zeus::CVector3f GetAimPosition(const CStateManager&, float val)
{
if (val <= 0.0)
return GetBoundingBox().center();
//zeus::CVector3f delta = PredictMotion(val);
return zeus::CVector3f();
}
zeus::CVector3f GetOrbitPosition(const CStateManager&)
{ return GetBoundingBox().center(); }
float GetStepUpHeight()
{ return x23c_stepUpHeight; }
float GetStepDownHeight()
{ return x240_stepDownHeight; }
void SetPrimitiveOffset(const zeus::CVector2f& offset)
{ x1e8_primitiveOffset = offset; }
zeus::CVector3f GetPrimitiveOffset()
{ return x1e8_primitiveOffset; }
float GetWeight()
{ return 24.525002f * xe8_mass; }
void MoveCollisionPrimitive(const zeus::CVector3f& offset)
{
x1e8_primitiveOffset = offset;
}
void SetBoundingBox(const zeus::CAABox& box)
{
x1a4_baseBoundingBox = box;
MoveCollisionPrimitive(zeus::CVector3f::skZero);
}
zeus::CAABox GetMotionVolume()
{ return zeus::CAABox::skInvertedBox; }
void SetPrimitiveOffset(const zeus::CVector2f& offset);
zeus::CVector3f GetPrimitiveOffset();
void MoveCollisionPrimitive(const zeus::CVector3f& offset);
void SetBoundingBox(const zeus::CAABox& box);
zeus::CAABox GetMotionVolume();
zeus::CAABox GetBoundingBox(); zeus::CAABox GetBoundingBox();
const zeus::CAABox& GetBaseBoundingBox() const;
const zeus::CAABox& GetBaseBoundingBox() const void SetInertiaTensorScalar(float tensor);
{ return x1a4_baseBoundingBox; } void SetMass(float mass);
void CollidedWith(const TUniqueId&, const CCollisionInfoList&, CStateManager&)
{}
zeus::CTransform GetPrimitiveTransform()
{
return zeus::CTransform();
}
const CCollisionPrimitive* GetCollisionPrimitive() const
{ return x1c0_collisionPrimitive.get(); }
void SetInertiaTensorScalar(float tensor)
{
if (tensor <= 0.0f)
tensor = 1.0f;
xf0_inertialTensor = tensor;
xf4_inertialTensorRecip = 1.0f / tensor;
}
void SetMass(float mass)
{
xe8_mass = mass;
float tensor = 1.0f;
if (mass > 0.0f)
tensor = 1.0f / mass;
xec_massRecip = tensor;
SetInertiaTensorScalar(mass * tensor);
}
}; };
} }

View File

@ -160,8 +160,9 @@ void CPlayer::PreRender(CStateManager& mgr, const zeus::CFrustum&)
{ {
} }
void CPlayer::CalculateRenderBounds() zeus::CAABox CPlayer::CalculateRenderBounds()
{ {
return {};
} }
void CPlayer::AddToRenderer(const zeus::CFrustum&, CStateManager&) void CPlayer::AddToRenderer(const zeus::CFrustum&, CStateManager&)
@ -495,7 +496,7 @@ zeus::CTransform CPlayer::CreateTransformFromMovementDirection() const
const CCollisionPrimitive& CPlayer::GetCollisionPrimitive() const const CCollisionPrimitive& CPlayer::GetCollisionPrimitive() const
{ {
return *CPhysicsActor::GetCollisionPrimitive(); return CPhysicsActor::GetCollisionPrimitive();
} }
zeus::CTransform CPlayer::GetPrimitiveTransform() const zeus::CTransform CPlayer::GetPrimitiveTransform() const

View File

@ -84,14 +84,14 @@ public:
bool IsPlayerDeadEnough() const; bool IsPlayerDeadEnough() const;
void AsyncLoadSuit(CStateManager& mgr); void AsyncLoadSuit(CStateManager& mgr);
void LoadAnimationTokens(); void LoadAnimationTokens();
bool CanRenderUnsorted(CStateManager& mgr) const; virtual bool CanRenderUnsorted(CStateManager& mgr) const;
const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f& v1, virtual const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f& v1,
const zeus::CVector3f& v2, const zeus::CVector3f& v2,
const CDamageInfo& info) const; const CDamageInfo& info) const;
const CDamageVulnerability* GetDamageVulnerability() const; virtual const CDamageVulnerability* GetDamageVulnerability() const;
zeus::CVector3f GetHomingPosition(CStateManager& mgr, float) const; virtual zeus::CVector3f GetHomingPosition(CStateManager& mgr, float) const;
zeus::CVector3f GetAimPosition(CStateManager& mgr, float) const; zeus::CVector3f GetAimPosition(CStateManager& mgr, float) const;
void FluidFXThink(CActor::EFluidState, CScriptWater& water, CStateManager& mgr); virtual void FluidFXThink(CActor::EFluidState, CScriptWater& water, CStateManager& mgr);
zeus::CVector3f GetDamageLocationWR() const; zeus::CVector3f GetDamageLocationWR() const;
float GetPrevDamageAmount() const; float GetPrevDamageAmount() const;
float GetDamageAmount() const; float GetDamageAmount() const;
@ -111,7 +111,7 @@ public:
void Render(CStateManager& mgr) const; void Render(CStateManager& mgr) const;
void RenderReflectedPlayer(CStateManager& mgr) const; void RenderReflectedPlayer(CStateManager& mgr) const;
void PreRender(CStateManager& mgr, const zeus::CFrustum&); void PreRender(CStateManager& mgr, const zeus::CFrustum&);
void CalculateRenderBounds(); zeus::CAABox CalculateRenderBounds();
void AddToRenderer(const zeus::CFrustum&, CStateManager&); void AddToRenderer(const zeus::CFrustum&, CStateManager&);
void ComputeFreeLook(const CFinalInput& input); void ComputeFreeLook(const CFinalInput& input);
void UpdateFreeLook(float dt); void UpdateFreeLook(float dt);

View File

@ -253,7 +253,7 @@ CLightParameters ScriptLoader::LoadLightParameters(CInputStream& in)
{ {
bool a = in.readBool(); bool a = in.readBool();
float b = in.readFloatBig(); float b = in.readFloatBig();
u32 c = in.readUint32Big(); CLightParameters::EShadowTesselation shadowTess = CLightParameters::EShadowTesselation(in.readUint32Big());
float d = in.readFloatBig(); float d = in.readFloatBig();
float e = in.readFloatBig(); float e = in.readFloatBig();
@ -261,8 +261,10 @@ CLightParameters ScriptLoader::LoadLightParameters(CInputStream& in)
col.readRGBABig(in); col.readRGBABig(in);
bool f = in.readBool(); bool f = in.readBool();
u32 g = in.readUint32Big(); CLightParameters::EWorldLightingOptions lightOpts =
u32 h = in.readUint32Big(); CLightParameters::EWorldLightingOptions(in.readUint32Big());
CLightParameters::ELightRecalculationOptions recalcOpts =
CLightParameters::ELightRecalculationOptions(in.readUint32Big());;
zeus::CVector3f vec; zeus::CVector3f vec;
vec.readBig(in); vec.readBig(in);
@ -283,7 +285,7 @@ CLightParameters ScriptLoader::LoadLightParameters(CInputStream& in)
if (propCount >= 14) if (propCount >= 14)
w3 = in.readUint32Big(); w3 = in.readUint32Big();
return CLightParameters(a, b, c, d, e, col, f, g, h, vec, w1, w2, b1, w3); return CLightParameters(a, b, shadowTess, d, e, col, f, lightOpts, recalcOpts, vec, w1, w2, b1, w3);
} }
return CLightParameters::None(); return CLightParameters::None();
} }
@ -1965,7 +1967,10 @@ CEntity* ScriptLoader::LoadSeedling(CStateManager& mgr, CInputStream& in,
CEntity* ScriptLoader::LoadThermalHeatFader(CStateManager& mgr, CInputStream& in, CEntity* ScriptLoader::LoadThermalHeatFader(CStateManager& mgr, CInputStream& in,
int propCount, const CEntityInfo& info) int propCount, const CEntityInfo& info)
{ {
return nullptr; if (!EnsurePropertyCount(propCount, 4, "ThermalHeatFader"))
return nullptr;
return LoadWorldLightFader(mgr, in, propCount, info);
} }
CEntity* ScriptLoader::LoadBurrower(CStateManager& mgr, CInputStream& in, CEntity* ScriptLoader::LoadBurrower(CStateManager& mgr, CInputStream& in,
@ -1983,6 +1988,9 @@ CEntity* ScriptLoader::LoadScriptBeam(CStateManager& mgr, CInputStream& in,
CEntity* ScriptLoader::LoadWorldLightFader(CStateManager& mgr, CInputStream& in, CEntity* ScriptLoader::LoadWorldLightFader(CStateManager& mgr, CInputStream& in,
int propCount, const CEntityInfo& info) int propCount, const CEntityInfo& info)
{ {
if (!EnsurePropertyCount(propCount, 4, "WorldLightFader"))
return nullptr;
return nullptr; return nullptr;
} }

@ -1 +1 @@
Subproject commit 948602e8c5852e70d6598e09b603983c91fb07ca Subproject commit 8395c1d5be86448f5072534f0b6d8699c2d32443