diff --git a/DataSpec/DNACommon/CMakeLists.txt b/DataSpec/DNACommon/CMakeLists.txt index bf24e777a..731a76125 100644 --- a/DataSpec/DNACommon/CMakeLists.txt +++ b/DataSpec/DNACommon/CMakeLists.txt @@ -31,6 +31,7 @@ set(DNACOMMON_SOURCES BabeDead.hpp BabeDead.cpp RigInverter.hpp RigInverter.cpp AROTBuilder.hpp AROTBuilder.cpp + Tweaks/ITweak.hpp Tweaks/TweakWriter.hpp Tweaks/ITweakGame.hpp Tweaks/ITweakParticle.hpp @@ -40,7 +41,8 @@ set(DNACOMMON_SOURCES Tweaks/ITweakGunRes.hpp Tweaks/ITweakPlayerRes.hpp Tweaks/ITweakGui.hpp - Tweaks/ITweakSlideShow.hpp) + Tweaks/ITweakSlideShow.hpp + Tweaks/ITweakTargeting.hpp) dataspec_add_list(DNACommon DNACOMMON_SOURCES) list(APPEND DNACOMMON_SOURCES ${liblist}) diff --git a/DataSpec/DNACommon/Tweaks/ITweak.hpp b/DataSpec/DNACommon/Tweaks/ITweak.hpp new file mode 100644 index 000000000..80549caa0 --- /dev/null +++ b/DataSpec/DNACommon/Tweaks/ITweak.hpp @@ -0,0 +1,13 @@ +#ifndef __DNACOMMON_ITWEAK_HPP__ +#define __DNACOMMON_ITWEAK_HPP__ + +#include "../DNACommon.hpp" + +namespace DataSpec +{ +struct ITweak : BigYAML +{ +}; +} + +#endif // __DNACOMMON_ITWEAK_HPP__ diff --git a/DataSpec/DNACommon/Tweaks/ITweakGame.hpp b/DataSpec/DNACommon/Tweaks/ITweakGame.hpp index b07636b6c..8f6dc8b80 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakGame.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakGame.hpp @@ -1,12 +1,12 @@ #ifndef __DNACOMMON_ITWEAKGAME_HPP__ #define __DNACOMMON_ITWEAKGAME_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" namespace DataSpec { -struct ITweakGame : BigYAML +struct ITweakGame : ITweak { virtual const std::string& GetWorldPrefix() const = 0; virtual bool GetSplashScreensDisabled() const = 0; diff --git a/DataSpec/DNACommon/Tweaks/ITweakGui.hpp b/DataSpec/DNACommon/Tweaks/ITweakGui.hpp index d11ad5a27..d0293e59a 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakGui.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakGui.hpp @@ -1,13 +1,13 @@ #ifndef __DNACOMMON_ITWEAKGUI_HPP__ #define __DNACOMMON_ITWEAKGUI_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" #include "zeus/CVector2f.hpp" namespace DataSpec { -struct ITweakGui : BigYAML +struct ITweakGui : ITweak { virtual float GetScanSpeed(int idx) const=0; virtual float GetXrayBlurScaleLinear() const=0; diff --git a/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp b/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp index d1ef1093d..3fe91543f 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakGunRes.hpp @@ -1,13 +1,13 @@ #ifndef __DNACOMMON_ITWEAKGUNRES_HPP__ #define __DNACOMMON_ITWEAKGUNRES_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" #include "Runtime/IFactory.hpp" namespace DataSpec { -struct ITweakGunRes : BigYAML +struct ITweakGunRes : ITweak { using ResId = int64_t; enum class EBeamId diff --git a/DataSpec/DNACommon/Tweaks/ITweakParticle.hpp b/DataSpec/DNACommon/Tweaks/ITweakParticle.hpp index 027ec8d48..d5f038768 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakParticle.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakParticle.hpp @@ -1,12 +1,12 @@ #ifndef __DNACOMMON_ITWEAKPARTICLE_HPP__ #define __DNACOMMON_ITWEAKPARTICLE_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" namespace DataSpec { -struct ITweakParticle : BigYAML +struct ITweakParticle : ITweak { }; diff --git a/DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp b/DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp index 01a86b016..ca825c353 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakPlayer.hpp @@ -1,13 +1,13 @@ #ifndef __DNACOMMON_ITWEAKPLAYER_HPP__ #define __DNACOMMON_ITWEAKPLAYER_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" #include "zeus/CAABox.hpp" namespace DataSpec { -struct ITweakPlayer : BigYAML +struct ITweakPlayer : ITweak { virtual float GetX50() const=0; virtual float GetX54() const=0; diff --git a/DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp b/DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp index c25f1faec..d8634cb6f 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakPlayerControl.hpp @@ -1,12 +1,12 @@ #ifndef __DNACOMMON_ITWEAKPLAYERCONTROL_HPP__ #define __DNACOMMON_ITWEAKPLAYERCONTROL_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" namespace DataSpec { -struct ITweakPlayerControl : BigYAML +struct ITweakPlayerControl : ITweak { virtual atUint32 GetMapping(atUint32) const=0; }; diff --git a/DataSpec/DNACommon/Tweaks/ITweakPlayerGun.hpp b/DataSpec/DNACommon/Tweaks/ITweakPlayerGun.hpp index 4a4daa40c..939c37f42 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakPlayerGun.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakPlayerGun.hpp @@ -1,13 +1,13 @@ #ifndef __DNACOMMON_ITWEAKPLAYERGUN_HPP__ #define __DNACOMMON_ITWEAKPLAYERGUN_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" #include "zeus/CAABox.hpp" namespace DataSpec { -struct ITweakPlayerGun : BigYAML +struct ITweakPlayerGun : ITweak { virtual float GetSomething1() const=0; // x24 virtual float GetSomething2() const=0; // x28 diff --git a/DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp b/DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp index 6899ddb07..2719e3ea8 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakPlayerRes.hpp @@ -1,13 +1,13 @@ #ifndef __DNACOMMON_ITWEAKPLAYERRES_HPP__ #define __DNACOMMON_ITWEAKPLAYERRES_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" #include "Runtime/IFactory.hpp" namespace DataSpec { -struct ITweakPlayerRes : BigYAML +struct ITweakPlayerRes : ITweak { using ResId = int64_t; enum class EBeamId diff --git a/DataSpec/DNACommon/Tweaks/ITweakSlideShow.hpp b/DataSpec/DNACommon/Tweaks/ITweakSlideShow.hpp index ceed62f3c..b90e9bf72 100644 --- a/DataSpec/DNACommon/Tweaks/ITweakSlideShow.hpp +++ b/DataSpec/DNACommon/Tweaks/ITweakSlideShow.hpp @@ -1,12 +1,12 @@ #ifndef __DNACOMMON_ITWEAKSLIDESHOW_HPP__ #define __DNACOMMON_ITWEAKSLIDESHOW_HPP__ -#include "../DNACommon.hpp" +#include "ITweak.hpp" namespace DataSpec { -struct ITweakSlideShow : BigYAML +struct ITweakSlideShow : ITweak { virtual const std::string& GetFont() const=0; virtual const zeus::CColor& GetFontColor() const=0; diff --git a/DataSpec/DNACommon/Tweaks/ITweakTargeting.hpp b/DataSpec/DNACommon/Tweaks/ITweakTargeting.hpp new file mode 100644 index 000000000..392959ce6 --- /dev/null +++ b/DataSpec/DNACommon/Tweaks/ITweakTargeting.hpp @@ -0,0 +1,12 @@ +#ifndef __DNACOMMON_ITWEAKTARGETING_HPP__ +#define __DNACOMMON_ITWEAKTARGETING_HPP__ + +#include "ITweak.hpp" +namespace DataSpec +{ +struct ITweakTargeting : public ITweak +{ +}; +} + +#endif // __DNACOMMON_ITWEAKTARGETING_HPP__ diff --git a/DataSpec/DNAMP1/CMakeLists.txt b/DataSpec/DNAMP1/CMakeLists.txt index f926da02b..631e93233 100644 --- a/DataSpec/DNAMP1/CMakeLists.txt +++ b/DataSpec/DNAMP1/CMakeLists.txt @@ -28,7 +28,8 @@ make_dnalist(liblist DNAMP1 Tweaks/CTweakPlayerRes Tweaks/CTweakGui Tweaks/CTweakSlideShow - Tweaks/CTweakCameraBob) + Tweaks/CTweakCameraBob + Tweaks/CTweakTargeting) set(DNAMP1_SOURCES DNAMP1.hpp DNAMP1.cpp @@ -48,7 +49,8 @@ set(DNAMP1_SOURCES SCLY.hpp SCLY.cpp FRME.cpp DeafBabe.cpp - Tweaks/CTweakPlayer.cpp) + Tweaks/CTweakPlayer.cpp + Tweaks/CTweakTargeting.cpp) dataspec_add_list(DNAMP1 DNAMP1_SOURCES) list(APPEND DNAMP1_SOURCES ${liblist}) diff --git a/DataSpec/DNAMP1/Tweaks/CTweakTargeting.cpp b/DataSpec/DNAMP1/Tweaks/CTweakTargeting.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp b/DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp new file mode 100644 index 000000000..b79e87f6e --- /dev/null +++ b/DataSpec/DNAMP1/Tweaks/CTweakTargeting.hpp @@ -0,0 +1,16 @@ +#ifndef _DNAMP1_CTWEAKTARGETING_HPP_ +#define _DNAMP1_CTWEAKTARGETING_HPP_ + +#include "../../DNACommon/Tweaks/ITweakTargeting.hpp" + +namespace DataSpec +{ +namespace DNAMP1 +{ +struct CTweakTargeting : public ITweakTargeting +{ + DECL_YAML +}; +} +} +#endif // _DNAMP1_CTWEAKTARGETING_HPP_ diff --git a/Runtime/Character/CParticleGenInfo.cpp b/Runtime/Character/CParticleGenInfo.cpp index 71e0169ea..580747ceb 100644 --- a/Runtime/Character/CParticleGenInfo.cpp +++ b/Runtime/Character/CParticleGenInfo.cpp @@ -1,108 +1,148 @@ #include "CParticleGenInfo.hpp" +#include "Graphics/IRenderer.hpp" #include "Particle/CParticleGen.hpp" +#include "GameGlobalObjects.hpp" +#include "World/CGameLight.hpp" +#include "CStateManager.hpp" +#include "Graphics/CBooRenderer.hpp" +#include "TCastTo.hpp" namespace urde { CParticleGenInfo::CParticleGenInfo(const SObjectTag& part, int frameCount, const std::string& boneName, - const zeus::CVector3f& scale, CParticleData::EParentedMode parentMode, - int a) -: x4_part(part), xc_seconds(frameCount / 60.f), x10_boneName(boneName), x28_parentMode(parentMode), - x2c_a(a), x30_particleScale(scale) -{} - -static TUniqueId _initializeLight(const std::weak_ptr& system, - CStateManager& stateMgr, int lightId) + const zeus::CVector3f& scale, CParticleData::EParentedMode parentMode, int a, int b) +: x4_part(part) +, xc_seconds(frameCount / 60.f) +, x10_boneName(boneName) +, x28_parentMode(parentMode) +, x2c_a(a) +, x30_particleScale(scale) +, x80_(b) { +} + +static TUniqueId _initializeLight(const std::weak_ptr& system, CStateManager& stateMgr, TAreaId areaId, + int lightId) +{ + TUniqueId ret = kInvalidUniqueId; std::shared_ptr systemRef = system.lock(); if (systemRef->SystemHasLight()) { - + ret = stateMgr.AllocateUniqueId(); + stateMgr.AddObject( + new CGameLight(ret, areaId, false, "ParticleLight", + zeus::CTransform(systemRef->GetOrientation().buildMatrix3f(), systemRef->GetTranslation()), + kInvalidUniqueId, systemRef->GetLight(), lightId, 0, 0.f)); } - return kInvalidUniqueId; + return ret; } -CParticleGenInfoGeneric::CParticleGenInfoGeneric(const SObjectTag& part, - const std::weak_ptr& system, +CParticleGenInfoGeneric::CParticleGenInfoGeneric(const SObjectTag& part, const std::weak_ptr& system, int frameCount, const std::string& boneName, - const zeus::CVector3f& scale, - CParticleData::EParentedMode parentMode, - int a, CStateManager& stateMgr, int lightId) -: CParticleGenInfo(part, frameCount, boneName, scale, parentMode, a), x80_system(system) + const zeus::CVector3f& scale, CParticleData::EParentedMode parentMode, + int a, CStateManager& stateMgr, TAreaId areaId, int lightId, int b) +: CParticleGenInfo(part, frameCount, boneName, scale, parentMode, a, b), x84_system(system) { if (lightId == -1) - x84_lightId = kInvalidUniqueId; + x88_lightId = kInvalidUniqueId; else - x84_lightId = _initializeLight(system, stateMgr, lightId); + x88_lightId = _initializeLight(system, stateMgr, lightId, areaId); } -void CParticleGenInfoGeneric::AddToRenderer() -{ -} +void CParticleGenInfoGeneric::AddToRenderer() { g_Renderer->AddParticleGen(*x84_system.get()); } -void CParticleGenInfoGeneric::Render() -{ -} +void CParticleGenInfoGeneric::Render() { x84_system->Render(); } void CParticleGenInfoGeneric::Update(float dt, CStateManager& stateMgr) { + x84_system->Update(dt); + + if (x88_lightId != kInvalidUniqueId) + { + TCastToPtr gl(stateMgr.ObjectById(x88_lightId)); + if (gl) + gl->SetLight(x84_system->GetLight()); + } } void CParticleGenInfoGeneric::SetOrientation(const zeus::CTransform& xf, CStateManager& stateMgr) { + x84_system->SetOrientation(xf); + + if (x88_lightId != kInvalidUniqueId) + { + TCastToPtr gl(stateMgr.ObjectById(x88_lightId)); + if (gl) + gl->SetRotation(zeus::CQuaternion(xf.buildMatrix3f())); + } } void CParticleGenInfoGeneric::SetTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr) { + x84_system->SetTranslation(trans); + + if (x88_lightId != kInvalidUniqueId) + { + TCastToPtr gl(stateMgr.ObjectById(x88_lightId)); + if (gl) + gl->SetTranslation(trans); + } } void CParticleGenInfoGeneric::SetGlobalOrientation(const zeus::CTransform& xf, CStateManager& stateMgr) { + x84_system->SetGlobalOrientation(xf); + + if (x88_lightId != kInvalidUniqueId) + { + TCastToPtr gl(stateMgr.ObjectById(x88_lightId)); + if (gl) + gl->SetRotation(zeus::CQuaternion(xf.buildMatrix3f())); + } } void CParticleGenInfoGeneric::SetGlobalTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr) { + x84_system->SetGlobalTranslation(trans); + + if (x88_lightId != kInvalidUniqueId) + { + TCastToPtr gl(stateMgr.ObjectById(x88_lightId)); + if (gl) + gl->SetTranslation(trans); + } } -void CParticleGenInfoGeneric::SetGlobalScale(const zeus::CVector3f& scale) +void CParticleGenInfoGeneric::SetGlobalScale(const zeus::CVector3f& scale) { x84_system->SetGlobalScale(scale); } + +void CParticleGenInfoGeneric::SetParticleEmission(bool emission, CStateManager& stateMgr) { + x84_system->SetParticleEmission(emission); + + TCastToPtr gl(stateMgr.ObjectById(x88_lightId)); + + if (gl) + gl->SetActive(emission); } -void CParticleGenInfoGeneric::SetParticleEmission(bool, CStateManager& stateMgr) -{ -} - -bool CParticleGenInfoGeneric::IsSystemDeletable() const -{ - return false; -} - -zeus::CAABox CParticleGenInfoGeneric::GetBounds() const -{ - return {}; -} - -bool CParticleGenInfoGeneric::HasActiveParticles() const -{ - return false; -} - -void CParticleGenInfoGeneric::DestroyParticles() -{ -} - -bool CParticleGenInfoGeneric::HasLight() const -{ - return false; -} - -TUniqueId CParticleGenInfoGeneric::GetLightId() const -{ - return kInvalidUniqueId; -} - -void CParticleGenInfoGeneric::SetModulationColor(const zeus::CColor& color) +bool CParticleGenInfoGeneric::IsSystemDeletable() const { return x84_system->IsSystemDeletable(); } + +rstl::optional_object CParticleGenInfoGeneric::GetBounds() const { return x84_system->GetBounds(); } + +bool CParticleGenInfoGeneric::HasActiveParticles() const { return x84_system->GetParticleCount() != 0; } + +void CParticleGenInfoGeneric::DestroyParticles() { x84_system->DestroyParticles(); } + +bool CParticleGenInfoGeneric::HasLight() const { return x84_system->SystemHasLight(); } + +TUniqueId CParticleGenInfoGeneric::GetLightId() const { return x88_lightId; } + +void CParticleGenInfoGeneric::DeleteLight(CStateManager& mgr) { + if (x88_lightId != kInvalidUniqueId) + mgr.DeleteObjectRequest(x88_lightId); } +void CParticleGenInfoGeneric::SetModulationColor(const zeus::CColor& color) { x84_system->SetModulationColor(color); } } diff --git a/Runtime/Character/CParticleGenInfo.hpp b/Runtime/Character/CParticleGenInfo.hpp index 4616a7f1c..deaba6e25 100644 --- a/Runtime/Character/CParticleGenInfo.hpp +++ b/Runtime/Character/CParticleGenInfo.hpp @@ -24,40 +24,61 @@ class CParticleGenInfo zeus::CVector3f x30_particleScale; float x3c_ = 0.f; bool x40_ = false; - zeus::CTransform x44_; - zeus::CVector3f x74_; + zeus::CTransform x44_transform; + zeus::CVector3f x74_offset; + s32 x80_; + public: - CParticleGenInfo(const SObjectTag& part, int frameCount, const std::string& boneName, - const zeus::CVector3f&, CParticleData::EParentedMode parentMode, int a); + CParticleGenInfo(const SObjectTag& part, int frameCount, const std::string& boneName, const zeus::CVector3f&, + CParticleData::EParentedMode parentMode, int a, int b); virtual ~CParticleGenInfo() = default; - virtual void AddToRenderer()=0; - virtual void Render()=0; - virtual void Update(float dt, CStateManager& stateMgr)=0; - virtual void SetOrientation(const zeus::CTransform& xf, CStateManager& stateMgr)=0; - virtual void SetTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr)=0; - virtual void SetGlobalOrientation(const zeus::CTransform& xf, CStateManager& stateMgr)=0; - virtual void SetGlobalTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr)=0; - virtual void SetGlobalScale(const zeus::CVector3f& scale)=0; - virtual void SetParticleEmission(bool, CStateManager& stateMgr)=0; - virtual bool IsSystemDeletable() const=0; - virtual zeus::CAABox GetBounds() const=0; - virtual bool HasActiveParticles() const=0; - virtual void DestroyParticles()=0; - virtual bool HasLight() const=0; - virtual TUniqueId GetLightId() const=0; - virtual void SetModulationColor(const zeus::CColor& color)=0; + virtual void AddToRenderer() = 0; + virtual void Render() = 0; + virtual void Update(float dt, CStateManager& stateMgr) = 0; + virtual void SetOrientation(const zeus::CTransform& xf, CStateManager& stateMgr) = 0; + virtual void SetTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr) = 0; + virtual void SetGlobalOrientation(const zeus::CTransform& xf, CStateManager& stateMgr) = 0; + virtual void SetGlobalTranslation(const zeus::CVector3f& trans, CStateManager& stateMgr) = 0; + virtual void SetGlobalScale(const zeus::CVector3f& scale) = 0; + virtual void SetParticleEmission(bool, CStateManager& stateMgr) = 0; + virtual bool IsSystemDeletable() const = 0; + virtual rstl::optional_object GetBounds() const = 0; + virtual bool HasActiveParticles() const = 0; + virtual void DestroyParticles() = 0; + virtual bool HasLight() const = 0; + virtual TUniqueId GetLightId() const = 0; + virtual void DeleteLight(CStateManager&) const = 0; + virtual void SetModulationColor(const zeus::CColor& color) = 0; + + void SetFlags(s32); + s32 GetFlags() const; + void SetIsGrabInitialData(bool); + bool GetIsGrabInitialData() const; + bool GetIsActive() const; + bool SetIsActive(bool); + void OffsetTime(float); + void SetCurOffset(const zeus::CVector3f& offset) { x74_offset = offset; } + void SetCurTransform(const zeus::CTransform& xf) { x44_transform = xf; } + void SetInactiveStartTime(float); + float GetInactiveStartTime() const; + float GetFinishTime() const; + float GetCurrentTime() const; + + CParticleData::EParentedMode GetParentedMode() const { return x28_parentMode; } + const std::string& GetLocatorName() const { return x10_boneName; } }; class CParticleGenInfoGeneric : public CParticleGenInfo { - std::shared_ptr x80_system; - TUniqueId x84_lightId; + std::shared_ptr x84_system; + TUniqueId x88_lightId; + public: - CParticleGenInfoGeneric(const SObjectTag& part, const std::weak_ptr& system, - int, const std::string& boneName, const zeus::CVector3f& scale, - CParticleData::EParentedMode parentMode, int a, CStateManager& stateMgr, - int lightId); + CParticleGenInfoGeneric(const SObjectTag& part, const std::weak_ptr& system, int, + const std::string& boneName, const zeus::CVector3f& scale, + CParticleData::EParentedMode parentMode, int a, CStateManager& stateMgr, TAreaId, + int lightId, int b); void AddToRenderer(); void Render(); @@ -69,14 +90,14 @@ public: void SetGlobalScale(const zeus::CVector3f& scale); void SetParticleEmission(bool, CStateManager& stateMgr); bool IsSystemDeletable() const; - zeus::CAABox GetBounds() const; + rstl::optional_object GetBounds() const; bool HasActiveParticles() const; void DestroyParticles(); bool HasLight() const; TUniqueId GetLightId() const; + void DeleteLight(CStateManager&); void SetModulationColor(const zeus::CColor& color); }; - } #endif // __URDE_CPARTICLEGENINFO_HPP__ diff --git a/Runtime/Graphics/CBooRenderer.cpp b/Runtime/Graphics/CBooRenderer.cpp index 9178f795b..6be14092b 100644 --- a/Runtime/Graphics/CBooRenderer.cpp +++ b/Runtime/Graphics/CBooRenderer.cpp @@ -483,11 +483,11 @@ void CBooRenderer::PostRenderFogs() void CBooRenderer::AddParticleGen(const CParticleGen& gen) { - std::pair bounds = gen.GetBounds(); - if (bounds.second) + auto bounds = gen.GetBounds(); + if (bounds) { - zeus::CVector3f pt = bounds.first.closestPointAlongVector(xb0_viewPlane.vec); - Buckets::Insert(pt, bounds.first, EDrawableType::Particle, &gen, xb0_viewPlane, 0); + zeus::CVector3f pt = bounds.value().closestPointAlongVector(xb0_viewPlane.vec); + Buckets::Insert(pt, bounds.value(), EDrawableType::Particle, &gen, xb0_viewPlane, 0); } } diff --git a/Runtime/MP1/MP1.hpp b/Runtime/MP1/MP1.hpp index 6a25c319c..1a0e2f5da 100644 --- a/Runtime/MP1/MP1.hpp +++ b/Runtime/MP1/MP1.hpp @@ -58,14 +58,14 @@ class CGameGlobalObjects std::unique_ptr x134_gameState; TLockedToken x13c_mainStringTable; CInGameTweakManager x150_tweakManager; - std::unique_ptr m_renderer; + std::unique_ptr m_renderer; void LoadStringTable() { x13c_mainStringTable = g_SimplePool->GetObj("STRG_Main"); g_MainStringTable = x13c_mainStringTable.GetObj(); } - static CBooRenderer* + static IRenderer* AllocateRenderer(IObjectStore& store, IFactory& resFactory) { g_Renderer = new CBooRenderer(store, resFactory); diff --git a/Runtime/Particle/CElementGen.cpp b/Runtime/Particle/CElementGen.cpp index fd504d7dd..96799ba04 100644 --- a/Runtime/Particle/CElementGen.cpp +++ b/Runtime/Particle/CElementGen.cpp @@ -1152,41 +1152,41 @@ void CElementGen::BuildParticleSystemBounds() for (std::unique_ptr& ch : x234_activePartChildren) { - std::pair chBounds = ch->GetBounds(); - if (chBounds.second) + auto chBounds = ch->GetBounds(); + if (chBounds) { accumulated = true; - aabb.accumulateBounds(chBounds.first); + aabb.accumulateBounds(chBounds.value()); } } for (std::unique_ptr& ch : x248_finishPartChildren) { - std::pair chBounds = ch->GetBounds(); - if (chBounds.second) + auto chBounds = ch->GetBounds(); + if (chBounds) { accumulated = true; - aabb.accumulateBounds(chBounds.first); + aabb.accumulateBounds(chBounds.value()); } } for (std::unique_ptr& ch : x260_swhcChildren) { - std::pair chBounds = ch->GetBounds(); - if (chBounds.second) + auto chBounds = ch->GetBounds(); + if (chBounds) { accumulated = true; - aabb.accumulateBounds(chBounds.first); + aabb.accumulateBounds(chBounds.value()); } } for (std::unique_ptr& ch : x280_elscChildren) { - std::pair chBounds = ch->GetBounds(); - if (chBounds.second) + auto chBounds = ch->GetBounds(); + if (chBounds) { accumulated = true; - aabb.accumulateBounds(chBounds.first); + aabb.accumulateBounds(chBounds.value()); } } @@ -2245,12 +2245,12 @@ bool CElementGen::IsSystemDeletable() const return false; } -std::pair CElementGen::GetBounds() const +rstl::optional_object CElementGen::GetBounds() const { if (GetParticleCountAll() == 0) - return {zeus::CAABox(), false}; + return {zeus::CAABox()}; else - return {x2c4_systemBounds, true}; + return {x2c4_systemBounds}; } u32 CElementGen::GetParticleCount() const diff --git a/Runtime/Particle/CElementGen.hpp b/Runtime/Particle/CElementGen.hpp index c001ff83d..20caf3b18 100644 --- a/Runtime/Particle/CElementGen.hpp +++ b/Runtime/Particle/CElementGen.hpp @@ -232,7 +232,7 @@ public: const zeus::CVector3f& GetGlobalScale() const; const zeus::CColor& GetModulationColor() const; bool IsSystemDeletable() const; - std::pair GetBounds() const; + rstl::optional_object GetBounds() const; u32 GetParticleCount() const; bool SystemHasLight() const; CLight GetLight() const; diff --git a/Runtime/Particle/CParticleElectric.cpp b/Runtime/Particle/CParticleElectric.cpp index cf343d1da..ee7084846 100644 --- a/Runtime/Particle/CParticleElectric.cpp +++ b/Runtime/Particle/CParticleElectric.cpp @@ -185,9 +185,9 @@ bool CParticleElectric::IsSystemDeletable() const return false; } -std::pair CParticleElectric::GetBounds() const +rstl::optional_object CParticleElectric::GetBounds() const { - return std::make_pair(zeus::CAABox(), false); + return {}; } u32 CParticleElectric::GetParticleCount() const diff --git a/Runtime/Particle/CParticleElectric.hpp b/Runtime/Particle/CParticleElectric.hpp index 080c4da67..d0de50d42 100644 --- a/Runtime/Particle/CParticleElectric.hpp +++ b/Runtime/Particle/CParticleElectric.hpp @@ -97,7 +97,7 @@ public: const zeus::CVector3f& GetGlobalScale() const; const zeus::CColor& GetModulationColor() const; bool IsSystemDeletable() const; - std::pair GetBounds() const; + rstl::optional_object GetBounds() const; u32 GetParticleCount() const; bool SystemHasLight() const; CLight GetLight() const; diff --git a/Runtime/Particle/CParticleGen.hpp b/Runtime/Particle/CParticleGen.hpp index a3294b863..eaf4aa05e 100644 --- a/Runtime/Particle/CParticleGen.hpp +++ b/Runtime/Particle/CParticleGen.hpp @@ -36,7 +36,7 @@ public: virtual const zeus::CVector3f& GetGlobalScale() const=0; virtual const zeus::CColor& GetModulationColor() const=0; virtual bool IsSystemDeletable() const=0; - virtual std::pair GetBounds() const=0; + virtual rstl::optional_object GetBounds() const=0; virtual u32 GetParticleCount() const=0; virtual bool SystemHasLight() const=0; virtual CLight GetLight() const=0; diff --git a/Runtime/Particle/CParticleSwoosh.cpp b/Runtime/Particle/CParticleSwoosh.cpp index 7d21d48d3..21280dd15 100644 --- a/Runtime/Particle/CParticleSwoosh.cpp +++ b/Runtime/Particle/CParticleSwoosh.cpp @@ -88,9 +88,9 @@ bool CParticleSwoosh::IsSystemDeletable() const return false; } -std::pair CParticleSwoosh::GetBounds() const +rstl::optional_object CParticleSwoosh::GetBounds() const { - return std::make_pair(zeus::CAABox(), false); + return {}; } u32 CParticleSwoosh::GetParticleCount() const diff --git a/Runtime/Particle/CParticleSwoosh.hpp b/Runtime/Particle/CParticleSwoosh.hpp index d1f7e0b2b..c7a4cfa6b 100644 --- a/Runtime/Particle/CParticleSwoosh.hpp +++ b/Runtime/Particle/CParticleSwoosh.hpp @@ -30,7 +30,7 @@ public: const zeus::CVector3f& GetGlobalScale() const; const zeus::CColor& GetModulationColor() const; bool IsSystemDeletable() const; - std::pair GetBounds() const; + rstl::optional_object GetBounds() const; u32 GetParticleCount() const; bool SystemHasLight() const; CLight GetLight() const; diff --git a/Runtime/World/CActor.cpp b/Runtime/World/CActor.cpp index b85d935ba..a0ca702e0 100644 --- a/Runtime/World/CActor.cpp +++ b/Runtime/World/CActor.cpp @@ -253,6 +253,14 @@ void CActor::SetSfxPitchBend(s32 val) CSfxManager::PitchBend(*x8c_sfxHandle.get(), val); } +void CActor::SetRotation(const zeus::CQuaternion &q) +{ + x34_transform = q.toTransform(x34_transform.origin); + xe4_27_ = true; + xe4_28_ = true; + xe4_29_ = true; +} + void CActor::SetTranslation(const zeus::CVector3f& tr) { x34_transform.origin = tr; diff --git a/Runtime/World/CActor.hpp b/Runtime/World/CActor.hpp index a79157c4f..8ae216f64 100644 --- a/Runtime/World/CActor.hpp +++ b/Runtime/World/CActor.hpp @@ -140,6 +140,7 @@ public: bool HasModelData() const; const CSfxHandle* GetSfxHandle() const; void SetSfxPitchBend(s32); + void SetRotation(const zeus::CQuaternion& q); void SetTranslation(const zeus::CVector3f& tr); void SetAddedToken(u32 tok); float GetPitch() const; diff --git a/Runtime/World/CGameLight.cpp b/Runtime/World/CGameLight.cpp index 217714ec8..9dc294be0 100644 --- a/Runtime/World/CGameLight.cpp +++ b/Runtime/World/CGameLight.cpp @@ -1,6 +1,7 @@ -#include "CGameLight.hpp" -#include "CActorParameters.hpp" +#include "World/CGameLight.hpp" +#include "World/CActorParameters.hpp" #include "CStateManager.hpp" +#include "TCastTo.hpp" namespace urde { @@ -9,20 +10,25 @@ CGameLight::CGameLight(TUniqueId uid, TAreaId aid, bool active, const std::strin TUniqueId parentId, const CLight& light, u32 w1, u32 w2, float f1) : CActor(uid, active, name, CEntityInfo(aid, CEntity::NullConnectionList), xf, CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(), kInvalidUniqueId), - xe8_parentId(parentId), xec_light(light), x13c_(w1), x140_(w2), x144_(f1) + xe8_parentId(parentId), xec_light(light), x13c_(w1), x140_(w2), x144_lifeTime(f1) { xec_light.GetRadius(); xec_light.GetIntensity(); SetLightPriorityAndId(); } +void CGameLight::Accept(IVisitor &visitor) +{ + visitor.Visit(this); +} + void CGameLight::Think(float dt, CStateManager& mgr) { - if (x144_ <= 0.f) + if (x144_lifeTime <= 0.f) return; - x144_ -= dt; + x144_lifeTime -= dt; - if (x144_ <= 0.f) + if (x144_lifeTime <= 0.f) mgr.RemoveActor(GetUniqueId()); } diff --git a/Runtime/World/CGameLight.hpp b/Runtime/World/CGameLight.hpp index 3b1ed8c8c..a79aafe10 100644 --- a/Runtime/World/CGameLight.hpp +++ b/Runtime/World/CGameLight.hpp @@ -11,12 +11,13 @@ class CGameLight : public CActor CLight xec_light; u32 x13c_; u32 x140_; - float x144_; + float x144_lifeTime; public: CGameLight(TUniqueId, TAreaId, bool, const std::string&, const zeus::CTransform&, TUniqueId, const CLight&, u32, u32, float); + void Accept(IVisitor &visitor); void Think(float, CStateManager&); void SetLightPriorityAndId(); void SetLight(const CLight&); diff --git a/Runtime/World/CWorldLight.cpp b/Runtime/World/CWorldLight.cpp index 18efb7b83..b01d9f796 100644 --- a/Runtime/World/CWorldLight.cpp +++ b/Runtime/World/CWorldLight.cpp @@ -23,7 +23,7 @@ CLight CWorldLight::GetAsCGraphicsLight() const zeus::CColor color(x4_color.x, x4_color.y, x4_color.z); float tmp = x28_q; if (epsilon < tmp) - tmp = 0.0000011920929f; + tmp = 0.000001f; /* if (x0_type == ELightType::Spot) { diff --git a/specter b/specter index 03e7124c5..a47613503 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit 03e7124c5f576033c10ad2d0a116e4a331c0381d +Subproject commit a4761350329459605dfb98d7eb27d453e6da2d29