mirror of
https://github.com/Relintai/godot-lportal.git
synced 2024-11-11 10:52:09 +01:00
Refactoring SOBs out of lrooms
This commit is contained in:
parent
eca14bea42
commit
fe83f1374e
72
lroom.cpp
72
lroom.cpp
@ -341,21 +341,25 @@ void LRoom::DetermineVisibility_Recursive(LRoomManager &manager, int depth, cons
|
||||
FirstTouch(manager);
|
||||
|
||||
|
||||
#define LPORTAL_CULL_STATIC
|
||||
#ifdef LPORTAL_CULL_STATIC
|
||||
|
||||
// clip all objects in this room to the clipping planes
|
||||
int last_sob = m_iFirstSOB + m_iNumSOBs;
|
||||
for (int n=m_iFirstSOB; n<last_sob; n++)
|
||||
{
|
||||
LSob &sob = manager.m_SOBs[n];
|
||||
// for (int n=0; n<m_SOBs.size(); n++)
|
||||
// {
|
||||
// LSob &sob = m_SOBs[n];
|
||||
|
||||
// already determined to be visible through another portal
|
||||
if (sob.m_bVisible)
|
||||
//if (sob.m_bVisible)
|
||||
//continue;
|
||||
|
||||
|
||||
//LPRINT_RUN(2, "sob " + itos(n) + " " + sob.GetSpatial()->get_name());
|
||||
// already determined to be visible through another portal
|
||||
if (manager.m_BF_visible_SOBs.GetBit(n))
|
||||
{
|
||||
//LPRINT_RUN(2, "\talready visible");
|
||||
continue;
|
||||
}
|
||||
|
||||
bool bShow = true;
|
||||
|
||||
@ -384,61 +388,17 @@ void LRoom::DetermineVisibility_Recursive(LRoomManager &manager, int depth, cons
|
||||
}
|
||||
|
||||
if (bShow)
|
||||
{
|
||||
sob.m_bVisible = true;
|
||||
// sob is renderable and visible (not shadow only)
|
||||
manager.m_BF_visible_SOBs.SetBit(n, true);
|
||||
//manager.m_BF_render_SOBs.SetBit(n, true);
|
||||
//manager.m_RenderList_SOBs.push_back(n);
|
||||
}
|
||||
|
||||
} // for through sobs
|
||||
|
||||
|
||||
#else
|
||||
// clip all objects in this room to the clipping planes
|
||||
for (int n=0; n<m_SOBs.size(); n++)
|
||||
{
|
||||
const LSob sob = m_SOBs[n];
|
||||
Object * pNode = ObjectDB::get_instance(sob.m_ID);
|
||||
|
||||
VisualInstance * pObj = Object::cast_to<VisualInstance>(pNode);
|
||||
|
||||
// should always be a visual instance, only these are added as SOBs
|
||||
if (pObj)
|
||||
{
|
||||
//Vector3 pt = pObj->get_global_transform().origin;
|
||||
|
||||
bool bShow = true;
|
||||
|
||||
|
||||
// estimate the radius .. for now
|
||||
AABB bb = pObj->get_transformed_aabb();
|
||||
|
||||
print("\t\t\tculling object " + pObj->get_name());
|
||||
|
||||
for (int p=0; p<planes.size(); p++)
|
||||
{
|
||||
// float dist = planes[p].distance_to(pt);
|
||||
// print("\t\t\t\t" + itos(p) + " : dist " + String(Variant(dist)));
|
||||
|
||||
float r_min, r_max;
|
||||
bb.project_range_in_plane(planes[p], r_min, r_max);
|
||||
|
||||
print("\t\t\t\t" + itos(p) + " : r_min " + String(Variant(r_min)) + ", r_max " + String(Variant(r_max)));
|
||||
|
||||
|
||||
if (r_min > 0.0f)
|
||||
{
|
||||
bShow = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bShow)
|
||||
sob.m_bVisible = true;
|
||||
// pObj->show();
|
||||
// else
|
||||
// pObj->hide();
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// cull DOBs
|
||||
for (int n=0; n<m_DOBs.size(); n++)
|
||||
{
|
||||
|
3
lroom.h
3
lroom.h
@ -61,9 +61,6 @@ public:
|
||||
int m_iFirstSOB;
|
||||
int m_iNumSOBs;
|
||||
|
||||
// static objects
|
||||
//LVector<LSob> m_SOBs;
|
||||
|
||||
// dynamic objects
|
||||
LVector<LDob> m_DOBs;
|
||||
|
||||
|
@ -58,6 +58,13 @@ void LRoomConverter::Convert(LRoomManager &manager)
|
||||
Convert_Portals();
|
||||
Convert_Bounds();
|
||||
|
||||
// make sure manager bitfields are the correct size for number of objects
|
||||
int num_sobs = LMAN->m_SOBs.size();
|
||||
LPRINT(5,"Total SOBs " + itos(num_sobs));
|
||||
//LMAN->m_BF_render_SOBs.Create(num_sobs);
|
||||
LMAN->m_BF_visible_SOBs.Create(num_sobs);
|
||||
|
||||
|
||||
// temp rooms no longer needed
|
||||
m_TempRooms.clear(true);
|
||||
|
||||
|
@ -625,6 +625,9 @@ void LRoomManager::FrameUpdate()
|
||||
|
||||
// clear the visible room list to write to each frame
|
||||
m_pCurr_VisibleRoomList->clear();
|
||||
//m_RenderList_SOBs.clear();
|
||||
//m_BF_render_SOBs.Blank();
|
||||
m_BF_visible_SOBs.Blank();
|
||||
|
||||
// get the camera desired and make into lcamera
|
||||
Camera * pCamera = 0;
|
||||
|
@ -49,6 +49,9 @@ class LRoomManager : public Spatial {
|
||||
// keep track of which rooms are visible, so we can hide ones that aren't hit that were previously on
|
||||
Lawn::LBitField_Dynamic m_BF_visible_rooms;
|
||||
|
||||
// visible bit marks in view, if not set, it is a shadow caster only
|
||||
Lawn::LBitField_Dynamic m_BF_visible_SOBs;
|
||||
|
||||
LVector<int> m_VisibleRoomList_A;
|
||||
LVector<int> m_VisibleRoomList_B;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user