mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-12 23:54:35 +00:00
- When moving polyobjects, recalculate the floors and ceilings for the actors in their bounding boxes. (See http://forum.zdoom.org/viewtopic.php?f=2&t=35616)
SVN r4192 (trunk)
This commit is contained in:
parent
53e73783e0
commit
cb41771342
3 changed files with 34 additions and 0 deletions
|
@ -57,6 +57,15 @@ public:
|
||||||
m_Box[BOXBOTTOM] = m_Box[BOXLEFT] = FIXED_MAX;
|
m_Box[BOXBOTTOM] = m_Box[BOXLEFT] = FIXED_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns a bounding box that encloses both bounding boxes
|
||||||
|
FBoundingBox operator | (const FBoundingBox &box2) const
|
||||||
|
{
|
||||||
|
return FBoundingBox(m_Box[BOXLEFT] < box2.m_Box[BOXLEFT] ? m_Box[BOXLEFT] : box2.m_Box[BOXLEFT],
|
||||||
|
m_Box[BOXBOTTOM] < box2.m_Box[BOXBOTTOM] ? m_Box[BOXBOTTOM] : box2.m_Box[BOXBOTTOM],
|
||||||
|
m_Box[BOXRIGHT] > box2.m_Box[BOXRIGHT] ? m_Box[BOXRIGHT] : box2.m_Box[BOXRIGHT],
|
||||||
|
m_Box[BOXTOP] > box2.m_Box[BOXTOP] ? m_Box[BOXTOP] : box2.m_Box[BOXTOP]);
|
||||||
|
}
|
||||||
|
|
||||||
void AddToBox (fixed_t x, fixed_t y);
|
void AddToBox (fixed_t x, fixed_t y);
|
||||||
|
|
||||||
inline fixed_t Top () const { return m_Box[BOXTOP]; }
|
inline fixed_t Top () const { return m_Box[BOXTOP]; }
|
||||||
|
|
|
@ -986,6 +986,7 @@ void FPolyObj::CalcCenter()
|
||||||
|
|
||||||
bool FPolyObj::MovePolyobj (int x, int y, bool force)
|
bool FPolyObj::MovePolyobj (int x, int y, bool force)
|
||||||
{
|
{
|
||||||
|
FBoundingBox oldbounds = Bounds;
|
||||||
UnLinkPolyobj ();
|
UnLinkPolyobj ();
|
||||||
DoMovePolyobj (x, y);
|
DoMovePolyobj (x, y);
|
||||||
|
|
||||||
|
@ -1013,6 +1014,7 @@ bool FPolyObj::MovePolyobj (int x, int y, bool force)
|
||||||
CenterSpot.y += y;
|
CenterSpot.y += y;
|
||||||
LinkPolyobj ();
|
LinkPolyobj ();
|
||||||
ClearSubsectorLinks();
|
ClearSubsectorLinks();
|
||||||
|
RecalcActorFloorCeil(Bounds | oldbounds);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1065,6 +1067,7 @@ bool FPolyObj::RotatePolyobj (angle_t angle)
|
||||||
{
|
{
|
||||||
int an;
|
int an;
|
||||||
bool blocked;
|
bool blocked;
|
||||||
|
FBoundingBox oldbounds = Bounds;
|
||||||
|
|
||||||
an = (this->angle+angle)>>ANGLETOFINESHIFT;
|
an = (this->angle+angle)>>ANGLETOFINESHIFT;
|
||||||
|
|
||||||
|
@ -1103,6 +1106,7 @@ bool FPolyObj::RotatePolyobj (angle_t angle)
|
||||||
this->angle += angle;
|
this->angle += angle;
|
||||||
LinkPolyobj();
|
LinkPolyobj();
|
||||||
ClearSubsectorLinks();
|
ClearSubsectorLinks();
|
||||||
|
RecalcActorFloorCeil(Bounds | oldbounds);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1338,6 +1342,26 @@ void FPolyObj::LinkPolyobj ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// FPolyObj :: RecalcActorFloorCeil
|
||||||
|
//
|
||||||
|
// For each actor within the bounding box, recalculate its floorz, ceilingz,
|
||||||
|
// and related values.
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
void FPolyObj::RecalcActorFloorCeil(FBoundingBox bounds) const
|
||||||
|
{
|
||||||
|
FBlockThingsIterator it(bounds);
|
||||||
|
AActor *actor;
|
||||||
|
|
||||||
|
while ((actor = it.Next()) != NULL)
|
||||||
|
{
|
||||||
|
P_FindFloorCeiling(actor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// PO_ClosestPoint
|
// PO_ClosestPoint
|
||||||
|
|
|
@ -76,6 +76,7 @@ struct FPolyObj
|
||||||
bool RotatePolyobj (angle_t angle);
|
bool RotatePolyobj (angle_t angle);
|
||||||
void ClosestPoint(fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy, side_t **side) const;
|
void ClosestPoint(fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy, side_t **side) const;
|
||||||
void LinkPolyobj ();
|
void LinkPolyobj ();
|
||||||
|
void RecalcActorFloorCeil(FBoundingBox bounds) const;
|
||||||
void CreateSubsectorLinks();
|
void CreateSubsectorLinks();
|
||||||
void ClearSubsectorLinks();
|
void ClearSubsectorLinks();
|
||||||
void CalcCenter();
|
void CalcCenter();
|
||||||
|
|
Loading…
Reference in a new issue