Dynamic lights work now if not a DOB

This commit is contained in:
lawnjelly 2020-04-02 12:08:42 +01:00 committed by GitHub
parent 6b74510611
commit 4bfe94b2b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 31 deletions

View File

@ -625,29 +625,28 @@ bool LRoomManager::DobTeleport(Spatial * pDOB, int iNewRoomID)
*/
// not tested...
/*
bool LRoomManager::dob_teleport(Node * pDOB)
{
CHECK_ROOM_LIST
return true;
/*
Spatial * pSpat = Object::cast_to<Spatial>(pDOB);
if (!pSpat)
return false;
// Spatial * pSpat = Object::cast_to<Spatial>(pDOB);
// if (!pSpat)
// return false;
Vector3 pt = pSpat->get_global_transform().origin;
// Vector3 pt = pSpat->get_global_transform().origin;
int iRoomNum = FindClosestRoom(pt);
//print_line("dob_teleport closest room " + itos(iRoomNum));
// int iRoomNum = FindClosestRoom(pt);
// //print_line("dob_teleport closest room " + itos(iRoomNum));
if (iRoomNum == -1)
return false;
// if (iRoomNum == -1)
// return false;
return DobTeleport(pSpat, iRoomNum);
*/
// return DobTeleport(pSpat, iRoomNum);
}
*/
bool LRoomManager::dob_unregister(int dob_id)
@ -935,7 +934,7 @@ int LRoomManager::dynamic_light_update(int light_id, const Vector3 &pos, const V
LLight &light = m_Lights[light_id];
int iRoom = light.m_Source.m_RoomID;
if ((iRoom == -1) || (light.m_DOB_id == -1))
if (iRoom == -1)
{
WARN_PRINT_ONCE("dynamic_light_update : can't update global light");
return -1;
@ -945,8 +944,11 @@ int LRoomManager::dynamic_light_update(int light_id, const Vector3 &pos, const V
light.m_Source.m_ptDir = dir.normalized();
// update dob
int iNewRoom = m_DobList.UpdateDob(*this, light.m_DOB_id, pos);
light.m_Source.m_RoomID = iNewRoom;
if (light.m_DOB_id != -1)
{
int iNewRoom = m_DobList.UpdateDob(*this, light.m_DOB_id, pos);
light.m_Source.m_RoomID = iNewRoom;
}
// update with a new Trace (we are assuming update is only called if the light has moved)
// remove the old local lights
@ -975,7 +977,7 @@ int LRoomManager::dynamic_light_update(int light_id, const Vector3 &pos, const V
}
// this may or may not have changed
return iNewRoom;
return light.m_Source.m_RoomID;
/*
if (!pLightNode)
@ -1094,7 +1096,7 @@ void LRoomManager::DebugString_Light_AffectedRooms(int light_id)
}
bool LRoomManager::light_register(Node * pLightNode, String szArea)
bool LRoomManager::global_light_register(Node * pLightNode, String szArea)
{
//CHECK_ROOM_LIST
@ -2216,7 +2218,7 @@ void LRoomManager::_bind_methods()
ClassDB::bind_method(D_METHOD("dob_register", "node", "pos", "radius"), &LRoomManager::dob_register);
ClassDB::bind_method(D_METHOD("dob_unregister", "dob_id"), &LRoomManager::dob_unregister);
ClassDB::bind_method(D_METHOD("dob_update", "dob_id", "pos"), &LRoomManager::dob_update);
ClassDB::bind_method(D_METHOD("dob_teleport", "dob"), &LRoomManager::dob_teleport);
// ClassDB::bind_method(D_METHOD("dob_teleport", "dob"), &LRoomManager::dob_teleport);
// ClassDB::bind_method(D_METHOD("dob_register_hint", "dob", "radius", "room"), &LRoomManager::dob_register_hint);
// ClassDB::bind_method(D_METHOD("dob_teleport_hint", "dob", "room"), &LRoomManager::dob_teleport_hint);
@ -2224,7 +2226,7 @@ void LRoomManager::_bind_methods()
ClassDB::bind_method(D_METHOD("dob_get_room_id", "dob"), &LRoomManager::dob_get_room_id);
ClassDB::bind_method(D_METHOD("light_register", "light", "area"), &LRoomManager::light_register);
ClassDB::bind_method(D_METHOD("global_light_register", "light", "area"), &LRoomManager::global_light_register);
ClassDB::bind_method(D_METHOD("dynamic_light_register", "light", "radius"), &LRoomManager::dynamic_light_register);
// ClassDB::bind_method(D_METHOD("dynamic_light_register_hint", "light", "radius", "room"), &LRoomManager::dynamic_light_register_hint);

View File

@ -83,24 +83,17 @@ public:
// These are defined by their ability to move from room to room.
// You can still move static objects within the same room (e.g. elevators, moving platforms)
// as these don't require checks for changing rooms.
// returns DOB ID
int dob_register(Node * pDOB, const Vector3 &pos, float radius);
// register but let LPortal know which room the dob should start in
// bool dob_register_hint(Node * pDOB, float radius, Node * pRoom);
bool dob_unregister(int dob_id);
// returns the room ID within
int dob_update(int dob_id, const Vector3 &pos);
// if we are moving the DOB possibly through multiple rooms, then teleport rather than detect
// portal crossings
bool dob_teleport(Node * pDOB);
// bool dob_teleport_hint(Node * pDOB, Node * pRoom);
//______________________________________________________________________________________
// LIGHTS
// global directional lights that will apply to all rooms
bool light_register(Node * pLightNode, String szArea);
bool global_light_register(Node * pLightNode, String szArea);
// dynamic lights (spot or omni within rooms)
// returns light ID
@ -165,8 +158,7 @@ public:
private:
// PER FRAME STUFF
// godot ID of the camera (which should be registered as a DOB to allow moving between rooms)
//ObjectID m_ID_camera;
// camera
int m_DOB_id_camera;
// keep track of which rooms are visible, so we can hide ones that aren't hit that were previously on