mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-30 13:11:23 +00:00
Use approximate equality for btBvhTriangleMeshShape triangles
This commit is contained in:
parent
4793b71eb3
commit
f8cc929f9a
1 changed files with 10 additions and 1 deletions
|
@ -14,6 +14,7 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <span>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
@ -62,6 +63,14 @@ namespace
|
||||||
return isNear(lhs.getOrigin(), rhs.getOrigin()) && isNear(lhs.getBasis(), rhs.getBasis());
|
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
|
struct WriteVec3f
|
||||||
{
|
{
|
||||||
osg::Vec3f mValue;
|
osg::Vec3f mValue;
|
||||||
|
@ -237,7 +246,7 @@ static bool operator==(const btBvhTriangleMeshShape& lhs, const btBvhTriangleMes
|
||||||
{
|
{
|
||||||
return isNear(lhs.getLocalScaling(), rhs.getLocalScaling())
|
return isNear(lhs.getLocalScaling(), rhs.getLocalScaling())
|
||||||
&& lhs.usesQuantizedAabbCompression() == rhs.usesQuantizedAabbCompression()
|
&& 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)
|
static bool operator==(const btCollisionShape& lhs, const btCollisionShape& rhs)
|
||||||
|
|
Loading…
Reference in a new issue