diff --git a/src/m_bbox.h b/src/m_bbox.h index febf9d2a25..256393d600 100644 --- a/src/m_bbox.h +++ b/src/m_bbox.h @@ -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]; } diff --git a/src/po_man.cpp b/src/po_man.cpp index 3355b6ca1e..1464f3ee5d 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -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 diff --git a/src/po_man.h b/src/po_man.h index 5603095d56..35dc2af9ce 100644 --- a/src/po_man.h +++ b/src/po_man.h @@ -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();