mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 10:23:52 +00:00
Merge branch 'fix_navigator_tests' into 'master'
Fix navigator tests (Bullet changes related) See merge request OpenMW/openmw!629
This commit is contained in:
commit
570bf567cd
2 changed files with 26 additions and 19 deletions
|
@ -76,6 +76,17 @@ namespace
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <std::size_t size>
|
||||||
|
btHeightfieldTerrainShape makeSquareHeightfieldTerrainShape(const std::array<btScalar, size>& values,
|
||||||
|
btScalar heightScale = 1, int upAxis = 2, PHY_ScalarType heightDataType = PHY_FLOAT, bool flipQuadEdges = false)
|
||||||
|
{
|
||||||
|
const int width = static_cast<int>(std::sqrt(size));
|
||||||
|
const btScalar min = *std::min_element(values.begin(), values.end());
|
||||||
|
const btScalar max = *std::max_element(values.begin(), values.end());
|
||||||
|
const btScalar greater = std::max(std::abs(min), std::abs(max));
|
||||||
|
return btHeightfieldTerrainShape(width, width, values.data(), heightScale, -greater, greater, upAxis, heightDataType, flipQuadEdges);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(DetourNavigatorNavigatorTest, find_path_for_empty_should_return_empty)
|
TEST_F(DetourNavigatorNavigatorTest, find_path_for_empty_should_return_empty)
|
||||||
{
|
{
|
||||||
EXPECT_EQ(mNavigator->findPath(mAgentHalfExtents, mStepSize, mStart, mEnd, Flag_walk, mAreaCosts, mOut),
|
EXPECT_EQ(mNavigator->findPath(mAgentHalfExtents, mStepSize, mStart, mEnd, Flag_walk, mAreaCosts, mOut),
|
||||||
|
@ -108,7 +119,7 @@ namespace
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
}};
|
}};
|
||||||
btHeightfieldTerrainShape shape(5, 5, heightfieldData.data(), 1, 0, 0, 2, PHY_FLOAT, false);
|
btHeightfieldTerrainShape shape = makeSquareHeightfieldTerrainShape(heightfieldData);
|
||||||
shape.setLocalScaling(btVector3(128, 128, 1));
|
shape.setLocalScaling(btVector3(128, 128, 1));
|
||||||
|
|
||||||
mNavigator->addAgent(mAgentHalfExtents);
|
mNavigator->addAgent(mAgentHalfExtents);
|
||||||
|
@ -154,7 +165,7 @@ namespace
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
}};
|
}};
|
||||||
btHeightfieldTerrainShape heightfieldShape(5, 5, heightfieldData.data(), 1, 0, 0, 2, PHY_FLOAT, false);
|
btHeightfieldTerrainShape heightfieldShape = makeSquareHeightfieldTerrainShape(heightfieldData);
|
||||||
heightfieldShape.setLocalScaling(btVector3(128, 128, 1));
|
heightfieldShape.setLocalScaling(btVector3(128, 128, 1));
|
||||||
|
|
||||||
btBoxShape boxShape(btVector3(20, 20, 100));
|
btBoxShape boxShape(btVector3(20, 20, 100));
|
||||||
|
@ -238,7 +249,7 @@ namespace
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
}};
|
}};
|
||||||
btHeightfieldTerrainShape heightfieldShape(5, 5, heightfieldData.data(), 1, 0, 0, 2, PHY_FLOAT, false);
|
btHeightfieldTerrainShape heightfieldShape = makeSquareHeightfieldTerrainShape(heightfieldData);
|
||||||
heightfieldShape.setLocalScaling(btVector3(128, 128, 1));
|
heightfieldShape.setLocalScaling(btVector3(128, 128, 1));
|
||||||
|
|
||||||
btBoxShape boxShape(btVector3(20, 20, 100));
|
btBoxShape boxShape(btVector3(20, 20, 100));
|
||||||
|
@ -325,7 +336,7 @@ namespace
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
}};
|
}};
|
||||||
btHeightfieldTerrainShape shape(5, 5, heightfieldData.data(), 1, 0, 0, 2, PHY_FLOAT, false);
|
btHeightfieldTerrainShape shape = makeSquareHeightfieldTerrainShape(heightfieldData);
|
||||||
shape.setLocalScaling(btVector3(128, 128, 1));
|
shape.setLocalScaling(btVector3(128, 128, 1));
|
||||||
|
|
||||||
const std::array<btScalar, 5 * 5> heightfieldData2 {{
|
const std::array<btScalar, 5 * 5> heightfieldData2 {{
|
||||||
|
@ -335,7 +346,7 @@ namespace
|
||||||
-25, -25, -25, -25, -25,
|
-25, -25, -25, -25, -25,
|
||||||
-25, -25, -25, -25, -25,
|
-25, -25, -25, -25, -25,
|
||||||
}};
|
}};
|
||||||
btHeightfieldTerrainShape shape2(5, 5, heightfieldData2.data(), 1, 0, 0, 2, PHY_FLOAT, false);
|
btHeightfieldTerrainShape shape2 = makeSquareHeightfieldTerrainShape(heightfieldData2);
|
||||||
shape2.setLocalScaling(btVector3(128, 128, 1));
|
shape2.setLocalScaling(btVector3(128, 128, 1));
|
||||||
|
|
||||||
mNavigator->addAgent(mAgentHalfExtents);
|
mNavigator->addAgent(mAgentHalfExtents);
|
||||||
|
@ -382,7 +393,7 @@ namespace
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
}};
|
}};
|
||||||
btHeightfieldTerrainShape shape(5, 5, heightfieldData.data(), 1, 0, 0, 2, PHY_FLOAT, false);
|
btHeightfieldTerrainShape shape = makeSquareHeightfieldTerrainShape(heightfieldData);
|
||||||
shape.setLocalScaling(btVector3(128, 128, 1));
|
shape.setLocalScaling(btVector3(128, 128, 1));
|
||||||
|
|
||||||
std::array<btScalar, 5 * 5> heightfieldDataAvoid {{
|
std::array<btScalar, 5 * 5> heightfieldDataAvoid {{
|
||||||
|
@ -392,7 +403,7 @@ namespace
|
||||||
-25, -25, -25, -25, -25,
|
-25, -25, -25, -25, -25,
|
||||||
-25, -25, -25, -25, -25,
|
-25, -25, -25, -25, -25,
|
||||||
}};
|
}};
|
||||||
btHeightfieldTerrainShape shapeAvoid(5, 5, heightfieldDataAvoid.data(), 1, 0, 0, 2, PHY_FLOAT, false);
|
btHeightfieldTerrainShape shapeAvoid = makeSquareHeightfieldTerrainShape(heightfieldDataAvoid);
|
||||||
shapeAvoid.setLocalScaling(btVector3(128, 128, 1));
|
shapeAvoid.setLocalScaling(btVector3(128, 128, 1));
|
||||||
|
|
||||||
mNavigator->addAgent(mAgentHalfExtents);
|
mNavigator->addAgent(mAgentHalfExtents);
|
||||||
|
@ -439,7 +450,7 @@ namespace
|
||||||
-50, -100, -150, -100, -100,
|
-50, -100, -150, -100, -100,
|
||||||
0, -50, -100, -100, -100,
|
0, -50, -100, -100, -100,
|
||||||
}};
|
}};
|
||||||
btHeightfieldTerrainShape shape(5, 5, heightfieldData.data(), 1, 0, 0, 2, PHY_FLOAT, false);
|
btHeightfieldTerrainShape shape = makeSquareHeightfieldTerrainShape(heightfieldData);
|
||||||
shape.setLocalScaling(btVector3(128, 128, 1));
|
shape.setLocalScaling(btVector3(128, 128, 1));
|
||||||
|
|
||||||
mNavigator->addAgent(mAgentHalfExtents);
|
mNavigator->addAgent(mAgentHalfExtents);
|
||||||
|
@ -487,7 +498,7 @@ namespace
|
||||||
0, -100, -100, -100, -100, -100, 0,
|
0, -100, -100, -100, -100, -100, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
}};
|
}};
|
||||||
btHeightfieldTerrainShape shape(7, 7, heightfieldData.data(), 1, 0, 0, 2, PHY_FLOAT, false);
|
btHeightfieldTerrainShape shape = makeSquareHeightfieldTerrainShape(heightfieldData);
|
||||||
shape.setLocalScaling(btVector3(128, 128, 1));
|
shape.setLocalScaling(btVector3(128, 128, 1));
|
||||||
|
|
||||||
mNavigator->addAgent(mAgentHalfExtents);
|
mNavigator->addAgent(mAgentHalfExtents);
|
||||||
|
@ -534,7 +545,7 @@ namespace
|
||||||
0, -100, -100, -100, -100, -100, 0,
|
0, -100, -100, -100, -100, -100, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
}};
|
}};
|
||||||
btHeightfieldTerrainShape shape(7, 7, heightfieldData.data(), 1, 0, 0, 2, PHY_FLOAT, false);
|
btHeightfieldTerrainShape shape = makeSquareHeightfieldTerrainShape(heightfieldData);
|
||||||
shape.setLocalScaling(btVector3(128, 128, 1));
|
shape.setLocalScaling(btVector3(128, 128, 1));
|
||||||
|
|
||||||
mNavigator->addAgent(mAgentHalfExtents);
|
mNavigator->addAgent(mAgentHalfExtents);
|
||||||
|
@ -581,7 +592,7 @@ namespace
|
||||||
0, -100, -100, -100, -100, -100, 0,
|
0, -100, -100, -100, -100, -100, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
}};
|
}};
|
||||||
btHeightfieldTerrainShape shape(7, 7, heightfieldData.data(), 1, 0, 0, 2, PHY_FLOAT, false);
|
btHeightfieldTerrainShape shape = makeSquareHeightfieldTerrainShape(heightfieldData);
|
||||||
shape.setLocalScaling(btVector3(128, 128, 1));
|
shape.setLocalScaling(btVector3(128, 128, 1));
|
||||||
|
|
||||||
mNavigator->addAgent(mAgentHalfExtents);
|
mNavigator->addAgent(mAgentHalfExtents);
|
||||||
|
@ -626,7 +637,7 @@ namespace
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
}};
|
}};
|
||||||
btHeightfieldTerrainShape shape(5, 5, heightfieldData.data(), 1, 0, 0, 2, PHY_FLOAT, false);
|
btHeightfieldTerrainShape shape = makeSquareHeightfieldTerrainShape(heightfieldData);
|
||||||
shape.setLocalScaling(btVector3(128, 128, 1));
|
shape.setLocalScaling(btVector3(128, 128, 1));
|
||||||
|
|
||||||
mNavigator->addAgent(mAgentHalfExtents);
|
mNavigator->addAgent(mAgentHalfExtents);
|
||||||
|
@ -680,7 +691,7 @@ namespace
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
}};
|
}};
|
||||||
btHeightfieldTerrainShape shape(5, 5, heightfieldData.data(), 1, 0, 0, 2, PHY_FLOAT, false);
|
btHeightfieldTerrainShape shape = makeSquareHeightfieldTerrainShape(heightfieldData);
|
||||||
shape.setLocalScaling(btVector3(128, 128, 1));
|
shape.setLocalScaling(btVector3(128, 128, 1));
|
||||||
|
|
||||||
mNavigator->addAgent(mAgentHalfExtents);
|
mNavigator->addAgent(mAgentHalfExtents);
|
||||||
|
@ -711,7 +722,7 @@ namespace
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
}};
|
}};
|
||||||
btHeightfieldTerrainShape heightfieldShape(5, 5, heightfieldData.data(), 1, 0, 0, 2, PHY_FLOAT, false);
|
btHeightfieldTerrainShape heightfieldShape = makeSquareHeightfieldTerrainShape(heightfieldData);
|
||||||
heightfieldShape.setLocalScaling(btVector3(128, 128, 1));
|
heightfieldShape.setLocalScaling(btVector3(128, 128, 1));
|
||||||
|
|
||||||
const std::vector<btBoxShape> boxShapes(100, btVector3(20, 20, 100));
|
const std::vector<btBoxShape> boxShapes(100, btVector3(20, 20, 100));
|
||||||
|
@ -812,7 +823,7 @@ namespace
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
0, -25, -100, -100, -100,
|
0, -25, -100, -100, -100,
|
||||||
}};
|
}};
|
||||||
btHeightfieldTerrainShape shape(5, 5, heightfieldData.data(), 1, 0, 0, 2, PHY_FLOAT, false);
|
btHeightfieldTerrainShape shape = makeSquareHeightfieldTerrainShape(heightfieldData);
|
||||||
shape.setLocalScaling(btVector3(128, 128, 1));
|
shape.setLocalScaling(btVector3(128, 128, 1));
|
||||||
|
|
||||||
mNavigator->addAgent(mAgentHalfExtents);
|
mNavigator->addAgent(mAgentHalfExtents);
|
||||||
|
|
|
@ -4,10 +4,6 @@
|
||||||
#include <components/detournavigator/settingsutils.hpp>
|
#include <components/detournavigator/settingsutils.hpp>
|
||||||
|
|
||||||
#include <BulletCollision/CollisionShapes/btBoxShape.h>
|
#include <BulletCollision/CollisionShapes/btBoxShape.h>
|
||||||
#include <BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btTriangleMesh.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h>
|
|
||||||
#include <BulletCollision/CollisionShapes/btCompoundShape.h>
|
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
|
|
Loading…
Reference in a new issue