OrientedBox no problem
Former-commit-id: ad1256baf4bf6d832cb376fe62b1b52f25479e67
This commit is contained in:
parent
9d7dc63574
commit
19e1cb05bb
|
|
@ -103,9 +103,9 @@ template<typename U>
|
||||||
NzOrientedBox<T>& NzOrientedBox<T>::Set(const NzOrientedBox<U>& orientedBox)
|
NzOrientedBox<T>& NzOrientedBox<T>::Set(const NzOrientedBox<U>& orientedBox)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i <= nzBoxCorner_Max; ++i)
|
for (unsigned int i = 0; i <= nzBoxCorner_Max; ++i)
|
||||||
m_corners[i].Set(orientedBox.m_corners[i]);
|
m_corners[i].Set(orientedBox(i));
|
||||||
|
|
||||||
localBox = orientedBox.localBox;
|
localBox.Set(orientedBox.localBox);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
@ -151,7 +151,7 @@ NzVector3<T>& NzOrientedBox<T>::operator()(unsigned int i)
|
||||||
if (i > nzBoxCorner_Max)
|
if (i > nzBoxCorner_Max)
|
||||||
{
|
{
|
||||||
NzStringStream ss;
|
NzStringStream ss;
|
||||||
ss << "Index out of range: (" << i << " >= 3)";
|
ss << "Index out of range: (" << i << " >= " << nzBoxCorner_Max << ")";
|
||||||
|
|
||||||
NazaraError(ss);
|
NazaraError(ss);
|
||||||
throw std::out_of_range(ss.ToString());
|
throw std::out_of_range(ss.ToString());
|
||||||
|
|
@ -168,7 +168,7 @@ NzVector3<T> NzOrientedBox<T>::operator()(unsigned int i) const
|
||||||
if (i > nzBoxCorner_Max)
|
if (i > nzBoxCorner_Max)
|
||||||
{
|
{
|
||||||
NzStringStream ss;
|
NzStringStream ss;
|
||||||
ss << "Index out of range: (" << i << " >= 3)";
|
ss << "Index out of range: (" << i << " >= " << nzBoxCorner_Max << ")";
|
||||||
|
|
||||||
NazaraError(ss);
|
NazaraError(ss);
|
||||||
throw std::out_of_range(ss.ToString());
|
throw std::out_of_range(ss.ToString());
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
#include <Nazara/Math/OrientedBox.hpp>
|
||||||
|
#include <catch.hpp>
|
||||||
|
|
||||||
|
SCENARIO("OrientedBox", "[MATH][ORIENTEDBOX]")
|
||||||
|
{
|
||||||
|
GIVEN("Two center and unit oriented boxes")
|
||||||
|
{
|
||||||
|
NzOrientedBoxf firstCenterAndUnit(0.f, 0.f, 0.f, 1.f, 1.f, 1.f);
|
||||||
|
NzOrientedBoxf secondCenterAndUnit(NzOrientedBox<int>(NzVector3i::Zero(), NzVector3i::Unit()));
|
||||||
|
|
||||||
|
firstCenterAndUnit.Update(NzMatrix4f::Identity());
|
||||||
|
|
||||||
|
WHEN("We compare them")
|
||||||
|
{
|
||||||
|
THEN("They are the same")
|
||||||
|
{
|
||||||
|
REQUIRE(firstCenterAndUnit == secondCenterAndUnit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WHEN("We ask if they are valid")
|
||||||
|
{
|
||||||
|
THEN("They are valid")
|
||||||
|
{
|
||||||
|
CHECK(firstCenterAndUnit.IsValid());
|
||||||
|
CHECK(secondCenterAndUnit.IsValid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WHEN("We multiply them")
|
||||||
|
{
|
||||||
|
THEN("Results are different between operator * and update(ScaleMatrix) but corners are the same")
|
||||||
|
{
|
||||||
|
firstCenterAndUnit *= 2.f;
|
||||||
|
firstCenterAndUnit.Update(NzMatrix4f::Identity());
|
||||||
|
secondCenterAndUnit.Update(NzMatrix4f::Scale(NzVector3f::Unit() * 2.f));
|
||||||
|
|
||||||
|
REQUIRE(firstCenterAndUnit != secondCenterAndUnit);
|
||||||
|
for (unsigned int i = 0; i <= nzBoxCorner_Max; ++i)
|
||||||
|
{
|
||||||
|
REQUIRE(firstCenterAndUnit(i) == secondCenterAndUnit(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue