Shadow caster list working

This commit is contained in:
lawnjelly 2019-09-25 16:35:14 +01:00 committed by GitHub
parent 561aa566b8
commit 15ab53250d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 6 deletions

View File

@ -129,7 +129,7 @@ LRoom * LRoom::DOB_Update(LRoomManager &manager, Spatial * pDOB)
// objects can still be rendered outside immediate view for casting shadows. // 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 // All objects in view (that are set to cast shadows) should cast shadows, so the actual
// shown objects are a superset of the softshown. // 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 // hijack this layer number
uint32_t mask = pVI->get_layer_mask(); 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<last_sob; n++)
{
bool bVisible = manager.m_BF_visible_SOBs.GetBit(n) != 0;
// already in list
if (bVisible)
continue;
manager.m_BF_render_SOBs.SetBit(n, true);
manager.m_RenderList_SOBs.push_back(n);
}
}
// hide all the objects not hit on this frame .. instead of calling godot hide without need // hide all the objects not hit on this frame .. instead of calling godot hide without need
// (it might be expensive) // (it might be expensive)
void LRoom::FinalizeVisibility(LRoomManager &manager) void LRoom::FinalizeVisibility(LRoomManager &manager)

View File

@ -108,6 +108,8 @@ public:
// (it might be expensive) // (it might be expensive)
void FinalizeVisibility(LRoomManager &manager); void FinalizeVisibility(LRoomManager &manager);
// naive version, adds all the non visible objects in visible rooms as shadow casters
void AddShadowCasters(LRoomManager &manager);
void DOB_Add(const LDob &dob); void DOB_Add(const LDob &dob);
const LDob &DOB_Get(unsigned int ui) const {return m_DOBs[ui];} const LDob &DOB_Get(unsigned int ui) const {return m_DOBs[ui];}
@ -126,7 +128,7 @@ private:
// instead of directly showing and hiding objects we now set their layer, // instead of directly showing and hiding objects we now set their layer,
// and the camera will hide them with a cull mask. This is so that // and the camera will hide them with a cull mask. This is so that
// objects can still be rendered outside immediate view for casting shadows. // objects can still be rendered outside immediate view for casting shadows.
void SoftShow(VisualInstance * pVI, bool bShow) const; static void SoftShow(VisualInstance * pVI, bool bShow);
// whether lportal thinks this room is currently visible // whether lportal thinks this room is currently visible
// this allows us to show / hide dobs as they cross room boundaries // this allows us to show / hide dobs as they cross room boundaries

View File

@ -698,6 +698,14 @@ void LRoomManager::FrameUpdate()
// set soft visibility of objects within visible rooms // set soft visibility of objects within visible rooms
FrameUpdate_FinalizeVisibility_WithinRooms(); FrameUpdate_FinalizeVisibility_WithinRooms();
FrameUpdate_AddShadowCasters();
// swap the current and previous visible room list
LVector<int> * pTemp = m_pCurr_VisibleRoomList;
m_pCurr_VisibleRoomList = m_pPrev_VisibleRoomList;
m_pPrev_VisibleRoomList = pTemp;
// draw debug // draw debug
FrameUpdate_DrawDebug(cam, *pRoom); 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; n<m_pCurr_VisibleRoomList->size(); n++)
{
int r = (*m_pCurr_VisibleRoomList)[n];
m_Rooms[r].AddShadowCasters(*this);
}
}
void LRoomManager::FrameUpdate_FinalizeVisibility_WithinRooms() void LRoomManager::FrameUpdate_FinalizeVisibility_WithinRooms()
{ {
// and hide all the dobs that are in visible rooms that haven't been made visible // 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); m_Rooms[r].FinalizeVisibility(*this);
} }
// swap the current and previous visible room list
LVector<int> * pTemp = m_pCurr_VisibleRoomList;
m_pCurr_VisibleRoomList = m_pPrev_VisibleRoomList;
m_pPrev_VisibleRoomList = pTemp;
} }

View File

@ -97,6 +97,7 @@ private:
void FrameUpdate(); void FrameUpdate();
void FrameUpdate_Prepare(); void FrameUpdate_Prepare();
void FrameUpdate_FinalizeRooms(); void FrameUpdate_FinalizeRooms();
void FrameUpdate_AddShadowCasters();
void FrameUpdate_FinalizeVisibility_WithinRooms(); void FrameUpdate_FinalizeVisibility_WithinRooms();
// debugging emulate view frustum // debugging emulate view frustum