mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
# Fixed minor shadow bug
CBound operator+= updated the minimum value or the maximum value, but never both. (I think the operator+=(CVector3D) has always been buggy (because it assumes min<max, which isn't true of empty bounds), and I propagated the error to operator+=(CBound) ages ago.) Added test cases, and fixed. This was SVN commit r4244.
This commit is contained in:
@@ -22,8 +22,9 @@
|
||||
// operator+=: extend this bound to include given bound
|
||||
CBound& CBound::operator+=(const CBound& b)
|
||||
{
|
||||
#define CMPT(c) if (b[0].c < m_Data[0].c) m_Data[0].c = b[0].c; \
|
||||
else if (b[1].c > m_Data[1].c) m_Data[1].c = b[1].c
|
||||
#define CMPT(c) \
|
||||
if (b[0].c < m_Data[0].c) m_Data[0].c = b[0].c; \
|
||||
if (b[1].c > m_Data[1].c) m_Data[1].c = b[1].c
|
||||
CMPT(X);
|
||||
CMPT(Y);
|
||||
CMPT(Z);
|
||||
@@ -36,8 +37,9 @@ CBound& CBound::operator+=(const CBound& b)
|
||||
// operator+=: extend this bound to include given point
|
||||
CBound& CBound::operator+=(const CVector3D& pt)
|
||||
{
|
||||
#define CMPT(c) if (pt.c < m_Data[0].c) m_Data[0].c = pt.c; \
|
||||
else if (pt.c > m_Data[1].c) m_Data[1].c = pt.c
|
||||
#define CMPT(c) \
|
||||
if (pt.c < m_Data[0].c) m_Data[0].c = pt.c; \
|
||||
if (pt.c > m_Data[1].c) m_Data[1].c = pt.c
|
||||
CMPT(X);
|
||||
CMPT(Y);
|
||||
CMPT(Z);
|
||||
|
||||
@@ -20,7 +20,7 @@ class CFrustum;
|
||||
class CBound
|
||||
{
|
||||
public:
|
||||
CBound() {}
|
||||
CBound() { SetEmpty(); }
|
||||
CBound(const CVector3D& min,const CVector3D& max) {
|
||||
m_Data[0]=min; m_Data[1]=max;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "lib/self_test.h"
|
||||
|
||||
#include "maths/Bound.h"
|
||||
|
||||
class TestBound : public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
void test_empty()
|
||||
{
|
||||
CBound bound;
|
||||
TS_ASSERT(bound.IsEmpty());
|
||||
bound += CVector3D(1, 2, 3);
|
||||
TS_ASSERT(! bound.IsEmpty());
|
||||
bound.SetEmpty();
|
||||
TS_ASSERT(bound.IsEmpty());
|
||||
}
|
||||
|
||||
void test_extend_vector()
|
||||
{
|
||||
CBound bound;
|
||||
CVector3D v (1, 2, 3);
|
||||
bound += v;
|
||||
|
||||
CVector3D centre;
|
||||
bound.GetCentre(centre);
|
||||
TS_ASSERT_EQUALS(centre, v);
|
||||
}
|
||||
|
||||
void test_extend_bound()
|
||||
{
|
||||
CBound bound;
|
||||
CVector3D v (1, 2, 3);
|
||||
CBound b (v, v);
|
||||
bound += b;
|
||||
|
||||
CVector3D centre;
|
||||
bound.GetCentre(centre);
|
||||
TS_ASSERT_EQUALS(centre, v);
|
||||
}
|
||||
};
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
// "test"-specific PCH:
|
||||
|
||||
#if HAVE_PCH
|
||||
|
||||
#include "lib/self_test.h"
|
||||
#include <cxxtest/TestListener.h>
|
||||
#include <cxxtest/TestTracker.h>
|
||||
#include <cxxtest/TestRunner.h>
|
||||
#include <cxxtest/RealDescriptions.h>
|
||||
|
||||
#endif // HAVE_PCH
|
||||
|
||||
Reference in New Issue
Block a user