|
|
|
@ -9,6 +9,8 @@
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
#include <gmock/gmock.h>
|
|
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
template <class T>
|
|
|
|
@ -30,6 +32,34 @@ namespace
|
|
|
|
|
shape.processAllTriangles(&callback, aabbMin, aabbMax);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isNear(btScalar lhs, btScalar rhs)
|
|
|
|
|
{
|
|
|
|
|
return std::abs(lhs - rhs) <= 1e-5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isNear(const btVector3& lhs, const btVector3& rhs)
|
|
|
|
|
{
|
|
|
|
|
return std::equal(
|
|
|
|
|
static_cast<const btScalar*>(lhs),
|
|
|
|
|
static_cast<const btScalar*>(lhs) + 3,
|
|
|
|
|
static_cast<const btScalar*>(rhs),
|
|
|
|
|
[] (btScalar lhs, btScalar rhs) { return isNear(lhs, rhs); }
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isNear(const btMatrix3x3& lhs, const btMatrix3x3& rhs)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < 3; ++i)
|
|
|
|
|
if (!isNear(lhs[i], rhs[i]))
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isNear(const btTransform& lhs, const btTransform& rhs)
|
|
|
|
|
{
|
|
|
|
|
return isNear(lhs.getOrigin(), rhs.getOrigin()) && isNear(lhs.getBasis(), rhs.getBasis());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static std::ostream& operator <<(std::ostream& stream, const btVector3& value)
|
|
|
|
@ -157,7 +187,7 @@ static bool operator ==(const btCompoundShape& lhs, const btCompoundShape& rhs)
|
|
|
|
|
for (int i = 0; i < lhs.getNumChildShapes(); ++i)
|
|
|
|
|
{
|
|
|
|
|
if (!compareObjects(lhs.getChildShape(i), rhs.getChildShape(i))
|
|
|
|
|
|| !(lhs.getChildTransform(i) == rhs.getChildTransform(i)))
|
|
|
|
|
|| !isNear(lhs.getChildTransform(i), rhs.getChildTransform(i)))
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
@ -165,13 +195,13 @@ static bool operator ==(const btCompoundShape& lhs, const btCompoundShape& rhs)
|
|
|
|
|
|
|
|
|
|
static bool operator ==(const btBoxShape& lhs, const btBoxShape& rhs)
|
|
|
|
|
{
|
|
|
|
|
return lhs.getLocalScaling() == rhs.getLocalScaling()
|
|
|
|
|
return isNear(lhs.getLocalScaling(), rhs.getLocalScaling())
|
|
|
|
|
&& lhs.getHalfExtentsWithoutMargin() == rhs.getHalfExtentsWithoutMargin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool operator ==(const btBvhTriangleMeshShape& lhs, const btBvhTriangleMeshShape& rhs)
|
|
|
|
|
{
|
|
|
|
|
return lhs.getLocalScaling() == rhs.getLocalScaling()
|
|
|
|
|
return isNear(lhs.getLocalScaling(), rhs.getLocalScaling())
|
|
|
|
|
&& lhs.usesQuantizedAabbCompression() == rhs.usesQuantizedAabbCompression()
|
|
|
|
|
&& lhs.getOwnsBvh() == rhs.getOwnsBvh()
|
|
|
|
|
&& getTriangles(lhs) == getTriangles(rhs);
|
|
|
|
|