mirror of
https://github.com/Relintai/godot-lportal.git
synced 2025-02-20 01:04:19 +01:00
Continuing conversion to sob list
This commit is contained in:
parent
02184f2022
commit
561aa566b8
@ -596,6 +596,24 @@ void LRoomManager::FrameUpdate_FrustumOnly()
|
|||||||
// NYI
|
// NYI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LRoomManager::FrameUpdate_Prepare()
|
||||||
|
{
|
||||||
|
if (m_bDebugPlanes)
|
||||||
|
m_DebugPlanes.clear();
|
||||||
|
// 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();
|
||||||
|
|
||||||
|
// as we hit visible rooms we will mark them in a bitset, so we can hide any rooms
|
||||||
|
// that are showing that haven't been hit this frame
|
||||||
|
m_BF_visible_rooms.Blank();
|
||||||
|
|
||||||
|
// reset the planes pool for another frame
|
||||||
|
m_Pool.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
void LRoomManager::FrameUpdate()
|
void LRoomManager::FrameUpdate()
|
||||||
{
|
{
|
||||||
if (Engine::get_singleton()->is_editor_hint())
|
if (Engine::get_singleton()->is_editor_hint())
|
||||||
@ -615,19 +633,12 @@ void LRoomManager::FrameUpdate()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_bDebugPlanes)
|
|
||||||
m_DebugPlanes.clear();
|
|
||||||
|
|
||||||
// we keep a frame counter to prevent visiting things multiple times on the same frame in recursive functions
|
// we keep a frame counter to prevent visiting things multiple times on the same frame in recursive functions
|
||||||
m_uiFrameCounter++;
|
m_uiFrameCounter++;
|
||||||
|
|
||||||
LPRINT(5, "\nFRAME " + itos(m_uiFrameCounter));
|
LPRINT(5, "\nFRAME " + itos(m_uiFrameCounter));
|
||||||
|
|
||||||
// clear the visible room list to write to each frame
|
FrameUpdate_Prepare();
|
||||||
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
|
// get the camera desired and make into lcamera
|
||||||
Camera * pCamera = 0;
|
Camera * pCamera = 0;
|
||||||
@ -653,17 +664,11 @@ void LRoomManager::FrameUpdate()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// as we hit visible rooms we will mark them in a bitset, so we can hide any rooms
|
|
||||||
// that are showing that haven't been hit this frame
|
|
||||||
m_BF_visible_rooms.Blank();
|
|
||||||
|
|
||||||
// lcamera contains the info needed for culling
|
// lcamera contains the info needed for culling
|
||||||
LCamera cam;
|
LCamera cam;
|
||||||
cam.m_ptPos = Vector3(0, 0, 0);
|
cam.m_ptPos = Vector3(0, 0, 0);
|
||||||
cam.m_ptDir = Vector3 (-1, 0, 0);
|
cam.m_ptDir = Vector3 (-1, 0, 0);
|
||||||
|
|
||||||
// reset the planes pool for another frame
|
|
||||||
m_Pool.Reset();
|
|
||||||
|
|
||||||
// the first set of planes are allocated and filled with the view frustum planes
|
// the first set of planes are allocated and filled with the view frustum planes
|
||||||
// Note that the visual server doesn't actually need to do view frustum culling as a result...
|
// Note that the visual server doesn't actually need to do view frustum culling as a result...
|
||||||
@ -687,6 +692,21 @@ void LRoomManager::FrameUpdate()
|
|||||||
// rendering through any portals in view into other rooms, etc etc
|
// rendering through any portals in view into other rooms, etc etc
|
||||||
pRoom->DetermineVisibility_Recursive(*this, 0, cam, planes);
|
pRoom->DetermineVisibility_Recursive(*this, 0, cam, planes);
|
||||||
|
|
||||||
|
// finally hide all the rooms that are currently visible but not in the visible bitfield as having been hit
|
||||||
|
FrameUpdate_FinalizeRooms();
|
||||||
|
|
||||||
|
// set soft visibility of objects within visible rooms
|
||||||
|
FrameUpdate_FinalizeVisibility_WithinRooms();
|
||||||
|
|
||||||
|
// draw debug
|
||||||
|
FrameUpdate_DrawDebug(cam, *pRoom);
|
||||||
|
|
||||||
|
// when running, emit less debugging output so as not to choke the IDE
|
||||||
|
Lawn::LDebug::m_bRunning = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LRoomManager::FrameUpdate_FinalizeRooms()
|
||||||
|
{
|
||||||
// finally hide all the rooms that are currently visible but not in the visible bitfield as having been hit
|
// finally hide all the rooms that are currently visible but not in the visible bitfield as having been hit
|
||||||
|
|
||||||
// to get started
|
// to get started
|
||||||
@ -713,8 +733,10 @@ void LRoomManager::FrameUpdate()
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
// if (m_pCurr_VisibleRoomList->size() == 0)
|
// if (m_pCurr_VisibleRoomList->size() == 0)
|
||||||
// print_line("WARNING : vis room list size is 0");
|
// print_line("WARNING : vis room list size is 0");
|
||||||
@ -730,14 +752,6 @@ void LRoomManager::FrameUpdate()
|
|||||||
m_pCurr_VisibleRoomList = m_pPrev_VisibleRoomList;
|
m_pCurr_VisibleRoomList = m_pPrev_VisibleRoomList;
|
||||||
m_pPrev_VisibleRoomList = pTemp;
|
m_pPrev_VisibleRoomList = pTemp;
|
||||||
|
|
||||||
|
|
||||||
// hide all the DOB
|
|
||||||
|
|
||||||
// draw debug
|
|
||||||
FrameUpdate_DrawDebug(cam, *pRoom);
|
|
||||||
|
|
||||||
// when running, emit less debugging output so as not to choke the IDE
|
|
||||||
Lawn::LDebug::m_bRunning = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
129
lroom_manager.h
129
lroom_manager.h
@ -74,9 +74,77 @@ class LRoomManager : public Spatial {
|
|||||||
// for debugging, can emulate view frustum culling
|
// for debugging, can emulate view frustum culling
|
||||||
bool m_bFrustumOnly;
|
bool m_bFrustumOnly;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// lists of rooms and portals, contiguous list so cache friendly
|
||||||
|
LVector<LRoom> m_Rooms;
|
||||||
|
LVector<LPortal> m_Portals;
|
||||||
|
|
||||||
|
// static objects
|
||||||
|
LVector<LSob> m_SOBs;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static void _bind_methods();
|
||||||
|
void _notification(int p_what);
|
||||||
|
|
||||||
|
// The recursive visibility function needs to allocate loads of planes.
|
||||||
|
// We use a pool for this instead of allocating on the fly.
|
||||||
|
LPlanesPool m_Pool;
|
||||||
|
|
||||||
|
// 0 to 5
|
||||||
|
int m_iLoggingLevel;
|
||||||
|
private:
|
||||||
|
// this is where we do all the culling
|
||||||
|
void FrameUpdate();
|
||||||
|
void FrameUpdate_Prepare();
|
||||||
|
void FrameUpdate_FinalizeRooms();
|
||||||
|
void FrameUpdate_FinalizeVisibility_WithinRooms();
|
||||||
|
|
||||||
|
// debugging emulate view frustum
|
||||||
|
void FrameUpdate_FrustumOnly();
|
||||||
|
|
||||||
|
// draw planes and room hulls
|
||||||
|
void FrameUpdate_DrawDebug(const LCamera &cam, const LRoom &lroom);
|
||||||
|
|
||||||
|
|
||||||
|
// internal
|
||||||
|
LRoom &Portal_GetLinkedRoom(const LPortal &port);
|
||||||
|
bool DobRegister(Spatial * pDOB, float radius, int iRoom);
|
||||||
|
ObjectID DobRegister_FindVIRecursive(Node * pNode) const;
|
||||||
|
bool DobTeleport(Spatial * pDOB, int iNewRoomID);
|
||||||
|
void CreateDebug();
|
||||||
|
void DobChangeVisibility(Spatial * pDOB, const LRoom * pOld, const LRoom * pNew);
|
||||||
|
|
||||||
|
|
||||||
|
// helper funcs
|
||||||
|
const LRoom * GetRoom(int i) const;
|
||||||
|
LRoom * GetRoom(int i);
|
||||||
|
|
||||||
|
LRoom * GetRoomFromDOB(Node * pNode);
|
||||||
|
int FindClosestRoom(const Vector3 &pt) const;
|
||||||
|
|
||||||
|
// for DOBs, we need some way of storing the room ID on them, so we use metadata (currently)
|
||||||
|
// this is pretty gross but hey ho
|
||||||
|
int Obj_GetRoomNum(Node * pNode) const;
|
||||||
|
void Obj_SetRoomNum(Node * pNode, int num);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// whether debug planes is switched on
|
||||||
|
bool m_bDebugPlanes;
|
||||||
|
bool m_bDebugBounds;
|
||||||
|
|
||||||
|
// the planes are shown as a list of lines from the camera to the portal verts
|
||||||
|
LVector<Vector3> m_DebugPlanes;
|
||||||
|
private:
|
||||||
|
ObjectID m_ID_DebugPlanes;
|
||||||
|
ObjectID m_ID_DebugBounds;
|
||||||
|
Ref<SpatialMaterial> m_mat_Debug_Planes;
|
||||||
|
Ref<SpatialMaterial> m_mat_Debug_Bounds;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LRoomManager();
|
LRoomManager();
|
||||||
|
|
||||||
|
// PUBLIC INTERFACE TO GDSCRIPT
|
||||||
// convert empties and meshes to rooms and portals
|
// convert empties and meshes to rooms and portals
|
||||||
void rooms_convert();
|
void rooms_convert();
|
||||||
|
|
||||||
@ -121,68 +189,7 @@ public:
|
|||||||
// helper func, not needed usually as dob_update returns the room
|
// helper func, not needed usually as dob_update returns the room
|
||||||
int dob_get_room_id(Node * pDOB);
|
int dob_get_room_id(Node * pDOB);
|
||||||
|
|
||||||
protected:
|
|
||||||
static void _bind_methods();
|
|
||||||
void _notification(int p_what);
|
|
||||||
|
|
||||||
// The recursive visibility function needs to allocate loads of planes.
|
|
||||||
// We use a pool for this instead of allocating on the fly.
|
|
||||||
LPlanesPool m_Pool;
|
|
||||||
|
|
||||||
// 0 to 5
|
|
||||||
int m_iLoggingLevel;
|
|
||||||
private:
|
|
||||||
// internal
|
|
||||||
bool DobRegister(Spatial * pDOB, float radius, int iRoom);
|
|
||||||
ObjectID DobRegister_FindVIRecursive(Node * pNode) const;
|
|
||||||
bool DobTeleport(Spatial * pDOB, int iNewRoomID);
|
|
||||||
void CreateDebug();
|
|
||||||
void DobChangeVisibility(Spatial * pDOB, const LRoom * pOld, const LRoom * pNew);
|
|
||||||
|
|
||||||
|
|
||||||
// helper funcs
|
|
||||||
const LRoom * GetRoom(int i) const;
|
|
||||||
LRoom * GetRoom(int i);
|
|
||||||
|
|
||||||
LRoom * GetRoomFromDOB(Node * pNode);
|
|
||||||
int FindClosestRoom(const Vector3 &pt) const;
|
|
||||||
|
|
||||||
// for DOBs, we need some way of storing the room ID on them, so we use metadata (currently)
|
|
||||||
// this is pretty gross but hey ho
|
|
||||||
int Obj_GetRoomNum(Node * pNode) const;
|
|
||||||
void Obj_SetRoomNum(Node * pNode, int num);
|
|
||||||
|
|
||||||
// this is where we do all the culling
|
|
||||||
void FrameUpdate();
|
|
||||||
|
|
||||||
// debugging emulate view frustum
|
|
||||||
void FrameUpdate_FrustumOnly();
|
|
||||||
|
|
||||||
// draw planes and room hulls
|
|
||||||
void FrameUpdate_DrawDebug(const LCamera &cam, const LRoom &lroom);
|
|
||||||
|
|
||||||
// find which room is linked by a portal
|
|
||||||
LRoom &Portal_GetLinkedRoom(const LPortal &port);
|
|
||||||
|
|
||||||
// lists of rooms and portals, contiguous list so cache friendly
|
|
||||||
LVector<LRoom> m_Rooms;
|
|
||||||
LVector<LPortal> m_Portals;
|
|
||||||
|
|
||||||
// static objects
|
|
||||||
LVector<LSob> m_SOBs;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// whether debug planes is switched on
|
|
||||||
bool m_bDebugPlanes;
|
|
||||||
bool m_bDebugBounds;
|
|
||||||
|
|
||||||
// the planes are shown as a list of lines from the camera to the portal verts
|
|
||||||
LVector<Vector3> m_DebugPlanes;
|
|
||||||
private:
|
|
||||||
ObjectID m_ID_DebugPlanes;
|
|
||||||
ObjectID m_ID_DebugBounds;
|
|
||||||
Ref<SpatialMaterial> m_mat_Debug_Planes;
|
|
||||||
Ref<SpatialMaterial> m_mat_Debug_Bounds;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user