From c35106c90704b1fc169aa5a336b1e2110cbb43f8 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 30 Aug 2016 17:33:59 -0700 Subject: [PATCH] Fix MP3 SAVW support, code cleanup, and more stubs --- .../DNAMP1/ScriptObjects/ThermalHeatFader.hpp | 4 +- .../DNAMP1/ScriptObjects/WorldLightFader.hpp | 2 +- DataSpec/DNAMP1/Tweaks/CTweakGui.hpp | 2 +- DataSpec/DNAMP3/SAVW.hpp | 2 - Runtime/Character/CActorLights.cpp | 6 +- Runtime/Character/CActorLights.hpp | 3 +- Runtime/Character/CAnimTreeSequence.cpp | 1 + Runtime/Character/CSequenceHelper.cpp | 1 + Runtime/Character/CSequenceHelper.hpp | 5 + Runtime/Character/IAnimReader.hpp | 2 + Runtime/Graphics/CMakeLists.txt | 1 + Runtime/Graphics/CSimpleShadow.cpp | 9 ++ Runtime/Graphics/CSimpleShadow.hpp | 14 ++ Runtime/MP1/Tweaks/CTweakGui.cpp | 2 +- Runtime/World/CActor.cpp | 83 ++++++++-- Runtime/World/CActor.hpp | 65 ++++---- Runtime/World/CActorParameters.hpp | 3 + Runtime/World/CEntity.hpp | 3 +- Runtime/World/CLightParameters.hpp | 87 ++++++++-- Runtime/World/CPhysicsActor.cpp | 97 ++++++++++++ Runtime/World/CPhysicsActor.hpp | 148 ++++++------------ Runtime/World/CPlayer.cpp | 5 +- Runtime/World/CPlayer.hpp | 12 +- Runtime/World/ScriptLoader.cpp | 18 ++- specter | 2 +- 25 files changed, 404 insertions(+), 173 deletions(-) create mode 100644 Runtime/Graphics/CSimpleShadow.cpp create mode 100644 Runtime/Graphics/CSimpleShadow.hpp diff --git a/DataSpec/DNAMP1/ScriptObjects/ThermalHeatFader.hpp b/DataSpec/DNAMP1/ScriptObjects/ThermalHeatFader.hpp index cc2c37fb2..9b5792015 100644 --- a/DataSpec/DNAMP1/ScriptObjects/ThermalHeatFader.hpp +++ b/DataSpec/DNAMP1/ScriptObjects/ThermalHeatFader.hpp @@ -14,8 +14,8 @@ struct ThermalHeatFader : IScriptObject DECL_YAML String<-1> name; Value active; - Value fadedHeatLevel; - Value initialHeatLevel; + Value fadedLevel; + Value initialLevel; }; } } diff --git a/DataSpec/DNAMP1/ScriptObjects/WorldLightFader.hpp b/DataSpec/DNAMP1/ScriptObjects/WorldLightFader.hpp index 9e0b4e1c3..a24effb23 100644 --- a/DataSpec/DNAMP1/ScriptObjects/WorldLightFader.hpp +++ b/DataSpec/DNAMP1/ScriptObjects/WorldLightFader.hpp @@ -13,7 +13,7 @@ struct WorldLightFader : IScriptObject { DECL_YAML String<-1> name; - Value activated; + Value active; Value fadedLevel; Value intialLevel; }; diff --git a/DataSpec/DNAMP1/Tweaks/CTweakGui.hpp b/DataSpec/DNAMP1/Tweaks/CTweakGui.hpp index 1eb96aa24..fdcae93c2 100644 --- a/DataSpec/DNAMP1/Tweaks/CTweakGui.hpp +++ b/DataSpec/DNAMP1/Tweaks/CTweakGui.hpp @@ -21,7 +21,7 @@ struct CTweakGui : ITweakGui Value x20_; Value x24_; Value x28_; - Value x2c_ = 0; + atUint32 x2c_ = 0; Value x30_; Value x34_; Value x38_; diff --git a/DataSpec/DNAMP3/SAVW.hpp b/DataSpec/DNAMP3/SAVW.hpp index 076119b13..40a8a03f4 100644 --- a/DataSpec/DNAMP3/SAVW.hpp +++ b/DataSpec/DNAMP3/SAVW.hpp @@ -35,8 +35,6 @@ struct SAVW : BigYAML Vector skippableCutscenes; Value relayCount; Vector relays; - Value layerCount; - Vector layers; Value doorCount; Vector doors; Value scanCount; diff --git a/Runtime/Character/CActorLights.cpp b/Runtime/Character/CActorLights.cpp index b98b7906c..f2e2812cc 100644 --- a/Runtime/Character/CActorLights.cpp +++ b/Runtime/Character/CActorLights.cpp @@ -4,7 +4,8 @@ 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) { x298_24_ = true; @@ -15,6 +16,9 @@ CActorLights::CActorLights(u32 unk, const zeus::CVector3f& vec, int a, int b, in x298_30_ = d; x298_31_ = e; x299_24_ = true; + + sFrameSchedulerCount++; + sFrameSchedulerCount &= 7; } void CActorLights::BuildConstantAmbientLighting() diff --git a/Runtime/Character/CActorLights.hpp b/Runtime/Character/CActorLights.hpp index 36c9a87ea..93c781b0c 100644 --- a/Runtime/Character/CActorLights.hpp +++ b/Runtime/Character/CActorLights.hpp @@ -15,6 +15,7 @@ class CGameArea; class CActorLights { + static s32 sFrameSchedulerCount; std::vector x0_areaLights; std::vector x144_dynamicLights; zeus::CColor x288_ambientColor; @@ -54,7 +55,7 @@ class CActorLights u32 x2dc_overrideDist = 0; 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(const zeus::CColor& color); diff --git a/Runtime/Character/CAnimTreeSequence.cpp b/Runtime/Character/CAnimTreeSequence.cpp index 1b86909bb..fbdf4f921 100644 --- a/Runtime/Character/CAnimTreeSequence.cpp +++ b/Runtime/Character/CAnimTreeSequence.cpp @@ -45,6 +45,7 @@ void CAnimTreeSequence::VGetWeightedReaders SAdvancementResults CAnimTreeSequence::VAdvanceView(const CCharAnimTime& a) { + return {}; } CCharAnimTime CAnimTreeSequence::VGetTimeRemaining() const diff --git a/Runtime/Character/CSequenceHelper.cpp b/Runtime/Character/CSequenceHelper.cpp index 6d43c3f2a..fd4f33ff9 100644 --- a/Runtime/Character/CSequenceHelper.cpp +++ b/Runtime/Character/CSequenceHelper.cpp @@ -35,6 +35,7 @@ CSequenceHelper::CSequenceHelper(const std::vector>& CSequenceFundamentals CSequenceHelper::ComputeSequenceFundamentals() { + return {}; } } diff --git a/Runtime/Character/CSequenceHelper.hpp b/Runtime/Character/CSequenceHelper.hpp index 97795cb5a..c1ac01958 100644 --- a/Runtime/Character/CSequenceHelper.hpp +++ b/Runtime/Character/CSequenceHelper.hpp @@ -21,6 +21,9 @@ class CSequenceFundamentals std::vector x38_particleNodes; std::vector x48_soundNodes; public: + /* HACK: Remove this default constructor */ + CSequenceFundamentals() = default; + CSequenceFundamentals(const CSteadyStateAnimInfo& ssInfo, const std::vector& boolNodes, const std::vector& int32Nodes, @@ -40,6 +43,8 @@ class CSequenceHelper std::vector> x10_treeNodes; std::vector x20_; public: + /* HACK: Remove this default constructor */ + CSequenceHelper() = default; CSequenceHelper(const std::shared_ptr& a, const std::shared_ptr& b, const CAnimSysContext& animCtx); diff --git a/Runtime/Character/IAnimReader.hpp b/Runtime/Character/IAnimReader.hpp index 190f83184..d49ec6095 100644 --- a/Runtime/Character/IAnimReader.hpp +++ b/Runtime/Character/IAnimReader.hpp @@ -37,6 +37,8 @@ class CSteadyStateAnimInfo bool x14_looping = false; public: + /* HACK: Remove this default constructor */ + CSteadyStateAnimInfo() = default; CSteadyStateAnimInfo(bool looping, const CCharAnimTime& duration, const zeus::CVector3f& offset) : x0_duration(duration), x8_offset(offset), x14_looping(looping) {} diff --git a/Runtime/Graphics/CMakeLists.txt b/Runtime/Graphics/CMakeLists.txt index 1564bcc21..3d4531a47 100644 --- a/Runtime/Graphics/CMakeLists.txt +++ b/Runtime/Graphics/CMakeLists.txt @@ -43,6 +43,7 @@ set(GRAPHICS_SOURCES CPVSBounds.hpp CPVSBounds.cpp CPVSAreaSet.hpp CPVSAreaSet.cpp CGraphics.hpp CGraphics.cpp + CSimpleShadow.hpp CSimpleShadow.cpp Shaders/TShader.hpp Shaders/TMultiBlendShader.hpp Shaders/TShaderDecl.hpp Shaders/TMultiBlendShaderDecl.hpp Shaders/CLineRendererShaders.hpp Shaders/CLineRendererShaders.cpp Shaders/CLineRendererShadersGLSL.cpp Shaders/CTexturedQuadFilter.hpp Shaders/CTexturedQuadFilter.cpp Shaders/CTexturedQuadFilterGLSL.cpp diff --git a/Runtime/Graphics/CSimpleShadow.cpp b/Runtime/Graphics/CSimpleShadow.cpp new file mode 100644 index 000000000..a69ea36b9 --- /dev/null +++ b/Runtime/Graphics/CSimpleShadow.cpp @@ -0,0 +1,9 @@ +#include "CSimpleShadow.hpp" + +namespace urde +{ +CSimpleShadow::CSimpleShadow(float, float, float, float) +{ + +} +} diff --git a/Runtime/Graphics/CSimpleShadow.hpp b/Runtime/Graphics/CSimpleShadow.hpp new file mode 100644 index 000000000..69122d37d --- /dev/null +++ b/Runtime/Graphics/CSimpleShadow.hpp @@ -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__ diff --git a/Runtime/MP1/Tweaks/CTweakGui.cpp b/Runtime/MP1/Tweaks/CTweakGui.cpp index 897c066b4..f22916bea 100644 --- a/Runtime/MP1/Tweaks/CTweakGui.cpp +++ b/Runtime/MP1/Tweaks/CTweakGui.cpp @@ -164,7 +164,7 @@ CTweakGui::CTweakGui(CInputStream& in) x278_(in.readFloatBig()), x27c_(ReadUnknownValx27c(in)), x280_(in.readFloatBig()), - x284_(in.readUint32Big()), + x284_(in.readFloatBig()), x288_(in.readVec4fBig()), x28c_(in.readFloatBig()), x290_(in.readVec4fBig()), diff --git a/Runtime/World/CActor.cpp b/Runtime/World/CActor.cpp index 5d9f36a9c..3f71cb13d 100644 --- a/Runtime/World/CActor.cpp +++ b/Runtime/World/CActor.cpp @@ -91,11 +91,56 @@ void CActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMana 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 CActor::GetTouchBounds() const +{ + return {} ; +} + +void CActor::Touch(CActor &, CStateManager &) +{ + +} + +zeus::CVector3f CActor::GetOrbitPosition(const CStateManager&) const { 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() { if (x8c_sfxHandle) @@ -112,6 +157,31 @@ EWeaponCollisionResponseTypes CActor::GetCollisionResponseType(const zeus::CVect 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) { x68_material.Remove(t1); @@ -223,15 +293,4 @@ void CActor::SetSfxPitchBend(s32 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); - -} - } diff --git a/Runtime/World/CActor.hpp b/Runtime/World/CActor.hpp index aa6ae9d06..22dc43711 100644 --- a/Runtime/World/CActor.hpp +++ b/Runtime/World/CActor.hpp @@ -3,10 +3,12 @@ #include "CEntity.hpp" #include "Graphics/CGraphics.hpp" +#include "Graphics/CSimpleShadow.hpp" #include "Audio/CSfxHandle.hpp" #include "zeus/zeus.hpp" #include "Collision/CMaterialFilter.hpp" #include "Character/CModelData.hpp" +#include "Character/CActorLights.hpp" #include "Collision/CCollisionResponseData.hpp" namespace urde @@ -15,8 +17,11 @@ namespace urde class CActorParameters; class CWeaponMode; class CHealthInfo; +class CDamageInfo; class CDamageVulnerability; class CLightParameters; +class CScannableObjectInfo; +class CScriptWater; class CSfxHandle; class CSimpleShadow; @@ -29,14 +34,23 @@ protected: CMaterialFilter x70_; s16 x88_sfxId = -1; std::unique_ptr x8c_sfxHandle; - //std::unique_ptr x94_simpleShadow; + std::unique_ptr x90_actorLights; + std::unique_ptr x94_simpleShadow; + std::unique_ptr> x98_scanObjectInfo; 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; s32 xc0_ = 0; TUniqueId xc4_fluidId = kInvalidUniqueId; TUniqueId xc6_ = kInvalidUniqueId; + s32 xc8_ = -1; + s32 xcc_ = -1; + float xd0_; u8 xd4_ = 0x7F; + u32 xd8_ = 2; union { struct @@ -71,10 +85,6 @@ public: const zeus::CTransform&, CModelData&&, const CMaterialList&, 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 SetActive(bool active) { @@ -84,20 +94,30 @@ public: xe7_29_ = true; CEntity::SetActive(active); } - - virtual zeus::CVector3f GetAimPosition(const CStateManager&, float) - { return x34_transform.origin; } - - virtual bool ValidAimTarget() { return true; } - virtual bool ValidOrbitTarget() { return true; } - virtual bool GetOrbitDistanceCheck() { return true; } - virtual zeus::CVector3f GetOrbitPosition(const CStateManager&); - - void RemoveEmitter(); - - virtual rstl::optional_object GetTouchBounds() const { return {} ; } + virtual void PreRender(const zeus::CFrustum&, const CStateManager&) {} + virtual void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const {} + virtual void Render(const CStateManager&) const {} + virtual bool CanRenderUnsorted(const CStateManager&) const { return false; } + virtual zeus::CAABox CalculateRenderBounds(); + virtual const CHealthInfo* GetHealthInfo() const; + virtual const CDamageVulnerability* GetDamageVulnerability() const; + virtual const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f&, const zeus::CVector3f&, const CDamageInfo&) const; + virtual rstl::optional_object GetTouchBounds() const; + virtual void Touch(CActor&, CStateManager&); + virtual zeus::CVector3f GetOrbitPosition(const CStateManager&) const; + 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&, 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, CStateManager&); @@ -110,24 +130,15 @@ public: void AddMaterial(EMaterialTypes, CStateManager&); void SetCallTouch(bool callTouch); - bool GetCallTouch() const; - void SetUseInSortedList(bool use); - bool GetUseInSortedLists() const; - const CMaterialFilter& GetMaterialFilter() const { return x70_; } - void SetInFluid(bool in, TUniqueId uid); - bool HasModelData() const; const CSfxHandle* GetSfxHandle() const; void SetSfxPitchBend(s32); - - virtual void OnScanStateChanged(EScanState, CStateManager&); }; - } #endif // __URDE_CACTOR_HPP__ diff --git a/Runtime/World/CActorParameters.hpp b/Runtime/World/CActorParameters.hpp index 8f778c1e5..650e44e5c 100644 --- a/Runtime/World/CActorParameters.hpp +++ b/Runtime/World/CActorParameters.hpp @@ -20,6 +20,9 @@ class CActorParameters bool b2 : 1; bool b3 : 1; bool b4 : 1; + float x5c_; + float x60_; + float x64_; public: CActorParameters() : b1(true), b2(false), b3(false), b4(false) {} diff --git a/Runtime/World/CEntity.hpp b/Runtime/World/CEntity.hpp index 59040e68e..f596735e5 100644 --- a/Runtime/World/CEntity.hpp +++ b/Runtime/World/CEntity.hpp @@ -58,8 +58,9 @@ public: virtual void PreThink(float, CStateManager&) {} virtual void Think(float, CStateManager&) {} 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;} + + bool GetActive() const {return x30_24_active;} void ToggleActive() { x30_24_active ^= 1; diff --git a/Runtime/World/CLightParameters.hpp b/Runtime/World/CLightParameters.hpp index 5656a4501..138fe20a5 100644 --- a/Runtime/World/CLightParameters.hpp +++ b/Runtime/World/CLightParameters.hpp @@ -3,32 +3,71 @@ #include "RetroTypes.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 { 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; float x8_b = 0.f; - u32 xc_c = 0; + EShadowTesselation xc_shadowTesselation = EShadowTesselation::Zero; float x10_d = 0.f; float x14_e = 0.f; zeus::CColor x18_f; - bool x1c_g = false; + bool x1c_noLights = false; bool x1d_h = false; - u32 x20_i = 0; - u32 x24_j = 1; - u32 x28_k = 0; + EWorldLightingOptions x20_worldLightingOptions = EWorldLightingOptions::Zero; + ELightRecalculationOptions x24_lightRecalcOpts = ELightRecalculationOptions::One; + s32 x28_k = 0; zeus::CVector3f x2c_l; - u32 x38_m = 4; - u32 x3c_n = 4; + s32 x38_m = 4; + s32 x3c_n = 4; public: CLightParameters() = default; - CLightParameters(bool a, float b, u32 c, 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) - : 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), - x24_j(j), x28_k(k), x2c_l(l), x38_m(m), x3c_n(n) + CLightParameters(bool a, float b, EShadowTesselation shadowTess, float d, float e, const zeus::CColor& f, + bool noLights, EWorldLightingOptions lightingOpts, ELightRecalculationOptions lightRecalcOpts, + const zeus::CVector3f& l, s32 m, s32 n, bool h, s32 k) + : 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) x38_m = 4; @@ -36,6 +75,32 @@ public: x3c_n = 4; } 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 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(std::move(lights)); + } }; } diff --git a/Runtime/World/CPhysicsActor.cpp b/Runtime/World/CPhysicsActor.cpp index 66c5caf15..d8070387b 100644 --- a/Runtime/World/CPhysicsActor.cpp +++ b/Runtime/World/CPhysicsActor.cpp @@ -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() { 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); +} + } diff --git a/Runtime/World/CPhysicsActor.hpp b/Runtime/World/CPhysicsActor.hpp index 8e6b1e54c..4de6794aa 100644 --- a/Runtime/World/CPhysicsActor.hpp +++ b/Runtime/World/CPhysicsActor.hpp @@ -2,7 +2,7 @@ #define __URDE_CPHYSICSACTOR_HPP__ #include "CActor.hpp" -#include "Collision/CCollisionPrimitive.hpp" +#include "Collision/CCollidableAABox.hpp" namespace urde { @@ -11,13 +11,18 @@ struct SMoverData; struct SMoverData { - zeus::CVector3f x0_; - zeus::CAxisAngle xc_; + zeus::CVector3f x0_velocity; + zeus::CAxisAngle xc_angularVelocity; zeus::CVector3f x18_; 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 @@ -27,114 +32,59 @@ protected: float xec_massRecip; float xf0_inertialTensor; 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; - std::unique_ptr x1c0_collisionPrimitive; + CCollidableAABox x1c0_collisionPrimitive; zeus::CVector3f x1e8_primitiveOffset; + zeus::CQuaternion x200_; + zeus::CVector3f x210_; + zeus::CVector3f x21c_; + bool x234_; + float x238_ = 1000000.0f; float x23c_stepUpHeight; float x240_stepDownHeight; float x244_restitutionCoefModifier; float x248_collisionAccuracyModifier; + u32 x24c_; + u32 x250_; public: CPhysicsActor(TUniqueId, bool, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, const CMaterialList&, const zeus::CAABox&, const SMoverData&, const CActorParameters&, float, float); - void AddToRenderer(const zeus::CFrustum &, CStateManager &){} - void Render(CStateManager& mgr) { CActor::Render(mgr); } - - float GetCollisionAccuracyModifier() - { return x248_collisionAccuracyModifier; } - - void SetCollisionAccuracyModifier(float modifier) - { x248_collisionAccuracyModifier = modifier; } - - 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 Render(const CStateManager& mgr); + zeus::CVector3f GetOrbitPosition(const CStateManager&); + zeus::CVector3f GetAimPosition(const CStateManager&, float val); + virtual const CCollisionPrimitive& GetCollisionPrimitive() const; + virtual zeus::CTransform GetPrimitiveTransform(); + virtual void CollidedWith(const TUniqueId&, const CCollisionInfoList&, CStateManager&); + virtual float GetStepUpHeight(); + virtual float GetStepDownHeight(); + virtual float GetWeight(); + 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(); - - const zeus::CAABox& GetBaseBoundingBox() const - { return x1a4_baseBoundingBox; } - - 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); - } + const zeus::CAABox& GetBaseBoundingBox() const; + void SetInertiaTensorScalar(float tensor); + void SetMass(float mass); }; } diff --git a/Runtime/World/CPlayer.cpp b/Runtime/World/CPlayer.cpp index ff0531b9f..f593c0175 100644 --- a/Runtime/World/CPlayer.cpp +++ b/Runtime/World/CPlayer.cpp @@ -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&) @@ -495,7 +496,7 @@ zeus::CTransform CPlayer::CreateTransformFromMovementDirection() const const CCollisionPrimitive& CPlayer::GetCollisionPrimitive() const { - return *CPhysicsActor::GetCollisionPrimitive(); + return CPhysicsActor::GetCollisionPrimitive(); } zeus::CTransform CPlayer::GetPrimitiveTransform() const diff --git a/Runtime/World/CPlayer.hpp b/Runtime/World/CPlayer.hpp index 25e35e69f..008be0ebd 100644 --- a/Runtime/World/CPlayer.hpp +++ b/Runtime/World/CPlayer.hpp @@ -84,14 +84,14 @@ public: bool IsPlayerDeadEnough() const; void AsyncLoadSuit(CStateManager& mgr); void LoadAnimationTokens(); - bool CanRenderUnsorted(CStateManager& mgr) const; - const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f& v1, + virtual bool CanRenderUnsorted(CStateManager& mgr) const; + virtual const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f& v1, const zeus::CVector3f& v2, const CDamageInfo& info) const; - const CDamageVulnerability* GetDamageVulnerability() const; - zeus::CVector3f GetHomingPosition(CStateManager& mgr, float) const; + virtual const CDamageVulnerability* GetDamageVulnerability() const; + virtual zeus::CVector3f GetHomingPosition(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; float GetPrevDamageAmount() const; float GetDamageAmount() const; @@ -111,7 +111,7 @@ public: void Render(CStateManager& mgr) const; void RenderReflectedPlayer(CStateManager& mgr) const; void PreRender(CStateManager& mgr, const zeus::CFrustum&); - void CalculateRenderBounds(); + zeus::CAABox CalculateRenderBounds(); void AddToRenderer(const zeus::CFrustum&, CStateManager&); void ComputeFreeLook(const CFinalInput& input); void UpdateFreeLook(float dt); diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index 0cb775275..6eaa45458 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -253,7 +253,7 @@ CLightParameters ScriptLoader::LoadLightParameters(CInputStream& in) { bool a = in.readBool(); float b = in.readFloatBig(); - u32 c = in.readUint32Big(); + CLightParameters::EShadowTesselation shadowTess = CLightParameters::EShadowTesselation(in.readUint32Big()); float d = in.readFloatBig(); float e = in.readFloatBig(); @@ -261,8 +261,10 @@ CLightParameters ScriptLoader::LoadLightParameters(CInputStream& in) col.readRGBABig(in); bool f = in.readBool(); - u32 g = in.readUint32Big(); - u32 h = in.readUint32Big(); + CLightParameters::EWorldLightingOptions lightOpts = + CLightParameters::EWorldLightingOptions(in.readUint32Big()); + CLightParameters::ELightRecalculationOptions recalcOpts = + CLightParameters::ELightRecalculationOptions(in.readUint32Big());; zeus::CVector3f vec; vec.readBig(in); @@ -283,7 +285,7 @@ CLightParameters ScriptLoader::LoadLightParameters(CInputStream& in) if (propCount >= 14) 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(); } @@ -1965,7 +1967,10 @@ CEntity* ScriptLoader::LoadSeedling(CStateManager& mgr, CInputStream& in, CEntity* ScriptLoader::LoadThermalHeatFader(CStateManager& mgr, CInputStream& in, 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, @@ -1983,6 +1988,9 @@ CEntity* ScriptLoader::LoadScriptBeam(CStateManager& mgr, CInputStream& in, CEntity* ScriptLoader::LoadWorldLightFader(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) { + if (!EnsurePropertyCount(propCount, 4, "WorldLightFader")) + return nullptr; + return nullptr; } diff --git a/specter b/specter index 948602e8c..8395c1d5b 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit 948602e8c5852e70d6598e09b603983c91fb07ca +Subproject commit 8395c1d5be86448f5072534f0b6d8699c2d32443