mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +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;
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
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)
|
||||
{
|
||||
FBoundingBox oldbounds = Bounds;
|
||||
UnLinkPolyobj ();
|
||||
DoMovePolyobj (x, y);
|
||||
|
||||
|
@ -1013,6 +1014,7 @@ bool FPolyObj::MovePolyobj (int x, int y, bool force)
|
|||
CenterSpot.y += y;
|
||||
LinkPolyobj ();
|
||||
ClearSubsectorLinks();
|
||||
RecalcActorFloorCeil(Bounds | oldbounds);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1065,6 +1067,7 @@ bool FPolyObj::RotatePolyobj (angle_t angle)
|
|||
{
|
||||
int an;
|
||||
bool blocked;
|
||||
FBoundingBox oldbounds = Bounds;
|
||||
|
||||
an = (this->angle+angle)>>ANGLETOFINESHIFT;
|
||||
|
||||
|
@ -1103,6 +1106,7 @@ bool FPolyObj::RotatePolyobj (angle_t angle)
|
|||
this->angle += angle;
|
||||
LinkPolyobj();
|
||||
ClearSubsectorLinks();
|
||||
RecalcActorFloorCeil(Bounds | oldbounds);
|
||||
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
|
||||
|
|
|
@ -76,6 +76,7 @@ struct FPolyObj
|
|||
bool RotatePolyobj (angle_t angle);
|
||||
void ClosestPoint(fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy, side_t **side) const;
|
||||
void LinkPolyobj ();
|
||||
void RecalcActorFloorCeil(FBoundingBox bounds) const;
|
||||
void CreateSubsectorLinks();
|
||||
void ClearSubsectorLinks();
|
||||
void CalcCenter();
|
||||
|
|
Loading…
Reference in a new issue