|
|
|
@ -40,7 +40,7 @@ namespace
|
|
|
|
|
const auto recastMesh = builder.create();
|
|
|
|
|
EXPECT_EQ(recastMesh->getVertices(), std::vector<float>());
|
|
|
|
|
EXPECT_EQ(recastMesh->getIndices(), std::vector<int>());
|
|
|
|
|
EXPECT_EQ(recastMesh->getFlags(), std::vector<unsigned char>());
|
|
|
|
|
EXPECT_EQ(recastMesh->getAreaTypes(), std::vector<AreaType>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(DetourNavigatorRecastMeshBuilderTest, add_bhv_triangle_mesh_shape)
|
|
|
|
@ -49,7 +49,7 @@ namespace
|
|
|
|
|
mesh.addTriangle(btVector3(-1, -1, 0), btVector3(-1, 1, 0), btVector3(1, -1, 0));
|
|
|
|
|
btBvhTriangleMeshShape shape(&mesh, true);
|
|
|
|
|
RecastMeshBuilder builder(mSettings, mBounds);
|
|
|
|
|
builder.addObject(static_cast<const btCollisionShape&>(shape), btTransform::getIdentity(), 1);
|
|
|
|
|
builder.addObject(static_cast<const btCollisionShape&>(shape), btTransform::getIdentity(), AreaType_ground);
|
|
|
|
|
const auto recastMesh = builder.create();
|
|
|
|
|
EXPECT_EQ(recastMesh->getVertices(), std::vector<float>({
|
|
|
|
|
1, 0, -1,
|
|
|
|
@ -57,7 +57,7 @@ namespace
|
|
|
|
|
-1, 0, -1,
|
|
|
|
|
}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getIndices(), std::vector<int>({0, 1, 2}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getFlags(), std::vector<unsigned char>({1}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getAreaTypes(), std::vector<AreaType>({AreaType_ground}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(DetourNavigatorRecastMeshBuilderTest, add_transformed_bhv_triangle_mesh_shape)
|
|
|
|
@ -69,7 +69,7 @@ namespace
|
|
|
|
|
builder.addObject(
|
|
|
|
|
static_cast<const btCollisionShape&>(shape),
|
|
|
|
|
btTransform(btMatrix3x3::getIdentity().scaled(btVector3(1, 2, 3)), btVector3(1, 2, 3)),
|
|
|
|
|
1
|
|
|
|
|
AreaType_ground
|
|
|
|
|
);
|
|
|
|
|
const auto recastMesh = builder.create();
|
|
|
|
|
EXPECT_EQ(recastMesh->getVertices(), std::vector<float>({
|
|
|
|
@ -78,7 +78,7 @@ namespace
|
|
|
|
|
0, 3, 0,
|
|
|
|
|
}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getIndices(), std::vector<int>({0, 1, 2}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getFlags(), std::vector<unsigned char>({1}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getAreaTypes(), std::vector<AreaType>({AreaType_ground}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(DetourNavigatorRecastMeshBuilderTest, add_heightfield_terrian_shape)
|
|
|
|
@ -86,7 +86,7 @@ namespace
|
|
|
|
|
const std::array<btScalar, 4> heightfieldData {{0, 0, 0, 0}};
|
|
|
|
|
btHeightfieldTerrainShape shape(2, 2, heightfieldData.data(), 1, 0, 0, 2, PHY_FLOAT, false);
|
|
|
|
|
RecastMeshBuilder builder(mSettings, mBounds);
|
|
|
|
|
builder.addObject(static_cast<const btCollisionShape&>(shape), btTransform::getIdentity(), 1);
|
|
|
|
|
builder.addObject(static_cast<const btCollisionShape&>(shape), btTransform::getIdentity(), AreaType_ground);
|
|
|
|
|
const auto recastMesh = builder.create();
|
|
|
|
|
EXPECT_EQ(recastMesh->getVertices(), std::vector<float>({
|
|
|
|
|
-0.5, 0, -0.5,
|
|
|
|
@ -97,14 +97,14 @@ namespace
|
|
|
|
|
0.5, 0, 0.5,
|
|
|
|
|
}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getIndices(), std::vector<int>({0, 1, 2, 3, 4, 5}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getFlags(), std::vector<unsigned char>({1, 1}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getAreaTypes(), std::vector<AreaType>({AreaType_ground, AreaType_ground}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(DetourNavigatorRecastMeshBuilderTest, add_box_shape_should_produce_12_triangles)
|
|
|
|
|
{
|
|
|
|
|
btBoxShape shape(btVector3(1, 1, 2));
|
|
|
|
|
RecastMeshBuilder builder(mSettings, mBounds);
|
|
|
|
|
builder.addObject(static_cast<const btCollisionShape&>(shape), btTransform::getIdentity(), 1);
|
|
|
|
|
builder.addObject(static_cast<const btCollisionShape&>(shape), btTransform::getIdentity(), AreaType_ground);
|
|
|
|
|
const auto recastMesh = builder.create();
|
|
|
|
|
EXPECT_EQ(recastMesh->getVertices(), std::vector<float>({
|
|
|
|
|
1, 2, 1,
|
|
|
|
@ -130,7 +130,7 @@ namespace
|
|
|
|
|
7, 6, 4,
|
|
|
|
|
4, 5, 7,
|
|
|
|
|
}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getFlags(), std::vector<unsigned char>({1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getAreaTypes(), std::vector<AreaType>(12, AreaType_ground));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(DetourNavigatorRecastMeshBuilderTest, add_compound_shape)
|
|
|
|
@ -147,7 +147,11 @@ namespace
|
|
|
|
|
shape.addChildShape(btTransform::getIdentity(), &box);
|
|
|
|
|
shape.addChildShape(btTransform::getIdentity(), &triangle2);
|
|
|
|
|
RecastMeshBuilder builder(mSettings, mBounds);
|
|
|
|
|
builder.addObject(static_cast<const btCollisionShape&>(shape), btTransform::getIdentity(), 1);
|
|
|
|
|
builder.addObject(
|
|
|
|
|
static_cast<const btCollisionShape&>(shape),
|
|
|
|
|
btTransform::getIdentity(),
|
|
|
|
|
AreaType_ground
|
|
|
|
|
);
|
|
|
|
|
const auto recastMesh = builder.create();
|
|
|
|
|
EXPECT_EQ(recastMesh->getVertices(), std::vector<float>({
|
|
|
|
|
1, 0, -1,
|
|
|
|
@ -181,7 +185,7 @@ namespace
|
|
|
|
|
7, 8, 10,
|
|
|
|
|
11, 12, 13,
|
|
|
|
|
}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getFlags(), std::vector<unsigned char>({1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getAreaTypes(), std::vector<AreaType>(14, AreaType_ground));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(DetourNavigatorRecastMeshBuilderTest, add_transformed_compound_shape)
|
|
|
|
@ -192,9 +196,11 @@ namespace
|
|
|
|
|
btCompoundShape shape;
|
|
|
|
|
shape.addChildShape(btTransform::getIdentity(), &triangle);
|
|
|
|
|
RecastMeshBuilder builder(mSettings, mBounds);
|
|
|
|
|
builder.addObject(static_cast<const btCollisionShape&>(shape),
|
|
|
|
|
btTransform(btMatrix3x3::getIdentity().scaled(btVector3(1, 2, 3)), btVector3(1, 2, 3)),
|
|
|
|
|
1);
|
|
|
|
|
builder.addObject(
|
|
|
|
|
static_cast<const btCollisionShape&>(shape),
|
|
|
|
|
btTransform(btMatrix3x3::getIdentity().scaled(btVector3(1, 2, 3)), btVector3(1, 2, 3)),
|
|
|
|
|
AreaType_ground
|
|
|
|
|
);
|
|
|
|
|
const auto recastMesh = builder.create();
|
|
|
|
|
EXPECT_EQ(recastMesh->getVertices(), std::vector<float>({
|
|
|
|
|
2, 3, 0,
|
|
|
|
@ -202,7 +208,7 @@ namespace
|
|
|
|
|
0, 3, 0,
|
|
|
|
|
}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getIndices(), std::vector<int>({0, 1, 2}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getFlags(), std::vector<unsigned char>({1}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getAreaTypes(), std::vector<AreaType>({AreaType_ground}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(DetourNavigatorRecastMeshBuilderTest, add_transformed_compound_shape_with_transformed_bhv_triangle_shape)
|
|
|
|
@ -217,7 +223,7 @@ namespace
|
|
|
|
|
builder.addObject(
|
|
|
|
|
static_cast<const btCollisionShape&>(shape),
|
|
|
|
|
btTransform(btMatrix3x3::getIdentity().scaled(btVector3(1, 2, 3)), btVector3(1, 2, 3)),
|
|
|
|
|
1
|
|
|
|
|
AreaType_ground
|
|
|
|
|
);
|
|
|
|
|
const auto recastMesh = builder.create();
|
|
|
|
|
EXPECT_EQ(recastMesh->getVertices(), std::vector<float>({
|
|
|
|
@ -226,7 +232,7 @@ namespace
|
|
|
|
|
1, 12, 2,
|
|
|
|
|
}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getIndices(), std::vector<int>({0, 1, 2}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getFlags(), std::vector<unsigned char>({1}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getAreaTypes(), std::vector<AreaType>({AreaType_ground}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(DetourNavigatorRecastMeshBuilderTest, without_bounds_add_bhv_triangle_shape_should_not_filter_by_bounds)
|
|
|
|
@ -236,7 +242,11 @@ namespace
|
|
|
|
|
mesh.addTriangle(btVector3(-3, -3, 0), btVector3(-3, -2, 0), btVector3(-2, -3, 0));
|
|
|
|
|
btBvhTriangleMeshShape shape(&mesh, true);
|
|
|
|
|
RecastMeshBuilder builder(mSettings, mBounds);
|
|
|
|
|
builder.addObject(static_cast<const btCollisionShape&>(shape), btTransform::getIdentity(), 1);
|
|
|
|
|
builder.addObject(
|
|
|
|
|
static_cast<const btCollisionShape&>(shape),
|
|
|
|
|
btTransform::getIdentity(),
|
|
|
|
|
AreaType_ground
|
|
|
|
|
);
|
|
|
|
|
const auto recastMesh = builder.create();
|
|
|
|
|
EXPECT_EQ(recastMesh->getVertices(), std::vector<float>({
|
|
|
|
|
1, 0, -1,
|
|
|
|
@ -247,7 +257,7 @@ namespace
|
|
|
|
|
-3, 0, -3,
|
|
|
|
|
}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getIndices(), std::vector<int>({0, 1, 2, 3, 4, 5}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getFlags(), std::vector<unsigned char>({1, 1}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getAreaTypes(), std::vector<AreaType>(2, AreaType_ground));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(DetourNavigatorRecastMeshBuilderTest, with_bounds_add_bhv_triangle_shape_should_filter_by_bounds)
|
|
|
|
@ -260,7 +270,11 @@ namespace
|
|
|
|
|
mesh.addTriangle(btVector3(-3, -3, 0), btVector3(-3, -2, 0), btVector3(-2, -3, 0));
|
|
|
|
|
btBvhTriangleMeshShape shape(&mesh, true);
|
|
|
|
|
RecastMeshBuilder builder(mSettings, mBounds);
|
|
|
|
|
builder.addObject(static_cast<const btCollisionShape&>(shape), btTransform::getIdentity(), 1);
|
|
|
|
|
builder.addObject(
|
|
|
|
|
static_cast<const btCollisionShape&>(shape),
|
|
|
|
|
btTransform::getIdentity(),
|
|
|
|
|
AreaType_ground
|
|
|
|
|
);
|
|
|
|
|
const auto recastMesh = builder.create();
|
|
|
|
|
EXPECT_EQ(recastMesh->getVertices(), std::vector<float>({
|
|
|
|
|
-0.2f, 0, -0.3f,
|
|
|
|
@ -268,7 +282,7 @@ namespace
|
|
|
|
|
-0.3f, 0, -0.3f,
|
|
|
|
|
}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getIndices(), std::vector<int>({0, 1, 2}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getFlags(), std::vector<unsigned char>({1}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getAreaTypes(), std::vector<AreaType>({AreaType_ground}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(DetourNavigatorRecastMeshBuilderTest, with_bounds_add_rotated_by_x_bhv_triangle_shape_should_filter_by_bounds)
|
|
|
|
@ -280,8 +294,12 @@ namespace
|
|
|
|
|
mesh.addTriangle(btVector3(0, -3, -3), btVector3(0, -3, -2), btVector3(0, -2, -3));
|
|
|
|
|
btBvhTriangleMeshShape shape(&mesh, true);
|
|
|
|
|
RecastMeshBuilder builder(mSettings, mBounds);
|
|
|
|
|
builder.addObject(static_cast<const btCollisionShape&>(shape),
|
|
|
|
|
btTransform(btQuaternion(btVector3(1, 0, 0), static_cast<btScalar>(-osg::PI_4))), 1);
|
|
|
|
|
builder.addObject(
|
|
|
|
|
static_cast<const btCollisionShape&>(shape),
|
|
|
|
|
btTransform(btQuaternion(btVector3(1, 0, 0),
|
|
|
|
|
static_cast<btScalar>(-osg::PI_4))),
|
|
|
|
|
AreaType_ground
|
|
|
|
|
);
|
|
|
|
|
const auto recastMesh = builder.create();
|
|
|
|
|
EXPECT_EQ(recastMesh->getVertices(), std::vector<float>({
|
|
|
|
|
0, -0.70710659027099609375, -3.535533905029296875,
|
|
|
|
@ -289,7 +307,7 @@ namespace
|
|
|
|
|
0, 2.384185791015625e-07, -4.24264049530029296875,
|
|
|
|
|
}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getIndices(), std::vector<int>({0, 1, 2}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getFlags(), std::vector<unsigned char>({1}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getAreaTypes(), std::vector<AreaType>({AreaType_ground}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(DetourNavigatorRecastMeshBuilderTest, with_bounds_add_rotated_by_y_bhv_triangle_shape_should_filter_by_bounds)
|
|
|
|
@ -301,8 +319,12 @@ namespace
|
|
|
|
|
mesh.addTriangle(btVector3(-3, 0, -3), btVector3(-3, 0, -2), btVector3(-2, 0, -3));
|
|
|
|
|
btBvhTriangleMeshShape shape(&mesh, true);
|
|
|
|
|
RecastMeshBuilder builder(mSettings, mBounds);
|
|
|
|
|
builder.addObject(static_cast<const btCollisionShape&>(shape),
|
|
|
|
|
btTransform(btQuaternion(btVector3(0, 1, 0), static_cast<btScalar>(osg::PI_4))), 1);
|
|
|
|
|
builder.addObject(
|
|
|
|
|
static_cast<const btCollisionShape&>(shape),
|
|
|
|
|
btTransform(btQuaternion(btVector3(0, 1, 0),
|
|
|
|
|
static_cast<btScalar>(osg::PI_4))),
|
|
|
|
|
AreaType_ground
|
|
|
|
|
);
|
|
|
|
|
const auto recastMesh = builder.create();
|
|
|
|
|
EXPECT_EQ(recastMesh->getVertices(), std::vector<float>({
|
|
|
|
|
-3.535533905029296875, -0.70710659027099609375, 0,
|
|
|
|
@ -310,7 +332,7 @@ namespace
|
|
|
|
|
-4.24264049530029296875, 2.384185791015625e-07, 0,
|
|
|
|
|
}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getIndices(), std::vector<int>({0, 1, 2}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getFlags(), std::vector<unsigned char>({1}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getAreaTypes(), std::vector<AreaType>({AreaType_ground}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(DetourNavigatorRecastMeshBuilderTest, with_bounds_add_rotated_by_z_bhv_triangle_shape_should_filter_by_bounds)
|
|
|
|
@ -322,8 +344,12 @@ namespace
|
|
|
|
|
mesh.addTriangle(btVector3(-3, -3, 0), btVector3(-3, -2, 0), btVector3(-2, -3, 0));
|
|
|
|
|
btBvhTriangleMeshShape shape(&mesh, true);
|
|
|
|
|
RecastMeshBuilder builder(mSettings, mBounds);
|
|
|
|
|
builder.addObject(static_cast<const btCollisionShape&>(shape),
|
|
|
|
|
btTransform(btQuaternion(btVector3(0, 0, 1), static_cast<btScalar>(osg::PI_4))), 1);
|
|
|
|
|
builder.addObject(
|
|
|
|
|
static_cast<const btCollisionShape&>(shape),
|
|
|
|
|
btTransform(btQuaternion(btVector3(0, 0, 1),
|
|
|
|
|
static_cast<btScalar>(osg::PI_4))),
|
|
|
|
|
AreaType_ground
|
|
|
|
|
);
|
|
|
|
|
const auto recastMesh = builder.create();
|
|
|
|
|
EXPECT_EQ(recastMesh->getVertices(), std::vector<float>({
|
|
|
|
|
0.707107067108154296875, 0, -3.535533905029296875,
|
|
|
|
@ -331,7 +357,7 @@ namespace
|
|
|
|
|
2.384185791015625e-07, 0, -4.24264049530029296875,
|
|
|
|
|
}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getIndices(), std::vector<int>({0, 1, 2}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getFlags(), std::vector<unsigned char>({1}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getAreaTypes(), std::vector<AreaType>({AreaType_ground}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(DetourNavigatorRecastMeshBuilderTest, flags_values_should_be_corresponding_to_added_objects)
|
|
|
|
@ -343,8 +369,16 @@ namespace
|
|
|
|
|
mesh2.addTriangle(btVector3(-3, -3, 0), btVector3(-3, -2, 0), btVector3(-2, -3, 0));
|
|
|
|
|
btBvhTriangleMeshShape shape2(&mesh2, true);
|
|
|
|
|
RecastMeshBuilder builder(mSettings, mBounds);
|
|
|
|
|
builder.addObject(static_cast<const btCollisionShape&>(shape1), btTransform::getIdentity(), 1);
|
|
|
|
|
builder.addObject(static_cast<const btCollisionShape&>(shape2), btTransform::getIdentity(), 0);
|
|
|
|
|
builder.addObject(
|
|
|
|
|
static_cast<const btCollisionShape&>(shape1),
|
|
|
|
|
btTransform::getIdentity(),
|
|
|
|
|
AreaType_ground
|
|
|
|
|
);
|
|
|
|
|
builder.addObject(
|
|
|
|
|
static_cast<const btCollisionShape&>(shape2),
|
|
|
|
|
btTransform::getIdentity(),
|
|
|
|
|
AreaType_null
|
|
|
|
|
);
|
|
|
|
|
const auto recastMesh = builder.create();
|
|
|
|
|
EXPECT_EQ(recastMesh->getVertices(), std::vector<float>({
|
|
|
|
|
1, 0, -1,
|
|
|
|
@ -355,6 +389,6 @@ namespace
|
|
|
|
|
-3, 0, -3,
|
|
|
|
|
}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getIndices(), std::vector<int>({0, 1, 2, 3, 4, 5}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getFlags(), std::vector<unsigned char>({1, 0}));
|
|
|
|
|
EXPECT_EQ(recastMesh->getAreaTypes(), std::vector<AreaType>({AreaType_ground, AreaType_null}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|