From da26e1095118631ba7cefa21101a123ff5258647 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 14 Mar 2015 09:34:55 +0100 Subject: [PATCH] - fixed: The FBoundingBox constructor taking a point and a radius needs to restrict the resulting values to the fixed point range. --- src/m_bbox.cpp | 21 +++++++++++++++++++++ src/m_bbox.h | 8 +------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/m_bbox.cpp b/src/m_bbox.cpp index 199da8d68..c73f47bc4 100644 --- a/src/m_bbox.cpp +++ b/src/m_bbox.cpp @@ -27,6 +27,27 @@ #include "m_bbox.h" #include "p_local.h" +//========================================================================== +// +// +// +//========================================================================== + +FBoundingBox::FBoundingBox(fixed_t x, fixed_t y, fixed_t radius) +{ + m_Box[BOXTOP] = (fixed_t)MIN((SQWORD)y + radius, FIXED_MAX); + m_Box[BOXLEFT] = (fixed_t)MAX((SQWORD)x - radius, FIXED_MIN); + m_Box[BOXRIGHT] = (fixed_t)MIN((SQWORD)x + radius, FIXED_MAX); + m_Box[BOXBOTTOM] = (fixed_t)MAX((SQWORD)y - radius, FIXED_MIN); +} + + +//========================================================================== +// +// +// +//========================================================================== + void FBoundingBox::AddToBox (fixed_t x, fixed_t y) { if (x < m_Box[BOXLEFT]) diff --git a/src/m_bbox.h b/src/m_bbox.h index 256393d60..174cd6ecf 100644 --- a/src/m_bbox.h +++ b/src/m_bbox.h @@ -43,13 +43,7 @@ public: m_Box[BOXBOTTOM] = bottom; } - FBoundingBox(fixed_t x, fixed_t y, fixed_t radius) - { - m_Box[BOXTOP] = y + radius; - m_Box[BOXLEFT] = x - radius; - m_Box[BOXRIGHT] = x + radius; - m_Box[BOXBOTTOM] = y - radius; - } + FBoundingBox(fixed_t x, fixed_t y, fixed_t radius); void ClearBox () {