mirror of
https://github.com/Relintai/godot-lportal.git
synced 2024-11-11 10:52:09 +01:00
Shadow caster list working
This commit is contained in:
parent
561aa566b8
commit
15ab53250d
21
lroom.cpp
21
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<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
|
||||
// (it might be expensive)
|
||||
void LRoom::FinalizeVisibility(LRoomManager &manager)
|
||||
|
4
lroom.h
4
lroom.h
@ -108,6 +108,8 @@ public:
|
||||
// (it might be expensive)
|
||||
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);
|
||||
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,
|
||||
// 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.
|
||||
void SoftShow(VisualInstance * pVI, bool bShow) const;
|
||||
static void SoftShow(VisualInstance * pVI, bool bShow);
|
||||
|
||||
// whether lportal thinks this room is currently visible
|
||||
// this allows us to show / hide dobs as they cross room boundaries
|
||||
|
@ -698,6 +698,14 @@ void LRoomManager::FrameUpdate()
|
||||
// set soft visibility of objects within visible rooms
|
||||
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
|
||||
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()
|
||||
{
|
||||
// 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<int> * pTemp = m_pCurr_VisibleRoomList;
|
||||
m_pCurr_VisibleRoomList = m_pPrev_VisibleRoomList;
|
||||
m_pPrev_VisibleRoomList = pTemp;
|
||||
|
||||
}
|
||||
|
||||
|
@ -97,6 +97,7 @@ private:
|
||||
void FrameUpdate();
|
||||
void FrameUpdate_Prepare();
|
||||
void FrameUpdate_FinalizeRooms();
|
||||
void FrameUpdate_AddShadowCasters();
|
||||
void FrameUpdate_FinalizeVisibility_WithinRooms();
|
||||
|
||||
// debugging emulate view frustum
|
||||
|
Loading…
Reference in New Issue
Block a user