mirror of
https://github.com/Relintai/godot-lportal.git
synced 2024-11-11 10:52:09 +01:00
More checks for DOBs moving outside current room
This commit is contained in:
parent
277fe59930
commit
533c40baa6
@ -52,14 +52,14 @@ float LBound::GetSmallestPenetrationDistance(const Vector3 &pt) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LBound::IsPointWithin(const Vector3 &pt) const
|
bool LBound::IsPointWithin(const Vector3 &pt, float epsilon) const
|
||||||
{
|
{
|
||||||
for (int n=0; n<m_Planes.size(); n++)
|
for (int n=0; n<m_Planes.size(); n++)
|
||||||
{
|
{
|
||||||
float d = m_Planes[n].distance_to(pt);
|
float d = m_Planes[n].distance_to(pt);
|
||||||
|
|
||||||
// if in front of plane, outside the convex hull
|
// if in front of plane, outside the convex hull
|
||||||
if (d > 0.0f)
|
if (d > epsilon)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
lbound.h
2
lbound.h
@ -30,7 +30,7 @@
|
|||||||
class LBound
|
class LBound
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool IsPointWithin(const Vector3 &pt) const;
|
bool IsPointWithin(const Vector3 &pt, float epsilon = 0.0f) const;
|
||||||
|
|
||||||
// get distance behind all planes and return the smallest..
|
// get distance behind all planes and return the smallest..
|
||||||
// if inside this will be negative, if outside, positive
|
// if inside this will be negative, if outside, positive
|
||||||
|
14
lroom.cpp
14
lroom.cpp
@ -99,6 +99,20 @@ LRoom * LRoom::DOB_Update(LRoomManager &manager, Spatial * pDOB)
|
|||||||
if (bCamera)
|
if (bCamera)
|
||||||
slop = 0.0f;
|
slop = 0.0f;
|
||||||
|
|
||||||
|
// deal with the case that the DOB has moved way outside the room
|
||||||
|
if (!m_Bound.IsPointWithin(pt, 1.0f))
|
||||||
|
{
|
||||||
|
// revert to expensive method (may have been teleported etc)
|
||||||
|
int iRoomNum = manager.FindClosestRoom(pt);
|
||||||
|
//print_line("dob_teleport closest room " + itos(iRoomNum));
|
||||||
|
|
||||||
|
if (iRoomNum == -1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
|
return manager.GetRoom(iRoomNum);
|
||||||
|
}
|
||||||
|
|
||||||
// the camera can't have slop because we might end up front side of a door without entering the room,
|
// the camera can't have slop because we might end up front side of a door without entering the room,
|
||||||
// hence can't see into the room through the portal!
|
// hence can't see into the room through the portal!
|
||||||
// if (bCamera)
|
// if (bCamera)
|
||||||
|
@ -219,7 +219,7 @@ void LRoomConverter::Convert_Room_FindObjects_Recursive(Node * pParent, LRoom &l
|
|||||||
|
|
||||||
// ignore invisible
|
// ignore invisible
|
||||||
Spatial * pSpatialChild = Object::cast_to<Spatial>(pChild);
|
Spatial * pSpatialChild = Object::cast_to<Spatial>(pChild);
|
||||||
if (pSpatialChild && (pSpatialChild->is_visible_in_tree() == false))
|
if (pSpatialChild && (Convert_IsVisibleInRooms(pSpatialChild) == false))
|
||||||
{
|
{
|
||||||
pSpatialChild->queue_delete();
|
pSpatialChild->queue_delete();
|
||||||
continue;
|
continue;
|
||||||
@ -287,6 +287,29 @@ void LRoomConverter::Convert_Room_FindObjects_Recursive(Node * pParent, LRoom &l
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LRoomConverter::Convert_IsVisibleInRooms(const Node * pNode) const
|
||||||
|
{
|
||||||
|
const Spatial * pS = Object::cast_to<Spatial>(pNode);
|
||||||
|
const Spatial * pRoomList = Object::cast_to<Spatial>(LROOMLIST);
|
||||||
|
|
||||||
|
while (pS)
|
||||||
|
{
|
||||||
|
if (!pS->is_visible())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
pS = pS->get_parent_spatial();
|
||||||
|
|
||||||
|
// terminate
|
||||||
|
if (pS == pRoomList)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// areaID could be -1 if unset
|
// areaID could be -1 if unset
|
||||||
bool LRoomConverter::Convert_Room(Spatial * pNode, int lroomID, int areaID)
|
bool LRoomConverter::Convert_Room(Spatial * pNode, int lroomID, int areaID)
|
||||||
{
|
{
|
||||||
|
@ -94,6 +94,7 @@ private:
|
|||||||
bool Convert_Room(Spatial * pNode, int lroomID, int areaID);
|
bool Convert_Room(Spatial * pNode, int lroomID, int areaID);
|
||||||
void Convert_Room_FindObjects_Recursive(Node * pParent, LRoom &lroom, LAABB &bb_room);
|
void Convert_Room_FindObjects_Recursive(Node * pParent, LRoom &lroom, LAABB &bb_room);
|
||||||
void Convert_Room_SetDefaultCullMask_Recursive(Node * pParent);
|
void Convert_Room_SetDefaultCullMask_Recursive(Node * pParent);
|
||||||
|
bool Convert_IsVisibleInRooms(const Node * pNode) const;
|
||||||
|
|
||||||
void Convert_Portals();
|
void Convert_Portals();
|
||||||
void Convert_Bounds();
|
void Convert_Bounds();
|
||||||
|
Loading…
Reference in New Issue
Block a user