1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-01 03:21:41 +00:00

Merge branch 'fix_bullet_nif_loader_tests' into 'master'

Use approximate equality for btBvhTriangleMeshShape triangles

See merge request OpenMW/openmw!2873
This commit is contained in:
psi29a 2023-03-30 21:43:47 +00:00
commit dbe273f57f

View File

@ -14,6 +14,7 @@
#include <gtest/gtest.h>
#include <algorithm>
#include <span>
#include <type_traits>
namespace
@ -62,6 +63,14 @@ namespace
return isNear(lhs.getOrigin(), rhs.getOrigin()) && isNear(lhs.getBasis(), rhs.getBasis());
}
bool isNear(std::span<const btVector3> lhs, std::span<const btVector3> rhs)
{
if (lhs.size() != rhs.size())
return false;
return std::equal(
lhs.begin(), lhs.end(), rhs.begin(), [](const btVector3& l, const btVector3& r) { return isNear(l, r); });
}
struct WriteVec3f
{
osg::Vec3f mValue;
@ -237,7 +246,7 @@ static bool operator==(const btBvhTriangleMeshShape& lhs, const btBvhTriangleMes
{
return isNear(lhs.getLocalScaling(), rhs.getLocalScaling())
&& lhs.usesQuantizedAabbCompression() == rhs.usesQuantizedAabbCompression()
&& lhs.getOwnsBvh() == rhs.getOwnsBvh() && getTriangles(lhs) == getTriangles(rhs);
&& lhs.getOwnsBvh() == rhs.getOwnsBvh() && isNear(getTriangles(lhs), getTriangles(rhs));
}
static bool operator==(const btCollisionShape& lhs, const btCollisionShape& rhs)