Merge remote-tracking branch 'origin/master' into omegapirate

This commit is contained in:
Luke Street 2020-04-09 20:06:33 -04:00
commit 6b814262fc
157 changed files with 707 additions and 530 deletions

View File

@ -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.

View File

@ -26,7 +26,7 @@ CFactoryFnReturn FAudioTranslationTableFactory(const SObjectTag& tag, CInputStre
return TToken<std::vector<u16>>::GetIObjObjectFor(std::move(obj));
}
CSfxManager::CSfxChannel CSfxManager::m_channels[4];
std::array<CSfxManager::CSfxChannel, 4> 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<CSfxWrapper>(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<CSfxEmitterWrapper>(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<TAreaId, 10>& 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<TAreaId, 10>& 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;

View File

@ -1,5 +1,6 @@
#pragma once
#include <array>
#include <memory>
#include <unordered_set>
#include <vector>
@ -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<amuse::Emitter> 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<CSfxChannel, 4> m_channels;
static ESfxChannels m_currentChannel;
static bool m_doUpdate;
static void* m_usedSounds;

View File

@ -6,6 +6,7 @@
#include "Runtime/CStringExtras.hpp"
#include <algorithm>
#include <array>
#include <cstdlib>
#include <cstring>
#include <memory>
@ -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<u16, 11> x4a_pad;
};
struct SDSPStreamInfo {
@ -74,7 +75,7 @@ struct SDSPStream : boo::IAudioVoiceCallback {
u8 xec_readState = 0; // 0: NoRead 1: Read 2: ReadWrap
std::optional<CDvdFile> m_file;
std::shared_ptr<IDvdRequest> m_readReqs[2];
std::array<std::shared_ptr<IDvdRequest>, 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,14 +259,14 @@ 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;
@ -273,14 +274,15 @@ struct SDSPStream : boo::IAudioVoiceCallback {
}
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<float, 8> 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<float, 8> coefs{};
m_booVoice->setMonoChannelLevels(nullptr, coefs.data(), true);
xe8_silent = true;
x0_active = false;
}
@ -399,12 +404,14 @@ 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;
@ -425,10 +432,10 @@ struct SDSPStream : boo::IAudioVoiceCallback {
UpdateStreamVolume(vol);
}
static SDSPStream g_Streams[4];
static std::array<SDSPStream, 4> g_Streams;
};
SDSPStream SDSPStream::g_Streams[4] = {};
std::array<SDSPStream, 4> 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<IDvdRequest> m_dvdReq;
// DVDFileInfo x80_dvdHandle;
static CDSPStreamManager g_Streams[4];
static std::array<CDSPStreamManager, 4> 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,11 +499,12 @@ 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, 4> 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<SDSPPlayer, 2>;
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];

View File

