From 15ab53250d0d13feea816d4ff00a26a4254dbf10 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Wed, 25 Sep 2019 16:35:14 +0100 Subject: [PATCH] Shadow caster list working --- lroom.cpp | 21 ++++++++++++++++++++- lroom.h | 4 +++- lroom_manager.cpp | 23 +++++++++++++++++++---- lroom_manager.h | 1 + 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/lroom.cpp b/lroom.cpp index 606450e..b021a30 100644 --- a/lroom.cpp +++ b/lroom.cpp @@ -129,7 +129,7 @@ LRoom * LRoom::DOB_Update(LRoomManager &manager, Spatial * pDOB) // objects can still be rendered outside immediate view for casting shadows. // All objects in view (that are set to cast shadows) should cast shadows, so the actual // shown objects are a superset of the softshown. -void LRoom::SoftShow(VisualInstance * pVI, bool bShow) const +void LRoom::SoftShow(VisualInstance * pVI, bool bShow) { // hijack this layer number uint32_t mask = pVI->get_layer_mask(); @@ -166,6 +166,25 @@ void LRoom::SoftShow(VisualInstance * pVI, bool bShow) const } +// naive version, adds all the non visible objects in visible rooms as shadow casters +void LRoom::AddShadowCasters(LRoomManager &manager) +{ + int last_sob = m_iFirstSOB + m_iNumSOBs; + for (int n=m_iFirstSOB; n * pTemp = m_pCurr_VisibleRoomList; + m_pCurr_VisibleRoomList = m_pPrev_VisibleRoomList; + m_pPrev_VisibleRoomList = pTemp; + + // draw debug FrameUpdate_DrawDebug(cam, *pRoom); @@ -735,6 +743,17 @@ void LRoomManager::FrameUpdate_FinalizeRooms() } } +void LRoomManager::FrameUpdate_AddShadowCasters() +{ + // simple for the moment, add all objects in visible rooms as casters if they are not already visible + for (int n=0; nsize(); n++) + { + int r = (*m_pCurr_VisibleRoomList)[n]; + m_Rooms[r].AddShadowCasters(*this); + } + +} + void LRoomManager::FrameUpdate_FinalizeVisibility_WithinRooms() { // and hide all the dobs that are in visible rooms that haven't been made visible @@ -747,10 +766,6 @@ void LRoomManager::FrameUpdate_FinalizeVisibility_WithinRooms() m_Rooms[r].FinalizeVisibility(*this); } - // swap the current and previous visible room list - LVector * pTemp = m_pCurr_VisibleRoomList; - m_pCurr_VisibleRoomList = m_pPrev_VisibleRoomList; - m_pPrev_VisibleRoomList = pTemp; } diff --git a/lroom_manager.h b/lroom_manager.h index 9c06af7..836fbe8 100644 --- a/lroom_manager.h +++ b/lroom_manager.h @@ -97,6 +97,7 @@ private: void FrameUpdate(); void FrameUpdate_Prepare(); void FrameUpdate_FinalizeRooms(); + void FrameUpdate_AddShadowCasters(); void FrameUpdate_FinalizeVisibility_WithinRooms(); // debugging emulate view frustum