diff --git a/CMakeLists.txt b/CMakeLists.txt index a25102e2f..ba71b695e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,8 +36,15 @@ endif() project(urde VERSION 0.1.0) -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) +# MSVC has a "latest" flag, which always uses the newest standard +# when available. GCC and Clang posess no such flag, and must be +# manually enforced. CMake, curiously, also doesn't have a "latest" +# standard flag either. +if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) +endif() + set(BUILD_SHARED_LIBS OFF CACHE BOOL "Force shared libs off" FORCE) set(BUILD_STATIC_LIBS ON CACHE BOOL "Force static libs on" FORCE) @@ -88,6 +95,7 @@ if(MSVC) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") add_compile_options( + /std:c++latest # Use latest C++ standard. /permissive- # Enforce various standards compliance features. /Zc:externConstexpr # Allow extern constexpr variables according to the standard. /Zc:throwingNew # Assume new throws, allowing for better code generation. diff --git a/Runtime/Audio/CSfxManager.cpp b/Runtime/Audio/CSfxManager.cpp index ae5a77bca..91ece74d9 100644 --- a/Runtime/Audio/CSfxManager.cpp +++ b/Runtime/Audio/CSfxManager.cpp @@ -26,7 +26,7 @@ CFactoryFnReturn FAudioTranslationTableFactory(const SObjectTag& tag, CInputStre return TToken>::GetIObjObjectFor(std::move(obj)); } -CSfxManager::CSfxChannel CSfxManager::m_channels[4]; +std::array CSfxManager::m_channels; CSfxManager::ESfxChannels CSfxManager::m_currentChannel = CSfxManager::ESfxChannels::Default; bool CSfxManager::m_doUpdate; void* CSfxManager::m_usedSounds; @@ -186,7 +186,7 @@ void CSfxManager::SetChannel(ESfxChannels chan) { } void CSfxManager::KillAll(ESfxChannels chan) { - CSfxChannel& chanObj = m_channels[int(chan)]; + CSfxChannel& chanObj = m_channels[size_t(chan)]; for (auto it = chanObj.x48_handles.begin(); it != chanObj.x48_handles.end();) { const CSfxHandle& handle = *it; handle->Stop(); @@ -197,7 +197,7 @@ void CSfxManager::KillAll(ESfxChannels chan) { } void CSfxManager::TurnOnChannel(ESfxChannels chan) { - CSfxChannel& chanObj = m_channels[int(chan)]; + CSfxChannel& chanObj = m_channels[size_t(chan)]; m_currentChannel = chan; m_doUpdate = true; if (chanObj.x44_listenerActive) { @@ -208,7 +208,7 @@ void CSfxManager::TurnOnChannel(ESfxChannels chan) { } void CSfxManager::TurnOffChannel(ESfxChannels chan) { - CSfxChannel& chanObj = m_channels[int(chan)]; + CSfxChannel& chanObj = m_channels[size_t(chan)]; for (auto it = chanObj.x48_handles.begin(); it != chanObj.x48_handles.end();) { const CSfxHandle& handle = *it; if (handle->IsLooped()) { @@ -260,24 +260,29 @@ void CSfxManager::UpdateListener(const zeus::CVector3f& pos, const zeus::CVector } s16 CSfxManager::GetRank(CBaseSfxWrapper* sfx) { - CSfxChannel& chanObj = m_channels[int(m_currentChannel)]; - if (!sfx->IsInArea()) + const CSfxChannel& chanObj = m_channels[size_t(m_currentChannel)]; + if (!sfx->IsInArea()) { return 0; + } s16 rank = sfx->GetPriority() / 4; - if (sfx->IsPlaying()) + if (sfx->IsPlaying()) { ++rank; + } - if (sfx->IsLooped()) + if (sfx->IsLooped()) { rank -= 2; + } - if (sfx->Ready() && !sfx->IsPlaying()) + if (sfx->Ready() && !sfx->IsPlaying()) { rank += 3; + } if (chanObj.x44_listenerActive) { - ESfxAudibility aud = sfx->GetAudible(chanObj.x0_pos); - if (aud == ESfxAudibility::Aud0) + const ESfxAudibility aud = sfx->GetAudible(chanObj.x0_pos); + if (aud == ESfxAudibility::Aud0) { return 0; + } rank += int(aud) / 2; } @@ -285,7 +290,7 @@ s16 CSfxManager::GetRank(CBaseSfxWrapper* sfx) { } void CSfxManager::ApplyReverb() { - CSfxChannel& chanObj = m_channels[int(m_currentChannel)]; + const CSfxChannel& chanObj = m_channels[size_t(m_currentChannel)]; for (const CSfxHandle& handle : chanObj.x48_handles) { handle->SetReverb(m_reverbAmount); } @@ -344,7 +349,7 @@ void CSfxManager::StopSound(const CSfxHandle& handle) { m_doUpdate = true; handle->Stop(); handle->Release(); - CSfxChannel& chanObj = m_channels[int(m_currentChannel)]; + CSfxChannel& chanObj = m_channels[size_t(m_currentChannel)]; handle->Close(); chanObj.x48_handles.erase(handle); } @@ -357,7 +362,7 @@ CSfxHandle CSfxManager::SfxStart(u16 id, float vol, float pan, bool useAcoustics m_doUpdate = true; CSfxHandle wrapper = std::make_shared(looped, prio, id, vol, pan, useAcoustics, areaId); - CSfxChannel& chanObj = m_channels[int(m_currentChannel)]; + CSfxChannel& chanObj = m_channels[size_t(m_currentChannel)]; chanObj.x48_handles.insert(wrapper); return wrapper; } @@ -428,14 +433,13 @@ CSfxHandle CSfxManager::AddEmitter(const CAudioSys::C3DEmitterParmData& parmData data.x20_flags |= 0x6; // Pausable/restartable when inaudible m_doUpdate = true; CSfxHandle wrapper = std::make_shared(looped, prio, data, useAcoustics, areaId); - CSfxChannel& chanObj = m_channels[int(m_currentChannel)]; + CSfxChannel& chanObj = m_channels[size_t(m_currentChannel)]; chanObj.x48_handles.insert(wrapper); return wrapper; } void CSfxManager::StopAndRemoveAllEmitters() { - for (int i = 0; i < 4; ++i) { - CSfxChannel& chanObj = m_channels[i]; + for (auto& chanObj : m_channels) { for (auto it = chanObj.x48_handles.begin(); it != chanObj.x48_handles.end();) { const CSfxHandle& handle = *it; handle->Stop(); @@ -538,15 +542,15 @@ void CSfxManager::DisableAuxProcessing() { } void CSfxManager::SetActiveAreas(const rstl::reserved_vector& areas) { - CSfxChannel& chanObj = m_channels[int(m_currentChannel)]; + const CSfxChannel& chanObj = m_channels[size_t(m_currentChannel)]; for (const CSfxHandle& hnd : chanObj.x48_handles) { - TAreaId sndArea = hnd->GetArea(); + const TAreaId sndArea = hnd->GetArea(); if (sndArea == kInvalidAreaId) { hnd->SetInArea(true); } else { bool inArea = false; - for (TAreaId id : areas) { + for (const TAreaId id : areas) { if (sndArea == id) { inArea = true; break; @@ -559,7 +563,7 @@ void CSfxManager::SetActiveAreas(const rstl::reserved_vector& areas } void CSfxManager::Update(float dt) { - CSfxChannel& chanObj = m_channels[int(m_currentChannel)]; + CSfxChannel& chanObj = m_channels[size_t(m_currentChannel)]; for (auto it = chanObj.x48_handles.begin(); it != chanObj.x48_handles.end();) { const CSfxHandle& handle = *it; diff --git a/Runtime/Audio/CSfxManager.hpp b/Runtime/Audio/CSfxManager.hpp index 9d13697c9..2e4e6a155 100644 --- a/Runtime/Audio/CSfxManager.hpp +++ b/Runtime/Audio/CSfxManager.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -109,8 +110,7 @@ public: void SetTimeRemaining(float t) { x4_timeRemaining = t; } CBaseSfxWrapper(bool looped, s16 prio, /*const CSfxHandle& handle,*/ bool useAcoustics, TAreaId area) - : x8_rank(0) - , xa_prio(prio) + : xa_prio(prio) , /*xc_handle(handle),*/ x10_area(area) , x14_24_isActive(true) , x14_25_isPlaying(false) @@ -118,15 +118,16 @@ public: , x14_27_inArea(true) , x14_28_isReleased(false) , x14_29_useAcoustics(useAcoustics) + , m_isEmitter(false) , m_isClosed(false) {} }; class CSfxEmitterWrapper : public CBaseSfxWrapper { - float x1a_reverb; + float x1a_reverb = 0.0f; CAudioSys::C3DEmitterParmData x24_parmData; amuse::ObjToken x50_emitterHandle; bool x54_ready = true; - float x55_cachedMaxVol; + float x55_cachedMaxVol = 0.0f; public: bool IsPlaying() const override; @@ -177,7 +178,7 @@ public: } }; - static CSfxChannel m_channels[4]; + static std::array m_channels; static ESfxChannels m_currentChannel; static bool m_doUpdate; static void* m_usedSounds; diff --git a/Runtime/Audio/CStreamAudioManager.cpp b/Runtime/Audio/CStreamAudioManager.cpp index 1660e097f..51ee8d788 100644 --- a/Runtime/Audio/CStreamAudioManager.cpp +++ b/Runtime/Audio/CStreamAudioManager.cpp @@ -6,6 +6,7 @@ #include "Runtime/CStringExtras.hpp" #include +#include #include #include #include @@ -36,7 +37,7 @@ struct dspadpcm_header { s16 x44_loop_ps; s16 x46_loop_hist1; s16 x48_loop_hist2; - u16 x4a_pad[11]; + std::array x4a_pad; }; struct SDSPStreamInfo { @@ -74,7 +75,7 @@ struct SDSPStream : boo::IAudioVoiceCallback { u8 xec_readState = 0; // 0: NoRead 1: Read 2: ReadWrap std::optional m_file; - std::shared_ptr m_readReqs[2]; + std::array, 2> m_readReqs; void ReadBuffer(int buf) { u32 halfSize = xd8_ringBytes / 2; @@ -242,7 +243,7 @@ struct SDSPStream : boo::IAudioVoiceCallback { } static void Initialize() { - for (int i = 0; i < 4; ++i) { + for (size_t i = 0; i < g_Streams.size(); ++i) { SDSPStream& stream = g_Streams[i]; stream.x0_active = false; stream.xd4_ringBuffer.reset(); @@ -258,29 +259,30 @@ struct SDSPStream : boo::IAudioVoiceCallback { } static void FreeAllStreams() { - for (int i = 0; i < 4; ++i) { - SDSPStream& stream = g_Streams[i]; + for (auto& stream : g_Streams) { stream.m_booVoice.reset(); stream.x0_active = false; - for (int j = 0; j < 2; ++j) - if (stream.m_readReqs[j]) { - stream.m_readReqs[j]->PostCancelRequest(); - stream.m_readReqs[j].reset(); + for (auto& request : stream.m_readReqs) { + if (request) { + request->PostCancelRequest(); + request.reset(); } + } stream.xd4_ringBuffer.reset(); stream.m_file = std::nullopt; } } static s32 PickFreeStream(SDSPStream*& streamOut, bool oneshot) { - for (int i = 0; i < 4; ++i) { - SDSPStream& stream = g_Streams[i]; - if (stream.x0_active || stream.x1_oneshot != oneshot) + for (auto& stream : g_Streams) { + if (stream.x0_active || stream.x1_oneshot != oneshot) { continue; + } stream.x0_active = true; stream.x4_ownerId = ++s_HandleCounter2; - if (stream.x4_ownerId == -1) + if (stream.x4_ownerId == -1) { stream.x4_ownerId = ++s_HandleCounter2; + } stream.x8_stereoLeft = nullptr; stream.xc_companionRight = nullptr; streamOut = &stream; @@ -290,22 +292,24 @@ struct SDSPStream : boo::IAudioVoiceCallback { } static s32 FindStreamIdx(s32 id) { - for (s32 i = 0; i < 4; ++i) { - SDSPStream& stream = g_Streams[i]; - if (stream.x4_ownerId == id) - return i; + for (size_t i = 0; i < g_Streams.size(); ++i) { + const SDSPStream& stream = g_Streams[i]; + if (stream.x4_ownerId == id) { + return s32(i); + } } return -1; } void UpdateStreamVolume(float vol) { x4c_vol = vol; - if (!x0_active || xe8_silent) + if (!x0_active || xe8_silent) { return; - float coefs[8] = {}; - coefs[int(boo::AudioChannel::FrontLeft)] = m_leftgain * vol; - coefs[int(boo::AudioChannel::FrontRight)] = m_rightgain * vol; - m_booVoice->setMonoChannelLevels(nullptr, coefs, true); + } + std::array coefs{}; + coefs[size_t(boo::AudioChannel::FrontLeft)] = m_leftgain * vol; + coefs[size_t(boo::AudioChannel::FrontRight)] = m_rightgain * vol; + m_booVoice->setMonoChannelLevels(nullptr, coefs.data(), true); } static void UpdateVolume(s32 id, float vol) { @@ -322,10 +326,11 @@ struct SDSPStream : boo::IAudioVoiceCallback { } void SilenceStream() { - if (!x0_active || xe8_silent) + if (!x0_active || xe8_silent) { return; - float coefs[8] = {}; - m_booVoice->setMonoChannelLevels(nullptr, coefs, true); + } + constexpr std::array coefs{}; + m_booVoice->setMonoChannelLevels(nullptr, coefs.data(), true); xe8_silent = true; x0_active = false; } @@ -399,13 +404,15 @@ struct SDSPStream : boo::IAudioVoiceCallback { void AllocateStream(const SDSPStreamInfo& info, float vol, float left, float right) { x10_info = info; m_file.emplace(x10_info.x0_fileName); - if (!xd4_ringBuffer) + if (!xd4_ringBuffer) { DoAllocateStream(); - for (int j = 0; j < 2; ++j) - if (m_readReqs[j]) { - m_readReqs[j]->PostCancelRequest(); - m_readReqs[j].reset(); + } + for (auto& request : m_readReqs) { + if (request) { + request->PostCancelRequest(); + request.reset(); } + } x4c_vol = vol; m_leftgain = left; m_rightgain = right; @@ -425,10 +432,10 @@ struct SDSPStream : boo::IAudioVoiceCallback { UpdateStreamVolume(vol); } - static SDSPStream g_Streams[4]; + static std::array g_Streams; }; -SDSPStream SDSPStream::g_Streams[4] = {}; +std::array SDSPStream::g_Streams{}; class CDSPStreamManager { friend struct SDSPStreamInfo; @@ -450,12 +457,12 @@ private: s8 x71_companionRight = -1; s8 x72_companionLeft = -1; float x73_volume = 0.f; - bool x74_oneshot; + bool x74_oneshot = false; s32 x78_handleId = -1; // arg2 s32 x7c_streamId = -1; std::shared_ptr m_dvdReq; // DVDFileInfo x80_dvdHandle; - static CDSPStreamManager g_Streams[4]; + static std::array g_Streams; public: CDSPStreamManager() { x70_24_unclaimed = true; } @@ -467,22 +474,23 @@ public: } static s32 FindUnclaimedStreamIdx() { - for (s32 i = 0; i < 4; ++i) { - CDSPStreamManager& stream = g_Streams[i]; - if (stream.x70_24_unclaimed) - return i; + for (size_t i = 0; i < g_Streams.size(); ++i) { + const CDSPStreamManager& stream = g_Streams[i]; + if (stream.x70_24_unclaimed) { + return s32(i); + } } return -1; } static bool FindUnclaimedStereoPair(s32& left, s32& right) { - s32 idx = FindUnclaimedStreamIdx(); + const s32 idx = FindUnclaimedStreamIdx(); - for (s32 i = 0; i < 4; ++i) { + for (size_t i = 0; i < g_Streams.size(); ++i) { CDSPStreamManager& stream = g_Streams[i]; - if (stream.x70_24_unclaimed && idx != i) { + if (stream.x70_24_unclaimed && idx != s32(i)) { left = idx; - right = i; + right = s32(i); return true; } } @@ -491,10 +499,11 @@ public: } static s32 FindClaimedStreamIdx(s32 handle) { - for (s32 i = 0; i < 4; ++i) { - CDSPStreamManager& stream = g_Streams[i]; - if (!stream.x70_24_unclaimed && stream.x78_handleId == handle) + for (size_t i = 0; i < g_Streams.size(); ++i) { + const CDSPStreamManager& stream = g_Streams[i]; + if (!stream.x70_24_unclaimed && stream.x78_handleId == handle) { return i; + } } return -1; } @@ -510,8 +519,7 @@ public: continue; } - for (int i = 0; i < 4; ++i) { - CDSPStreamManager& stream = g_Streams[i]; + for (auto& stream : g_Streams) { if (!stream.x70_24_unclaimed && stream.x78_handleId == handle) { good = false; break; @@ -595,9 +603,9 @@ public: void HeaderReadComplete() { s32 selfIdx = -1; - for (int i = 0; i < 4; ++i) { + for (size_t i = 0; i < g_Streams.size(); ++i) { if (this == &g_Streams[i]) { - selfIdx = i; + selfIdx = s32(i); break; } } @@ -641,8 +649,7 @@ public: } static void PollHeaderReadCompletions() { - for (int i = 0; i < 4; ++i) { - CDSPStreamManager& stream = g_Streams[i]; + for (auto& stream : g_Streams) { if (stream.m_dvdReq && stream.m_dvdReq->IsComplete()) { stream.m_dvdReq.reset(); stream.HeaderReadComplete(); @@ -790,22 +797,20 @@ public: static void Initialize() { SDSPStream::Initialize(); - for (int i = 0; i < 4; ++i) { - CDSPStreamManager& stream = g_Streams[i]; + for (auto& stream : g_Streams) { stream = CDSPStreamManager(); } } static void Shutdown() { SDSPStream::FreeAllStreams(); - for (int i = 0; i < 4; ++i) { - CDSPStreamManager& stream = g_Streams[i]; + for (auto& stream : g_Streams) { stream = CDSPStreamManager(); } } }; -CDSPStreamManager CDSPStreamManager::g_Streams[4] = {}; +std::array CDSPStreamManager::g_Streams{}; SDSPStreamInfo::SDSPStreamInfo(const CDSPStreamManager& stream) { x0_fileName = stream.x60_fileName.c_str(); @@ -853,8 +858,10 @@ struct SDSPPlayer { , x20_internalHandle(handle) , x28_music(music) {} }; -static SDSPPlayer s_Players[2]; // looping, oneshot -static SDSPPlayer s_QueuedPlayers[2]; // looping, oneshot + +using PlayerArray = std::array; +static PlayerArray s_Players; // looping, oneshot +static PlayerArray s_QueuedPlayers; // looping, oneshot float CStreamAudioManager::GetTargetDSPVolume(float fileVol, bool music) { if (music) @@ -1000,7 +1007,7 @@ void CStreamAudioManager::UpdateDSPStreamers(float dt) { } void CStreamAudioManager::StopAllStreams() { - for (int i = 0; i < 2; ++i) { + for (size_t i = 0; i < s_Players.size(); ++i) { StopStreaming(bool(i)); SDSPPlayer& p = s_Players[i]; SDSPPlayer& qp = s_QueuedPlayers[i]; diff --git a/Runtime/CStateManager.cpp b/Runtime/CStateManager.cpp index 80e565795..fda9eeb25 100644 --- a/Runtime/CStateManager.cpp +++ b/Runtime/CStateManager.cpp @@ -285,24 +285,26 @@ void CStateManager::UpdateThermalVisor() { } } -void CStateManager::RendererDrawCallback(const void* drawable, const void* ctx, int type) { - const CStateManager& mgr = *static_cast(ctx); +void CStateManager::RendererDrawCallback(void* drawable, void* ctx, int type) { + CStateManager& mgr = *static_cast(ctx); switch (type) { case 0: { - const CActor& actor = *static_cast(drawable); - if (actor.xc8_drawnToken == mgr.x8dc_objectDrawToken) + CActor& actor = *static_cast(drawable); + if (actor.xc8_drawnToken == mgr.x8dc_objectDrawToken) { break; - if (actor.xc6_nextDrawNode != kInvalidUniqueId) + } + if (actor.xc6_nextDrawNode != kInvalidUniqueId) { mgr.RecursiveDrawTree(actor.xc6_nextDrawNode); + } actor.Render(mgr); - const_cast(actor).xc8_drawnToken = mgr.x8dc_objectDrawToken; + actor.xc8_drawnToken = mgr.x8dc_objectDrawToken; break; } case 1: - static_cast(drawable)->Render(mgr.x8f0_shadowTex); + static_cast(drawable)->Render(mgr.x8f0_shadowTex); break; case 2: - static_cast(drawable)->Render(); + static_cast(drawable)->Render(); break; default: break; @@ -316,14 +318,13 @@ bool CStateManager::RenderLast(TUniqueId uid) { return true; } -void CStateManager::AddDrawableActorPlane(const CActor& actor, const zeus::CPlane& plane, - const zeus::CAABox& aabb) const { - const_cast(actor).SetAddedToken(x8dc_objectDrawToken + 1); +void CStateManager::AddDrawableActorPlane(CActor& actor, const zeus::CPlane& plane, const zeus::CAABox& aabb) const { + actor.SetAddedToken(x8dc_objectDrawToken + 1); g_Renderer->AddPlaneObject(&actor, aabb, plane, 0); } -void CStateManager::AddDrawableActor(const CActor& actor, const zeus::CVector3f& vec, const zeus::CAABox& aabb) const { - const_cast(actor).SetAddedToken(x8dc_objectDrawToken + 1); +void CStateManager::AddDrawableActor(CActor& actor, const zeus::CVector3f& vec, const zeus::CAABox& aabb) const { + actor.SetAddedToken(x8dc_objectDrawToken + 1); g_Renderer->AddDrawable(&actor, vec, aabb, 0, IRenderer::EDrawableSorting::SortedCallback); } @@ -518,10 +519,11 @@ void CStateManager::DrawDebugStuff() const { } } -void CStateManager::RenderCamerasAndAreaLights() const { +void CStateManager::RenderCamerasAndAreaLights() { x870_cameraManager->RenderCameras(*this); - for (const CCameraFilterPassPoly& filter : xb84_camFilterPasses) + for (const CCameraFilterPassPoly& filter : xb84_camFilterPasses) { filter.Draw(); + } } void CStateManager::DrawE3DeathEffect() { @@ -716,10 +718,13 @@ void CStateManager::DrawWorld() { if (areaCount) SetupFogForArea(*areaArr[areaCount - 1]); - for (TUniqueId id : x86c_stateManagerContainer->xf370_) - if (const CActor* ent = static_cast(GetObjectById(id))) - if (!thermal || ent->xe6_27_thermalVisorFlags & 0x1) + for (const TUniqueId id : x86c_stateManagerContainer->xf370_) { + if (auto* ent = static_cast(ObjectById(id))) { + if (!thermal || ent->xe6_27_thermalVisorFlags & 0x1) { ent->Render(*this); + } + } + } bool morphingPlayerVisible = false; int thermalActorCount = 0; @@ -784,19 +789,25 @@ void CStateManager::DrawWorld() { if (thermal) { if (x86c_stateManagerContainer->xf39c_renderLast.size()) { CGraphics::SetDepthRange(DEPTH_SCREEN_ACTORS, DEPTH_GUN); - for (TUniqueId id : x86c_stateManagerContainer->xf39c_renderLast) - if (const CActor* actor = static_cast(GetObjectById(id))) - if (actor->xe6_27_thermalVisorFlags & 0x1) + for (const TUniqueId id : x86c_stateManagerContainer->xf39c_renderLast) { + if (auto* actor = static_cast(ObjectById(id))) { + if (actor->xe6_27_thermalVisorFlags & 0x1) { actor->Render(*this); + } + } + } CGraphics::SetDepthRange(DEPTH_WORLD, DEPTH_FAR); } g_Renderer->DoThermalBlendCold(); xf34_thermalFlag = EThermalDrawFlag::Hot; - for (TUniqueId id : x86c_stateManagerContainer->xf370_) - if (const CActor* actor = static_cast(GetObjectById(id))) - if (actor->xe6_27_thermalVisorFlags & 0x2) + for (const TUniqueId id : x86c_stateManagerContainer->xf370_) { + if (auto* actor = static_cast(ObjectById(id))) { + if (actor->xe6_27_thermalVisorFlags & 0x2) { actor->Render(*this); + } + } + } for (int i = areaCount - 1; i >= 0; --i) { const CGameArea& area = *areaArr[i]; @@ -851,10 +862,13 @@ void CStateManager::DrawWorld() { if (x86c_stateManagerContainer->xf39c_renderLast.size()) { CGraphics::SetDepthRange(DEPTH_SCREEN_ACTORS, DEPTH_GUN); - for (TUniqueId id : x86c_stateManagerContainer->xf39c_renderLast) - if (const CActor* actor = static_cast(GetObjectById(id))) - if (!thermal || actor->xe6_27_thermalVisorFlags & 0x2) + for (const TUniqueId id : x86c_stateManagerContainer->xf39c_renderLast) { + if (auto* actor = static_cast(ObjectById(id))) { + if (!thermal || actor->xe6_27_thermalVisorFlags & 0x2) { actor->Render(*this); + } + } + } CGraphics::SetDepthRange(DEPTH_WORLD, DEPTH_FAR); } @@ -1173,14 +1187,16 @@ bool CStateManager::GetVisSetForArea(TAreaId a, TAreaId b, CPVSVisSet& setOut) c return false; } -void CStateManager::RecursiveDrawTree(TUniqueId node) const { - if (TCastToConstPtr actor = GetObjectById(node)) { +void CStateManager::RecursiveDrawTree(TUniqueId node) { + if (const TCastToPtr actor = ObjectById(node)) { if (x8dc_objectDrawToken != actor->xc8_drawnToken) { - if (actor->xc6_nextDrawNode != kInvalidUniqueId) + if (actor->xc6_nextDrawNode != kInvalidUniqueId) { RecursiveDrawTree(actor->xc6_nextDrawNode); - if (x8dc_objectDrawToken == actor->xcc_addedToken) + } + if (x8dc_objectDrawToken == actor->xcc_addedToken) { actor->Render(*this); - const_cast(actor.GetPtr())->xc8_drawnToken = x8dc_objectDrawToken; + } + actor->xc8_drawnToken = x8dc_objectDrawToken; } } } @@ -1572,10 +1588,10 @@ bool CStateManager::TestRayDamage(const zeus::CVector3f& pos, const CActor& dama if (!hInfo) return false; - static const CMaterialList incList(EMaterialTypes::Solid); - static const CMaterialList exList(EMaterialTypes::ProjectilePassthrough, EMaterialTypes::Player, - EMaterialTypes::Occluder, EMaterialTypes::Character); - static const CMaterialFilter filter(incList, exList, CMaterialFilter::EFilterType::IncludeExclude); + static constexpr CMaterialList incList(EMaterialTypes::Solid); + static constexpr CMaterialList exList(EMaterialTypes::ProjectilePassthrough, EMaterialTypes::Player, + EMaterialTypes::Occluder, EMaterialTypes::Character); + static constexpr CMaterialFilter filter(incList, exList, CMaterialFilter::EFilterType::IncludeExclude); std::optional bounds = damagee.GetTouchBounds(); if (!bounds) diff --git a/Runtime/CStateManager.hpp b/Runtime/CStateManager.hpp index 565a08efa..225c79e07 100644 --- a/Runtime/CStateManager.hpp +++ b/Runtime/CStateManager.hpp @@ -221,7 +221,7 @@ private: bool m_warping = false; void UpdateThermalVisor(); - static void RendererDrawCallback(const void*, const void*, int); + static void RendererDrawCallback(void*, void*, int); public: CStateManager(const std::weak_ptr&, const std::weak_ptr&, @@ -231,8 +231,8 @@ public: u32 GetInputFrameIdx() const { return x8d4_inputFrameIdx; } bool RenderLast(TUniqueId); - void AddDrawableActorPlane(const CActor& actor, const zeus::CPlane&, const zeus::CAABox& aabb) const; - void AddDrawableActor(const CActor& actor, const zeus::CVector3f& vec, const zeus::CAABox& aabb) const; + void AddDrawableActorPlane(CActor& actor, const zeus::CPlane&, const zeus::CAABox& aabb) const; + void AddDrawableActor(CActor& actor, const zeus::CVector3f& vec, const zeus::CAABox& aabb) const; bool SpecialSkipCinematic(); TAreaId GetVisAreaId() const; s32 GetWeaponIdCount(TUniqueId, EWeaponType) const; @@ -255,7 +255,7 @@ public: const std::vector& GetDynamicLightList() const { return x8e0_dynamicLights; } void BuildDynamicLightListForWorld(); void DrawDebugStuff() const; - void RenderCamerasAndAreaLights() const; + void RenderCamerasAndAreaLights(); void DrawE3DeathEffect(); void DrawAdditionalFilters(); zeus::CFrustum SetupDrawFrustum(const SViewport& vp) const; @@ -275,7 +275,7 @@ public: void PreRender(); void GetCharacterRenderMaskAndTarget(bool thawed, int& mask, int& target) const; bool GetVisSetForArea(TAreaId, TAreaId, CPVSVisSet& setOut) const; - void RecursiveDrawTree(TUniqueId) const; + void RecursiveDrawTree(TUniqueId); void SendScriptMsg(CEntity* dest, TUniqueId src, EScriptObjectMessage msg); void SendScriptMsg(TUniqueId dest, TUniqueId src, EScriptObjectMessage msg); void SendScriptMsg(TUniqueId src, TEditorId dest, EScriptObjectMessage msg, EScriptObjectState state); diff --git a/Runtime/Camera/CBallCamera.cpp b/Runtime/Camera/CBallCamera.cpp index 5bf69a461..d2b285ae8 100644 --- a/Runtime/Camera/CBallCamera.cpp +++ b/Runtime/Camera/CBallCamera.cpp @@ -242,7 +242,7 @@ void CBallCamera::Reset(const zeus::CTransform& xf, CStateManager& mgr) { } } -void CBallCamera::Render(const CStateManager& mgr) const { +void CBallCamera::Render(CStateManager& mgr) { // Empty } diff --git a/Runtime/Camera/CBallCamera.hpp b/Runtime/Camera/CBallCamera.hpp index 617cfd889..dcc6572b8 100644 --- a/Runtime/Camera/CBallCamera.hpp +++ b/Runtime/Camera/CBallCamera.hpp @@ -247,7 +247,7 @@ public: void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) override; void ProcessInput(const CFinalInput& input, CStateManager& mgr) override; void Reset(const zeus::CTransform&, CStateManager& mgr) override; - void Render(const CStateManager& mgr) const override; + void Render(CStateManager& mgr) override; EBallCameraBehaviour GetBehaviour() const { return x188_behaviour; } EBallCameraState GetState() const { return x400_state; } void SetState(EBallCameraState state, CStateManager& mgr); diff --git a/Runtime/Camera/CCameraFilter.cpp b/Runtime/Camera/CCameraFilter.cpp index 53ff45c88..426463ae5 100644 --- a/Runtime/Camera/CCameraFilter.cpp +++ b/Runtime/Camera/CCameraFilter.cpp @@ -104,9 +104,11 @@ void CCameraFilterPass::DisableFilter(float time) { } template -void CCameraFilterPass::Draw() const { - if (m_shader) - const_cast(*m_shader).DrawFilter(x8_shape, x18_curColor, GetT(x4_nextType == EFilterType::Passthru)); +void CCameraFilterPass::Draw() { + if (!m_shader) { + return; + } + m_shader->DrawFilter(x8_shape, x18_curColor, GetT(x4_nextType == EFilterType::Passthru)); } float CCameraFilterPassBase::GetT(bool invert) const { diff --git a/Runtime/Camera/CCameraFilter.hpp b/Runtime/Camera/CCameraFilter.hpp index 027bf2466..f42aeaec6 100644 --- a/Runtime/Camera/CCameraFilter.hpp +++ b/Runtime/Camera/CCameraFilter.hpp @@ -58,7 +58,7 @@ public: virtual void SetFilter(EFilterType type, EFilterShape shape, float time, const zeus::CColor& color, CAssetId txtr) = 0; virtual void DisableFilter(float time) = 0; - virtual void Draw() const = 0; + virtual void Draw() = 0; }; template @@ -69,11 +69,11 @@ public: void Update(float dt) override; void SetFilter(EFilterType type, EFilterShape shape, float time, const zeus::CColor& color, CAssetId txtr) override; void DisableFilter(float time) override; - void Draw() const override; + void Draw() override; }; class CCameraFilterPassPoly { - EFilterShape m_shape; + EFilterShape m_shape{}; std::unique_ptr m_filter; public: @@ -107,8 +107,8 @@ class CCameraBlurPass { // bool x2d_noPersistentCopy = false; // u32 x30_persistentBuf = 0; - mutable std::optional m_shader; - mutable std::optional m_xrayShader; + std::optional m_shader; + std::optional m_xrayShader; public: void Draw(bool clearDepth = false); diff --git a/Runtime/Camera/CCameraManager.cpp b/Runtime/Camera/CCameraManager.cpp index 8ea777feb..b73158140 100644 --- a/Runtime/Camera/CCameraManager.cpp +++ b/Runtime/Camera/CCameraManager.cpp @@ -603,9 +603,10 @@ void CCameraManager::ProcessInput(const CFinalInput& input, CStateManager& state } } -void CCameraManager::RenderCameras(const CStateManager& mgr) { - for (CEntity* cam : mgr.GetCameraObjectList()) +void CCameraManager::RenderCameras(CStateManager& mgr) { + for (CEntity* cam : mgr.GetCameraObjectList()) { static_cast(cam)->Render(mgr); + } } void CCameraManager::SetupBallCamera(CStateManager& mgr) { diff --git a/Runtime/Camera/CCameraManager.hpp b/Runtime/Camera/CCameraManager.hpp index d3c2f2204..7268b6bf8 100644 --- a/Runtime/Camera/CCameraManager.hpp +++ b/Runtime/Camera/CCameraManager.hpp @@ -139,7 +139,7 @@ public: void ProcessInput(const CFinalInput& input, CStateManager& stateMgr); - void RenderCameras(const CStateManager& mgr); + void RenderCameras(CStateManager& mgr); void SetupBallCamera(CStateManager& mgr); void SetPlayerCamera(CStateManager& mgr, TUniqueId newCamId); int GetFluidCounter() const { return x74_fluidCounter; } diff --git a/Runtime/Camera/CInterpolationCamera.cpp b/Runtime/Camera/CInterpolationCamera.cpp index 09d6eaedd..af20e7d51 100644 --- a/Runtime/Camera/CInterpolationCamera.cpp +++ b/Runtime/Camera/CInterpolationCamera.cpp @@ -14,7 +14,8 @@ CInterpolationCamera::CInterpolationCamera(TUniqueId uid, const zeus::CTransform : CGameCamera(uid, false, "Interpolation Camera", CEntityInfo(kInvalidAreaId, CEntity::NullConnectionList, kInvalidEditorId), xf, CCameraManager::ThirdPersonFOV(), CCameraManager::NearPlane(), CCameraManager::FarPlane(), - CCameraManager::Aspect(), kInvalidUniqueId, false, 0) {} + CCameraManager::Aspect(), kInvalidUniqueId, false, 0) +, x1d8_24_sinusoidal{false} {} void CInterpolationCamera::Accept(IVisitor& visitor) { visitor.Visit(this); } @@ -26,7 +27,7 @@ void CInterpolationCamera::ProcessInput(const CFinalInput& input, CStateManager& // Empty } -void CInterpolationCamera::Render(const CStateManager& mgr) const { +void CInterpolationCamera::Render(CStateManager& mgr) { // Empty } diff --git a/Runtime/Camera/CInterpolationCamera.hpp b/Runtime/Camera/CInterpolationCamera.hpp index 395efe605..3ac69efdd 100644 --- a/Runtime/Camera/CInterpolationCamera.hpp +++ b/Runtime/Camera/CInterpolationCamera.hpp @@ -30,7 +30,7 @@ public: void Accept(IVisitor& visitor) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void ProcessInput(const CFinalInput&, CStateManager& mgr) override; - void Render(const CStateManager&) const override; + void Render(CStateManager&) override; void Reset(const zeus::CTransform&, CStateManager& mgr) override; void Think(float, CStateManager&) override; void SetInterpolation(const zeus::CTransform& xf, const zeus::CVector3f& lookPos, float maxTime, float positionSpeed, diff --git a/Runtime/Camera/CPathCamera.hpp b/Runtime/Camera/CPathCamera.hpp index 96691fe2d..7757e76a1 100644 --- a/Runtime/Camera/CPathCamera.hpp +++ b/Runtime/Camera/CPathCamera.hpp @@ -29,7 +29,7 @@ public: void Accept(IVisitor&) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void Think(float, CStateManager&) override; - void Render(const CStateManager&) const override {} + void Render(CStateManager&) override {} void ProcessInput(const CFinalInput&, CStateManager& mgr) override; void Reset(const zeus::CTransform&, CStateManager& mgr) override; zeus::CTransform MoveAlongSpline(float, CStateManager&); diff --git a/Runtime/Character/CAdditiveBodyState.cpp b/Runtime/Character/CAdditiveBodyState.cpp index ff5a449f4..587e89499 100644 --- a/Runtime/Character/CAdditiveBodyState.cpp +++ b/Runtime/Character/CAdditiveBodyState.cpp @@ -14,9 +14,9 @@ void CABSAim::Start(CBodyController& bc, CStateManager& mgr) { const CPASAnimState* aimState = bc.GetPASDatabase().GetAnimState(22); // Left, Right, Up, Down - for (int i = 0; i < 4; ++i) { - CPASAnimParmData parms(22, CPASAnimParm::FromEnum(i)); - std::pair best = bc.GetPASDatabase().FindBestAnimation(parms, *mgr.GetActiveRandom(), -1); + for (size_t i = 0; i < x8_anims.size(); ++i) { + const CPASAnimParmData parms(22, CPASAnimParm::FromEnum(s32(i))); + const std::pair best = bc.GetPASDatabase().FindBestAnimation(parms, *mgr.GetActiveRandom(), -1); x8_anims[i] = best.second; x18_angles[i] = zeus::degToRad(aimState->GetAnimParmData(x8_anims[i], 1).GetReal32Value()); } diff --git a/Runtime/Character/CAdditiveBodyState.hpp b/Runtime/Character/CAdditiveBodyState.hpp index 8bdbcfdd6..3c2c3bbb6 100644 --- a/Runtime/Character/CAdditiveBodyState.hpp +++ b/Runtime/Character/CAdditiveBodyState.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include "Runtime/RetroTypes.hpp" #include "Runtime/Character/CBodyStateCmdMgr.hpp" #include "Runtime/Character/CharacterCommon.hpp" @@ -21,8 +23,8 @@ public: class CABSAim : public CAdditiveBodyState { bool x4_needsIdle = false; - s32 x8_anims[4]; - float x18_angles[4]; + std::array x8_anims{}; + std::array x18_angles{}; float x28_hWeight = 0.f; float x2c_hWeightVel = 0.f; float x30_vWeight = 0.f; diff --git a/Runtime/Character/CAnimData.hpp b/Runtime/Character/CAnimData.hpp index 2ea18709b..184874263 100644 --- a/Runtime/Character/CAnimData.hpp +++ b/Runtime/Character/CAnimData.hpp @@ -223,6 +223,7 @@ public: std::shared_ptr GetXRayModel() const { return xf4_xrayModel; } void SetInfraModel(const TLockedToken& model, const TLockedToken& skinRules); std::shared_ptr GetInfraModel() const { return xf8_infraModel; } + TLockedToken& GetModelData() { return xd8_modelData; } const TLockedToken& GetModelData() const { return xd8_modelData; } static void PoseSkinnedModel(CSkinnedModel& model, const CPoseAsTransforms& pose, const CModelFlags& drawFlags, diff --git a/Runtime/Character/CAnimationDatabase.hpp b/Runtime/Character/CAnimationDatabase.hpp index 0d7d98c71..93f4c19e2 100644 --- a/Runtime/Character/CAnimationDatabase.hpp +++ b/Runtime/Character/CAnimationDatabase.hpp @@ -12,6 +12,7 @@ class IMetaAnim; class CAnimationDatabase { public: + virtual ~CAnimationDatabase() = default; virtual const std::shared_ptr& GetMetaAnim(s32) const = 0; virtual u32 GetNumMetaAnims() const = 0; virtual const char* GetMetaAnimName(s32) const = 0; diff --git a/Runtime/Character/CBodyState.hpp b/Runtime/Character/CBodyState.hpp index 091a52e76..9dfce3539 100644 --- a/Runtime/Character/CBodyState.hpp +++ b/Runtime/Character/CBodyState.hpp @@ -198,7 +198,7 @@ public: class CBSJump : public CBodyState { pas::EJumpState x4_state = pas::EJumpState::Invalid; - pas::EJumpType x8_jumpType; + pas::EJumpType x8_jumpType{}; zeus::CVector3f xc_waypoint1; zeus::CVector3f x18_velocity; zeus::CVector3f x24_waypoint2; @@ -362,12 +362,12 @@ class CBSBiPedLocomotion : public CBSLocomotion { protected: rstl::reserved_vector, 8>, 14> x8_anims; pas::ELocomotionAnim x3c4_anim = pas::ELocomotionAnim::Invalid; - float x3c8_primeTime; + float x3c8_primeTime = 0.0f; float UpdateRun(float vel, CBodyController& bc, pas::ELocomotionAnim anim); float UpdateWalk(float vel, CBodyController& bc, pas::ELocomotionAnim anim); float UpdateStrafe(float vel, CBodyController& bc, pas::ELocomotionAnim anim); const std::pair& GetLocoAnimation(pas::ELocomotionType type, pas::ELocomotionAnim anim) const { - return x8_anims[int(type)][int(anim)]; + return x8_anims[size_t(type)][size_t(anim)]; } public: diff --git a/Runtime/Character/CLayoutDescription.hpp b/Runtime/Character/CLayoutDescription.hpp index 05c2e041b..e6f29864a 100644 --- a/Runtime/Character/CLayoutDescription.hpp +++ b/Runtime/Character/CLayoutDescription.hpp @@ -13,7 +13,7 @@ class CLayoutDescription { public: class CScaledLayoutDescription { TLockedToken x0_layoutToken; - float xc_scale; + float xc_scale = 0.0f; std::optional x10_scaleVec; public: diff --git a/Runtime/Character/CModelData.hpp b/Runtime/Character/CModelData.hpp index d11d8f36d..ab746220f 100644 --- a/Runtime/Character/CModelData.hpp +++ b/Runtime/Character/CModelData.hpp @@ -52,7 +52,7 @@ public: void SetCharacterNodeId(s32 id) { x4_charIdx = id; } const zeus::CVector3f& GetScale() const { return x8_scale; } bool CanLoop() const { return x14_canLoop; } - void SetCanLoop(bool l) { x14_canLoop = l; } + void SetCanLoop(bool loop) { x14_canLoop = loop; } s32 GetDefaultAnim() const { return x18_defaultAnim; } void SetDefaultAnim(s32 anim) { x18_defaultAnim = anim; } }; @@ -84,7 +84,7 @@ class CModelData { public: enum class EWhichModel { Normal, XRay, Thermal, ThermalHot }; - void SetSortThermal(bool v) { x14_25_sortThermal = v; } + void SetSortThermal(bool sort) { x14_25_sortThermal = sort; } bool GetSortThermal() const { return x14_25_sortThermal; } ~CModelData(); @@ -106,16 +106,16 @@ public: void SetInfraModel(const std::pair& modelSkin); bool IsDefinitelyOpaque(EWhichModel) const; bool GetIsLoop() const; - float GetAnimationDuration(int) const; - void EnableLooping(bool); - void AdvanceParticles(const zeus::CTransform& xf, float, CStateManager& stateMgr); + float GetAnimationDuration(int idx) const; + void EnableLooping(bool enable); + void AdvanceParticles(const zeus::CTransform& xf, float dt, CStateManager& stateMgr); zeus::CAABox GetBounds() const; zeus::CAABox GetBounds(const zeus::CTransform& xf) const; zeus::CTransform GetScaledLocatorTransformDynamic(std::string_view name, const CCharAnimTime* time) const; zeus::CTransform GetScaledLocatorTransform(std::string_view name) const; zeus::CTransform GetLocatorTransformDynamic(std::string_view name, const CCharAnimTime* time) const; zeus::CTransform GetLocatorTransform(std::string_view name) const; - SAdvancementDeltas AdvanceAnimationIgnoreParticles(float dt, CRandom16&, bool advTree); + SAdvancementDeltas AdvanceAnimationIgnoreParticles(float dt, CRandom16& rand, bool advTree); SAdvancementDeltas AdvanceAnimation(float dt, CStateManager& stateMgr, TAreaId aid, bool advTree); bool IsAnimating() const; bool IsInFrustum(const zeus::CTransform& xf, const zeus::CFrustum& frustum) const; diff --git a/Runtime/Character/CTransitionDatabase.hpp b/Runtime/Character/CTransitionDatabase.hpp index 17266590e..891bbf166 100644 --- a/Runtime/Character/CTransitionDatabase.hpp +++ b/Runtime/Character/CTransitionDatabase.hpp @@ -8,6 +8,7 @@ class IMetaTrans; class CTransitionDatabase { public: + virtual ~CTransitionDatabase() = default; virtual const std::shared_ptr& GetMetaTrans(u32, u32) const = 0; }; diff --git a/Runtime/Collision/ICollisionFilter.hpp b/Runtime/Collision/ICollisionFilter.hpp index c21f26b75..e0a7a0d53 100644 --- a/Runtime/Collision/ICollisionFilter.hpp +++ b/Runtime/Collision/ICollisionFilter.hpp @@ -11,6 +11,7 @@ protected: explicit ICollisionFilter(CActor& actor) : x4_actor(actor) {} public: + virtual ~ICollisionFilter() = default; virtual void Filter(const CCollisionInfoList& in, CCollisionInfoList& out) const = 0; }; diff --git a/Runtime/Graphics/CBooRenderer.cpp b/Runtime/Graphics/CBooRenderer.cpp index 8c07d64a7..1007d117c 100644 --- a/Runtime/Graphics/CBooRenderer.cpp +++ b/Runtime/Graphics/CBooRenderer.cpp @@ -72,8 +72,8 @@ public: static void Clear(); static void Sort(); static void InsertPlaneObject(float closeDist, float farDist, const zeus::CAABox& aabb, bool invertTest, - const zeus::CPlane& plane, bool zOnly, EDrawableType dtype, const void* data); - static void Insert(const zeus::CVector3f& pos, const zeus::CAABox& aabb, EDrawableType dtype, const void* data, + const zeus::CPlane& plane, bool zOnly, EDrawableType dtype, void* data); + static void Insert(const zeus::CVector3f& pos, const zeus::CAABox& aabb, EDrawableType dtype, void* data, const zeus::CPlane& plane, u16 extraSort); static void Shutdown(); static void Init(); @@ -173,14 +173,14 @@ void Buckets::Sort() { } void Buckets::InsertPlaneObject(float closeDist, float farDist, const zeus::CAABox& aabb, bool invertTest, - const zeus::CPlane& plane, bool zOnly, EDrawableType dtype, const void* data) { + const zeus::CPlane& plane, bool zOnly, EDrawableType dtype, void* data) { if (sPlaneObjectData->size() == sPlaneObjectData->capacity()) { return; } sPlaneObjectData->emplace_back(dtype, closeDist, farDist, aabb, invertTest, plane, zOnly, data); } -void Buckets::Insert(const zeus::CVector3f& pos, const zeus::CAABox& aabb, EDrawableType dtype, const void* data, +void Buckets::Insert(const zeus::CVector3f& pos, const zeus::CAABox& aabb, EDrawableType dtype, void* data, const zeus::CPlane& plane, u16 extraSort) { if (sData->size() == sData->capacity()) { Log.report(logvisor::Fatal, fmt("Rendering buckets filled to capacity")); @@ -291,12 +291,12 @@ void CBooRenderer::RenderBucketItems(CAreaListItem* item) { for (CDrawable* drawable : bucket) { switch (drawable->GetType()) { case EDrawableType::Particle: { - static_cast((void*)drawable->GetData())->Render(); + static_cast(drawable->GetData())->Render(); break; } case EDrawableType::WorldSurface: { // SetupRendererStates(); - CBooSurface* surf = static_cast((void*)drawable->GetData()); + auto* surf = static_cast(drawable->GetData()); CBooModel* model = surf->m_parent; if (model) { ActivateLightsForModel(item, *model); @@ -988,18 +988,18 @@ void CBooRenderer::PostRenderFogs() { void CBooRenderer::SetModelMatrix(const zeus::CTransform& xf) { CGraphics::SetModelMatrix(xf); } -void CBooRenderer::AddParticleGen(const CParticleGen& gen) { +void CBooRenderer::AddParticleGen(CParticleGen& gen) { if (auto bounds = gen.GetBounds()) { zeus::CVector3f pt = bounds.value().closestPointAlongVector(xb0_viewPlane.normal()); Buckets::Insert(pt, bounds.value(), EDrawableType::Particle, &gen, xb0_viewPlane, 0); } } -void CBooRenderer::AddParticleGen(const CParticleGen& gen, const zeus::CVector3f& pos, const zeus::CAABox& bounds) { +void CBooRenderer::AddParticleGen(CParticleGen& gen, const zeus::CVector3f& pos, const zeus::CAABox& bounds) { Buckets::Insert(pos, bounds, EDrawableType::Particle, &gen, xb0_viewPlane, 0); } -void CBooRenderer::AddPlaneObject(const void* obj, const zeus::CAABox& aabb, const zeus::CPlane& plane, int type) { +void CBooRenderer::AddPlaneObject(void* obj, const zeus::CAABox& aabb, const zeus::CPlane& plane, int type) { zeus::CVector3f closePoint = aabb.closestPointAlongVector(xb0_viewPlane.normal()); zeus::CVector3f farPoint = aabb.furthestPointAlongVector(xb0_viewPlane.normal()); float closeDist = xb0_viewPlane.pointToPlaneDist(closePoint); @@ -1015,7 +1015,7 @@ void CBooRenderer::AddPlaneObject(const void* obj, const zeus::CAABox& aabb, con } } -void CBooRenderer::AddDrawable(const void* obj, const zeus::CVector3f& pos, const zeus::CAABox& aabb, int mode, +void CBooRenderer::AddDrawable(void* obj, const zeus::CVector3f& pos, const zeus::CAABox& aabb, int mode, EDrawableSorting sorting) { if (sorting == EDrawableSorting::UnsortedCallback) xa8_drawableCallback(obj, xac_callbackContext, mode); @@ -1023,7 +1023,7 @@ void CBooRenderer::AddDrawable(const void* obj, const zeus::CVector3f& pos, cons Buckets::Insert(pos, aabb, EDrawableType(mode + 2), obj, xb0_viewPlane, 0); } -void CBooRenderer::SetDrawableCallback(TDrawableCallback cb, const void* ctx) { +void CBooRenderer::SetDrawableCallback(TDrawableCallback cb, void* ctx) { xa8_drawableCallback = cb; xac_callbackContext = ctx; } diff --git a/Runtime/Graphics/CBooRenderer.hpp b/Runtime/Graphics/CBooRenderer.hpp index 92ef59938..7c3016297 100644 --- a/Runtime/Graphics/CBooRenderer.hpp +++ b/Runtime/Graphics/CBooRenderer.hpp @@ -96,7 +96,7 @@ class CBooRenderer final : public IRenderer { zeus::CFrustum x44_frustumPlanes; TDrawableCallback xa8_drawableCallback; - const void* xac_callbackContext; + void* xac_callbackContext; zeus::CPlane xb0_viewPlane = {0.f, 1.f, 0.f, 0.f}; @@ -212,12 +212,12 @@ public: void DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly) override; void PostRenderFogs() override; void SetModelMatrix(const zeus::CTransform& xf) override; - void AddParticleGen(const CParticleGen& gen) override; - void AddParticleGen(const CParticleGen& gen, const zeus::CVector3f& pos, const zeus::CAABox& bounds) override; - void AddPlaneObject(const void* obj, const zeus::CAABox& aabb, const zeus::CPlane& plane, int type) override; - void AddDrawable(const void* obj, const zeus::CVector3f& pos, const zeus::CAABox& aabb, int mode, + void AddParticleGen(CParticleGen& gen) override; + void AddParticleGen(CParticleGen& gen, const zeus::CVector3f& pos, const zeus::CAABox& bounds) override; + void AddPlaneObject(void* obj, const zeus::CAABox& aabb, const zeus::CPlane& plane, int type) override; + void AddDrawable(void* obj, const zeus::CVector3f& pos, const zeus::CAABox& aabb, int mode, EDrawableSorting sorting) override; - void SetDrawableCallback(TDrawableCallback cb, const void* ctx) override; + void SetDrawableCallback(TDrawableCallback cb, void* ctx) override; void SetWorldViewpoint(const zeus::CTransform& xf) override; void SetPerspective(float fovy, float width, float height, float znear, float zfar) override; void SetPerspective(float fovy, float aspect, float znear, float zfar) override; diff --git a/Runtime/Graphics/CDrawable.hpp b/Runtime/Graphics/CDrawable.hpp index 8851b520d..5329fb267 100644 --- a/Runtime/Graphics/CDrawable.hpp +++ b/Runtime/Graphics/CDrawable.hpp @@ -9,17 +9,18 @@ enum class EDrawableType : u16 { WorldSurface, Particle, Actor, SimpleShadow, De class CDrawable { EDrawableType x0_type; u16 x2_extraSort; - const void* x4_data; + void* x4_data; zeus::CAABox x8_aabb; float x20_viewDist; public: - CDrawable(EDrawableType dtype, u16 extraSort, float planeDot, const zeus::CAABox& aabb, const void* data) + CDrawable(EDrawableType dtype, u16 extraSort, float planeDot, const zeus::CAABox& aabb, void* data) : x0_type(dtype), x2_extraSort(extraSort), x4_data(data), x8_aabb(aabb), x20_viewDist(planeDot) {} EDrawableType GetType() const { return x0_type; } const zeus::CAABox& GetBounds() const { return x8_aabb; } float GetDistance() const { return x20_viewDist; } + void* GetData() { return x4_data; } const void* GetData() const { return x4_data; } u16 GetExtraSort() const { return x2_extraSort; } }; diff --git a/Runtime/Graphics/CDrawablePlaneObject.hpp b/Runtime/Graphics/CDrawablePlaneObject.hpp index aa94540cb..eb20bc5fd 100644 --- a/Runtime/Graphics/CDrawablePlaneObject.hpp +++ b/Runtime/Graphics/CDrawablePlaneObject.hpp @@ -14,7 +14,7 @@ class CDrawablePlaneObject : public CDrawable { public: CDrawablePlaneObject(EDrawableType dtype, float closeDist, float farDist, const zeus::CAABox& aabb, bool invertTest, - const zeus::CPlane& plane, bool zOnly, const void* data) + const zeus::CPlane& plane, bool zOnly, void* data) : CDrawable(dtype, 0, closeDist, aabb, data), x24_targetBucket(0), x28_farDist(farDist), x2c_plane(plane) { x3c_24_invertTest = invertTest; x3c_25_zOnly = zOnly; diff --git a/Runtime/Graphics/CRainSplashGenerator.hpp b/Runtime/Graphics/CRainSplashGenerator.hpp index 2978c3750..3f2ade690 100644 --- a/Runtime/Graphics/CRainSplashGenerator.hpp +++ b/Runtime/Graphics/CRainSplashGenerator.hpp @@ -46,9 +46,9 @@ class CRainSplashGenerator { std::vector x0_rainSplashes; CRandom16 x10_random = {99}; zeus::CVector3f x14_scale; - float x20_generateTimer = 0.f; - float x24_generateInterval; - float x28_dt = 0.f; + float x20_generateTimer = 0.0f; + float x24_generateInterval = 0.0f; + float x28_dt = 0.0f; float x2c_minZ; float x30_alpha; u32 x34_curPoint = 0; diff --git a/Runtime/Graphics/IRenderer.hpp b/Runtime/Graphics/IRenderer.hpp index 0d6bfae8c..4817183ca 100644 --- a/Runtime/Graphics/IRenderer.hpp +++ b/Runtime/Graphics/IRenderer.hpp @@ -27,7 +27,7 @@ struct SShader; class IRenderer { public: - using TDrawableCallback = void (*)(const void*, const void*, int); + using TDrawableCallback = void (*)(void*, void*, int); using TReflectionCallback = std::function; enum class EDrawableSorting { SortedCallback, UnsortedCallback }; @@ -47,12 +47,12 @@ public: virtual void DrawModelFlat(const CModel& model, const CModelFlags& flags, bool unsortedOnly) = 0; virtual void PostRenderFogs() = 0; virtual void SetModelMatrix(const zeus::CTransform& xf) = 0; - virtual void AddParticleGen(const CParticleGen& gen) = 0; - virtual void AddParticleGen(const CParticleGen& gen, const zeus::CVector3f& pos, const zeus::CAABox& bounds) = 0; - virtual void AddPlaneObject(const void* obj, const zeus::CAABox& aabb, const zeus::CPlane& plane, int type) = 0; - virtual void AddDrawable(const void* obj, const zeus::CVector3f& pos, const zeus::CAABox& aabb, int mode, + virtual void AddParticleGen(CParticleGen& gen) = 0; + virtual void AddParticleGen(CParticleGen& gen, const zeus::CVector3f& pos, const zeus::CAABox& bounds) = 0; + virtual void AddPlaneObject(void* obj, const zeus::CAABox& aabb, const zeus::CPlane& plane, int type) = 0; + virtual void AddDrawable(void* obj, const zeus::CVector3f& pos, const zeus::CAABox& aabb, int mode, EDrawableSorting sorting) = 0; - virtual void SetDrawableCallback(TDrawableCallback cb, const void* ctx) = 0; + virtual void SetDrawableCallback(TDrawableCallback cb, void* ctx) = 0; virtual void SetWorldViewpoint(const zeus::CTransform& xf) = 0; virtual void SetPerspective(float fovy, float width, float height, float znear, float zfar) = 0; virtual void SetPerspective(float fovy, float aspect, float znear, float zfar) = 0; diff --git a/Runtime/GuiSys/CWordBreakTables.cpp b/Runtime/GuiSys/CWordBreakTables.cpp index d1e377f57..f132bb4e5 100644 --- a/Runtime/GuiSys/CWordBreakTables.cpp +++ b/Runtime/GuiSys/CWordBreakTables.cpp @@ -1,28 +1,28 @@ #include "Runtime/GuiSys/CWordBreakTables.hpp" -#include +#include #include "Runtime/GCNTypes.hpp" #include "Runtime/rstl.hpp" namespace urde { - +namespace { struct CCharacterIdentifier { wchar_t chr; u32 rank; }; -static const CCharacterIdentifier gCantBeginChars[] = { - {L'!', 1}, {L')', 1}, {L',', 1}, {L'-', 1}, {L'.', 1}, {L':', 1}, {L';', 1}, {L'?', 1}, - {L']', 1}, {L'}', 1}, {0x92, 1}, {0x94, 1}, {0xBB, 1}, {0x3001, 1}, {0x3002, 1}, {0x3005, 1}, - {0x300D, 1}, {0x300F, 1}, {0x3011, 1}, {0x3015, 1}, {0x3017, 1}, {0x3019, 1}, {0x301B, 1}, {0x301C, 3}, - {0x301E, 1}, {0x302B, 3}, {0x3041, 2}, {0x3043, 2}, {0x3045, 2}, {0x3047, 2}, {0x3049, 2}, {0x3063, 2}, - {0x3083, 2}, {0x3085, 2}, {0x3087, 2}, {0x308E, 2}, {0x309D, 3}, {0x309E, 3}, {0x30A1, 2}, {0x30A3, 2}, - {0x30A5, 2}, {0x30A7, 2}, {0x30A9, 2}, {0x30C3, 2}, {0x30E3, 2}, {0x30E5, 2}, {0x30E7, 2}, {0x30EE, 2}, - {0x30F5, 2}, {0x30F6, 2}, {0x30FC, 2}, {0x30FD, 3}, {0x30FE, 3}, {0xFF01, 1}, {0xFF05, 3}, {0xFF09, 1}, - {0xFF0D, 1}, {0xFF3D, 1}, {0xFF5D, 1}, {0xFF61, 1}, {0xFF63, 1}, {0xFF64, 1}, {0xFF1F, 1}}; +constexpr std::array sCantBeginChars{{ + {L'!', 1}, {L')', 1}, {L',', 1}, {L'-', 1}, {L'.', 1}, {L':', 1}, {L';', 1}, {L'?', 1}, {L']', 1}, + {L'}', 1}, {0x92, 1}, {0x94, 1}, {0xBB, 1}, {0x3001, 1}, {0x3002, 1}, {0x3005, 1}, {0x300D, 1}, {0x300F, 1}, + {0x3011, 1}, {0x3015, 1}, {0x3017, 1}, {0x3019, 1}, {0x301B, 1}, {0x301C, 3}, {0x301E, 1}, {0x302B, 3}, {0x3041, 2}, + {0x3043, 2}, {0x3045, 2}, {0x3047, 2}, {0x3049, 2}, {0x3063, 2}, {0x3083, 2}, {0x3085, 2}, {0x3087, 2}, {0x308E, 2}, + {0x309D, 3}, {0x309E, 3}, {0x30A1, 2}, {0x30A3, 2}, {0x30A5, 2}, {0x30A7, 2}, {0x30A9, 2}, {0x30C3, 2}, {0x30E3, 2}, + {0x30E5, 2}, {0x30E7, 2}, {0x30EE, 2}, {0x30F5, 2}, {0x30F6, 2}, {0x30FC, 2}, {0x30FD, 3}, {0x30FE, 3}, {0xFF01, 1}, + {0xFF05, 3}, {0xFF09, 1}, {0xFF0D, 1}, {0xFF3D, 1}, {0xFF5D, 1}, {0xFF61, 1}, {0xFF63, 1}, {0xFF64, 1}, {0xFF1F, 1}, +}}; -static const CCharacterIdentifier gCantEndChars[] = { +constexpr std::array sCantEndChars{{ {L'#', 2}, {L'$', 2}, {L'(', 1}, {L'@', 2}, {L'B', 4}, {L'C', 4}, {L'D', 4}, {L'E', 4}, {L'F', 4}, {L'G', 4}, {L'J', 4}, {L'K', 4}, {L'L', 4}, {L'M', 4}, {L'N', 4}, {L'P', 4}, {L'Q', 4}, {L'R', 4}, {L'S', 4}, {L'T', 4}, {L'V', 4}, {L'W', 4}, {L'X', 4}, {L'Y', 4}, {L'Z', 4}, {L'b', 4}, {L'c', 4}, @@ -33,21 +33,24 @@ static const CCharacterIdentifier gCantEndChars[] = { {0x20A5, 2}, {0x20A6, 2}, {0x20A7, 2}, {0x20A8, 2}, {0x20A9, 2}, {0x20AA, 2}, {0x20AB, 2}, {0x20AC, 2}, {0x300C, 1}, {0x300E, 1}, {0x3010, 1}, {0x3012, 2}, {0x3014, 1}, {0x3016, 1}, {0x3018, 1}, {0x301A, 1}, {0xFF03, 2}, {0xFF04, 2}, {0xFF20, 2}, {0xFF3C, 1}, {0xFF5C, 1}, {0xFFE0, 2}, {0xFFE1, 2}, {0xFFEF, 2}, -}; +}}; +} // Anonymous namespace int CWordBreakTables::GetBeginRank(wchar_t ch) { - auto search = rstl::binary_find(std::cbegin(gCantBeginChars), std::cend(gCantBeginChars), ch, - [](const CCharacterIdentifier& item) { return item.chr; }); - if (search == std::cend(gCantBeginChars)) + const auto search = rstl::binary_find(sCantBeginChars.cbegin(), sCantBeginChars.cend(), ch, + [](const CCharacterIdentifier& item) { return item.chr; }); + if (search == sCantBeginChars.cend()) { return 5; + } return search->rank; } int CWordBreakTables::GetEndRank(wchar_t ch) { - auto search = rstl::binary_find(std::cbegin(gCantEndChars), std::cend(gCantEndChars), ch, - [](const CCharacterIdentifier& item) { return item.chr; }); - if (search == std::cend(gCantEndChars)) + const auto search = rstl::binary_find(sCantEndChars.cbegin(), sCantEndChars.cend(), ch, + [](const CCharacterIdentifier& item) { return item.chr; }); + if (search == sCantEndChars.cend()) { return 5; + } return search->rank; } diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index 3e59e411e..3c1735d0d 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -633,7 +633,7 @@ static u32 DiscordItemPercent = 0xffffffff; static std::string DiscordState; void CMain::InitializeDiscord() { - DiscordStartTime = time(0); + DiscordStartTime = std::time(nullptr); DiscordEventHandlers handlers = {}; handlers.ready = HandleDiscordReady; handlers.disconnected = HandleDiscordDisconnected; diff --git a/Runtime/MP1/World/CAtomicAlpha.cpp b/Runtime/MP1/World/CAtomicAlpha.cpp index d3af41292..b01194626 100644 --- a/Runtime/MP1/World/CAtomicAlpha.cpp +++ b/Runtime/MP1/World/CAtomicAlpha.cpp @@ -50,7 +50,7 @@ void CAtomicAlpha::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta } } -void CAtomicAlpha::Render(const CStateManager& mgr) const { +void CAtomicAlpha::Render(CStateManager& mgr) { if (mgr.GetPlayerState()->GetActiveVisor(mgr) != CPlayerState::EPlayerVisor::XRay && x568_25_invisible) return; @@ -66,9 +66,10 @@ void CAtomicAlpha::Render(const CStateManager& mgr) const { x690_bombModel.Render(mgr, locatorXf, x90_actorLights.get(), flags); } } -void CAtomicAlpha::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { - if (mgr.GetPlayerState()->GetActiveVisor(mgr) != CPlayerState::EPlayerVisor::XRay && x568_25_invisible) +void CAtomicAlpha::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { + if (mgr.GetPlayerState()->GetActiveVisor(mgr) != CPlayerState::EPlayerVisor::XRay && x568_25_invisible) { return; + } CPatterned::AddToRenderer(frustum, mgr); } diff --git a/Runtime/MP1/World/CAtomicAlpha.hpp b/Runtime/MP1/World/CAtomicAlpha.hpp index 5f1a9e335..a0499941d 100644 --- a/Runtime/MP1/World/CAtomicAlpha.hpp +++ b/Runtime/MP1/World/CAtomicAlpha.hpp @@ -39,8 +39,8 @@ public: CAssetId, bool, bool); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; - void Render(const CStateManager&) const override; - void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const override; + void Render(CStateManager&) override; + void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override; void Think(float, CStateManager&) override; void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) override; diff --git a/Runtime/MP1/World/CBeetle.cpp b/Runtime/MP1/World/CBeetle.cpp index 94a31f8c6..85764d1e0 100644 --- a/Runtime/MP1/World/CBeetle.cpp +++ b/Runtime/MP1/World/CBeetle.cpp @@ -151,7 +151,7 @@ void CBeetle::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) { CPatterned::PreRender(mgr, frustum); } -void CBeetle::Render(const CStateManager& mgr) const { +void CBeetle::Render(CStateManager& mgr) { if (x3fc_flavor == EFlavorType::One && x400_25_alive) { zeus::CTransform tailXf = GetLctrTransform("Target_Tail"sv); if (x428_damageCooldownTimer >= 0.f && x42c_color.a() == 1.f) { diff --git a/Runtime/MP1/World/CBeetle.hpp b/Runtime/MP1/World/CBeetle.hpp index 55c146d9c..3e396b02e 100644 --- a/Runtime/MP1/World/CBeetle.hpp +++ b/Runtime/MP1/World/CBeetle.hpp @@ -67,7 +67,7 @@ public: void Think(float dt, CStateManager& mgr) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) override; void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override; - void Render(const CStateManager& mgr) const override; + void Render(CStateManager& mgr) override; const CDamageVulnerability* GetDamageVulnerability() const override; const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f& pos, const zeus::CVector3f& dir, diff --git a/Runtime/MP1/World/CBloodFlower.cpp b/Runtime/MP1/World/CBloodFlower.cpp index 7ffe40295..ce54a9ba9 100644 --- a/Runtime/MP1/World/CBloodFlower.cpp +++ b/Runtime/MP1/World/CBloodFlower.cpp @@ -143,7 +143,7 @@ void CBloodFlower::LaunchPollenProjectile(const zeus::CTransform& xf, CStateMana } } -void CBloodFlower::Render(const CStateManager& mgr) const { +void CBloodFlower::Render(CStateManager& mgr) { CPatterned::Render(mgr); x574_podEffect->Render(GetActorLights()); } diff --git a/Runtime/MP1/World/CBloodFlower.hpp b/Runtime/MP1/World/CBloodFlower.hpp index 3e42a9afc..8f8a519fb 100644 --- a/Runtime/MP1/World/CBloodFlower.hpp +++ b/Runtime/MP1/World/CBloodFlower.hpp @@ -54,7 +54,7 @@ public: void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void Think(float dt, CStateManager& mgr) override; void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) override; - void Render(const CStateManager& mgr) const override; + void Render(CStateManager& mgr) override; void Touch(CActor&, CStateManager&) override {} EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f& v1, const zeus::CVector3f& v2, const CWeaponMode& weaponMode, diff --git a/Runtime/MP1/World/CBouncyGrenade.cpp b/Runtime/MP1/World/CBouncyGrenade.cpp index 05fe40b0f..bd88c8c2e 100644 --- a/Runtime/MP1/World/CBouncyGrenade.cpp +++ b/Runtime/MP1/World/CBouncyGrenade.cpp @@ -36,7 +36,7 @@ CBouncyGrenade::CBouncyGrenade(TUniqueId uid, std::string_view name, const CEnti SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(filter.IncludeList(), filter.ExcludeList())); } -void CBouncyGrenade::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { +void CBouncyGrenade::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { CActor::AddToRenderer(frustum, mgr); if (!x2b4_24_exploded) { g_Renderer->AddParticleGen(*x2ac_elementGen4); @@ -98,7 +98,7 @@ void CBouncyGrenade::CollidedWith(TUniqueId id, const CCollisionInfoList& list, std::optional CBouncyGrenade::GetTouchBounds() const { return GetModelData()->GetBounds(GetTransform()); } -void CBouncyGrenade::Render(const CStateManager& mgr) const { +void CBouncyGrenade::Render(CStateManager& mgr) { if (!x2b4_24_exploded) { GetModelData()->Render(mgr, GetTransform(), nullptr, {0, 0, 3, zeus::skWhite}); } else if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay) { diff --git a/Runtime/MP1/World/CBouncyGrenade.hpp b/Runtime/MP1/World/CBouncyGrenade.hpp index 1ea0f9533..ab6cfa9d7 100644 --- a/Runtime/MP1/World/CBouncyGrenade.hpp +++ b/Runtime/MP1/World/CBouncyGrenade.hpp @@ -77,10 +77,10 @@ public: const SBouncyGrenadeData& data, float velocity, float explodePlayerDistance); void Accept(IVisitor& visitor) override { visitor.Visit(this); } - void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const override; + void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override; void CollidedWith(TUniqueId id, const CCollisionInfoList& list, CStateManager& mgr) override; [[nodiscard]] std::optional GetTouchBounds() const override; - void Render(const CStateManager& mgr) const override; + void Render(CStateManager& mgr) override; void Think(float dt, CStateManager& mgr) override; void Touch(CActor& act, CStateManager& mgr) override; diff --git a/Runtime/MP1/World/CChozoGhost.cpp b/Runtime/MP1/World/CChozoGhost.cpp index d267e7703..6018129a0 100644 --- a/Runtime/MP1/World/CChozoGhost.cpp +++ b/Runtime/MP1/World/CChozoGhost.cpp @@ -212,7 +212,7 @@ void CChozoGhost::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) { *GetBodyController()); } -void CChozoGhost::Render(const CStateManager& mgr) const { +void CChozoGhost::Render(CStateManager& mgr) { if (x6c8_spaceWarpTime > 0.f) mgr.DrawSpaceWarp(x6cc_spaceWarpPosition, std::sin((M_PIF * x6c8_spaceWarpTime) / x56c_fadeOutDelay)); diff --git a/Runtime/MP1/World/CChozoGhost.hpp b/Runtime/MP1/World/CChozoGhost.hpp index 82fb3f002..9252fac8b 100644 --- a/Runtime/MP1/World/CChozoGhost.hpp +++ b/Runtime/MP1/World/CChozoGhost.hpp @@ -109,7 +109,7 @@ public: void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override; void Think(float dt, CStateManager&) override; void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override; - void Render(const CStateManager& mgr) const override; + void Render(CStateManager& mgr) override; void Touch(CActor& act, CStateManager& mgr) override; EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f& pos, const zeus::CVector3f& dir, const CWeaponMode& mode, diff --git a/Runtime/MP1/World/CFlaahgra.cpp b/Runtime/MP1/World/CFlaahgra.cpp index 2261d7e6b..bc707b59c 100644 --- a/Runtime/MP1/World/CFlaahgra.cpp +++ b/Runtime/MP1/World/CFlaahgra.cpp @@ -56,11 +56,11 @@ CFlaahgraRenderer::CFlaahgraRenderer(TUniqueId uid, TUniqueId owner, std::string CActorParameters::None(), kInvalidUniqueId) , xe8_owner(owner) {} -void CFlaahgraRenderer::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { - +void CFlaahgraRenderer::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { if (const CActor* act = static_cast(mgr.GetObjectById(xe8_owner))) { - if (act->HasModelData() && (act->GetModelData()->HasAnimData() || act->GetModelData()->HasNormalModel())) + if (act->HasModelData() && (act->GetModelData()->HasAnimData() || act->GetModelData()->HasNormalModel())) { act->GetModelData()->RenderParticles(frustum); + } } } void CFlaahgraRenderer::Accept(IVisitor& visitor) { visitor.Visit(this); } @@ -254,14 +254,16 @@ void CFlaahgra::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateM CPatterned::AcceptScriptMsg(msg, uid, mgr); } -void CFlaahgra::AddToRenderer(const zeus::CFrustum& frustum, const urde::CStateManager& mgr) const { - if ((!GetModelData()->HasAnimData() && !GetModelData()->HasNormalModel()) || xe4_30_outOfFrustum) +void CFlaahgra::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { + if ((!GetModelData()->HasAnimData() && !GetModelData()->HasNormalModel()) || xe4_30_outOfFrustum) { return; + } - if (CanRenderUnsorted(mgr)) + if (CanRenderUnsorted(mgr)) { Render(mgr); - else + } else { EnsureRendered(mgr); + } } void CFlaahgra::Death(CStateManager& mgr, const zeus::CVector3f& dir, EScriptObjectState state) { @@ -1270,7 +1272,7 @@ void CFlaahgraPlants::Think(float dt, CStateManager& mgr) { mgr.FreeScriptObject(GetUniqueId()); } -void CFlaahgraPlants::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { +void CFlaahgraPlants::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { g_Renderer->AddParticleGen(*xe8_elementGen.get()); CActor::AddToRenderer(frustum, mgr); } diff --git a/Runtime/MP1/World/CFlaahgra.hpp b/Runtime/MP1/World/CFlaahgra.hpp index 46a01e1f1..b8f0e32d0 100644 --- a/Runtime/MP1/World/CFlaahgra.hpp +++ b/Runtime/MP1/World/CFlaahgra.hpp @@ -59,7 +59,7 @@ class CFlaahgraRenderer : public CActor { public: CFlaahgraRenderer(TUniqueId, TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&); - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; void Accept(IVisitor&) override; std::optional GetTouchBounds() const override { return {}; } }; @@ -80,7 +80,7 @@ public: void Accept(IVisitor&) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void Think(float, CStateManager&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; std::optional GetTouchBounds() const override { return x110_aabox; } void Touch(CActor&, CStateManager&) override; }; @@ -200,7 +200,7 @@ public: void Think(float, CStateManager&) override; void PreThink(float, CStateManager&) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; bool CanRenderUnsorted(const CStateManager&) const override { return true; } zeus::CVector3f GetAimPosition(const CStateManager&, float) const override { return x820_; } void Death(CStateManager&, const zeus::CVector3f&, EScriptObjectState) override; diff --git a/Runtime/MP1/World/CFlaahgraTentacle.cpp b/Runtime/MP1/World/CFlaahgraTentacle.cpp index fcd97f228..7004b05f5 100644 --- a/Runtime/MP1/World/CFlaahgraTentacle.cpp +++ b/Runtime/MP1/World/CFlaahgraTentacle.cpp @@ -1,5 +1,7 @@ #include "Runtime/MP1/World/CFlaahgraTentacle.hpp" +#include + #include "Runtime/CStateManager.hpp" #include "Runtime/Collision/CCollisionActor.hpp" #include "Runtime/World/CPlayer.hpp" @@ -8,6 +10,15 @@ #include "TCastTo.hpp" // Generated file, do not modify include path namespace urde::MP1 { +namespace { +constexpr std::string_view skpTentacleTip = "Arm_12"sv; +constexpr std::array skJointList{{ + {"Arm_8", 2.f}, + {"Arm_10", 1.2f}, + {"Arm_12", 1.2f}, +}}; +} // Anonymous namespace + CFlaahgraTentacle::CFlaahgraTentacle(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo, const CActorParameters& actParms) @@ -28,13 +39,13 @@ void CFlaahgraTentacle::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, } case EScriptObjectMessage::Deleted: { x56c_collisionManager->Destroy(mgr); - if (TCastToPtr trigger = mgr.ObjectById(x58c_triggerId)) { + if (const TCastToPtr trigger = mgr.ObjectById(x58c_triggerId)) { trigger->SetForceVector(x580_forceVector); } break; } case EScriptObjectMessage::Touched: { - if (TCastToConstPtr colAct = mgr.GetObjectById(uid)) { + if (const TCastToConstPtr colAct = mgr.GetObjectById(uid)) { if (colAct->GetLastTouchedObject() == mgr.GetPlayer().GetUniqueId() && x420_curDamageRemTime <= 0.f) { mgr.ApplyDamage(GetUniqueId(), mgr.GetPlayer().GetUniqueId(), GetUniqueId(), GetContactDamage(), CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {}); @@ -71,24 +82,27 @@ void CFlaahgraTentacle::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, } void CFlaahgraTentacle::Think(float dt, CStateManager& mgr) { - if (!GetActive()) + if (!GetActive()) { return; + } CPatterned::Think(dt, mgr); x56c_collisionManager->Update(dt, mgr, CCollisionActorManager::EUpdateOptions::ObjectSpace); - if (x574_ > 0.f) + if (x574_ > 0.f) { x574_ -= dt; + } - if (x578_ > 0.f) + if (x578_ > 0.f) { x578_ -= dt; + } } -void CFlaahgraTentacle::AddSphereCollisionList(const SSphereJointInfo* sphereJoints, s32 jointCount, +void CFlaahgraTentacle::AddSphereCollisionList(const SSphereJointInfo* sphereJoints, size_t jointCount, std::vector& outJoints) { const CAnimData* animData = GetModelData()->GetAnimationData(); - for (s32 i = 0; i < jointCount; ++i) { + for (size_t i = 0; i < jointCount; ++i) { const SSphereJointInfo& sphereJoint = sphereJoints[i]; const CSegId segId = animData->GetLocatorSegId(sphereJoint.name); @@ -100,17 +114,15 @@ void CFlaahgraTentacle::AddSphereCollisionList(const SSphereJointInfo* sphereJoi } } -const SSphereJointInfo CFlaahgraTentacle::skJointList[3] = {{"Arm_8", 2.f}, {"Arm_10", 1.2f}, {"Arm_12", 1.2f}}; - void CFlaahgraTentacle::SetupCollisionManager(CStateManager& mgr) { std::vector jointList; - AddSphereCollisionList(skJointList, 3, jointList); + AddSphereCollisionList(skJointList.data(), skJointList.size(), jointList); x56c_collisionManager = std::make_unique(mgr, GetUniqueId(), GetAreaIdAlways(), jointList, true); for (u32 i = 0; i < x56c_collisionManager->GetNumCollisionActors(); ++i) { const CJointCollisionDescription& desc = x56c_collisionManager->GetCollisionDescFromIndex(i); - if (TCastToPtr colAct = mgr.ObjectById(desc.GetCollisionActorId())) { + if (const TCastToPtr colAct = mgr.ObjectById(desc.GetCollisionActorId())) { colAct->SetMaterialFilter(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Player}, {EMaterialTypes::Character, EMaterialTypes::CollisionActor, @@ -119,8 +131,9 @@ void CFlaahgraTentacle::SetupCollisionManager(CStateManager& mgr) { colAct->AddMaterial(EMaterialTypes::ScanPassthrough); colAct->SetDamageVulnerability(*GetDamageVulnerability()); - if (x57c_tentacleTipAct == kInvalidUniqueId && desc.GetName() == skpTentacleTip) + if (x57c_tentacleTipAct == kInvalidUniqueId && desc.GetName() == skpTentacleTip) { x57c_tentacleTipAct = desc.GetCollisionActorId(); + } } } @@ -129,35 +142,38 @@ void CFlaahgraTentacle::SetupCollisionManager(CStateManager& mgr) { } zeus::CVector3f CFlaahgraTentacle::GetAimPosition(const CStateManager& mgr, float dt) const { - if (TCastToConstPtr colAct = mgr.GetObjectById(x57c_tentacleTipAct)) + if (const TCastToConstPtr colAct = mgr.GetObjectById(x57c_tentacleTipAct)) { return colAct->GetTranslation(); + } return CPatterned::GetAimPosition(mgr, dt); } void CFlaahgraTentacle::ExtractTentacle(CStateManager& mgr) { - if (!Inside(mgr, 0.f)) + if (!Inside(mgr, 0.f)) { return; + } x58e_24_ = true; - if (TCastToPtr trigger = mgr.ObjectById(x58c_triggerId)) { + if (const TCastToPtr trigger = mgr.ObjectById(x58c_triggerId)) { trigger->SetForceVector(x580_forceVector); } } void CFlaahgraTentacle::RetractTentacle(CStateManager& mgr) { x450_bodyController->SetLocomotionType(pas::ELocomotionType::Crouch); - if (TCastToPtr trigger = mgr.ObjectById(x58c_triggerId)) { + if (const TCastToPtr trigger = mgr.ObjectById(x58c_triggerId)) { trigger->SetForceVector({}); } } void CFlaahgraTentacle::SaveBombSlotInfo(CStateManager& mgr) { for (const SConnection& conn : GetConnectionList()) { - if (conn.x0_state != EScriptObjectState::Modify || conn.x4_msg != EScriptObjectMessage::ToggleActive) + if (conn.x0_state != EScriptObjectState::Modify || conn.x4_msg != EScriptObjectMessage::ToggleActive) { continue; + } - TUniqueId uid = mgr.GetIdForScript(conn.x8_objId); - if (TCastToConstPtr trigger = mgr.GetObjectById(uid)) { + const TUniqueId uid = mgr.GetIdForScript(conn.x8_objId); + if (const TCastToConstPtr trigger = mgr.GetObjectById(uid)) { x58c_triggerId = uid; x580_forceVector = trigger->GetForceVector(); return; @@ -166,14 +182,16 @@ void CFlaahgraTentacle::SaveBombSlotInfo(CStateManager& mgr) { } bool CFlaahgraTentacle::ShouldAttack(CStateManager& mgr, float) { - if (x578_ > 0.f) - return true; + if (x578_ > 0.f) { + return true; + } - if (x574_ > 0.f || mgr.GetPlayer().IsInWaterMovement()) + if (x574_ > 0.f || mgr.GetPlayer().IsInWaterMovement()) { return false; + } - if (TCastToConstPtr colAct = mgr.GetObjectById(x57c_tentacleTipAct)) { - float mag = (colAct->GetTranslation().toVec2f() - mgr.GetPlayer().GetTranslation().toVec2f()).magSquared(); + if (const TCastToConstPtr colAct = mgr.GetObjectById(x57c_tentacleTipAct)) { + const float mag = (colAct->GetTranslation().toVec2f() - mgr.GetPlayer().GetTranslation().toVec2f()).magSquared(); return mag >= (x2fc_minAttackRange * x2fc_minAttackRange) && mag <= (x300_maxAttackRange * x300_maxAttackRange); } @@ -185,11 +203,12 @@ void CFlaahgraTentacle::Attack(CStateManager& mgr, EStateMsg msg, float) { x568_ = 0; } else if (msg == EStateMsg::Update) { if (x568_ == 0) { - if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::MeleeAttack) + if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::MeleeAttack) { x568_ = 2; - else + } else { x450_bodyController->GetCommandMgr().DeliverCmd( CBCMeleeAttackCmd((x578_ > 0.f ? pas::ESeverity::Zero : pas::ESeverity::One), {})); + } } else if (x568_ == 2 && x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::MeleeAttack) { x568_ = 3; @@ -202,15 +221,18 @@ void CFlaahgraTentacle::Attack(CStateManager& mgr, EStateMsg msg, float) { } void CFlaahgraTentacle::Retreat(CStateManager& mgr, EStateMsg msg, float) { if (msg == EStateMsg::Update) { - if (!x58e_24_) + if (!x58e_24_) { return; + } - if (x330_stateMachineState.GetTime() <= 1.f) + if (x330_stateMachineState.GetTime() <= 1.f) { return; + } - if (TCastToPtr trigger = mgr.ObjectById(x58c_triggerId)) { - if (trigger->IsPlayerTriggerProc()) + if (const TCastToConstPtr trigger = mgr.ObjectById(x58c_triggerId)) { + if (trigger->IsPlayerTriggerProc()) { x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed); + } } } else if (msg == EStateMsg::Deactivate) { x58e_24_ = false; @@ -220,16 +242,18 @@ void CFlaahgraTentacle::InActive(CStateManager& mgr, EStateMsg msg, float arg) { if (msg == EStateMsg::Activate) { x570_ = 0.f; } else if (msg == EStateMsg::Update) { - if (Inside(mgr, 0.f)) + if (Inside(mgr, 0.f)) { return; + } - if (TCastToPtr trigger = mgr.ObjectById(x58c_triggerId)) { + if (const TCastToConstPtr trigger = mgr.ObjectById(x58c_triggerId)) { if (trigger->IsPlayerTriggerProc()) { if (x570_ > 1.f) { RetractTentacle(mgr); ExtractTentacle(mgr); - } else + } else { x570_ += arg; + } } } } diff --git a/Runtime/MP1/World/CFlaahgraTentacle.hpp b/Runtime/MP1/World/CFlaahgraTentacle.hpp index 0308120b5..5c55392aa 100644 --- a/Runtime/MP1/World/CFlaahgraTentacle.hpp +++ b/Runtime/MP1/World/CFlaahgraTentacle.hpp @@ -11,8 +11,6 @@ namespace urde::MP1 { class CFlaahgraTentacle : public CPatterned { - static const SSphereJointInfo skJointList[3]; - static constexpr std::string_view skpTentacleTip = "Arm_12"sv; s32 x568_ = -1; std::unique_ptr x56c_collisionManager; float x570_ = 0.f; @@ -23,7 +21,8 @@ class CFlaahgraTentacle : public CPatterned { TUniqueId x58c_triggerId = kInvalidUniqueId; bool x58e_24_ : 1; - void AddSphereCollisionList(const SSphereJointInfo*, s32, std::vector&); + void AddSphereCollisionList(const SSphereJointInfo* sphereJoints, size_t jointCount, + std::vector& outJoints); void SetupCollisionManager(CStateManager&); void ExtractTentacle(CStateManager&); void RetractTentacle(CStateManager&); diff --git a/Runtime/MP1/World/CFlickerBat.cpp b/Runtime/MP1/World/CFlickerBat.cpp index 1ef1a2f24..6fc2c5696 100644 --- a/Runtime/MP1/World/CFlickerBat.cpp +++ b/Runtime/MP1/World/CFlickerBat.cpp @@ -96,7 +96,7 @@ void CFlickerBat::Think(float dt, CStateManager& mgr) { CPatterned::Think(dt, mgr); } -void CFlickerBat::Render(const CStateManager& mgr) const { +void CFlickerBat::Render(CStateManager& mgr) { if (!x580_24_wasInXray && x580_26_inLOS && (GetFlickerBatState() == EFlickerBatState::FadeIn || GetFlickerBatState() == EFlickerBatState::FadeOut)) { float strength = 0.f; diff --git a/Runtime/MP1/World/CFlickerBat.hpp b/Runtime/MP1/World/CFlickerBat.hpp index eb6d864a3..729bb9835 100644 --- a/Runtime/MP1/World/CFlickerBat.hpp +++ b/Runtime/MP1/World/CFlickerBat.hpp @@ -31,7 +31,7 @@ public: void Accept(IVisitor&) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void Think(float, CStateManager&) override; - void Render(const CStateManager&) const override; + void Render(CStateManager&) override; void Touch(CActor&, CStateManager&) override; void DoUserAnimEvent(CStateManager&, const CInt32POINode&, EUserEventType, float dt) override; void Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state) override; diff --git a/Runtime/MP1/World/CFlyingPirate.cpp b/Runtime/MP1/World/CFlyingPirate.cpp index ba5aa6359..6a561f026 100644 --- a/Runtime/MP1/World/CFlyingPirate.cpp +++ b/Runtime/MP1/World/CFlyingPirate.cpp @@ -463,7 +463,7 @@ void CFlyingPirate::RemoveFromTeam(CStateManager& mgr) { } } -void CFlyingPirate::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { +void CFlyingPirate::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { for (const auto& gen : x684_particleGens) { if (frustum.aabbFrustumTest(GetBoundingBox())) { g_Renderer->AddParticleGen(*gen); diff --git a/Runtime/MP1/World/CFlyingPirate.hpp b/Runtime/MP1/World/CFlyingPirate.hpp index bfd0d66e1..f705b1abc 100644 --- a/Runtime/MP1/World/CFlyingPirate.hpp +++ b/Runtime/MP1/World/CFlyingPirate.hpp @@ -84,7 +84,7 @@ public: void Accept(IVisitor& visitor) override { visitor.Visit(this); } void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override; - void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const override; + void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override; bool AnimOver(CStateManager& mgr, float arg) override; void CalculateRenderBounds() override; void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) override; diff --git a/Runtime/MP1/World/CGrenadeLauncher.cpp b/Runtime/MP1/World/CGrenadeLauncher.cpp index b88d9e46e..703a5c5ce 100644 --- a/Runtime/MP1/World/CGrenadeLauncher.cpp +++ b/Runtime/MP1/World/CGrenadeLauncher.cpp @@ -117,7 +117,7 @@ void CGrenadeLauncher::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, } } -void CGrenadeLauncher::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { +void CGrenadeLauncher::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { CActor::AddToRenderer(frustum, mgr); } @@ -137,7 +137,7 @@ void CGrenadeLauncher::PreRender(CStateManager& mgr, const zeus::CFrustum& frust CActor::PreRender(mgr, frustum); } -void CGrenadeLauncher::Render(const CStateManager& mgr) const { +void CGrenadeLauncher::Render(CStateManager& mgr) { if (x3fd_visible) { CPhysicsActor::Render(mgr); } diff --git a/Runtime/MP1/World/CGrenadeLauncher.hpp b/Runtime/MP1/World/CGrenadeLauncher.hpp index 7a047b5b4..2993176fd 100644 --- a/Runtime/MP1/World/CGrenadeLauncher.hpp +++ b/Runtime/MP1/World/CGrenadeLauncher.hpp @@ -98,13 +98,13 @@ public: void Accept(IVisitor& visitor) override { visitor.Visit(this); } void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override; - void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const override; + void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override; [[nodiscard]] const CCollisionPrimitive* GetCollisionPrimitive() const override { return &x328_cSphere; } [[nodiscard]] const CDamageVulnerability* GetDamageVulnerability() const override { return &x264_vulnerability; } [[nodiscard]] std::optional GetTouchBounds() const override; CHealthInfo* HealthInfo(CStateManager& mgr) override { return &x25c_healthInfo; } void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override; - void Render(const CStateManager& mgr) const override; + void Render(CStateManager& mgr) override; void Think(float dt, CStateManager& mgr) override; void Touch(CActor& act, CStateManager& mgr) override; diff --git a/Runtime/MP1/World/CMetroidBeta.cpp b/Runtime/MP1/World/CMetroidBeta.cpp index 5405520de..fac634659 100644 --- a/Runtime/MP1/World/CMetroidBeta.cpp +++ b/Runtime/MP1/World/CMetroidBeta.cpp @@ -170,70 +170,106 @@ void CMetroidBeta::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta break; } } -void CMetroidBeta::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { + +void CMetroidBeta::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { CPatterned::AddToRenderer(frustum, mgr); } -void CMetroidBeta::Render(const CStateManager& mgr) const { CPatterned::Render(mgr); } + +void CMetroidBeta::Render(CStateManager& mgr) { CPatterned::Render(mgr); } + const CDamageVulnerability* CMetroidBeta::GetDamageVulnerability() const { return CAi::GetDamageVulnerability(); } + const CDamageVulnerability* CMetroidBeta::GetDamageVulnerability(const zeus::CVector3f& vec1, const zeus::CVector3f& vec2, const CDamageInfo& dInfo) const { return CActor::GetDamageVulnerability(vec1, vec2, dInfo); } + void CMetroidBeta::Touch(CActor& act, CStateManager& mgr) { CPatterned::Touch(act, mgr); } + zeus::CVector3f CMetroidBeta::GetAimPosition(const CStateManager& mgr, float dt) const { return CPatterned::GetAimPosition(mgr, dt); } + void CMetroidBeta::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType eType, float dt) { CPatterned::DoUserAnimEvent(mgr, node, eType, dt); } + const CCollisionPrimitive* CMetroidBeta::GetCollisionPrimitive() const { return CPhysicsActor::GetCollisionPrimitive(); } + void CMetroidBeta::CollidedWith(TUniqueId collidee, const CCollisionInfoList& info, CStateManager& mgr) { CPatterned::CollidedWith(collidee, info, mgr); } + zeus::CVector3f CMetroidBeta::GetOrigin(const CStateManager& mgr, const CTeamAiRole& role, const zeus::CVector3f& aimPos) const { return CAi::GetOrigin(mgr, role, aimPos); } + void CMetroidBeta::Patrol(CStateManager& mgr, EStateMsg msg, float arg) { CPatterned::Patrol(mgr, msg, arg); } + void CMetroidBeta::PathFind(CStateManager& mgr, EStateMsg msg, float arg) { CPatterned::PathFind(mgr, msg, arg); } + void CMetroidBeta::SelectTarget(CStateManager& mgr, EStateMsg msg, float arg) { CAi::SelectTarget(mgr, msg, arg); } + void CMetroidBeta::TargetPatrol(CStateManager& mgr, EStateMsg msg, float arg) { CPatterned::TargetPatrol(mgr, msg, arg); } + void CMetroidBeta::Generate(CStateManager& mgr, EStateMsg msg, float arg) { CAi::Generate(mgr, msg, arg); } + void CMetroidBeta::Attack(CStateManager& mgr, EStateMsg msg, float arg) { CAi::Attack(mgr, msg, arg); } + void CMetroidBeta::TurnAround(CStateManager& mgr, EStateMsg msg, float arg) { CAi::TurnAround(mgr, msg, arg); } + void CMetroidBeta::TelegraphAttack(CStateManager& mgr, EStateMsg msg, float arg) { CAi::TelegraphAttack(mgr, msg, arg); } + void CMetroidBeta::WallHang(CStateManager& mgr, EStateMsg msg, float arg) { CAi::WallHang(mgr, msg, arg); } + void CMetroidBeta::SpecialAttack(CStateManager& mgr, EStateMsg msg, float arg) { CAi::SpecialAttack(mgr, msg, arg); } + bool CMetroidBeta::InAttackPosition(CStateManager& mgr, float arg) { return CAi::InAttackPosition(mgr, arg); } + bool CMetroidBeta::Attacked(CStateManager& mgr, float arg) { return CPatterned::Attacked(mgr, arg); } + bool CMetroidBeta::PathShagged(CStateManager& mgr, float arg) { return CPatterned::PathShagged(mgr, arg); } + bool CMetroidBeta::InDetectionRange(CStateManager& mgr, float arg) { return CPatterned::InDetectionRange(mgr, arg); } + bool CMetroidBeta::AnimOver(CStateManager& mgr, float arg) { return CPatterned::AnimOver(mgr, arg); } + bool CMetroidBeta::ShouldAttack(CStateManager& mgr, float arg) { return CAi::ShouldAttack(mgr, arg); } + bool CMetroidBeta::InPosition(CStateManager& mgr, float arg) { return CPatterned::InPosition(mgr, arg); } + bool CMetroidBeta::ShouldTurn(CStateManager& mgr, float arg) { return CAi::ShouldTurn(mgr, arg); } + bool CMetroidBeta::AttackOver(CStateManager& mgr, float arg) { return CAi::AttackOver(mgr, arg); } + bool CMetroidBeta::ShotAt(CStateManager& mgr, float arg) { return CAi::ShotAt(mgr, arg); } + bool CMetroidBeta::ShouldWallHang(CStateManager& mgr, float arg) { return CAi::ShouldWallHang(mgr, arg); } + bool CMetroidBeta::StartAttack(CStateManager& mgr, float arg) { return CAi::StartAttack(mgr, arg); } + bool CMetroidBeta::BreakAttack(CStateManager& mgr, float arg) { return CAi::BreakAttack(mgr, arg); } + bool CMetroidBeta::ShouldSpecialAttack(CStateManager& mgr, float arg) { return CAi::ShouldSpecialAttack(mgr, arg); } void CMetroidBeta::RenderHitGunEffect() const {} void CMetroidBeta::RenderHitBallEffect() const {} + static SSphereJointInfo skPelvisInfo[1] { {"Pelvis", 1.5f}, }; + void CMetroidBeta::CreateCollisionActorManager(CStateManager& mgr) { std::vector joints; AddSphereJoints(skPelvisInfo, 1, joints); @@ -272,6 +308,7 @@ void CMetroidBeta::AddSphereJoints(SSphereJointInfo* sphereJoints, s32 count, joints.push_back(CJointCollisionDescription::SphereCollision(id, sphereJoint.radius, sphereJoint.name, 1000.0f)); } } + void CMetroidBeta::SetCollisionActorHealthAndVulnerability(CStateManager& mgr) { CHealthInfo* hInfo = HealthInfo(mgr); if (TCastToPtr colAct = mgr.ObjectById(x790_)) { @@ -279,6 +316,7 @@ void CMetroidBeta::SetCollisionActorHealthAndVulnerability(CStateManager& mgr) { colAct->SetDamageVulnerability(*GetDamageVulnerability()); } } + void CMetroidBeta::RemoveFromTeam(CStateManager& mgr) { if (x678_teamMgr == kInvalidUniqueId) return; @@ -288,6 +326,7 @@ void CMetroidBeta::RemoveFromTeam(CStateManager& mgr) { teamMgr->RemoveTeamAiRole(GetUniqueId()); } } + void CMetroidBeta::AddToTeam(CStateManager& mgr) { if (x678_teamMgr == kInvalidUniqueId) return; diff --git a/Runtime/MP1/World/CMetroidBeta.hpp b/Runtime/MP1/World/CMetroidBeta.hpp index 2b09987cc..5c421dcf6 100644 --- a/Runtime/MP1/World/CMetroidBeta.hpp +++ b/Runtime/MP1/World/CMetroidBeta.hpp @@ -102,8 +102,8 @@ public: void Think(float dt, CStateManager& mgr) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override; - void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const override; - void Render(const CStateManager& mgr) const override; + void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override; + void Render(CStateManager& mgr) override; const CDamageVulnerability* GetDamageVulnerability() const override; const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f& vec1, const zeus::CVector3f& vec2, const CDamageInfo& dInfo) const override; diff --git a/Runtime/MP1/World/CNewIntroBoss.cpp b/Runtime/MP1/World/CNewIntroBoss.cpp index d24dcd8ff..7678f004c 100644 --- a/Runtime/MP1/World/CNewIntroBoss.cpp +++ b/Runtime/MP1/World/CNewIntroBoss.cpp @@ -303,7 +303,7 @@ void CNewIntroBoss::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& nod } } -void CNewIntroBoss::AddToRenderer(const zeus::CFrustum&, const CStateManager& mgr) const { EnsureRendered(mgr); } +void CNewIntroBoss::AddToRenderer(const zeus::CFrustum&, CStateManager& mgr) { EnsureRendered(mgr); } float CNewIntroBoss::GetNextAttackTime(CStateManager& mgr) const { float attackTime = 2.f * mgr.GetActiveRandom()->Float() + 6.f; diff --git a/Runtime/MP1/World/CNewIntroBoss.hpp b/Runtime/MP1/World/CNewIntroBoss.hpp index 844d26f12..75c7c133a 100644 --- a/Runtime/MP1/World/CNewIntroBoss.hpp +++ b/Runtime/MP1/World/CNewIntroBoss.hpp @@ -61,7 +61,7 @@ public: void Accept(IVisitor& visitor) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager&) override; void Think(float dt, CStateManager& mgr) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; void OnScanStateChanged(EScanState, CStateManager&) override; CProjectileInfo* GetProjectileInfo() override { return &x5ac_projectileInfo; } zeus::CAABox GetSortingBounds(const CStateManager&) const override { diff --git a/Runtime/MP1/World/CParasite.cpp b/Runtime/MP1/World/CParasite.cpp index b62efb09c..07fb97d61 100644 --- a/Runtime/MP1/World/CParasite.cpp +++ b/Runtime/MP1/World/CParasite.cpp @@ -303,7 +303,7 @@ void CParasite::Think(float dt, CStateManager& mgr) { x742_27_landed = false; } -void CParasite::Render(const CStateManager& mgr) const { CWallWalker::Render(mgr); } +void CParasite::Render(CStateManager& mgr) { CWallWalker::Render(mgr); } const CDamageVulnerability* CParasite::GetDamageVulnerability() const { switch (x5d0_walkerType) { diff --git a/Runtime/MP1/World/CParasite.hpp b/Runtime/MP1/World/CParasite.hpp index 22059d0b7..1e673d124 100644 --- a/Runtime/MP1/World/CParasite.hpp +++ b/Runtime/MP1/World/CParasite.hpp @@ -117,7 +117,7 @@ public: void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void PreThink(float, CStateManager&) override; void Think(float dt, CStateManager& mgr) override; - void Render(const CStateManager&) const override; + void Render(CStateManager&) override; const CDamageVulnerability* GetDamageVulnerability() const override; CDamageInfo GetContactDamage() const override; void Touch(CActor& actor, CStateManager&) override; diff --git a/Runtime/MP1/World/CPuddleSpore.cpp b/Runtime/MP1/World/CPuddleSpore.cpp index 663dc07c1..9ac5a7951 100644 --- a/Runtime/MP1/World/CPuddleSpore.cpp +++ b/Runtime/MP1/World/CPuddleSpore.cpp @@ -134,7 +134,7 @@ void CPuddleSpore::Think(float dt, CStateManager& mgr) { CPatterned::Think(dt, mgr); } -void CPuddleSpore::Render(const CStateManager& mgr) const { +void CPuddleSpore::Render(CStateManager& mgr) { CPatterned::Render(mgr); if (x56c_ > 0.01f) { for (const auto& elemGen : x5dc_elemGens) diff --git a/Runtime/MP1/World/CPuddleSpore.hpp b/Runtime/MP1/World/CPuddleSpore.hpp index 7d22c671d..9d37a99bf 100644 --- a/Runtime/MP1/World/CPuddleSpore.hpp +++ b/Runtime/MP1/World/CPuddleSpore.hpp @@ -46,7 +46,7 @@ public: void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override; void PreThink(float, CStateManager&) override; void Think(float, CStateManager&) override; - void Render(const CStateManager&) const override; + void Render(CStateManager&) override; void Touch(CActor&, CStateManager&) override; void FluidFXThink(EFluidState, CScriptWater&, CStateManager&) override; void KnockBack(const zeus::CVector3f& dir, CStateManager& mgr, const CDamageInfo& dInfo, EKnockBackType type, diff --git a/Runtime/MP1/World/CRidley.cpp b/Runtime/MP1/World/CRidley.cpp index 2e462b89b..80dbe047e 100644 --- a/Runtime/MP1/World/CRidley.cpp +++ b/Runtime/MP1/World/CRidley.cpp @@ -669,7 +669,7 @@ void CRidley::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) { } } -void CRidley::Render(const CStateManager& mgr) const { +void CRidley::Render(CStateManager& mgr) { zeus::CColor multiplyColor = zeus::skBlack; if (xb24_ > 0.f) { multiplyColor = zeus::CColor::lerp(zeus::skWhite, x430_damageColor, xb24_ / 0.33f); @@ -697,7 +697,7 @@ void CRidley::Render(const CStateManager& mgr) const { CPatterned::Render(mgr); } -void CRidley::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { +void CRidley::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { CPatterned::AddToRenderer(frustum, mgr); if (xce0_ && frustum.aabbFrustumTest(*xce0_->GetBounds())) { g_Renderer->AddParticleGen(*xce0_); diff --git a/Runtime/MP1/World/CRidley.hpp b/Runtime/MP1/World/CRidley.hpp index 6460d7f6a..dc42688f7 100644 --- a/Runtime/MP1/World/CRidley.hpp +++ b/Runtime/MP1/World/CRidley.hpp @@ -206,8 +206,8 @@ public: void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override; void Think(float dt, CStateManager& mgr) override; void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override; - void Render(const CStateManager& mgr) const override; - void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const override; + void Render(CStateManager& mgr) override; + void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override; zeus::CAABox GetSortingBounds(const CStateManager&) const override { return GetBoundingBox(); } const CDamageVulnerability* GetDamageVulnerability() const override { return &CDamageVulnerability::ImmuneVulnerabilty(); diff --git a/Runtime/MP1/World/CSeedling.cpp b/Runtime/MP1/World/CSeedling.cpp index e22dd03a2..a8a98e5d9 100644 --- a/Runtime/MP1/World/CSeedling.cpp +++ b/Runtime/MP1/World/CSeedling.cpp @@ -107,7 +107,7 @@ void CSeedling::Think(float dt, CStateManager& mgr) { x71c_attackCoolOff -= dt; } -void CSeedling::Render(const CStateManager& mgr) const { +void CSeedling::Render(CStateManager& mgr) { if (x400_25_alive && x6bc_spikeData) { const size_t index = x722_24_renderOnlyClusterA ? 0 : size_t(x722_25_curNeedleCluster); CModelFlags flags; diff --git a/Runtime/MP1/World/CSeedling.hpp b/Runtime/MP1/World/CSeedling.hpp index 0996b20f2..fa07befbe 100644 --- a/Runtime/MP1/World/CSeedling.hpp +++ b/Runtime/MP1/World/CSeedling.hpp @@ -31,7 +31,7 @@ public: void Accept(IVisitor&) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void Think(float, CStateManager&) override; - void Render(const CStateManager&) const override; + void Render(CStateManager&) override; void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) override; CProjectileInfo* GetProjectileInfo() override { return &x6c0_projectileInfo; } std::optional GetTouchBounds() const override; diff --git a/Runtime/MP1/World/CShockWave.cpp b/Runtime/MP1/World/CShockWave.cpp index aa94fa878..344cf5ffa 100644 --- a/Runtime/MP1/World/CShockWave.cpp +++ b/Runtime/MP1/World/CShockWave.cpp @@ -53,7 +53,7 @@ void CShockWave::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CState mgr.SendScriptMsgAlways(x980_id2, uid, msg); } -void CShockWave::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { +void CShockWave::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { CActor::AddToRenderer(frustum, mgr); g_Renderer->AddParticleGen(*x110_elementGen); } @@ -65,7 +65,7 @@ std::optional CShockWave::GetTouchBounds() const { return zeus::CAABox({-x150_, -x150_, 0.f}, {x150_, x150_, 1.f}).getTransformedAABox(GetTransform()); } -void CShockWave::Render(const CStateManager& mgr) const { +void CShockWave::Render(CStateManager& mgr) { CActor::Render(mgr); x110_elementGen->Render(); } diff --git a/Runtime/MP1/World/CShockWave.hpp b/Runtime/MP1/World/CShockWave.hpp index 3d8d9f9c3..089fe3239 100644 --- a/Runtime/MP1/World/CShockWave.hpp +++ b/Runtime/MP1/World/CShockWave.hpp @@ -57,9 +57,9 @@ public: void Accept(IVisitor& visitor) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override; - void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const override; + void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override; [[nodiscard]] std::optional GetTouchBounds() const override; - void Render(const CStateManager& mgr) const override; + void Render(CStateManager& mgr) override; void Think(float dt, CStateManager& mgr) override; void Touch(CActor& actor, CStateManager& mgr) override; diff --git a/Runtime/MP1/World/CSpacePirate.cpp b/Runtime/MP1/World/CSpacePirate.cpp index 3e8d59d30..409a11e5b 100644 --- a/Runtime/MP1/World/CSpacePirate.cpp +++ b/Runtime/MP1/World/CSpacePirate.cpp @@ -1060,7 +1060,7 @@ void CSpacePirate::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) } } -void CSpacePirate::Render(const CStateManager& mgr) const { +void CSpacePirate::Render(CStateManager& mgr) { float time = x400_25_alive ? CGraphics::GetSecondsMod900() : 0.f; CTimeProvider prov(time); g_Renderer->SetGXRegister1Color(x8cc_trooperColor); diff --git a/Runtime/MP1/World/CSpacePirate.hpp b/Runtime/MP1/World/CSpacePirate.hpp index c05f31afc..0663fd803 100644 --- a/Runtime/MP1/World/CSpacePirate.hpp +++ b/Runtime/MP1/World/CSpacePirate.hpp @@ -245,7 +245,7 @@ public: void Think(float dt, CStateManager& mgr) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) override; void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override; - void Render(const CStateManager& mgr) const override; + void Render(CStateManager& mgr) override; void CalculateRenderBounds() override; void Touch(CActor& other, CStateManager& mgr) override; diff --git a/Runtime/MP1/World/CThardus.cpp b/Runtime/MP1/World/CThardus.cpp index 2f6472a6a..d0f8f6763 100644 --- a/Runtime/MP1/World/CThardus.cpp +++ b/Runtime/MP1/World/CThardus.cpp @@ -443,7 +443,7 @@ void CThardus::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) { xb4_drawFlags = CModelFlags(0, 0, 3, zeus::skWhite); } } -void CThardus::Render(const CStateManager& mgr) const { +void CThardus::Render(CStateManager& mgr) { CPatterned::Render(mgr); if (mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::Thermal && x7c4_ != 0) { RenderFlare(mgr, x7c0_); diff --git a/Runtime/MP1/World/CThardus.hpp b/Runtime/MP1/World/CThardus.hpp index 82aa78a85..1fdb108b3 100644 --- a/Runtime/MP1/World/CThardus.hpp +++ b/Runtime/MP1/World/CThardus.hpp @@ -177,7 +177,7 @@ public: void Think(float dt, CStateManager& mgr) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override; void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override; - void Render(const CStateManager& mgr) const override; + void Render(CStateManager& mgr) override; bool CanRenderUnsorted(const CStateManager&) const override { return false; } void Touch(CActor& act, CStateManager& mgr) override; zeus::CVector3f GetOrbitPosition(const CStateManager& mgr) const override; diff --git a/Runtime/MP1/World/CTryclops.cpp b/Runtime/MP1/World/CTryclops.cpp index 16c32f7f1..da9539c6b 100644 --- a/Runtime/MP1/World/CTryclops.cpp +++ b/Runtime/MP1/World/CTryclops.cpp @@ -496,7 +496,7 @@ void CTryclops::LaunchPlayer(CStateManager& mgr, const zeus::CTransform& xf, flo player.Stop(); zeus::CTransform tmpXf = (xf * x64c_); tmpXf.origin += zeus::CVector3f(0.f, 0.f, -0.5f); - player.Teleport(xf, mgr, false); + player.Teleport(tmpXf, mgr, false); player.ApplyImpulseWR(f1 * (player.GetMass() * xf.basis[1].normalized()), zeus::CAxisAngle()); player.SetMoveState(CPlayer::EPlayerMovementState::ApplyJump, mgr); player.AddMaterial(EMaterialTypes::Solid, mgr); diff --git a/Runtime/Particle/CDecal.cpp b/Runtime/Particle/CDecal.cpp index e51bc51b9..c18156852 100644 --- a/Runtime/Particle/CDecal.cpp +++ b/Runtime/Particle/CDecal.cpp @@ -164,7 +164,7 @@ void CDecal::RenderQuad(CQuadDecal& decal, const SQuadDescr& desc) const { } } -void CDecal::RenderMdl() const { +void CDecal::RenderMdl() { const CDecalDescription& desc = *x0_description; zeus::CColor color = zeus::skWhite; zeus::CVector3f dmop; @@ -179,7 +179,7 @@ void CDecal::RenderMdl() const { zeus::CTransform dmrtXf; if (dmrtIsConst) { - desc.x50_DMRT->GetValue(x58_frameIdx, const_cast(x60_rotation)); + desc.x50_DMRT->GetValue(x58_frameIdx, x60_rotation); dmrtXf = zeus::CTransform::RotateZ(zeus::degToRad(x60_rotation.z())); dmrtXf.rotateLocalY(zeus::degToRad(x60_rotation.y())); dmrtXf.rotateLocalX(zeus::degToRad(x60_rotation.x())); @@ -232,7 +232,7 @@ void CDecal::RenderMdl() const { } } -void CDecal::Render() const { +void CDecal::Render() { SCOPED_GRAPHICS_DEBUG_GROUP("CDecal::Render", zeus::skYellow); CGlobalRandom gr(sDecalRandom); if (x5c_29_modelInvalid && x5c_30_quad2Invalid && x5c_31_quad1Invalid) @@ -245,12 +245,12 @@ void CDecal::Render() const { if (desc.x0_Quads[0].x14_TEX && !x5c_31_quad1Invalid) { CParticleGlobals::instance()->SetParticleLifetime(x3c_decalQuads[0].x4_lifetime); CParticleGlobals::instance()->UpdateParticleLifetimeTweenValues(x58_frameIdx); - RenderQuad(const_cast(x3c_decalQuads[0]), desc.x0_Quads[0]); + RenderQuad(x3c_decalQuads[0], desc.x0_Quads[0]); } if (desc.x0_Quads[1].x14_TEX && !x5c_30_quad2Invalid) { CParticleGlobals::instance()->SetParticleLifetime(x3c_decalQuads[1].x4_lifetime); CParticleGlobals::instance()->UpdateParticleLifetimeTweenValues(x58_frameIdx); - RenderQuad(const_cast(x3c_decalQuads[1]), desc.x0_Quads[1]); + RenderQuad(x3c_decalQuads[1], desc.x0_Quads[1]); } if (desc.x38_DMDL && !x5c_29_modelInvalid) { CParticleGlobals::instance()->SetParticleLifetime(x54_modelLifetime); diff --git a/Runtime/Particle/CDecal.hpp b/Runtime/Particle/CDecal.hpp index 58c333d37..224658da1 100644 --- a/Runtime/Particle/CDecal.hpp +++ b/Runtime/Particle/CDecal.hpp @@ -55,8 +55,8 @@ class CDecal { public: CDecal(const TToken& desc, const zeus::CTransform& xf); void RenderQuad(CQuadDecal& decal, const SQuadDescr& desc) const; - void RenderMdl() const; - void Render() const; + void RenderMdl(); + void Render(); void Update(float dt); static void SetGlobalSeed(u16); diff --git a/Runtime/Weapon/CBomb.cpp b/Runtime/Weapon/CBomb.cpp index 4ae123bf3..71b00a877 100644 --- a/Runtime/Weapon/CBomb.cpp +++ b/Runtime/Weapon/CBomb.cpp @@ -114,7 +114,7 @@ void CBomb::Think(float dt, urde::CStateManager& mgr) { x184_particle2->SetGlobalTranslation(GetTranslation()); } -void CBomb::AddToRenderer(const zeus::CFrustum& frustum, const urde::CStateManager& mgr) const { +void CBomb::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { zeus::CVector3f origin = GetTranslation(); float ballRadius = mgr.GetPlayer().GetMorphBall()->GetBallRadius(); diff --git a/Runtime/Weapon/CBomb.hpp b/Runtime/Weapon/CBomb.hpp index bde620c07..eaaf2f313 100644 --- a/Runtime/Weapon/CBomb.hpp +++ b/Runtime/Weapon/CBomb.hpp @@ -33,8 +33,8 @@ public: void Accept(IVisitor&) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void Think(float, CStateManager&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; - void Render(const CStateManager&) const override {} + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; + void Render(CStateManager&) override {} void Touch(CActor&, CStateManager&) override; void Explode(const zeus::CVector3f&, CStateManager&); void UpdateLight(float, CStateManager&); diff --git a/Runtime/Weapon/CEnergyProjectile.cpp b/Runtime/Weapon/CEnergyProjectile.cpp index 64933d2a7..cfc6e12d0 100644 --- a/Runtime/Weapon/CEnergyProjectile.cpp +++ b/Runtime/Weapon/CEnergyProjectile.cpp @@ -185,7 +185,7 @@ void CEnergyProjectile::Think(float dt, CStateManager& mgr) { mgr.FreeScriptObject(GetUniqueId()); } -void CEnergyProjectile::Render(const CStateManager& mgr) const { +void CEnergyProjectile::Render(CStateManager& mgr) { SCOPED_GRAPHICS_DEBUG_GROUP(fmt::format(fmt("CEnergyProjectile::Render WPSC_{}"), x2cc_wpscId).c_str(), zeus::skOrange); CPlayerState::EPlayerVisor visor = mgr.GetPlayerState()->GetActiveVisor(mgr); @@ -217,7 +217,7 @@ void CEnergyProjectile::Render(const CStateManager& mgr) const { } } -void CEnergyProjectile::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { +void CEnergyProjectile::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { auto bounds = x170_projectile.GetBounds(); if (bounds && !frustum.aabbFrustumTest(*bounds)) return; @@ -225,8 +225,9 @@ void CEnergyProjectile::AddToRenderer(const zeus::CFrustum& frustum, const CStat CPlayerState::EPlayerVisor visor = mgr.GetPlayerState()->GetActiveVisor(mgr); if (visor != CPlayerState::EPlayerVisor::XRay && ((xe8_projectileAttribs & EProjectileAttrib::Ice) != EProjectileAttrib::Ice || - mgr.GetThermalDrawFlag() != EThermalDrawFlag::Hot)) + mgr.GetThermalDrawFlag() != EThermalDrawFlag::Hot)) { x170_projectile.AddToRenderer(); + } EnsureRendered(mgr); } diff --git a/Runtime/Weapon/CEnergyProjectile.hpp b/Runtime/Weapon/CEnergyProjectile.hpp index e8289db5d..6156e0e0f 100644 --- a/Runtime/Weapon/CEnergyProjectile.hpp +++ b/Runtime/Weapon/CEnergyProjectile.hpp @@ -39,8 +39,8 @@ public: void ResolveCollisionWithWorld(const CRayCastResult& res, CStateManager& mgr); void ResolveCollisionWithActor(const CRayCastResult& res, CActor& act, CStateManager& mgr); void Think(float dt, CStateManager& mgr); - void Render(const CStateManager& mgr) const; - void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const; + void Render(CStateManager& mgr); + void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr); void Touch(CActor& act, CStateManager& mgr); virtual bool Explode(const zeus::CVector3f& pos, const zeus::CVector3f& normal, EWeaponCollisionResponseTypes type, CStateManager& mgr, const CDamageVulnerability& dVuln, TUniqueId hitActor); diff --git a/Runtime/Weapon/CFlameThrower.cpp b/Runtime/Weapon/CFlameThrower.cpp index bc661fa16..154c80e31 100644 --- a/Runtime/Weapon/CFlameThrower.cpp +++ b/Runtime/Weapon/CFlameThrower.cpp @@ -90,12 +90,12 @@ void CFlameThrower::CreateFlameParticles(CStateManager& mgr) { CreateProjectileLight("FlameThrower_Light"sv, x348_flameGen->GetLight(), mgr); } -void CFlameThrower::AddToRenderer(const zeus::CFrustum&, const CStateManager& mgr) const { +void CFlameThrower::AddToRenderer(const zeus::CFrustum&, CStateManager& mgr) { g_Renderer->AddParticleGen(*x348_flameGen); EnsureRendered(mgr, x2e8_flameXf.origin, GetRenderBounds()); } -void CFlameThrower::Render(const CStateManager&) const {} +void CFlameThrower::Render(CStateManager&) {} std::optional CFlameThrower::GetTouchBounds() const { return std::nullopt; } diff --git a/Runtime/Weapon/CFlameThrower.hpp b/Runtime/Weapon/CFlameThrower.hpp index 4a9890aca..423f8e7d4 100644 --- a/Runtime/Weapon/CFlameThrower.hpp +++ b/Runtime/Weapon/CFlameThrower.hpp @@ -56,8 +56,8 @@ public: void Accept(IVisitor& visitor) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void Think(float, CStateManager&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; - void Render(const CStateManager& mgr) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; + void Render(CStateManager& mgr) override; std::optional GetTouchBounds() const override; void Touch(CActor& actor, CStateManager& mgr) override; void SetTransform(const zeus::CTransform& xf, float); diff --git a/Runtime/Weapon/CGunWeapon.cpp b/Runtime/Weapon/CGunWeapon.cpp index eaf212c6b..5ff1215c1 100644 --- a/Runtime/Weapon/CGunWeapon.cpp +++ b/Runtime/Weapon/CGunWeapon.cpp @@ -254,7 +254,7 @@ void CGunWeapon::PointGenerator(void* ctx, const std::vectorGetScale())); // CGraphics::DisableAllLights(); // g_Renderer->SetAmbientColor(zeus::skWhite); - CSkinnedModel& model = const_cast(*x60_holoModelData->GetAnimationData()->GetModelData()); + CSkinnedModel& model = *x60_holoModelData->GetAnimationData()->GetModelData(); model.GetModelInst()->ActivateLights({CLight::BuildLocalAmbient({}, zeus::skWhite)}); - const_cast(this)->x10_solidModelData->GetAnimationData()->Render(model, flags, std::nullopt, nullptr); + x10_solidModelData->GetAnimationData()->Render(model, flags, std::nullopt, nullptr); // g_Renderer->SetAmbientColor(zeus::skWhite); // CGraphics::DisableAllLights(); } diff --git a/Runtime/Weapon/CGunWeapon.hpp b/Runtime/Weapon/CGunWeapon.hpp index 879548feb..30328d686 100644 --- a/Runtime/Weapon/CGunWeapon.hpp +++ b/Runtime/Weapon/CGunWeapon.hpp @@ -133,13 +133,13 @@ public: void Touch(const CStateManager& mgr); void TouchHolo(const CStateManager& mgr); virtual void Draw(bool drawSuitArm, const CStateManager& mgr, const zeus::CTransform& xf, const CModelFlags& flags, - const CActorLights* lights) const; + const CActorLights* lights); virtual void DrawMuzzleFx(const CStateManager& mgr) const; virtual void Update(float dt, CStateManager& mgr); virtual void Load(CStateManager& mgr, bool subtypeBasePose); virtual void Unload(CStateManager& mgr); virtual bool IsLoaded() const; - void DrawHologram(const CStateManager& mgr, const zeus::CTransform& xf, const CModelFlags& flags) const; + void DrawHologram(const CStateManager& mgr, const zeus::CTransform& xf, const CModelFlags& flags); void UpdateMuzzleFx(float dt, const zeus::CVector3f& scale, const zeus::CVector3f& pos, bool emitting); const CVelocityInfo& GetVelocityInfo() const { return x1d0_velInfo; } void SetRainSplashGenerator(CRainSplashGenerator* g) { x1bc_rainSplashGenerator = g; } diff --git a/Runtime/Weapon/CPhazonBeam.cpp b/Runtime/Weapon/CPhazonBeam.cpp index a91d00e39..3017a7fa1 100644 --- a/Runtime/Weapon/CPhazonBeam.cpp +++ b/Runtime/Weapon/CPhazonBeam.cpp @@ -167,18 +167,18 @@ void CPhazonBeam::Unload(CStateManager& mgr) { bool CPhazonBeam::IsLoaded() const { return CGunWeapon::IsLoaded() && x274_24_loaded; } -void CPhazonBeam::DrawClipScaleCube() const { +void CPhazonBeam::DrawClipScaleCube() { // Render AABB as completely transparent object, only modifying Z-buffer m_aaboxShaderScale.draw(zeus::skClear); } -void CPhazonBeam::DrawClipTranslateCube() const { +void CPhazonBeam::DrawClipTranslateCube() { // Render AABB as completely transparent object, only modifying Z-buffer m_aaboxShaderTranslate.draw(zeus::skClear); } void CPhazonBeam::Draw(bool drawSuitArm, const CStateManager& mgr, const zeus::CTransform& xf, const CModelFlags& flags, - const CActorLights* lights) const { + const CActorLights* lights) { CPlayerState::EPlayerVisor visor = mgr.GetPlayerState()->GetActiveVisor(mgr); bool drawIndirect = visor == CPlayerState::EPlayerVisor::Combat || visor == CPlayerState::EPlayerVisor::Scan; diff --git a/Runtime/Weapon/CPhazonBeam.hpp b/Runtime/Weapon/CPhazonBeam.hpp index 5b63feb0a..7e123eec2 100644 --- a/Runtime/Weapon/CPhazonBeam.hpp +++ b/Runtime/Weapon/CPhazonBeam.hpp @@ -22,11 +22,11 @@ class CPhazonBeam final : public CGunWeapon { bool x274_26_veinsAlphaActive : 1; bool x274_27_phazonVeinsIdx : 1; float x278_fireTime = 1.f / 3.f; - mutable CAABoxShader m_aaboxShaderScale{true}; - mutable CAABoxShader m_aaboxShaderTranslate{true}; + CAABoxShader m_aaboxShaderScale{true}; + CAABoxShader m_aaboxShaderTranslate{true}; void ReInitVariables(); - void DrawClipScaleCube() const; - void DrawClipTranslateCube() const; + void DrawClipScaleCube(); + void DrawClipTranslateCube(); public: CPhazonBeam(CAssetId characterId, EWeaponType type, TUniqueId playerId, EMaterialTypes playerMaterial, @@ -49,7 +49,7 @@ public: void Unload(CStateManager& mgr) override; bool IsLoaded() const override; void Draw(bool drawSuitArm, const CStateManager& mgr, const zeus::CTransform& xf, const CModelFlags& flags, - const CActorLights* lights) const override; + const CActorLights* lights) override; void DrawMuzzleFx(const CStateManager& mgr) const override; }; diff --git a/Runtime/Weapon/CPlasmaProjectile.cpp b/Runtime/Weapon/CPlasmaProjectile.cpp index 730669605..7d25610d7 100644 --- a/Runtime/Weapon/CPlasmaProjectile.cpp +++ b/Runtime/Weapon/CPlasmaProjectile.cpp @@ -394,7 +394,7 @@ bool CPlasmaProjectile::CanRenderUnsorted(const CStateManager& mgr) const { return false; } -void CPlasmaProjectile::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { +void CPlasmaProjectile::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { if (GetActive()) { g_Renderer->AddParticleGen(*x518_contactGen); if (x478_beamAttributes & 0x2) { @@ -404,7 +404,7 @@ void CPlasmaProjectile::AddToRenderer(const zeus::CFrustum& frustum, const CStat EnsureRendered(mgr, GetBeamTransform().origin, GetSortingBounds(mgr)); } -void CPlasmaProjectile::Render(const CStateManager& mgr) const { +void CPlasmaProjectile::Render(CStateManager& mgr) { if (!GetActive()) return; SCOPED_GRAPHICS_DEBUG_GROUP("CPlasmaProjectile::Render", zeus::skOrange); diff --git a/Runtime/Weapon/CPlasmaProjectile.hpp b/Runtime/Weapon/CPlasmaProjectile.hpp index b2e7e7d8d..d9c249c5b 100644 --- a/Runtime/Weapon/CPlasmaProjectile.hpp +++ b/Runtime/Weapon/CPlasmaProjectile.hpp @@ -121,7 +121,7 @@ public: void Fire(const zeus::CTransform& xf, CStateManager& mgr, bool b) override; void Touch(CActor& other, CStateManager& mgr) override; bool CanRenderUnsorted(const CStateManager& mgr) const override; - void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const override; - void Render(const CStateManager& mgr) const override; + void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override; + void Render(CStateManager& mgr) override; }; } // namespace urde diff --git a/Runtime/Weapon/CPlayerGun.cpp b/Runtime/Weapon/CPlayerGun.cpp index d13a0f51a..8a279abc3 100644 --- a/Runtime/Weapon/CPlayerGun.cpp +++ b/Runtime/Weapon/CPlayerGun.cpp @@ -2129,20 +2129,20 @@ void CPlayerGun::CopyScreenTex() { CGraphics::ResolveSpareTexture(g_Viewport); } -void CPlayerGun::DrawScreenTex(float z) const { +void CPlayerGun::DrawScreenTex(float z) { // Use CopyScreenTex rendering to draw over framebuffer pixels in front of `z` // This is accomplished using orthographic projection quad with sweeping `y` coordinates // Depth is set to GEQUAL to obscure pixels in front rather than behind m_screenQuad.draw(zeus::skWhite, 1.f, CTexturedQuadFilter::DefaultRect, z); } -void CPlayerGun::DrawClipCube(const zeus::CAABox& aabb) const { +void CPlayerGun::DrawClipCube(const zeus::CAABox& aabb) { // Render AABB as completely transparent object, only modifying Z-buffer // AABB has already been set in constructor (since it's constant) m_aaboxShader.draw(zeus::skClear); } -void CPlayerGun::Render(const CStateManager& mgr, const zeus::CVector3f& pos, const CModelFlags& flags) const { +void CPlayerGun::Render(const CStateManager& mgr, const zeus::CVector3f& pos, const CModelFlags& flags) { SCOPED_GRAPHICS_DEBUG_GROUP("CPlayerGun::Render", zeus::skMagenta); CGraphics::CProjectionState projState = CGraphics::GetProjectionState(); diff --git a/Runtime/Weapon/CPlayerGun.hpp b/Runtime/Weapon/CPlayerGun.hpp index 692a2cac3..1a0dda246 100644 --- a/Runtime/Weapon/CPlayerGun.hpp +++ b/Runtime/Weapon/CPlayerGun.hpp @@ -266,9 +266,9 @@ private: u32 _dummy = 0; }; - mutable CTexturedQuadFilter m_screenQuad{EFilterType::Blend, CGraphics::g_SpareTexture.get(), - CTexturedQuadFilter::ZTest::GEqualZWrite}; - mutable CAABoxShader m_aaboxShader{true}; + CTexturedQuadFilter m_screenQuad{EFilterType::Blend, CGraphics::g_SpareTexture.get(), + CTexturedQuadFilter::ZTest::GEqualZWrite}; + CAABoxShader m_aaboxShader{true}; void InitBeamData(); void InitBombData(); @@ -322,8 +322,8 @@ private: void DrawArm(const CStateManager& mgr, const zeus::CVector3f& pos, const CModelFlags& flags) const; zeus::CVector3f ConvertToScreenSpace(const zeus::CVector3f& pos, const CGameCamera& cam) const; static void CopyScreenTex(); - void DrawScreenTex(float z) const; - void DrawClipCube(const zeus::CAABox& aabb) const; + void DrawScreenTex(float z); + void DrawClipCube(const zeus::CAABox& aabb); public: explicit CPlayerGun(TUniqueId playerId); @@ -358,7 +358,7 @@ public: void StopContinuousBeam(CStateManager& mgr, bool b1); void Update(float grappleSwingT, float cameraBobT, float dt, CStateManager& mgr); void PreRender(const CStateManager& mgr, const zeus::CFrustum& frustum, const zeus::CVector3f& camPos); - void Render(const CStateManager& mgr, const zeus::CVector3f& pos, const CModelFlags& flags) const; + void Render(const CStateManager& mgr, const zeus::CVector3f& pos, const CModelFlags& flags); void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const; u32 GetLastFireButtonStates() const { return x2ec_lastFireButtonStates; } void DropBomb(EBWeapon weapon, CStateManager& mgr); diff --git a/Runtime/Weapon/CPowerBeam.cpp b/Runtime/Weapon/CPowerBeam.cpp index de075e063..2d822bbcf 100644 --- a/Runtime/Weapon/CPowerBeam.cpp +++ b/Runtime/Weapon/CPowerBeam.cpp @@ -1,5 +1,7 @@ #include "Runtime/Weapon/CPowerBeam.hpp" +#include + #include "Runtime/CSimplePool.hpp" #include "Runtime/GameGlobalObjects.hpp" @@ -69,12 +71,15 @@ void CPowerBeam::UpdateGunFx(bool shotSmoke, float dt, const CStateManager& mgr, CGunWeapon::UpdateGunFx(shotSmoke, dt, mgr, xf); } -static const u16 skSoundId[] = {SFXwpn_fire_power_normal, SFXwpn_fire_power_charged}; - void CPowerBeam::Fire(bool underwater, float dt, EChargeState chargeState, const zeus::CTransform& xf, CStateManager& mgr, TUniqueId homingTarget, float chargeFactor1, float chargeFactor2) { + static constexpr std::array skSoundId{ + SFXwpn_fire_power_normal, + SFXwpn_fire_power_charged, + }; + CGunWeapon::Fire(underwater, dt, chargeState, xf, mgr, homingTarget, chargeFactor1, chargeFactor2); - NWeaponTypes::play_sfx(skSoundId[int(chargeState)], underwater, false, 0.165f); + NWeaponTypes::play_sfx(skSoundId[size_t(chargeState)], underwater, false, 0.165f); } void CPowerBeam::EnableSecondaryFx(ESecondaryFxType type) { diff --git a/Runtime/Weapon/CPowerBomb.cpp b/Runtime/Weapon/CPowerBomb.cpp index abbf37a46..715a1f497 100644 --- a/Runtime/Weapon/CPowerBomb.cpp +++ b/Runtime/Weapon/CPowerBomb.cpp @@ -89,7 +89,7 @@ void CPowerBomb::Think(float dt, CStateManager& mgr) { x15c_curTime += dt; } -void CPowerBomb::AddToRenderer(const zeus::CFrustum&, const CStateManager&) const { +void CPowerBomb::AddToRenderer(const zeus::CFrustum&, CStateManager&) { g_Renderer->AddParticleGen(*x168_particle); } diff --git a/Runtime/Weapon/CPowerBomb.hpp b/Runtime/Weapon/CPowerBomb.hpp index eb562559b..6a20fc052 100644 --- a/Runtime/Weapon/CPowerBomb.hpp +++ b/Runtime/Weapon/CPowerBomb.hpp @@ -27,8 +27,8 @@ public: void Accept(IVisitor& visitor) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void Think(float, CStateManager&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; - void Render(const CStateManager&) const override {} + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; + void Render(CStateManager&) override {} std::optional GetTouchBounds() const override { return std::nullopt; } void Touch(CActor&, CStateManager&) override { /*x158_24_canStartFilter; */ } diff --git a/Runtime/Weapon/CWeapon.cpp b/Runtime/Weapon/CWeapon.cpp index 42bf34247..ef5934533 100644 --- a/Runtime/Weapon/CWeapon.cpp +++ b/Runtime/Weapon/CWeapon.cpp @@ -37,7 +37,7 @@ void CWeapon::Think(float dt, CStateManager& mgr) { CEntity::Think(dt, mgr); } -void CWeapon::Render(const CStateManager&) const { +void CWeapon::Render(CStateManager&) { // Empty } diff --git a/Runtime/Weapon/CWeapon.hpp b/Runtime/Weapon/CWeapon.hpp index 025e89ab6..3c4a475cc 100644 --- a/Runtime/Weapon/CWeapon.hpp +++ b/Runtime/Weapon/CWeapon.hpp @@ -45,7 +45,7 @@ public: void SetInterferenceDuration(float dur) { x154_interferenceDuration = dur; } void Think(float, CStateManager&) override; - void Render(const CStateManager&) const override; + void Render(CStateManager&) override; EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, const CWeaponMode&, EProjectileAttrib) const override; void FluidFXThink(EFluidState state, CScriptWater& water, CStateManager& mgr) override; diff --git a/Runtime/Weapon/CWeaponMgr.cpp b/Runtime/Weapon/CWeaponMgr.cpp index 86db9d2b4..28cfa89e0 100644 --- a/Runtime/Weapon/CWeaponMgr.cpp +++ b/Runtime/Weapon/CWeaponMgr.cpp @@ -3,47 +3,64 @@ namespace urde { void CWeaponMgr::Add(TUniqueId uid, EWeaponType type) { - x0_weapons.insert(std::make_pair(uid, rstl::reserved_vector())); - x0_weapons[uid].resize(15); - ++x0_weapons[uid][u32(type)]; + auto iter = x0_weapons.emplace(uid, rstl::reserved_vector()).first; + iter->second.resize(15); + ++iter->second[size_t(type)]; } void CWeaponMgr::Remove(TUniqueId uid) { - s32 totalActive = 0; - for (u32 i = 0; i < 10; ++i) - totalActive += x0_weapons[uid][i]; + const auto& weapon = x0_weapons[uid]; - if (totalActive == 0) - x0_weapons.erase(uid); + s32 totalActive = 0; + for (size_t i = 0; i < 10; ++i) { + totalActive += weapon[i]; + } + + if (totalActive != 0) { + return; + } + + x0_weapons.erase(uid); } void CWeaponMgr::IncrCount(TUniqueId uid, EWeaponType type) { - if (GetIndex(uid) < 0) + if (GetIndex(uid) < 0) { Add(uid, type); - else - x0_weapons[uid][u32(type)]++; + } else { + x0_weapons[uid][size_t(type)]++; + } } void CWeaponMgr::DecrCount(TUniqueId uid, EWeaponType type) { - if (GetIndex(uid) < 0) + if (GetIndex(uid) < 0) { return; + } - x0_weapons[uid][u32(type)]--; - if (x0_weapons[uid][u32(type)] <= 0) - Remove(uid); + auto& weapon = x0_weapons[uid]; + weapon[size_t(type)]--; + if (weapon[size_t(type)] > 0) { + return; + } + + Remove(uid); } s32 CWeaponMgr::GetNumActive(TUniqueId uid, EWeaponType type) const { - if (GetIndex(uid) < 0) + if (GetIndex(uid) < 0) { return 0; + } - return x0_weapons.at(uid)[u32(type)]; + return x0_weapons.at(uid)[size_t(type)]; } s32 CWeaponMgr::GetIndex(TUniqueId uid) const { - if (x0_weapons.find(uid) == x0_weapons.end()) + const auto iter = x0_weapons.find(uid); + + if (iter == x0_weapons.cend()) { return -1; - return s32(std::distance(x0_weapons.begin(), x0_weapons.find(uid))); + } + + return s32(std::distance(x0_weapons.cbegin(), iter)); } } // namespace urde diff --git a/Runtime/World/CActor.cpp b/Runtime/World/CActor.cpp index 32bba7477..37fa2b6d4 100644 --- a/Runtime/World/CActor.cpp +++ b/Runtime/World/CActor.cpp @@ -181,25 +181,29 @@ void CActor::PreRender(CStateManager& mgr, const zeus::CFrustum& planes) { } } -void CActor::AddToRenderer(const zeus::CFrustum& planes, const CStateManager& mgr) const { - if (!x64_modelData || x64_modelData->IsNull()) +void CActor::AddToRenderer(const zeus::CFrustum& planes, CStateManager& mgr) { + if (!x64_modelData || x64_modelData->IsNull()) { return; + } - if (xe6_29_renderParticleDBInside) + if (xe6_29_renderParticleDBInside) { x64_modelData->RenderParticles(planes); + } if (!xe4_30_outOfFrustum) { - if (CanRenderUnsorted(mgr)) + if (CanRenderUnsorted(mgr)) { Render(mgr); - else + } else { EnsureRendered(mgr); + } } if (mgr.GetPlayerState()->GetActiveVisor(mgr) != CPlayerState::EPlayerVisor::XRay && mgr.GetPlayerState()->GetActiveVisor(mgr) != CPlayerState::EPlayerVisor::Thermal && xe5_24_shadowEnabled && - x94_simpleShadow->Valid() && planes.aabbFrustumTest(x94_simpleShadow->GetBounds())) + x94_simpleShadow->Valid() && planes.aabbFrustumTest(x94_simpleShadow->GetBounds())) { g_Renderer->AddDrawable(x94_simpleShadow.get(), x94_simpleShadow->GetTransform().origin, x94_simpleShadow->GetBounds(), 1, CBooRenderer::EDrawableSorting::SortedCallback); + } } void CActor::DrawTouchBounds() const { @@ -253,7 +257,7 @@ bool CActor::IsModelOpaque(const CStateManager& mgr) const { return x64_modelData->IsDefinitelyOpaque(CModelData::GetRenderingModel(mgr)); } -void CActor::Render(const CStateManager& mgr) const { +void CActor::Render(CStateManager& mgr) { if (x64_modelData && !x64_modelData->IsNull()) { bool renderPrePostParticles = xe6_29_renderParticleDBInside && x64_modelData && x64_modelData->HasAnimData(); if (renderPrePostParticles) @@ -508,12 +512,12 @@ float CActor::GetPitch() const { return zeus::CQuaternion(x34_transform.buildMat float CActor::GetYaw() const { return zeus::CQuaternion(x34_transform.buildMatrix3f()).yaw(); } -void CActor::EnsureRendered(const CStateManager& mgr) const { - zeus::CAABox aabb = GetSortingBounds(mgr); +void CActor::EnsureRendered(const CStateManager& mgr) { + const zeus::CAABox aabb = GetSortingBounds(mgr); EnsureRendered(mgr, aabb.closestPointAlongVector(CGraphics::g_ViewMatrix.basis[1]), aabb); } -void CActor::EnsureRendered(const CStateManager& stateMgr, const zeus::CVector3f& pos, const zeus::CAABox& aabb) const { +void CActor::EnsureRendered(const CStateManager& stateMgr, const zeus::CVector3f& pos, const zeus::CAABox& aabb) { if (x64_modelData) { x64_modelData->RenderUnsortedParts(x64_modelData->GetRenderingModel(stateMgr), x34_transform, x90_actorLights.get(), xb4_drawFlags); diff --git a/Runtime/World/CActor.hpp b/Runtime/World/CActor.hpp index 48b6d3a33..3dc0d863d 100644 --- a/Runtime/World/CActor.hpp +++ b/Runtime/World/CActor.hpp @@ -108,8 +108,8 @@ public: CEntity::SetActive(active); } virtual void PreRender(CStateManager&, const zeus::CFrustum&); - virtual void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const; - virtual void Render(const CStateManager&) const; + virtual void AddToRenderer(const zeus::CFrustum&, CStateManager&); + virtual void Render(CStateManager&); virtual bool CanRenderUnsorted(const CStateManager&) const; virtual void CalculateRenderBounds(); virtual CHealthInfo* HealthInfo(CStateManager&); @@ -168,8 +168,8 @@ public: float GetYaw() const; const CModelData* GetModelData() const { return x64_modelData.get(); } CModelData* GetModelData() { return x64_modelData.get(); } - void EnsureRendered(const CStateManager&) const; - void EnsureRendered(const CStateManager&, const zeus::CVector3f&, const zeus::CAABox&) const; + void EnsureRendered(const CStateManager&); + void EnsureRendered(const CStateManager&, const zeus::CVector3f&, const zeus::CAABox&); void ProcessSoundEvent(u32 sfxId, float weight, u32 flags, float falloff, float maxDist, float minVol, float maxVol, const zeus::CVector3f& toListener, const zeus::CVector3f& position, TAreaId aid, CStateManager& mgr, bool translateId); diff --git a/Runtime/World/CEffect.hpp b/Runtime/World/CEffect.hpp index ef3b7fea2..d43df85ee 100644 --- a/Runtime/World/CEffect.hpp +++ b/Runtime/World/CEffect.hpp @@ -8,8 +8,8 @@ class CEffect : public CActor { public: CEffect(TUniqueId uid, const CEntityInfo& info, bool active, std::string_view name, const zeus::CTransform& xf); - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override {} - void Render(const CStateManager&) const override {} + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override {} + void Render(CStateManager&) override {} }; } // namespace urde diff --git a/Runtime/World/CExplosion.cpp b/Runtime/World/CExplosion.cpp index 06d3ce62b..4aa319553 100644 --- a/Runtime/World/CExplosion.cpp +++ b/Runtime/World/CExplosion.cpp @@ -89,9 +89,10 @@ void CExplosion::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) { xe4_30_outOfFrustum = !xf4_25_ || !frustum.aabbFrustumTest(x9c_renderBounds); } -void CExplosion::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { - if (xe4_30_outOfFrustum) +void CExplosion::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { + if (xe4_30_outOfFrustum) { return; + } if (!(xf4_24_renderThermalHot && mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot) && !(xf4_26_renderXray && mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay)) { @@ -102,7 +103,7 @@ void CExplosion::AddToRenderer(const zeus::CFrustum& frustum, const CStateManage EnsureRendered(mgr); } -void CExplosion::Render(const CStateManager& mgr) const { +void CExplosion::Render(CStateManager& mgr) { if (mgr.GetThermalDrawFlag() == EThermalDrawFlag::Hot && xf4_24_renderThermalHot) { CElementGen::SetSubtractBlend(true); CBooModel::SetRenderModelBlack(true); diff --git a/Runtime/World/CExplosion.hpp b/Runtime/World/CExplosion.hpp index 8dd858bd4..dfdbc5c90 100644 --- a/Runtime/World/CExplosion.hpp +++ b/Runtime/World/CExplosion.hpp @@ -33,8 +33,8 @@ public: void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void Think(float, CStateManager&) override; void PreRender(CStateManager&, const zeus::CFrustum&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; - void Render(const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; + void Render(CStateManager&) override; bool CanRenderUnsorted(const CStateManager&) const override; }; diff --git a/Runtime/World/CFire.cpp b/Runtime/World/CFire.cpp index cde3c3726..713a1798f 100644 --- a/Runtime/World/CFire.cpp +++ b/Runtime/World/CFire.cpp @@ -84,7 +84,7 @@ void CFire::Touch(CActor& act, CStateManager& mgr) { CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {}); } -void CFire::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { +void CFire::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { bool drawParticles = true; if (!x148_27_) { using EPlayerVisor = CPlayerState::EPlayerVisor; diff --git a/Runtime/World/CFire.hpp b/Runtime/World/CFire.hpp index 6988fda22..f2471d3b2 100644 --- a/Runtime/World/CFire.hpp +++ b/Runtime/World/CFire.hpp @@ -42,6 +42,6 @@ public: } void Touch(CActor&, CStateManager&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; }; } // namespace urde \ No newline at end of file diff --git a/Runtime/World/CFishCloud.cpp b/Runtime/World/CFishCloud.cpp index 408f0803d..16f86f27d 100644 --- a/Runtime/World/CFishCloud.cpp +++ b/Runtime/World/CFishCloud.cpp @@ -522,7 +522,7 @@ void CFishCloud::RenderBoid(int idx, const CBoid& boid, u32& drawMask, } } -void CFishCloud::Render(const CStateManager& mgr) const { +void CFishCloud::Render(CStateManager& mgr) { if (!GetActive()) return; SCOPED_GRAPHICS_DEBUG_GROUP(fmt::format(fmt("CFishCloud::Render {} {} {}"), diff --git a/Runtime/World/CFishCloud.hpp b/Runtime/World/CFishCloud.hpp index 036606ef0..f6c13f3bf 100644 --- a/Runtime/World/CFishCloud.hpp +++ b/Runtime/World/CFishCloud.hpp @@ -145,7 +145,7 @@ public: void Think(float dt, CStateManager& mgr) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) override; void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override; - void Render(const CStateManager& mgr) const override; + void Render(CStateManager& mgr) override; void CalculateRenderBounds() override; std::optional GetTouchBounds() const override; void Touch(CActor& other, CStateManager& mgr) override; diff --git a/Runtime/World/CHUDBillboardEffect.cpp b/Runtime/World/CHUDBillboardEffect.cpp index 20a4a442d..f7b86cd37 100644 --- a/Runtime/World/CHUDBillboardEffect.cpp +++ b/Runtime/World/CHUDBillboardEffect.cpp @@ -78,7 +78,7 @@ void CHUDBillboardEffect::Think(float dt, CStateManager& mgr) { } } -void CHUDBillboardEffect::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { +void CHUDBillboardEffect::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { if (x104_25_enableRender && x104_24_renderAsParticleGen) { g_Renderer->AddParticleGen(*xe8_generator); } @@ -96,7 +96,7 @@ void CHUDBillboardEffect::PreRender(CStateManager& mgr, const zeus::CFrustum& fr x104_24_renderAsParticleGen = !mgr.RenderLast(GetUniqueId()); } -void CHUDBillboardEffect::Render(const CStateManager& mgr) const { +void CHUDBillboardEffect::Render(CStateManager& mgr) { if (x104_25_enableRender && !x104_24_renderAsParticleGen) { SCOPED_GRAPHICS_DEBUG_GROUP("CHUDBillboardEffect::Render", zeus::skPurple); xe8_generator->Render(); diff --git a/Runtime/World/CHUDBillboardEffect.hpp b/Runtime/World/CHUDBillboardEffect.hpp index cba72ef0d..4cc9ed779 100644 --- a/Runtime/World/CHUDBillboardEffect.hpp +++ b/Runtime/World/CHUDBillboardEffect.hpp @@ -37,9 +37,9 @@ public: ~CHUDBillboardEffect() override; void Accept(IVisitor& visitor) override; void Think(float dt, CStateManager& mgr) override; - void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const override; + void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override; void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override; - void Render(const CStateManager& mgr) const override; + void Render(CStateManager& mgr) override; bool IsElementGen() const { return x104_26_isElementGen; } void SetRunIndefinitely(bool b) { x104_27_runIndefinitely = b; } CParticleGen* GetParticleGen() const { return xe8_generator.get(); } diff --git a/Runtime/World/CPatterned.cpp b/Runtime/World/CPatterned.cpp index 3bfbbb3ee..1360075e3 100644 --- a/Runtime/World/CPatterned.cpp +++ b/Runtime/World/CPatterned.cpp @@ -1570,13 +1570,14 @@ void CPatterned::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) { CActor::PreRender(mgr, frustum); } -void CPatterned::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { +void CPatterned::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { if (x402_29_drawParticles) { if (x64_modelData && !x64_modelData->IsNull()) { int mask, target; mgr.GetCharacterRenderMaskAndTarget(x402_31_thawed, mask, target); - if (CAnimData* aData = x64_modelData->GetAnimationData()) + if (CAnimData* aData = x64_modelData->GetAnimationData()) { aData->GetParticleDB().AddToRendererClippedMasked(frustum, mask, target); + } } } CActor::AddToRenderer(frustum, mgr); @@ -1590,7 +1591,7 @@ void CPatterned::RenderIceModelWithFlags(const CModelFlags& flags) const { animData->Render(*iceModel, useFlags, {*x510_vertexMorph}, iceModel->GetMorphMagnitudes()); } -void CPatterned::Render(const CStateManager& mgr) const { +void CPatterned::Render(CStateManager& mgr) { int mask = 0; int target = 0; if (x402_29_drawParticles) { diff --git a/Runtime/World/CPatterned.hpp b/Runtime/World/CPatterned.hpp index c1ac59538..6cacca57b 100644 --- a/Runtime/World/CPatterned.hpp +++ b/Runtime/World/CPatterned.hpp @@ -273,8 +273,8 @@ public: } void Think(float, CStateManager&) override; void PreRender(CStateManager&, const zeus::CFrustum&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; - void Render(const CStateManager& mgr) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; + void Render(CStateManager& mgr) override; void CollidedWith(TUniqueId, const CCollisionInfoList&, CStateManager& mgr) override; void Touch(CActor& act, CStateManager& mgr) override; diff --git a/Runtime/World/CPhysicsActor.cpp b/Runtime/World/CPhysicsActor.cpp index 9bf2343a6..b894a6b6a 100644 --- a/Runtime/World/CPhysicsActor.cpp +++ b/Runtime/World/CPhysicsActor.cpp @@ -25,7 +25,7 @@ CPhysicsActor::CPhysicsActor(TUniqueId uid, bool active, std::string_view name, ComputeDerivedQuantities(); } -void CPhysicsActor::Render(const CStateManager& mgr) const { CActor::Render(mgr); } +void CPhysicsActor::Render(CStateManager& mgr) { CActor::Render(mgr); } zeus::CVector3f CPhysicsActor::GetOrbitPosition(const CStateManager&) const { return GetBoundingBox().center(); } diff --git a/Runtime/World/CPhysicsActor.hpp b/Runtime/World/CPhysicsActor.hpp index 905aadc5f..887ae123c 100644 --- a/Runtime/World/CPhysicsActor.hpp +++ b/Runtime/World/CPhysicsActor.hpp @@ -121,7 +121,7 @@ public: CModelData&& mData, const CMaterialList& matList, const zeus::CAABox& box, const SMoverData& moverData, const CActorParameters& actorParms, float stepUp, float stepDown); - void Render(const CStateManager& mgr) const override; + void Render(CStateManager& mgr) override; zeus::CVector3f GetOrbitPosition(const CStateManager& mgr) const override; zeus::CVector3f GetAimPosition(const CStateManager& mgr, float val) const override; virtual const CCollisionPrimitive* GetCollisionPrimitive() const; diff --git a/Runtime/World/CPlayer.cpp b/Runtime/World/CPlayer.cpp index aa41942dd..812085fe1 100644 --- a/Runtime/World/CPlayer.cpp +++ b/Runtime/World/CPlayer.cpp @@ -1406,7 +1406,7 @@ void CPlayer::RenderGun(const CStateManager& mgr, const zeus::CVector3f& pos) co } } -void CPlayer::Render(const CStateManager& mgr) const { +void CPlayer::Render(CStateManager& mgr) { bool doRender = x2f4_cameraState != EPlayerCameraState::Spawned; if (!doRender) { if (TCastToConstPtr cam = mgr.GetCameraManager()->GetCurrentCamera(mgr)) { @@ -1597,7 +1597,7 @@ void CPlayer::CalculateRenderBounds() { } } -void CPlayer::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { +void CPlayer::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { if (x2f4_cameraState != EPlayerCameraState::FirstPerson && x2f8_morphBallState == EPlayerMorphBallState::Morphed) { if (x768_morphball->IsInFrustum(frustum)) { CActor::AddToRenderer(frustum, mgr); diff --git a/Runtime/World/CPlayer.hpp b/Runtime/World/CPlayer.hpp index 9f573aa24..bbe098bd5 100644 --- a/Runtime/World/CPlayer.hpp +++ b/Runtime/World/CPlayer.hpp @@ -401,11 +401,11 @@ public: bool GetExplorationMode() const; bool GetCombatMode() const; void RenderGun(const CStateManager& mgr, const zeus::CVector3f& pos) const; - void Render(const CStateManager& mgr) const override; + void Render(CStateManager& mgr) override; void RenderReflectedPlayer(CStateManager& mgr); void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override; void CalculateRenderBounds() override; - void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const override; + void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override; void ComputeFreeLook(const CFinalInput& input); void UpdateFreeLookState(const CFinalInput& input, float dt, CStateManager& mgr); void UpdateFreeLook(float dt); diff --git a/Runtime/World/CScriptAiJumpPoint.hpp b/Runtime/World/CScriptAiJumpPoint.hpp index 31dfce661..1f62259a8 100644 --- a/Runtime/World/CScriptAiJumpPoint.hpp +++ b/Runtime/World/CScriptAiJumpPoint.hpp @@ -29,8 +29,8 @@ public: void Accept(IVisitor& visitor) override; void Think(float, CStateManager&) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override {} - void Render(const CStateManager&) const override {} + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override {} + void Render(CStateManager&) override {} std::optional GetTouchBounds() const override; bool GetInUse(TUniqueId uid) const; TUniqueId GetJumpPoint() const { return x10c_currentWaypoint; } diff --git a/Runtime/World/CScriptCameraWaypoint.hpp b/Runtime/World/CScriptCameraWaypoint.hpp index 26f8d9c51..014037d73 100644 --- a/Runtime/World/CScriptCameraWaypoint.hpp +++ b/Runtime/World/CScriptCameraWaypoint.hpp @@ -17,8 +17,8 @@ public: void Accept(IVisitor& visitor) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override {} - void Render(const CStateManager&) const override {} + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override {} + void Render(CStateManager&) override {} TUniqueId GetRandomNextWaypointId(CStateManager& mgr) const; float GetHFov() const { return xe8_hfov; } }; diff --git a/Runtime/World/CScriptCoverPoint.hpp b/Runtime/World/CScriptCoverPoint.hpp index c644d3832..176636db9 100644 --- a/Runtime/World/CScriptCoverPoint.hpp +++ b/Runtime/World/CScriptCoverPoint.hpp @@ -40,9 +40,9 @@ public: void Accept(IVisitor& visitor) override; void Think(float, CStateManager&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override {} + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override {} void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; - void Render(const CStateManager&) const override {} + void Render(CStateManager&) override {} std::optional GetTouchBounds() const override; void SetInUse(bool inUse); bool GetInUse(TUniqueId uid) const; diff --git a/Runtime/World/CScriptDamageableTrigger.cpp b/Runtime/World/CScriptDamageableTrigger.cpp index 59b0796df..3b0a6040b 100644 --- a/Runtime/World/CScriptDamageableTrigger.cpp +++ b/Runtime/World/CScriptDamageableTrigger.cpp @@ -105,7 +105,7 @@ EWeaponCollisionResponseTypes CScriptDamageableTrigger::GetCollisionResponseType : EWeaponCollisionResponseTypes::Unknown15; } -void CScriptDamageableTrigger::Render(const CStateManager& mgr) const { +void CScriptDamageableTrigger::Render(CStateManager& mgr) { if (x30_24_active && x1dc_faceFlag != 0 && std::fabs(x1e0_alpha) >= 0.00001f) { zeus::CAABox aabb = x14c_bounds.getTransformedAABox(x214_faceDirInv); zeus::CTransform xf = x34_transform * zeus::CTransform::Translate(x244_faceTranslate) * x1e4_faceDir; @@ -116,9 +116,11 @@ void CScriptDamageableTrigger::Render(const CStateManager& mgr) const { CActor::Render(mgr); } -void CScriptDamageableTrigger::AddToRenderer(const zeus::CFrustum& /*frustum*/, const CStateManager& mgr) const { - if (x300_26_outOfFrustum) +void CScriptDamageableTrigger::AddToRenderer(const zeus::CFrustum& /*frustum*/, CStateManager& mgr) { + if (x300_26_outOfFrustum) { return; + } + EnsureRendered(mgr, GetTranslation() - x244_faceTranslate, GetSortingBounds(mgr)); } diff --git a/Runtime/World/CScriptDamageableTrigger.hpp b/Runtime/World/CScriptDamageableTrigger.hpp index 344db2222..590cff53b 100644 --- a/Runtime/World/CScriptDamageableTrigger.hpp +++ b/Runtime/World/CScriptDamageableTrigger.hpp @@ -58,8 +58,8 @@ public: void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&, const CWeaponMode&, EProjectileAttrib) const override; - void Render(const CStateManager& mgr) const override; - void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const override; + void Render(CStateManager& mgr) override; + void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override; void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override; const CDamageVulnerability* GetDamageVulnerability() const override { return &x174_dVuln; } CHealthInfo* HealthInfo(CStateManager&) override { return &x16c_hInfo; } diff --git a/Runtime/World/CScriptDebris.cpp b/Runtime/World/CScriptDebris.cpp index 5c7c669e7..740c2bda1 100644 --- a/Runtime/World/CScriptDebris.cpp +++ b/Runtime/World/CScriptDebris.cpp @@ -143,21 +143,28 @@ CScriptDebris::CScriptDebris(TUniqueId uid, std::string_view name, const CEntity void CScriptDebris::Accept(IVisitor& visitor) { visitor.Visit(this); } -void CScriptDebris::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { - if (x2d4_particleGens[0]) - if (x270_curTime < x274_duration || x281_26_deferDeleteTillParticle1Done) +void CScriptDebris::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { + if (x2d4_particleGens[0]) { + if (x270_curTime < x274_duration || x281_26_deferDeleteTillParticle1Done) { g_Renderer->AddParticleGen(*x2d4_particleGens[0]); + } + } - if (x2d4_particleGens[1]) - if (x270_curTime < x274_duration || x281_28_deferDeleteTillParticle2Done) + if (x2d4_particleGens[1]) { + if (x270_curTime < x274_duration || x281_28_deferDeleteTillParticle2Done) { g_Renderer->AddParticleGen(*x2d4_particleGens[1]); + } + } - if (x281_29_particle3Active) + if (x281_29_particle3Active) { g_Renderer->AddParticleGen(*x2d4_particleGens[2]); + } - if (x64_modelData && !x64_modelData->IsNull()) - if (x270_curTime < x274_duration) + if (x64_modelData && !x64_modelData->IsNull()) { + if (x270_curTime < x274_duration) { CActor::AddToRenderer(frustum, mgr); + } + } } static zeus::CVector3f debris_cone(CStateManager& mgr, float coneAng, float minMag, float maxMag) { @@ -372,7 +379,7 @@ void CScriptDebris::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) xb4_drawFlags = CModelFlags(5, 0, 3, zeus::CColor::lerp(zeus::skWhite, x268_endsColor, t)); } -void CScriptDebris::Render(const CStateManager& mgr) const { CPhysicsActor::Render(mgr); } +void CScriptDebris::Render(CStateManager& mgr) { CPhysicsActor::Render(mgr); } void CScriptDebris::CollidedWith(TUniqueId, const CCollisionInfoList& colList, CStateManager&) { if (colList.GetCount() == 0) diff --git a/Runtime/World/CScriptDebris.hpp b/Runtime/World/CScriptDebris.hpp index 8121c352d..bf7ca8cfa 100644 --- a/Runtime/World/CScriptDebris.hpp +++ b/Runtime/World/CScriptDebris.hpp @@ -78,13 +78,13 @@ public: bool noBounce, bool active); void Accept(IVisitor& visitor) override; - void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const override; + void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) override; void Think(float dt, CStateManager& mgr) override; void Touch(CActor& other, CStateManager& mgr) override; std::optional GetTouchBounds() const override; void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override; - void Render(const CStateManager& mgr) const override; + void Render(CStateManager& mgr) override; void CollidedWith(TUniqueId uid, const CCollisionInfoList&, CStateManager&) override; }; diff --git a/Runtime/World/CScriptDoor.cpp b/Runtime/World/CScriptDoor.cpp index aefc9b05f..f58c5dda8 100644 --- a/Runtime/World/CScriptDoor.cpp +++ b/Runtime/World/CScriptDoor.cpp @@ -197,9 +197,12 @@ void CScriptDoor::Think(float dt, CStateManager& mgr) { xe7_31_targetable = mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan; } -void CScriptDoor::AddToRenderer(const zeus::CFrustum& /*frustum*/, const CStateManager& mgr) const { - if (!xe4_30_outOfFrustum) - CPhysicsActor::Render(mgr); +void CScriptDoor::AddToRenderer(const zeus::CFrustum& /*frustum*/, CStateManager& mgr) { + if (xe4_30_outOfFrustum) { + return; + } + + CPhysicsActor::Render(mgr); } /* ORIGINAL 0-00 OFFSET: 8007E0BC */ diff --git a/Runtime/World/CScriptDoor.hpp b/Runtime/World/CScriptDoor.hpp index e87f15267..5ae6d6324 100644 --- a/Runtime/World/CScriptDoor.hpp +++ b/Runtime/World/CScriptDoor.hpp @@ -51,8 +51,8 @@ public: void Accept(IVisitor& visitor) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override; void Think(float, CStateManager& mgr) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager& mgr) const override; - void Render(const CStateManager&) const override {} + void AddToRenderer(const zeus::CFrustum&, CStateManager& mgr) override; + void Render(CStateManager&) override {} void ForceClosed(CStateManager&); bool IsConnectedToArea(const CStateManager& mgr, TAreaId area) const; void OpenDoor(TUniqueId, CStateManager&); diff --git a/Runtime/World/CScriptEMPulse.cpp b/Runtime/World/CScriptEMPulse.cpp index 6ba18efdc..34e45251a 100644 --- a/Runtime/World/CScriptEMPulse.cpp +++ b/Runtime/World/CScriptEMPulse.cpp @@ -55,10 +55,11 @@ void CScriptEMPulse::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CS } } -void CScriptEMPulse::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { +void CScriptEMPulse::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { CActor::AddToRenderer(frustum, mgr); - if (GetActive()) + if (GetActive()) { g_Renderer->AddParticleGen(*x114_particleGen); + } } void CScriptEMPulse::CalculateRenderBounds() { x9c_renderBounds = CalculateBoundingBox(); } diff --git a/Runtime/World/CScriptEMPulse.hpp b/Runtime/World/CScriptEMPulse.hpp index 6f8e4d5be..4a3bcbcab 100644 --- a/Runtime/World/CScriptEMPulse.hpp +++ b/Runtime/World/CScriptEMPulse.hpp @@ -27,7 +27,7 @@ public: void Accept(IVisitor&) override; void Think(float, CStateManager&) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; void CalculateRenderBounds() override; std::optional GetTouchBounds() const override; void Touch(CActor&, CStateManager&) override; diff --git a/Runtime/World/CScriptEffect.cpp b/Runtime/World/CScriptEffect.cpp index c7b391a37..f62b93e18 100644 --- a/Runtime/World/CScriptEffect.cpp +++ b/Runtime/World/CScriptEffect.cpp @@ -208,37 +208,39 @@ void CScriptEffect::PreRender(CStateManager& mgr, const zeus::CFrustum&) { x13c_triggerId = kInvalidUniqueId; } -void CScriptEffect::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { +void CScriptEffect::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { if (!x111_26_canRender) { - const_cast(*this).x12c_remTime = zeus::max(x12c_remTime, x134_durationResetWhileVisible); + x12c_remTime = zeus::max(x12c_remTime, x134_durationResetWhileVisible); return; } - if (!frustum.aabbFrustumTest(x9c_renderBounds)) + if (!frustum.aabbFrustumTest(x9c_renderBounds)) { return; - const_cast(*this).x12c_remTime = zeus::max(x12c_remTime, x134_durationResetWhileVisible); + } + x12c_remTime = zeus::max(x12c_remTime, x134_durationResetWhileVisible); if (x110_31_anyVisorVisible) { bool visible = false; const CPlayerState::EPlayerVisor visor = mgr.GetPlayerState()->GetActiveVisor(mgr); - if (visor == CPlayerState::EPlayerVisor::Combat || visor == CPlayerState::EPlayerVisor::Scan) + if (visor == CPlayerState::EPlayerVisor::Combat || visor == CPlayerState::EPlayerVisor::Scan) { visible = x110_28_combatVisorVisible; - else if (visor == CPlayerState::EPlayerVisor::XRay) + } else if (visor == CPlayerState::EPlayerVisor::XRay) { visible = x110_30_xrayVisorVisible; - else if (visor == CPlayerState::EPlayerVisor::Thermal) + } else if (visor == CPlayerState::EPlayerVisor::Thermal) { visible = x110_29_thermalVisorVisible; + } if (visible && x138_actorLights) { const CGameArea* area = mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways()); - const_cast(*this).x138_actorLights->BuildAreaLightList( + x138_actorLights->BuildAreaLightList( mgr, *area, zeus::CAABox{x9c_renderBounds.center(), x9c_renderBounds.center()}); - const_cast(*this).x138_actorLights->BuildDynamicLightList(mgr, x9c_renderBounds); + x138_actorLights->BuildDynamicLightList(mgr, x9c_renderBounds); } EnsureRendered(mgr); } } -void CScriptEffect::Render(const CStateManager& mgr) const { +void CScriptEffect::Render(CStateManager& mgr) { /* The following code is kept for reference, this is now performed in CElementGen if (x138_actorLights) x138_actorLights->ActivateLights(); diff --git a/Runtime/World/CScriptEffect.hpp b/Runtime/World/CScriptEffect.hpp index c01f617cb..384b62130 100644 --- a/Runtime/World/CScriptEffect.hpp +++ b/Runtime/World/CScriptEffect.hpp @@ -60,8 +60,8 @@ public: void Accept(IVisitor& visitor) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void PreRender(CStateManager&, const zeus::CFrustum&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; - void Render(const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; + void Render(CStateManager&) override; void Think(float, CStateManager&) override; bool CanRenderUnsorted(const CStateManager&) const override { return false; } void SetActive(bool active) override { diff --git a/Runtime/World/CScriptGrapplePoint.cpp b/Runtime/World/CScriptGrapplePoint.cpp index 67cf77195..7d96927c4 100644 --- a/Runtime/World/CScriptGrapplePoint.cpp +++ b/Runtime/World/CScriptGrapplePoint.cpp @@ -40,13 +40,13 @@ void CScriptGrapplePoint::Think(float, CStateManager&) { // Empty } -void CScriptGrapplePoint::Render(const CStateManager&) const { +void CScriptGrapplePoint::Render(CStateManager&) { // Empty } std::optional CScriptGrapplePoint::GetTouchBounds() const { return {xe8_touchBounds}; } -void CScriptGrapplePoint::AddToRenderer(const zeus::CFrustum&, const CStateManager& mgr) const { +void CScriptGrapplePoint::AddToRenderer(const zeus::CFrustum&, CStateManager& mgr) { CActor::EnsureRendered(mgr); } diff --git a/Runtime/World/CScriptGrapplePoint.hpp b/Runtime/World/CScriptGrapplePoint.hpp index 13a616670..eb67176f5 100644 --- a/Runtime/World/CScriptGrapplePoint.hpp +++ b/Runtime/World/CScriptGrapplePoint.hpp @@ -19,9 +19,9 @@ public: void Accept(IVisitor& visitor) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void Think(float, CStateManager&) override; - void Render(const CStateManager&) const override; + void Render(CStateManager&) override; std::optional GetTouchBounds() const override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; const CGrappleParameters& GetGrappleParameters() const { return x100_parameters; } }; } // namespace urde diff --git a/Runtime/World/CScriptGunTurret.cpp b/Runtime/World/CScriptGunTurret.cpp index 1ebc061fa..774a4319e 100644 --- a/Runtime/World/CScriptGunTurret.cpp +++ b/Runtime/World/CScriptGunTurret.cpp @@ -444,11 +444,12 @@ void CScriptGunTurret::PlayAdditiveFlinchAnimation(CStateManager& mgr) { GetModelData()->GetAnimationData()->AddAdditiveAnimation(pair.second, 1.f, false, true); } -void CScriptGunTurret::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { +void CScriptGunTurret::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { CActor::AddToRenderer(frustum, mgr); - if (x258_type != ETurretComponent::Gun) + if (x258_type != ETurretComponent::Gun) { return; + } if (!x560_25_frozen) { switch (x520_state) { @@ -471,8 +472,9 @@ void CScriptGunTurret::AddToRenderer(const zeus::CFrustum& frustum, const CState case ETurretState::ExitTargeting: case ETurretState::Frenzy: g_Renderer->AddParticleGen(*x478_targettingLight); - if (x520_state == ETurretState::Firing || x520_state == ETurretState::Frenzy) + if (x520_state == ETurretState::Firing || x520_state == ETurretState::Frenzy) { g_Renderer->AddParticleGen(*x488_chargingEffect); + } break; default: break; @@ -482,7 +484,7 @@ void CScriptGunTurret::AddToRenderer(const zeus::CFrustum& frustum, const CState } } -void CScriptGunTurret::Render(const CStateManager& mgr) const { +void CScriptGunTurret::Render(CStateManager& mgr) { CPhysicsActor::Render(mgr); if (x258_type == ETurretComponent::Gun) { diff --git a/Runtime/World/CScriptGunTurret.hpp b/Runtime/World/CScriptGunTurret.hpp index 0a786761d..779005a86 100644 --- a/Runtime/World/CScriptGunTurret.hpp +++ b/Runtime/World/CScriptGunTurret.hpp @@ -227,8 +227,8 @@ public: void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void Think(float, CStateManager&) override; void Touch(CActor&, CStateManager&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; - void Render(const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; + void Render(CStateManager&) override; std::optional GetTouchBounds() const override; zeus::CVector3f GetOrbitPosition(const CStateManager&) const override; zeus::CVector3f GetAimPosition(const CStateManager&, float) const override; diff --git a/Runtime/World/CScriptPlatform.cpp b/Runtime/World/CScriptPlatform.cpp index c08b7c89a..38c8eff84 100644 --- a/Runtime/World/CScriptPlatform.cpp +++ b/Runtime/World/CScriptPlatform.cpp @@ -293,7 +293,7 @@ void CScriptPlatform::PreRender(CStateManager& mgr, const zeus::CFrustum& frustu x354_boundsTrigger = kInvalidUniqueId; } -void CScriptPlatform::Render(const CStateManager& mgr) const { +void CScriptPlatform::Render(CStateManager& mgr) { bool xray = mgr.GetPlayerState()->GetActiveVisor(mgr) == CPlayerState::EPlayerVisor::XRay; if (xray && !x356_31_xrayFog) g_Renderer->SetWorldFog(ERglFogMode::None, 0.f, 1.f, zeus::skBlack); diff --git a/Runtime/World/CScriptPlatform.hpp b/Runtime/World/CScriptPlatform.hpp index ffa6806c8..bf796205c 100644 --- a/Runtime/World/CScriptPlatform.hpp +++ b/Runtime/World/CScriptPlatform.hpp @@ -91,7 +91,7 @@ public: void PreThink(float, CStateManager&) override; void Think(float, CStateManager&) override; void PreRender(CStateManager&, const zeus::CFrustum&) override; - void Render(const CStateManager&) const override; + void Render(CStateManager&) override; std::optional GetTouchBounds() const override; zeus::CTransform GetPrimitiveTransform() const override; const CCollisionPrimitive* GetCollisionPrimitive() const override; diff --git a/Runtime/World/CScriptPlayerActor.cpp b/Runtime/World/CScriptPlayerActor.cpp index 21712affb..206d1f3d4 100644 --- a/Runtime/World/CScriptPlayerActor.cpp +++ b/Runtime/World/CScriptPlayerActor.cpp @@ -368,13 +368,14 @@ void CScriptPlayerActor::PreRender(CStateManager& mgr, const zeus::CFrustum& fru CScriptActor::PreRender(mgr, frustum); } -void CScriptPlayerActor::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { - const_cast(this)->TouchModels_Internal(mgr); - if (GetActive()) +void CScriptPlayerActor::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { + TouchModels_Internal(mgr); + if (GetActive()) { CActor::AddToRenderer(frustum, mgr); + } } -void CScriptPlayerActor::Render(const CStateManager& mgr) const { +void CScriptPlayerActor::Render(CStateManager& mgr) { CBooModel::SetReflectionCube(m_reflectionCube); bool phazonSuit = x2e8_suitRes.GetCharacterNodeId() == 3; diff --git a/Runtime/World/CScriptPlayerActor.hpp b/Runtime/World/CScriptPlayerActor.hpp index bbd4d910f..041f1a05a 100644 --- a/Runtime/World/CScriptPlayerActor.hpp +++ b/Runtime/World/CScriptPlayerActor.hpp @@ -67,8 +67,8 @@ public: void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void SetActive(bool active) override; void PreRender(CStateManager&, const zeus::CFrustum&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; - void Render(const CStateManager& mgr) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; + void Render(CStateManager& mgr) override; void TouchModels(const CStateManager& mgr) const; }; } // namespace urde diff --git a/Runtime/World/CScriptPointOfInterest.cpp b/Runtime/World/CScriptPointOfInterest.cpp index d40a5c5c8..fe60339ea 100644 --- a/Runtime/World/CScriptPointOfInterest.cpp +++ b/Runtime/World/CScriptPointOfInterest.cpp @@ -26,9 +26,9 @@ void CScriptPointOfInterest::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId CActor::AcceptScriptMsg(msg, uid, mgr); } -void CScriptPointOfInterest::AddToRenderer(const zeus::CFrustum&, const CStateManager&) const {} +void CScriptPointOfInterest::AddToRenderer(const zeus::CFrustum&, CStateManager&) {} -void CScriptPointOfInterest::Render(const CStateManager&) const {} +void CScriptPointOfInterest::Render(CStateManager&) {} void CScriptPointOfInterest::CalculateRenderBounds() { if (xe8_pointSize == 0.f) diff --git a/Runtime/World/CScriptPointOfInterest.hpp b/Runtime/World/CScriptPointOfInterest.hpp index 89ee604e8..e7bb74eb5 100644 --- a/Runtime/World/CScriptPointOfInterest.hpp +++ b/Runtime/World/CScriptPointOfInterest.hpp @@ -17,8 +17,8 @@ public: void Accept(IVisitor& visitor) override; void Think(float, CStateManager&) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; - void Render(const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; + void Render(CStateManager&) override; void CalculateRenderBounds() override; std::optional GetTouchBounds() const override; }; diff --git a/Runtime/World/CScriptShadowProjector.hpp b/Runtime/World/CScriptShadowProjector.hpp index 188369b7e..54a521def 100644 --- a/Runtime/World/CScriptShadowProjector.hpp +++ b/Runtime/World/CScriptShadowProjector.hpp @@ -37,7 +37,7 @@ public: void Think(float, CStateManager&) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void PreRender(CStateManager&, const zeus::CFrustum&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override {} + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override {} void CreateProjectedShadow(); }; } // namespace urde diff --git a/Runtime/World/CScriptSound.hpp b/Runtime/World/CScriptSound.hpp index 030a3c1d4..63e33e989 100644 --- a/Runtime/World/CScriptSound.hpp +++ b/Runtime/World/CScriptSound.hpp @@ -53,7 +53,7 @@ public: bool worldSfx, bool allowDuplicates, s32 pitch); void Accept(IVisitor& visitor) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override {} + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override {} void PreThink(float, CStateManager&) override; void Think(float, CStateManager&) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; diff --git a/Runtime/World/CScriptSpecialFunction.cpp b/Runtime/World/CScriptSpecialFunction.cpp index 3739d03c2..460612f5a 100644 --- a/Runtime/World/CScriptSpecialFunction.cpp +++ b/Runtime/World/CScriptSpecialFunction.cpp @@ -184,8 +184,7 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId case ESpecialFunction::MapStation: { if (msg == EScriptObjectMessage::Action) { mgr.MapWorldInfo()->SetMapStationUsed(true); - const_cast(*mgr.GetWorld()->GetMapWorld()) - .RecalculateWorldSphere(*mgr.MapWorldInfo(), *mgr.GetWorld()); + mgr.GetWorld()->GetMapWorld()->RecalculateWorldSphere(*mgr.MapWorldInfo(), *mgr.GetWorld()); } break; } @@ -481,15 +480,17 @@ void CScriptSpecialFunction::PreRender(CStateManager&, const zeus::CFrustum& fru x1e4_28_frustumEntered = true; } -void CScriptSpecialFunction::AddToRenderer(const zeus::CFrustum&, const CStateManager& mgr) const { - if (!GetActive()) +void CScriptSpecialFunction::AddToRenderer(const zeus::CFrustum&, CStateManager& mgr) { + if (!GetActive()) { return; + } - if (xe8_function == ESpecialFunction::FogVolume && x1e4_30_) + if (xe8_function == ESpecialFunction::FogVolume && x1e4_30_) { EnsureRendered(mgr); + } } -void CScriptSpecialFunction::Render(const CStateManager& mgr) const { +void CScriptSpecialFunction::Render(CStateManager& mgr) { if (xe8_function == ESpecialFunction::FogVolume) { float z = mgr.IntegrateVisorFog(xfc_float1 * std::sin(CGraphics::GetSecondsMod900())); if (z > 0.f) { diff --git a/Runtime/World/CScriptSpecialFunction.hpp b/Runtime/World/CScriptSpecialFunction.hpp index 8e190f73e..0d5dc7935 100644 --- a/Runtime/World/CScriptSpecialFunction.hpp +++ b/Runtime/World/CScriptSpecialFunction.hpp @@ -125,8 +125,8 @@ public: void Think(float, CStateManager&) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void PreRender(CStateManager&, const zeus::CFrustum&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; - void Render(const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; + void Render(CStateManager&) override; std::optional GetTouchBounds() const override { return x1c8_touchBounds; } void SkipCinematic(CStateManager&); diff --git a/Runtime/World/CScriptSpiderBallWaypoint.hpp b/Runtime/World/CScriptSpiderBallWaypoint.hpp index 7fb1e7ba2..32d209bcf 100644 --- a/Runtime/World/CScriptSpiderBallWaypoint.hpp +++ b/Runtime/World/CScriptSpiderBallWaypoint.hpp @@ -19,8 +19,8 @@ public: CScriptSpiderBallWaypoint(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, bool, u32); void Accept(IVisitor&) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; - void Render(const CStateManager& mgr) const override { CActor::Render(mgr); } - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override {} + void Render(CStateManager& mgr) override { CActor::Render(mgr); } + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override {} std::optional GetTouchBounds() const override { return xfc_aabox; } void AccumulateBounds(const zeus::CVector3f& v); void BuildWaypointListAndBounds(CStateManager& mgr); diff --git a/Runtime/World/CScriptSpindleCamera.cpp b/Runtime/World/CScriptSpindleCamera.cpp index db2aa728d..a8dc0b06f 100644 --- a/Runtime/World/CScriptSpindleCamera.cpp +++ b/Runtime/World/CScriptSpindleCamera.cpp @@ -337,7 +337,7 @@ void CScriptSpindleCamera::Think(float dt, CStateManager& mgr) { } } -void CScriptSpindleCamera::Render(const CStateManager&) const { +void CScriptSpindleCamera::Render(CStateManager&) { // Empty } diff --git a/Runtime/World/CScriptSpindleCamera.hpp b/Runtime/World/CScriptSpindleCamera.hpp index 8d1a8f1b3..5f6fe7983 100644 --- a/Runtime/World/CScriptSpindleCamera.hpp +++ b/Runtime/World/CScriptSpindleCamera.hpp @@ -105,7 +105,7 @@ public: void Accept(IVisitor& visitor) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void Think(float, CStateManager&) override; - void Render(const CStateManager&) const override; + void Render(CStateManager&) override; void Reset(const zeus::CTransform& xf, CStateManager& mgr) override; void ProcessInput(const CFinalInput& input, CStateManager& mgr) override; }; diff --git a/Runtime/World/CScriptTargetingPoint.hpp b/Runtime/World/CScriptTargetingPoint.hpp index 92b61fe12..672f7366e 100644 --- a/Runtime/World/CScriptTargetingPoint.hpp +++ b/Runtime/World/CScriptTargetingPoint.hpp @@ -23,7 +23,7 @@ public: void Accept(IVisitor& visitor) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void Think(float, CStateManager&) override; - void Render(const CStateManager&) const override {} + void Render(CStateManager&) override {} bool GetLocked() const; }; diff --git a/Runtime/World/CScriptVisorFlare.cpp b/Runtime/World/CScriptVisorFlare.cpp index 895d6afcc..a1e87afb9 100644 --- a/Runtime/World/CScriptVisorFlare.cpp +++ b/Runtime/World/CScriptVisorFlare.cpp @@ -33,11 +33,12 @@ void CScriptVisorFlare::PreRender(CStateManager& stateMgr, const zeus::CFrustum& x11c_notInRenderLast = !stateMgr.RenderLast(x8_uid); } -void CScriptVisorFlare::AddToRenderer(const zeus::CFrustum&, const CStateManager& stateMgr) const { - if (x11c_notInRenderLast) +void CScriptVisorFlare::AddToRenderer(const zeus::CFrustum&, CStateManager& stateMgr) { + if (x11c_notInRenderLast) { EnsureRendered(stateMgr, stateMgr.GetPlayer().GetTranslation(), GetSortingBounds(stateMgr)); + } } -void CScriptVisorFlare::Render(const CStateManager& stateMgr) const { xe8_flare.Render(GetTranslation(), stateMgr); } +void CScriptVisorFlare::Render(CStateManager& stateMgr) { xe8_flare.Render(GetTranslation(), stateMgr); } } // namespace urde diff --git a/Runtime/World/CScriptVisorFlare.hpp b/Runtime/World/CScriptVisorFlare.hpp index f5a6883b1..0cda8755c 100644 --- a/Runtime/World/CScriptVisorFlare.hpp +++ b/Runtime/World/CScriptVisorFlare.hpp @@ -20,8 +20,8 @@ public: void Think(float, CStateManager& stateMgr) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) override; void PreRender(CStateManager&, const zeus::CFrustum&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; - void Render(const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; + void Render(CStateManager&) override; }; } // namespace urde diff --git a/Runtime/World/CScriptVisorGoo.cpp b/Runtime/World/CScriptVisorGoo.cpp index 298ba9cd2..ee559fbb6 100644 --- a/Runtime/World/CScriptVisorGoo.cpp +++ b/Runtime/World/CScriptVisorGoo.cpp @@ -101,11 +101,11 @@ void CScriptVisorGoo::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CActor::AcceptScriptMsg(msg, objId, mgr); } -void CScriptVisorGoo::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { +void CScriptVisorGoo::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { // Empty } -void CScriptVisorGoo::Render(const CStateManager& mgr) const { +void CScriptVisorGoo::Render(CStateManager& mgr) { // Empty } diff --git a/Runtime/World/CScriptVisorGoo.hpp b/Runtime/World/CScriptVisorGoo.hpp index df683ca51..e53bcf58f 100644 --- a/Runtime/World/CScriptVisorGoo.hpp +++ b/Runtime/World/CScriptVisorGoo.hpp @@ -30,8 +30,8 @@ public: void Accept(IVisitor& visitor) override; void Think(float, CStateManager& stateMgr) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; - void Render(const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; + void Render(CStateManager&) override; std::optional GetTouchBounds() const override; void Touch(CActor&, CStateManager&) override; }; diff --git a/Runtime/World/CScriptWater.cpp b/Runtime/World/CScriptWater.cpp index 14a7e74a3..92e1ba2d0 100644 --- a/Runtime/World/CScriptWater.cpp +++ b/Runtime/World/CScriptWater.cpp @@ -413,15 +413,17 @@ void CScriptWater::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) } } -void CScriptWater::AddToRenderer(const zeus::CFrustum& /*frustum*/, const CStateManager& mgr) const { - if (!xe4_30_outOfFrustum) { - zeus::CPlane plane(zeus::skUp, x34_transform.origin.z() + x130_bounds.max.z()); - zeus::CAABox renderBounds = GetSortingBounds(mgr); - mgr.AddDrawableActorPlane(*this, plane, renderBounds); +void CScriptWater::AddToRenderer(const zeus::CFrustum& /*frustum*/, CStateManager& mgr) { + if (xe4_30_outOfFrustum) { + return; } + + const zeus::CPlane plane(zeus::skUp, x34_transform.origin.z() + x130_bounds.max.z()); + const zeus::CAABox renderBounds = GetSortingBounds(mgr); + mgr.AddDrawableActorPlane(*this, plane, renderBounds); } -void CScriptWater::Render(const CStateManager& mgr) const { +void CScriptWater::Render(CStateManager& mgr) { if (x30_24_active && !xe4_30_outOfFrustum) { float zOffset = 0.5f * (x9c_renderBounds.max.z() + x9c_renderBounds.min.z()) - x34_transform.origin.z(); zeus::CAABox aabb = x9c_renderBounds.getTransformedAABox(zeus::CTransform::Translate( diff --git a/Runtime/World/CScriptWater.hpp b/Runtime/World/CScriptWater.hpp index d13e2f12a..3751aef0a 100644 --- a/Runtime/World/CScriptWater.hpp +++ b/Runtime/World/CScriptWater.hpp @@ -104,8 +104,8 @@ public: void Think(float, CStateManager&) override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void PreRender(CStateManager&, const zeus::CFrustum&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; - void Render(const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; + void Render(CStateManager&) override; void Touch(CActor&, CStateManager&) override; void CalculateRenderBounds() override; zeus::CAABox GetSortingBounds(const CStateManager&) const override; diff --git a/Runtime/World/CScriptWaypoint.cpp b/Runtime/World/CScriptWaypoint.cpp index 681a76b81..52c41f327 100644 --- a/Runtime/World/CScriptWaypoint.cpp +++ b/Runtime/World/CScriptWaypoint.cpp @@ -33,7 +33,7 @@ void CScriptWaypoint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender SendScriptMsgs(EScriptObjectState::Arrived, mgr, EScriptObjectMessage::None); } -void CScriptWaypoint::AddToRenderer(const zeus::CFrustum&, const CStateManager&) const { +void CScriptWaypoint::AddToRenderer(const zeus::CFrustum&, CStateManager&) { // Empty } diff --git a/Runtime/World/CScriptWaypoint.hpp b/Runtime/World/CScriptWaypoint.hpp index 101fb526e..0963963a5 100644 --- a/Runtime/World/CScriptWaypoint.hpp +++ b/Runtime/World/CScriptWaypoint.hpp @@ -25,7 +25,7 @@ public: void Accept(IVisitor& visitor) override; void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; TUniqueId FollowWaypoint(CStateManager& mgr) const; TUniqueId NextWaypoint(CStateManager& mgr) const; float GetSpeed() const { return xe8_speed; } diff --git a/Runtime/World/CSnakeWeedSwarm.cpp b/Runtime/World/CSnakeWeedSwarm.cpp index 0f5038380..76609926a 100644 --- a/Runtime/World/CSnakeWeedSwarm.cpp +++ b/Runtime/World/CSnakeWeedSwarm.cpp @@ -139,14 +139,17 @@ void CSnakeWeedSwarm::PreRender(CStateManager& mgr, const zeus::CFrustum& frustu } } -void CSnakeWeedSwarm::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const { - if (xe4_30_outOfFrustum) +void CSnakeWeedSwarm::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { + if (xe4_30_outOfFrustum) { return; + } - if (x1ec_particleGen1) + if (x1ec_particleGen1) { g_Renderer->AddParticleGen(*x1ec_particleGen1); - if (x1f4_particleGen2) + } + if (x1f4_particleGen2) { g_Renderer->AddParticleGen(*x1f4_particleGen2); + } if (x90_actorLights) { for (const auto& modelData : x1b0_modelData) { @@ -158,8 +161,9 @@ void CSnakeWeedSwarm::AddToRenderer(const zeus::CFrustum& frustum, const CStateM } u32 posesToBuild = -1; - for (u32 i = 0; i < x134_boids.size(); ++i) + for (u32 i = 0; i < x134_boids.size(); ++i) { RenderBoid(i, x134_boids[i], posesToBuild); + } CGraphics::DisableAllLights(); } diff --git a/Runtime/World/CSnakeWeedSwarm.hpp b/Runtime/World/CSnakeWeedSwarm.hpp index def7ca182..03ae8e944 100644 --- a/Runtime/World/CSnakeWeedSwarm.hpp +++ b/Runtime/World/CSnakeWeedSwarm.hpp @@ -103,7 +103,7 @@ public: std::optional GetTouchBounds() const override; void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void PreRender(CStateManager&, const zeus::CFrustum&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; void Touch(CActor&, CStateManager&) override; void Think(float, CStateManager&) override; diff --git a/Runtime/World/CWallCrawlerSwarm.cpp b/Runtime/World/CWallCrawlerSwarm.cpp index 3c162eddb..57f9658bb 100644 --- a/Runtime/World/CWallCrawlerSwarm.cpp +++ b/Runtime/World/CWallCrawlerSwarm.cpp @@ -983,7 +983,7 @@ void CWallCrawlerSwarm::RenderParticles() const { } } -void CWallCrawlerSwarm::AddToRenderer(const zeus::CFrustum&, const CStateManager& mgr) const { +void CWallCrawlerSwarm::AddToRenderer(const zeus::CFrustum&, CStateManager& mgr) { if (!GetActive()) { return; } @@ -1082,7 +1082,7 @@ void CWallCrawlerSwarm::RenderBoid(const CBoid* boid, u32& drawMask, bool therma } } -void CWallCrawlerSwarm::Render(const CStateManager& mgr) const { +void CWallCrawlerSwarm::Render(CStateManager& mgr) { SCOPED_GRAPHICS_DEBUG_GROUP(fmt::format(fmt("CWallCrawlerSwarm::Render {} {} {}"), x8_uid, xc_editorId, x10_name).c_str(), zeus::skOrange); u32 drawMask = 0xffffffff; diff --git a/Runtime/World/CWallCrawlerSwarm.hpp b/Runtime/World/CWallCrawlerSwarm.hpp index f88871b9c..a7c934f2a 100644 --- a/Runtime/World/CWallCrawlerSwarm.hpp +++ b/Runtime/World/CWallCrawlerSwarm.hpp @@ -195,8 +195,8 @@ public: void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override; void Think(float, CStateManager&) override; void PreRender(CStateManager&, const zeus::CFrustum&) override; - void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const override; - void Render(const CStateManager&) const override; + void AddToRenderer(const zeus::CFrustum&, CStateManager&) override; + void Render(CStateManager&) override; bool CanRenderUnsorted(const CStateManager&) const override; void CalculateRenderBounds() override; std::optional GetTouchBounds() const override; diff --git a/Runtime/World/CWallWalker.cpp b/Runtime/World/CWallWalker.cpp index df83a32f2..e76ae0432 100644 --- a/Runtime/World/CWallWalker.cpp +++ b/Runtime/World/CWallWalker.cpp @@ -164,7 +164,7 @@ void CWallWalker::Think(float dt, CStateManager& mgr) { } } -void CWallWalker::Render(const CStateManager& mgr) const { CPatterned::Render(mgr); } +void CWallWalker::Render(CStateManager& mgr) { CPatterned::Render(mgr); } void CWallWalker::UpdateWPDestination(CStateManager& mgr) { if (TCastToPtr wp = mgr.ObjectById(x2dc_destObj)) { diff --git a/Runtime/World/CWallWalker.hpp b/Runtime/World/CWallWalker.hpp index ab51512d6..133af55b2 100644 --- a/Runtime/World/CWallWalker.hpp +++ b/Runtime/World/CWallWalker.hpp @@ -55,7 +55,7 @@ public: void PreThink(float, CStateManager&) override; void Think(float, CStateManager&) override; - void Render(const CStateManager&) const override; + void Render(CStateManager&) override; const CCollisionPrimitive* GetCollisionPrimitive() const override { return &x590_colSphere; } void UpdateWPDestination(CStateManager&); }; diff --git a/Runtime/World/CWorldLight.hpp b/Runtime/World/CWorldLight.hpp index 055d02a39..4302617c2 100644 --- a/Runtime/World/CWorldLight.hpp +++ b/Runtime/World/CWorldLight.hpp @@ -29,8 +29,14 @@ private: float x40_ = 0.f; public: - CWorldLight(const CWorldLight&) = default; explicit CWorldLight(CInputStream& in); + + CWorldLight(const CWorldLight&) = default; + CWorldLight& operator=(const CWorldLight&) = default; + + CWorldLight(CWorldLight&&) = default; + CWorldLight& operator=(CWorldLight&&) = default; + EWorldLightType GetLightType() const { return x0_type; } const zeus::CVector3f& GetDirection() const { return x1c_direction; } const zeus::CVector3f& GetPosition() const { return x10_position; } diff --git a/Runtime/World/CWorldTransManager.cpp b/Runtime/World/CWorldTransManager.cpp index 43091ff55..067978fe8 100644 --- a/Runtime/World/CWorldTransManager.cpp +++ b/Runtime/World/CWorldTransManager.cpp @@ -44,11 +44,12 @@ CWorldTransManager::SModelDatas::SModelDatas(const CAnimRes& samusRes) : x0_samu } void CWorldTransManager::UpdateLights(float dt) { - if (!x4_modelData) + if (!x4_modelData) { return; + } x4_modelData->x1a0_lights.clear(); - zeus::CVector3f lightPos(0.f, 10.f, 0.f); + constexpr zeus::CVector3f lightPos(0.f, 10.f, 0.f); CLight spot = CLight::BuildSpot(lightPos, zeus::skBack, zeus::skWhite, 90.f); spot.SetAttenuation(1.f, 0.f, 0.f);