@ -285,24 +285,26 @@ void CStateManager::UpdateThermalVisor() {
}
}
void CStateManager::RendererDrawCallback(const void* drawable, const void* ctx, int type) {
const CStateManager& mgr = *static_cast<const CStateManager*>(ctx);
void CStateManager::RendererDrawCallback(void* drawable, void* ctx, int type) {
CStateManager& mgr = *static_cast<CStateManager*>(ctx);
switch (type) {
case 0: {
const CActor& actor = *static_cast<const CActor*>(drawable);
if (actor.xc8_drawnToken == mgr.x8dc_objectDrawToken)
CActor& actor = *static_cast<CActor*>(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<CActor&>(actor).xc8_drawnToken = mgr.x8dc_objectDrawToken;
actor.xc8_drawnToken = mgr.x8dc_objectDrawToken;
break;
}
case 1:
static_cast<const CSimpleShadow*>(drawable)->Render(mgr.x8f0_shadowTex);
static_cast<CSimpleShadow*>(drawable)->Render(mgr.x8f0_shadowTex);
break;
case 2:
static_cast<const CDecal*>(drawable)->Render();
static_cast<CDecal*>(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<CActor&>(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<CActor&>(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<const CActor*>(GetObjectById(id)))
if (!thermal || ent->xe6_27_thermalVisorFlags & 0x1)
for (const TUniqueId id : x86c_stateManagerContainer->xf370_) {
if (auto* ent = static_cast<CActor*>(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<const CActor*>(GetObjectById(id)))
if (actor->xe6_27_thermalVisorFlags & 0x1)
for (const TUniqueId id : x86c_stateManagerContainer->xf39c_renderLast) {
if (auto* actor = static_cast<CActor*>(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<const CActor*>(GetObjectById(id)))
if (actor->xe6_27_thermalVisorFlags & 0x2)
for (const TUniqueId id : x86c_stateManagerContainer->xf370_) {
if (auto* actor = static_cast<CActor*>(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<const CActor*>(GetObjectById(id)))
if (!thermal || actor->xe6_27_thermalVisorFlags & 0x2)
for (const TUniqueId id : x86c_stateManagerContainer->xf39c_renderLast) {
if (auto* actor = static_cast<CActor*>(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<CActor> actor = GetObjectById(node)) {
void CStateManager::RecursiveDrawTree(TUniqueId node) {
if (const TCastToPtr<CActor> 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<CActor*>(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,
static constexpr CMaterialList incList(EMaterialTypes::Solid);
static constexpr CMaterialList exList(EMaterialTypes::ProjectilePassthrough, EMaterialTypes::Player,
EMaterialTypes::Occluder, EMaterialTypes::Character);
static const CMaterialFilter filter(incList, exList, CMaterialFilter::EFilterType::IncludeExclude);
static constexpr CMaterialFilter filter(incList, exList, CMaterialFilter::EFilterType::IncludeExclude);
std::optional<zeus::CAABox> bounds = damagee.GetTouchBounds();
if (!bounds)

View File

@ -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<CRelayTracker>&, const std::weak_ptr<CMapWorldInfo>&,
@ -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<CLight>& 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);

View File

@ -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
}

View File

@ -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);

View File

@ -104,9 +104,11 @@ void CCameraFilterPass<S>::DisableFilter(float time) {
}
template <class S>
void CCameraFilterPass<S>::Draw() const {
if (m_shader)
const_cast<S&>(*m_shader).DrawFilter(x8_shape, x18_curColor, GetT(x4_nextType == EFilterType::Passthru));
void CCameraFilterPass<S>::Draw() {
if (!m_shader) {
return;
}
m_shader->DrawFilter(x8_shape, x18_curColor, GetT(x4_nextType == EFilterType::Passthru));
}
float CCameraFilterPassBase::GetT(bool invert) const {

View File

@ -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 <class S>
@ -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<CCameraFilterPassBase> m_filter;
public:
@ -107,8 +107,8 @@ class CCameraBlurPass {
// bool x2d_noPersistentCopy = false;
// u32 x30_persistentBuf = 0;
mutable std::optional<CCameraBlurFilter> m_shader;
mutable std::optional<CXRayBlurFilter> m_xrayShader;
std::optional<CCameraBlurFilter> m_shader;
std::optional<CXRayBlurFilter> m_xrayShader;
public:
void Draw(bool clearDepth = false);

View File

@ -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<CGameCamera*>(cam)->Render(mgr);
}
}
void CCameraManager::SetupBallCamera(CStateManager& mgr) {

View File

@ -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; }

View File

@ -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
}

View File

@ -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,

View File

@ -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&);

View File

@ -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<float, s32> 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<float, s32> 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());
}

View File

@ -1,5 +1,7 @@
#pragma once
#include <array>
#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<s32, 4> x8_anims{};
std::array<float, 4> x18_angles{};
float x28_hWeight = 0.f;
float x2c_hWeightVel = 0.f;
float x30_vWeight = 0.f;

View File

@ -223,6 +223,7 @@ public:
std::shared_ptr<CSkinnedModel> GetXRayModel() const { return xf4_xrayModel; }
void SetInfraModel(const TLockedToken<CModel>& model, const TLockedToken<CSkinRules>& skinRules);
std::shared_ptr<CSkinnedModel> GetInfraModel() const { return xf8_infraModel; }
TLockedToken<CSkinnedModel>& GetModelData() { return xd8_modelData; }
const TLockedToken<CSkinnedModel>& GetModelData() const { return xd8_modelData; }
static void PoseSkinnedModel(CSkinnedModel& model, const CPoseAsTransforms& pose, const CModelFlags& drawFlags,

View File

@ -12,6 +12,7 @@ class IMetaAnim;
class CAnimationDatabase {
public:
virtual ~CAnimationDatabase() = default;
virtual const std::shared_ptr<IMetaAnim>& GetMetaAnim(s32) const = 0;
virtual u32 GetNumMetaAnims() const = 0;
virtual const char* GetMetaAnimName(s32) const = 0;

View File

@ -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<rstl::reserved_vector<std::pair<s32, float>, 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<s32, float>& 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:

View File

@ -13,7 +13,7 @@ class CLayoutDescription {
public:
class CScaledLayoutDescription {
TLockedToken<CCharLayoutInfo> x0_layoutToken;
float xc_scale;
float xc_scale = 0.0f;
std::optional<zeus::CVector3f> x10_scaleVec;
public:

View File

@ -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<CAssetId, CAssetId>& 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;

View File

@ -8,6 +8,7 @@ class IMetaTrans;
class CTransitionDatabase {
public:
virtual ~CTransitionDatabase() = default;
virtual const std::shared_ptr<IMetaTrans>& GetMetaTrans(u32, u32) const = 0;
};

View File

@ -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;
};

View File

@ -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<CParticleGen*>((void*)drawable->GetData())->Render();
static_cast<CParticleGen*>(drawable->GetData())->Render();
break;
}
case EDrawableType::WorldSurface: {
// SetupRendererStates();
CBooSurface* surf = static_cast<CBooSurface*>((void*)drawable->GetData());
auto* surf = static_cast<CBooSurface*>(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;
}

View File

@ -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;

View File

@ -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; }
};

View File

@ -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;

View File

@ -46,9 +46,9 @@ class CRainSplashGenerator {
std::vector<SRainSplash> 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;

View File

@ -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<void(void*, const zeus::CVector3f&)>;
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;

View File

@ -1,28 +1,28 @@
#include "Runtime/GuiSys/CWordBreakTables.hpp"
#include <iterator>
#include <array>
#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<CCharacterIdentifier, 63> 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<CCharacterIdentifier, 87> 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 auto search = rstl::binary_find(sCantBeginChars.cbegin(), sCantBeginChars.cend(), ch,
[](const CCharacterIdentifier& item) { return item.chr; });
if (search == std::cend(gCantBeginChars))
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 auto search = rstl::binary_find(sCantEndChars.cbegin(), sCantEndChars.cend(), ch,
[](const CCharacterIdentifier& item) { return item.chr; });
if (search == std::cend(gCantEndChars))
if (search == sCantEndChars.cend()) {
return 5;
}
return search->rank;
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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) {

View File

@ -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,

View File

@ -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());
}

View File

@ -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,

View File

@ -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<zeus::CAABox> 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) {

View File

@ -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<zeus::CAABox> 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;

View File

@ -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));

View File

@ -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,

View File

@ -56,12 +56,12 @@ 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<const CActor*>(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);
}

View File

@ -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<zeus::CAABox> 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<zeus::CAABox> 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;

View File

@ -1,5 +1,7 @@
#include "Runtime/MP1/World/CFlaahgraTentacle.hpp"
#include <array>
#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<SSphereJointInfo, 3> 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<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
if (const TCastToPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
trigger->SetForceVector(x580_forceVector);
}
break;
}
case EScriptObjectMessage::Touched: {
if (TCastToConstPtr<CCollisionActor> colAct = mgr.GetObjectById(uid)) {
if (const TCastToConstPtr<CCollisionActor> 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<CJointCollisionDescription>& 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<CJointCollisionDescription> jointList;
AddSphereCollisionList(skJointList, 3, jointList);
AddSphereCollisionList(skJointList.data(), skJointList.size(), jointList);
x56c_collisionManager =
std::make_unique<CCollisionActorManager>(mgr, GetUniqueId(), GetAreaIdAlways(), jointList, true);
for (u32 i = 0; i < x56c_collisionManager->GetNumCollisionActors(); ++i) {
const CJointCollisionDescription& desc = x56c_collisionManager->GetCollisionDescFromIndex(i);
if (TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(desc.GetCollisionActorId())) {
if (const TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(desc.GetCollisionActorId())) {
colAct->SetMaterialFilter(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Player},
{EMaterialTypes::Character,
EMaterialTypes::CollisionActor,
@ -119,45 +131,49 @@ 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();
}
}
}
RemoveMaterial(EMaterialTypes::Solid, EMaterialTypes::Target, EMaterialTypes::Orbit, mgr);
AddMaterial(EMaterialTypes::Scannable, mgr);
}
zeus::CVector3f CFlaahgraTentacle::GetAimPosition(const CStateManager& mgr, float dt) const {
if (TCastToConstPtr<CCollisionActor> colAct = mgr.GetObjectById(x57c_tentacleTipAct))
if (const TCastToConstPtr<CCollisionActor> 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<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
if (const TCastToPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
trigger->SetForceVector(x580_forceVector);
}
}
void CFlaahgraTentacle::RetractTentacle(CStateManager& mgr) {
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Crouch);
if (TCastToPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
if (const TCastToPtr<CScriptTrigger> 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<CScriptTrigger> trigger = mgr.GetObjectById(uid)) {
const TUniqueId uid = mgr.GetIdForScript(conn.x8_objId);
if (const TCastToConstPtr<CScriptTrigger> 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)
if (x578_ > 0.f) {
return true;
}
if (x574_ > 0.f || mgr.GetPlayer().IsInWaterMovement())
if (x574_ > 0.f || mgr.GetPlayer().IsInWaterMovement()) {
return false;
}
if (TCastToConstPtr<CCollisionActor> colAct = mgr.GetObjectById(x57c_tentacleTipAct)) {
float mag = (colAct->GetTranslation().toVec2f() - mgr.GetPlayer().GetTranslation().toVec2f()).magSquared();
if (const TCastToConstPtr<CCollisionActor> 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,16 +221,19 @@ 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<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
if (trigger->IsPlayerTriggerProc())
if (const TCastToConstPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
if (trigger->IsPlayerTriggerProc()) {
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
}
}
} else if (msg == EStateMsg::Deactivate) {
x58e_24_ = false;
}
@ -220,19 +242,21 @@ 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<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
if (const TCastToConstPtr<CScriptTrigger> trigger = mgr.ObjectById(x58c_triggerId)) {
if (trigger->IsPlayerTriggerProc()) {
if (x570_ > 1.f) {
RetractTentacle(mgr);
ExtractTentacle(mgr);
} else
} else {
x570_ += arg;
}
}
}
}
}
}

View File

@ -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<CCollisionActorManager> 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<CJointCollisionDescription>&);
void AddSphereCollisionList(const SSphereJointInfo* sphereJoints, size_t jointCount,
std::vector<CJointCollisionDescription>& outJoints);
void SetupCollisionManager(CStateManager&);
void ExtractTentacle(CStateManager&);
void RetractTentacle(CStateManager&);

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);
}

View File

@ -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<zeus::CAABox> 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;

View File

@ -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<CJointCollisionDescription> 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<CCollisionActor> 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;

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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) {

View File

@ -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;

View File

@ -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)

View File

@ -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,

View File

@ -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_);

View File

@ -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();

View File

@ -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;

View File

@ -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<zeus::CAABox> GetTouchBounds() const override;

View File

@ -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<zeus::CAABox> 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();
}

View File

@ -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<zeus::CAABox> 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;

View File

@ -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);

View File

@ -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;

View File

@ -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_);

View File

@ -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;

View File

@ -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);

View File

@ -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<zeus::CVector3f&>(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<CQuadDecal&>(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<CQuadDecal&>(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);

View File

@ -55,8 +55,8 @@ class CDecal {
public:
CDecal(const TToken<CDecalDescription>& 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);

View File

@ -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();

View File

@ -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&);

View File

@ -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);
}

View File

@ -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);

