mirror of
https://github.com/Relintai/godot-lportal.git
synced 2024-11-11 10:52:09 +01:00
Added single room mode
This commit is contained in:
parent
9b8a614ca3
commit
87d946f3d8
@ -33,11 +33,11 @@
|
||||
|
||||
|
||||
|
||||
void LRoomConverter::Convert(LRoomManager &manager, bool bVerbose, bool bPreparationRun, bool bDeleteLights)
|
||||
void LRoomConverter::Convert(LRoomManager &manager, bool bVerbose, bool bPreparationRun, bool bDeleteLights, bool bSingleRoomMode)
|
||||
{
|
||||
m_bFinalRun = (bPreparationRun == false);
|
||||
|
||||
m_bDeleteLights = bDeleteLights;
|
||||
m_bSingleRoomMode = bSingleRoomMode;
|
||||
|
||||
// This just is simply used to set how much debugging output .. more during conversion, less during running
|
||||
// except when requested by explicitly clearing this flag.
|
||||
@ -142,6 +142,21 @@ void LRoomConverter::Convert_Rooms()
|
||||
{
|
||||
LPRINT(5,"Convert_Rooms");
|
||||
|
||||
// allow faking a single room in single room mode
|
||||
if (m_bSingleRoomMode)
|
||||
{
|
||||
Spatial * pSpat = Object::cast_to<Spatial>(LROOMLIST);
|
||||
if (!pSpat)
|
||||
return;
|
||||
|
||||
// add a default area
|
||||
int area = Area_FindOrCreate("default");
|
||||
|
||||
Convert_Room(pSpat, 0, area);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// first find all room empties and convert to LRooms
|
||||
int count = 0;
|
||||
int area = -1;
|
||||
@ -916,6 +931,9 @@ void LRoomConverter::Convert_Portals()
|
||||
|
||||
int LRoomConverter::CountRooms()
|
||||
{
|
||||
if (m_bSingleRoomMode)
|
||||
return 1; // hard coded
|
||||
|
||||
int nChildren = LROOMLIST->get_child_count();
|
||||
int count = 0;
|
||||
|
||||
|
@ -82,7 +82,9 @@ public:
|
||||
};
|
||||
|
||||
// this function calls everything else in the converter
|
||||
void Convert(LRoomManager &manager, bool bVerbose, bool bPreparationRun, bool bDeleteLights);
|
||||
// single room mode enables us to emulate a room list in games that do not have rooms...
|
||||
// this allows taking advantage of basic LPortal speedup without converting games / demos
|
||||
void Convert(LRoomManager &manager, bool bVerbose, bool bPreparationRun, bool bDeleteLights, bool bSingleRoomMode = false);
|
||||
|
||||
private:
|
||||
int CountRooms();
|
||||
@ -147,4 +149,5 @@ private:
|
||||
// in which case we should delete lights and set vis flags
|
||||
bool m_bFinalRun;
|
||||
bool m_bDeleteLights;
|
||||
bool m_bSingleRoomMode;
|
||||
};
|
||||
|
@ -1083,12 +1083,12 @@ void LRoomManager::rooms_set_active(bool bActive)
|
||||
|
||||
m_bActive = bActive;
|
||||
|
||||
if (m_bActive)
|
||||
{
|
||||
// if (m_bActive)
|
||||
// {
|
||||
// clear these to ensure the system is initialized
|
||||
m_pCurr_VisibleRoomList->clear();
|
||||
m_pPrev_VisibleRoomList->clear();
|
||||
}
|
||||
// }
|
||||
|
||||
// show all
|
||||
for (int n=0; n<m_Rooms.size(); n++)
|
||||
@ -1098,6 +1098,7 @@ void LRoomManager::rooms_set_active(bool bActive)
|
||||
}
|
||||
|
||||
|
||||
// SOBS
|
||||
for (int n=0; n<m_SOBs.size(); n++)
|
||||
{
|
||||
LSob &sob = m_SOBs[n];
|
||||
@ -1113,9 +1114,30 @@ void LRoomManager::rooms_set_active(bool bActive)
|
||||
}
|
||||
LRoom::SoftShow(pVI, mask);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// LIGHTS
|
||||
for (int n=0; n<m_Lights.size(); n++)
|
||||
{
|
||||
LLight &light = m_Lights[n];
|
||||
// if (!light.m_Source.IsGlobal())
|
||||
light.Show(!bActive);
|
||||
}
|
||||
|
||||
m_ActiveLights.clear();
|
||||
m_ActiveLights_prev.clear();
|
||||
|
||||
m_VisibleRoomList_A.clear();
|
||||
m_VisibleRoomList_B.clear();
|
||||
|
||||
m_MasterList_SOBs.clear();
|
||||
m_MasterList_SOBs_prev.clear();
|
||||
|
||||
m_VisibleList_SOBs.clear();
|
||||
m_CasterList_SOBs.clear();
|
||||
|
||||
m_BF_ActiveLights_prev.Blank();
|
||||
m_BF_ActiveLights.Blank();
|
||||
}
|
||||
|
||||
String LRoomManager::rooms_get_debug_frame_string()
|
||||
@ -1170,18 +1192,28 @@ bool LRoomManager::rooms_set_camera(Node * pCam)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// convert empties and meshes to rooms and portals
|
||||
bool LRoomManager::rooms_convert(bool bVerbose, bool bDeleteLights)
|
||||
bool LRoomManager::RoomsConvert(bool bVerbose, bool bDeleteLights, bool bSingleRoomMode)
|
||||
{
|
||||
ResolveRoomListPath();
|
||||
CHECK_ROOM_LIST
|
||||
|
||||
LRoomConverter conv;
|
||||
conv.Convert(*this, bVerbose, false, bDeleteLights);
|
||||
conv.Convert(*this, bVerbose, false, bDeleteLights, bSingleRoomMode);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LRoomManager::rooms_single_room_convert(bool bVerbose, bool bDeleteLights)
|
||||
{
|
||||
return RoomsConvert(bVerbose, bDeleteLights, true);
|
||||
}
|
||||
|
||||
// convert empties and meshes to rooms and portals
|
||||
bool LRoomManager::rooms_convert(bool bVerbose, bool bDeleteLights)
|
||||
{
|
||||
return RoomsConvert(bVerbose, bDeleteLights, false);
|
||||
}
|
||||
|
||||
bool LRoomManager::rooms_transfer_uv2s(Node * pMeshInstance_From, Node * pMeshInstance_To)
|
||||
{
|
||||
CheckRoomList();
|
||||
@ -1841,6 +1873,7 @@ void LRoomManager::_bind_methods()
|
||||
{
|
||||
// main functions
|
||||
ClassDB::bind_method(D_METHOD("rooms_convert", "verbose", "delete lights"), &LRoomManager::rooms_convert);
|
||||
ClassDB::bind_method(D_METHOD("rooms_single_room_convert", "verbose", "delete lights"), &LRoomManager::rooms_single_room_convert);
|
||||
ClassDB::bind_method(D_METHOD("rooms_release"), &LRoomManager::rooms_release);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("rooms_set_camera", "camera"), &LRoomManager::rooms_set_camera);
|
||||
|
@ -59,6 +59,7 @@ public:
|
||||
// MAIN
|
||||
// convert empties and meshes to rooms and portals
|
||||
bool rooms_convert(bool bVerbose, bool bDeleteLights);
|
||||
bool rooms_single_room_convert(bool bVerbose, bool bDeleteLights);
|
||||
// free memory for current set of rooms, prepare for converting a new game level
|
||||
void rooms_release();
|
||||
|
||||
@ -301,6 +302,8 @@ private:
|
||||
void FrameUpdate_DrawDebug(const LSource &cam, const LRoom &lroom);
|
||||
|
||||
// internal
|
||||
bool RoomsConvert(bool bVerbose, bool bDeleteLights, bool bSingleRoomMode);
|
||||
|
||||
// dobs
|
||||
bool DobRegister(Spatial * pDOB, float radius, int iRoom);
|
||||
ObjectID DobRegister_FindVIRecursive(Node * pNode) const;
|
||||
|
Loading…
Reference in New Issue
Block a user