From f8cc929f9a07f63e01655cb4bd55f1d3a812e7af Mon Sep 17 00:00:00 2001 From: elsid Date: Thu, 30 Mar 2023 21:41:40 +0200 Subject: [PATCH] Use approximate equality for btBvhTriangleMeshShape triangles --- .../nifloader/testbulletnifloader.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp b/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp index 2804bbd31c..44c1ffb1e7 100644 --- a/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp +++ b/apps/openmw_test_suite/nifloader/testbulletnifloader.cpp @@ -14,6 +14,7 @@ #include #include +#include #include namespace @@ -62,6 +63,14 @@ namespace return isNear(lhs.getOrigin(), rhs.getOrigin()) && isNear(lhs.getBasis(), rhs.getBasis()); } + bool isNear(std::span lhs, std::span 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)