View File

@ -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<zeus::CAABox> CFlameThrower::GetTouchBounds() const { return std::nullopt; }

View File

@ -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<zeus::CAABox> GetTouchBounds() const override;
void Touch(CActor& actor, CStateManager& mgr) override;
void SetTransform(const zeus::CTransform& xf, float);

View File

@ -254,7 +254,7 @@ void CGunWeapon::PointGenerator(void* ctx, const std::vector<std::pair<zeus::CVe
}
void CGunWeapon::Draw(bool drawSuitArm, const CStateManager& mgr, const zeus::CTransform& xf, const CModelFlags& flags,
const CActorLights* lights) const {
const CActorLights* lights) {
if (!x218_26_loaded)
return;
@ -498,7 +498,7 @@ void CGunWeapon::Unload(CStateManager& mgr) {
bool CGunWeapon::IsLoaded() const { return x218_26_loaded; }
void CGunWeapon::DrawHologram(const CStateManager& mgr, const zeus::CTransform& xf, const CModelFlags& flags) const {
void CGunWeapon::DrawHologram(const CStateManager& mgr, const zeus::CTransform& xf, const CModelFlags& flags) {
if (!x218_26_loaded)
return;
@ -510,9 +510,9 @@ void CGunWeapon::DrawHologram(const CStateManager& mgr, const zeus::CTransform&
CGraphics::SetModelMatrix(xf * zeus::CTransform::Scale(x10_solidModelData->GetScale()));
// CGraphics::DisableAllLights();
// g_Renderer->SetAmbientColor(zeus::skWhite);
CSkinnedModel& model = const_cast<CSkinnedModel&>(*x60_holoModelData->GetAnimationData()->GetModelData());
CSkinnedModel& model = *x60_holoModelData->GetAnimationData()->GetModelData();
model.GetModelInst()->ActivateLights({CLight::BuildLocalAmbient({}, zeus::skWhite)});
const_cast<CGunWeapon*>(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();
}

View File

@ -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; }

View File

@ -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;

View File

@ -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;
};

View File

@ -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);

View File

@ -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

View File

@ -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();

View File

@ -266,9 +266,9 @@ private:
u32 _dummy = 0;
};
mutable CTexturedQuadFilter m_screenQuad{EFilterType::Blend, CGraphics::g_SpareTexture.get(),
CTexturedQuadFilter m_screenQuad{EFilterType::Blend, CGraphics::g_SpareTexture.get(),
CTexturedQuadFilter::ZTest::GEqualZWrite};
mutable CAABoxShader m_aaboxShader{true};
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);

View File

@ -1,5 +1,7 @@
#include "Runtime/Weapon/CPowerBeam.hpp"
#include <array>
#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<u16, 2> 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) {

View File

@ -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);
}

View File

@ -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<zeus::CAABox> GetTouchBounds() const override { return std::nullopt; }
void Touch(CActor&, CStateManager&) override { /*x158_24_canStartFilter; */
}

View File

@ -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
}

View File

@ -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;

View File

@ -3,47 +3,64 @@
namespace urde {
void CWeaponMgr::Add(TUniqueId uid, EWeaponType type) {
x0_weapons.insert(std::make_pair(uid, rstl::reserved_vector<s32, 15>()));
x0_weapons[uid].resize(15);
++x0_weapons[uid][u32(type)];
auto iter = x0_weapons.emplace(uid, rstl::reserved_vector<s32, 15>()).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];
s32 totalActive = 0;
for (size_t i = 0; i < 10; ++i) {
totalActive += weapon[i];
}
if (totalActive != 0) {
return;
}
if (totalActive == 0)
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;
}
auto& weapon = x0_weapons[uid];
weapon[size_t(type)]--;
if (weapon[size_t(type)] > 0) {
return;
}
x0_weapons[uid][u32(type)]--;
if (x0_weapons[uid][u32(type)] <= 0)
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

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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;
};

View File

@ -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;

View File

@ -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

Some files were not shown because too many files have changed in this diff Show More