diff --git a/lroom.cpp b/lroom.cpp index 3ea882c..6ccfb5a 100644 --- a/lroom.cpp +++ b/lroom.cpp @@ -33,6 +33,9 @@ LRoom::LRoom() { m_iFirstPortal = 0; m_iNumPortals = 0; m_bVisible = true; + + m_iFirstSOB = 0; + m_iNumSOBs = 0; } @@ -169,9 +172,10 @@ void LRoom::FinalizeVisibility(LRoomManager &manager) { //print_line("FinalizeVisibility room " + get_name() + " NumSOBs " + itos(m_SOBs.size()) + ", NumDOBs " + itos(m_DOBs.size())); - for (int n=0; npush_back(m_RoomID); // hide all objects - for (int n=0; n m_SOBs; + //LVector m_SOBs; // dynamic objects LVector m_DOBs; diff --git a/lroom_converter.cpp b/lroom_converter.cpp index 0b46d30..4b0109c 100644 --- a/lroom_converter.cpp +++ b/lroom_converter.cpp @@ -41,6 +41,8 @@ void LRoomConverter::Convert(LRoomManager &manager) LMAN = &manager; int count = CountRooms(); + LMAN->m_SOBs.clear(); + // make sure bitfield is right size for number of rooms LMAN->m_BF_visible_rooms.Create(count); @@ -129,7 +131,8 @@ void LRoomConverter::Convert_Room_FindObjects_Recursive(Node * pParent, LRoom &l sob.m_ID = pVI->get_instance_id(); sob.m_aabb = bb; - lroom.m_SOBs.push_back(sob); + //lroom.m_SOBs.push_back(sob); + LRoom_PushBackSOB(lroom, sob); } else { @@ -409,6 +412,17 @@ void LRoomConverter::LRoom_DetectPortalMeshes(LRoom &lroom, LTempRoom &troom) } +void LRoomConverter::LRoom_PushBackSOB(LRoom &lroom, const LSob &sob) +{ + // first added for this room? + if (lroom.m_iNumSOBs == 0) + lroom.m_iFirstSOB = LMAN->m_SOBs.size(); + + LMAN->m_SOBs.push_back(sob); + lroom.m_iNumSOBs++; +} + + // handles the slight faff involved in getting a new portal in the manager contiguous list of portals LPortal * LRoomConverter::LRoom_RequestNewPortal(LRoom &lroom) { diff --git a/lroom_converter.h b/lroom_converter.h index 1880d58..8919449 100644 --- a/lroom_converter.h +++ b/lroom_converter.h @@ -100,6 +100,7 @@ private: void LRoom_MakePortalFinalList(LRoom &lroom, LTempRoom &troom); void LRoom_DetectedPortalMesh(LRoom &lroom, LTempRoom &troom, MeshInstance * pMeshInstance, String szLinkRoom); LPortal * LRoom_RequestNewPortal(LRoom &lroom); + void LRoom_PushBackSOB(LRoom &lroom, const LSob &sob); void TRoom_MakeOppositePortal(const LPortal &port, int iRoomOrig); diff --git a/lroom_manager.h b/lroom_manager.h index 7f19884..bce68ce 100644 --- a/lroom_manager.h +++ b/lroom_manager.h @@ -159,6 +159,9 @@ private: LVector m_Rooms; LVector m_Portals; + // static objects + LVector m_SOBs; + public: // whether debug planes is switched on bool m_bDebugPlanes;