From 72f211ef28d83bd76a135bc4cfc598e2da7c04cb Mon Sep 17 00:00:00 2001 From: elsid Date: Wed, 18 Jul 2018 22:09:50 +0300 Subject: [PATCH] Add enums for area type and flags --- .../detournavigator/recastmeshbuilder.cpp | 100 ++++++++++++------ .../detournavigator/recastmeshobject.cpp | 28 ++--- components/detournavigator/areatype.hpp | 15 +++ .../cachedrecastmeshmanager.cpp | 8 +- .../cachedrecastmeshmanager.hpp | 4 +- components/detournavigator/chunkytrimesh.cpp | 20 ++-- components/detournavigator/chunkytrimesh.hpp | 10 +- components/detournavigator/flags.hpp | 15 +++ components/detournavigator/makenavmesh.cpp | 11 +- components/detournavigator/navigator.cpp | 8 +- components/detournavigator/navigator.hpp | 3 +- components/detournavigator/navmeshmanager.cpp | 8 +- components/detournavigator/navmeshmanager.hpp | 4 +- components/detournavigator/recastmesh.cpp | 10 +- components/detournavigator/recastmesh.hpp | 9 +- .../detournavigator/recastmeshbuilder.cpp | 30 +++--- .../detournavigator/recastmeshbuilder.hpp | 12 +-- .../detournavigator/recastmeshmanager.cpp | 10 +- .../detournavigator/recastmeshmanager.hpp | 4 +- .../detournavigator/recastmeshobject.cpp | 27 ++--- .../detournavigator/recastmeshobject.hpp | 18 ++-- .../tilecachedrecastmeshmanager.cpp | 8 +- .../tilecachedrecastmeshmanager.hpp | 4 +- 23 files changed, 218 insertions(+), 148 deletions(-) create mode 100644 components/detournavigator/areatype.hpp create mode 100644 components/detournavigator/flags.hpp diff --git a/apps/openmw_test_suite/detournavigator/recastmeshbuilder.cpp b/apps/openmw_test_suite/detournavigator/recastmeshbuilder.cpp index ad0502cb83..c27f608a9e 100644 --- a/apps/openmw_test_suite/detournavigator/recastmeshbuilder.cpp +++ b/apps/openmw_test_suite/detournavigator/recastmeshbuilder.cpp @@ -40,7 +40,7 @@ namespace const auto recastMesh = builder.create(); EXPECT_EQ(recastMesh->getVertices(), std::vector()); EXPECT_EQ(recastMesh->getIndices(), std::vector()); - EXPECT_EQ(recastMesh->getFlags(), std::vector()); + EXPECT_EQ(recastMesh->getAreaTypes(), std::vector()); } 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(shape), btTransform::getIdentity(), 1); + builder.addObject(static_cast(shape), btTransform::getIdentity(), AreaType_ground); const auto recastMesh = builder.create(); EXPECT_EQ(recastMesh->getVertices(), std::vector({ 1, 0, -1, @@ -57,7 +57,7 @@ namespace -1, 0, -1, })); EXPECT_EQ(recastMesh->getIndices(), std::vector({0, 1, 2})); - EXPECT_EQ(recastMesh->getFlags(), std::vector({1})); + EXPECT_EQ(recastMesh->getAreaTypes(), std::vector({AreaType_ground})); } TEST_F(DetourNavigatorRecastMeshBuilderTest, add_transformed_bhv_triangle_mesh_shape) @@ -69,7 +69,7 @@ namespace builder.addObject( static_cast(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({ @@ -78,7 +78,7 @@ namespace 0, 3, 0, })); EXPECT_EQ(recastMesh->getIndices(), std::vector({0, 1, 2})); - EXPECT_EQ(recastMesh->getFlags(), std::vector({1})); + EXPECT_EQ(recastMesh->getAreaTypes(), std::vector({AreaType_ground})); } TEST_F(DetourNavigatorRecastMeshBuilderTest, add_heightfield_terrian_shape) @@ -86,7 +86,7 @@ namespace const std::array 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(shape), btTransform::getIdentity(), 1); + builder.addObject(static_cast(shape), btTransform::getIdentity(), AreaType_ground); const auto recastMesh = builder.create(); EXPECT_EQ(recastMesh->getVertices(), std::vector({ -0.5, 0, -0.5, @@ -97,14 +97,14 @@ namespace 0.5, 0, 0.5, })); EXPECT_EQ(recastMesh->getIndices(), std::vector({0, 1, 2, 3, 4, 5})); - EXPECT_EQ(recastMesh->getFlags(), std::vector({1, 1})); + EXPECT_EQ(recastMesh->getAreaTypes(), std::vector({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(shape), btTransform::getIdentity(), 1); + builder.addObject(static_cast(shape), btTransform::getIdentity(), AreaType_ground); const auto recastMesh = builder.create(); EXPECT_EQ(recastMesh->getVertices(), std::vector({ 1, 2, 1, @@ -130,7 +130,7 @@ namespace 7, 6, 4, 4, 5, 7, })); - EXPECT_EQ(recastMesh->getFlags(), std::vector({1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})); + EXPECT_EQ(recastMesh->getAreaTypes(), std::vector(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(shape), btTransform::getIdentity(), 1); + builder.addObject( + static_cast(shape), + btTransform::getIdentity(), + AreaType_ground + ); const auto recastMesh = builder.create(); EXPECT_EQ(recastMesh->getVertices(), std::vector({ 1, 0, -1, @@ -181,7 +185,7 @@ namespace 7, 8, 10, 11, 12, 13, })); - EXPECT_EQ(recastMesh->getFlags(), std::vector({1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})); + EXPECT_EQ(recastMesh->getAreaTypes(), std::vector(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(shape), - btTransform(btMatrix3x3::getIdentity().scaled(btVector3(1, 2, 3)), btVector3(1, 2, 3)), - 1); + builder.addObject( + static_cast(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({ 2, 3, 0, @@ -202,7 +208,7 @@ namespace 0, 3, 0, })); EXPECT_EQ(recastMesh->getIndices(), std::vector({0, 1, 2})); - EXPECT_EQ(recastMesh->getFlags(), std::vector({1})); + EXPECT_EQ(recastMesh->getAreaTypes(), std::vector({AreaType_ground})); } TEST_F(DetourNavigatorRecastMeshBuilderTest, add_transformed_compound_shape_with_transformed_bhv_triangle_shape) @@ -217,7 +223,7 @@ namespace builder.addObject( static_cast(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({ @@ -226,7 +232,7 @@ namespace 1, 12, 2, })); EXPECT_EQ(recastMesh->getIndices(), std::vector({0, 1, 2})); - EXPECT_EQ(recastMesh->getFlags(), std::vector({1})); + EXPECT_EQ(recastMesh->getAreaTypes(), std::vector({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(shape), btTransform::getIdentity(), 1); + builder.addObject( + static_cast(shape), + btTransform::getIdentity(), + AreaType_ground + ); const auto recastMesh = builder.create(); EXPECT_EQ(recastMesh->getVertices(), std::vector({ 1, 0, -1, @@ -247,7 +257,7 @@ namespace -3, 0, -3, })); EXPECT_EQ(recastMesh->getIndices(), std::vector({0, 1, 2, 3, 4, 5})); - EXPECT_EQ(recastMesh->getFlags(), std::vector({1, 1})); + EXPECT_EQ(recastMesh->getAreaTypes(), std::vector(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(shape), btTransform::getIdentity(), 1); + builder.addObject( + static_cast(shape), + btTransform::getIdentity(), + AreaType_ground + ); const auto recastMesh = builder.create(); EXPECT_EQ(recastMesh->getVertices(), std::vector({ -0.2f, 0, -0.3f, @@ -268,7 +282,7 @@ namespace -0.3f, 0, -0.3f, })); EXPECT_EQ(recastMesh->getIndices(), std::vector({0, 1, 2})); - EXPECT_EQ(recastMesh->getFlags(), std::vector({1})); + EXPECT_EQ(recastMesh->getAreaTypes(), std::vector({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(shape), - btTransform(btQuaternion(btVector3(1, 0, 0), static_cast(-osg::PI_4))), 1); + builder.addObject( + static_cast(shape), + btTransform(btQuaternion(btVector3(1, 0, 0), + static_cast(-osg::PI_4))), + AreaType_ground + ); const auto recastMesh = builder.create(); EXPECT_EQ(recastMesh->getVertices(), std::vector({ 0, -0.70710659027099609375, -3.535533905029296875, @@ -289,7 +307,7 @@ namespace 0, 2.384185791015625e-07, -4.24264049530029296875, })); EXPECT_EQ(recastMesh->getIndices(), std::vector({0, 1, 2})); - EXPECT_EQ(recastMesh->getFlags(), std::vector({1})); + EXPECT_EQ(recastMesh->getAreaTypes(), std::vector({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(shape), - btTransform(btQuaternion(btVector3(0, 1, 0), static_cast(osg::PI_4))), 1); + builder.addObject( + static_cast(shape), + btTransform(btQuaternion(btVector3(0, 1, 0), + static_cast(osg::PI_4))), + AreaType_ground + ); const auto recastMesh = builder.create(); EXPECT_EQ(recastMesh->getVertices(), std::vector({ -3.535533905029296875, -0.70710659027099609375, 0, @@ -310,7 +332,7 @@ namespace -4.24264049530029296875, 2.384185791015625e-07, 0, })); EXPECT_EQ(recastMesh->getIndices(), std::vector({0, 1, 2})); - EXPECT_EQ(recastMesh->getFlags(), std::vector({1})); + EXPECT_EQ(recastMesh->getAreaTypes(), std::vector({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(shape), - btTransform(btQuaternion(btVector3(0, 0, 1), static_cast(osg::PI_4))), 1); + builder.addObject( + static_cast(shape), + btTransform(btQuaternion(btVector3(0, 0, 1), + static_cast(osg::PI_4))), + AreaType_ground + ); const auto recastMesh = builder.create(); EXPECT_EQ(recastMesh->getVertices(), std::vector({ 0.707107067108154296875, 0, -3.535533905029296875, @@ -331,7 +357,7 @@ namespace 2.384185791015625e-07, 0, -4.24264049530029296875, })); EXPECT_EQ(recastMesh->getIndices(), std::vector({0, 1, 2})); - EXPECT_EQ(recastMesh->getFlags(), std::vector({1})); + EXPECT_EQ(recastMesh->getAreaTypes(), std::vector({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(shape1), btTransform::getIdentity(), 1); - builder.addObject(static_cast(shape2), btTransform::getIdentity(), 0); + builder.addObject( + static_cast(shape1), + btTransform::getIdentity(), + AreaType_ground + ); + builder.addObject( + static_cast(shape2), + btTransform::getIdentity(), + AreaType_null + ); const auto recastMesh = builder.create(); EXPECT_EQ(recastMesh->getVertices(), std::vector({ 1, 0, -1, @@ -355,6 +389,6 @@ namespace -3, 0, -3, })); EXPECT_EQ(recastMesh->getIndices(), std::vector({0, 1, 2, 3, 4, 5})); - EXPECT_EQ(recastMesh->getFlags(), std::vector({1, 0})); + EXPECT_EQ(recastMesh->getAreaTypes(), std::vector({AreaType_ground, AreaType_null})); } } diff --git a/apps/openmw_test_suite/detournavigator/recastmeshobject.cpp b/apps/openmw_test_suite/detournavigator/recastmeshobject.cpp index ba8441c60b..9b30cadd7a 100644 --- a/apps/openmw_test_suite/detournavigator/recastmeshobject.cpp +++ b/apps/openmw_test_suite/detournavigator/recastmeshobject.cpp @@ -26,47 +26,47 @@ namespace TEST_F(DetourNavigatorRecastMeshObjectTest, constructed_object_should_have_shape_and_transform) { - const RecastMeshObject object(mBoxShape, mTransform, 1); + const RecastMeshObject object(mBoxShape, mTransform, AreaType_ground); EXPECT_EQ(std::addressof(object.getShape()), std::addressof(mBoxShape)); EXPECT_EQ(object.getTransform(), mTransform); } TEST_F(DetourNavigatorRecastMeshObjectTest, update_with_same_transform_for_not_compound_shape_should_return_false) { - RecastMeshObject object(mBoxShape, mTransform, 1); - EXPECT_FALSE(object.update(mTransform, 1)); + RecastMeshObject object(mBoxShape, mTransform, AreaType_ground); + EXPECT_FALSE(object.update(mTransform, AreaType_ground)); } TEST_F(DetourNavigatorRecastMeshObjectTest, update_with_different_transform_should_return_true) { - RecastMeshObject object(mBoxShape, mTransform, 1); - EXPECT_TRUE(object.update(btTransform::getIdentity(), 1)); + RecastMeshObject object(mBoxShape, mTransform, AreaType_ground); + EXPECT_TRUE(object.update(btTransform::getIdentity(), AreaType_ground)); } TEST_F(DetourNavigatorRecastMeshObjectTest, update_with_different_flags_should_return_true) { - RecastMeshObject object(mBoxShape, mTransform, 1); - EXPECT_TRUE(object.update(mTransform, 2)); + RecastMeshObject object(mBoxShape, mTransform, AreaType_ground); + EXPECT_TRUE(object.update(mTransform, AreaType_null)); } TEST_F(DetourNavigatorRecastMeshObjectTest, update_for_compound_shape_with_same_transform_and_not_changed_child_transform_should_return_false) { - RecastMeshObject object(mCompoundShape, mTransform, 1); - EXPECT_FALSE(object.update(mTransform, 1)); + RecastMeshObject object(mCompoundShape, mTransform, AreaType_ground); + EXPECT_FALSE(object.update(mTransform, AreaType_ground)); } TEST_F(DetourNavigatorRecastMeshObjectTest, update_for_compound_shape_with_same_transform_and_changed_child_transform_should_return_true) { - RecastMeshObject object(mCompoundShape, mTransform, 1); + RecastMeshObject object(mCompoundShape, mTransform, AreaType_ground); mCompoundShape.updateChildTransform(0, btTransform::getIdentity()); - EXPECT_TRUE(object.update(mTransform, 1)); + EXPECT_TRUE(object.update(mTransform, AreaType_ground)); } TEST_F(DetourNavigatorRecastMeshObjectTest, repeated_update_for_compound_shape_without_changes_should_return_false) { - RecastMeshObject object(mCompoundShape, mTransform, 1); + RecastMeshObject object(mCompoundShape, mTransform, AreaType_ground); mCompoundShape.updateChildTransform(0, btTransform::getIdentity()); - object.update(mTransform, 1); - EXPECT_FALSE(object.update(mTransform, 1)); + object.update(mTransform, AreaType_ground); + EXPECT_FALSE(object.update(mTransform, AreaType_ground)); } } diff --git a/components/detournavigator/areatype.hpp b/components/detournavigator/areatype.hpp new file mode 100644 index 0000000000..3efaccc44c --- /dev/null +++ b/components/detournavigator/areatype.hpp @@ -0,0 +1,15 @@ +#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_AREATYPE_H +#define OPENMW_COMPONENTS_DETOURNAVIGATOR_AREATYPE_H + +#include + +namespace DetourNavigator +{ + enum AreaType : unsigned char + { + AreaType_null = RC_NULL_AREA, + AreaType_ground = RC_WALKABLE_AREA, + }; +} + +#endif diff --git a/components/detournavigator/cachedrecastmeshmanager.cpp b/components/detournavigator/cachedrecastmeshmanager.cpp index ce9fe5c517..c5ff00a265 100644 --- a/components/detournavigator/cachedrecastmeshmanager.cpp +++ b/components/detournavigator/cachedrecastmeshmanager.cpp @@ -8,17 +8,17 @@ namespace DetourNavigator {} bool CachedRecastMeshManager::addObject(std::size_t id, const btCollisionShape& shape, - const btTransform& transform, const unsigned char flags) + const btTransform& transform, const AreaType areaType) { - if (!mImpl.addObject(id, shape, transform, flags)) + if (!mImpl.addObject(id, shape, transform, areaType)) return false; mCached.reset(); return true; } - bool CachedRecastMeshManager::updateObject(std::size_t id, const btTransform& transform, const unsigned char flags) + bool CachedRecastMeshManager::updateObject(std::size_t id, const btTransform& transform, const AreaType areaType) { - if (!mImpl.updateObject(id, transform, flags)) + if (!mImpl.updateObject(id, transform, areaType)) return false; mCached.reset(); return true; diff --git a/components/detournavigator/cachedrecastmeshmanager.hpp b/components/detournavigator/cachedrecastmeshmanager.hpp index 6f3f2a05ab..15168f9ad6 100644 --- a/components/detournavigator/cachedrecastmeshmanager.hpp +++ b/components/detournavigator/cachedrecastmeshmanager.hpp @@ -13,9 +13,9 @@ namespace DetourNavigator CachedRecastMeshManager(const Settings& settings, const TileBounds& bounds); bool addObject(std::size_t id, const btCollisionShape& shape, const btTransform& transform, - const unsigned char flags); + const AreaType areaType); - bool updateObject(std::size_t id, const btTransform& transform, const unsigned char flags); + bool updateObject(std::size_t id, const btTransform& transform, const AreaType areaType); boost::optional removeObject(std::size_t id); diff --git a/components/detournavigator/chunkytrimesh.cpp b/components/detournavigator/chunkytrimesh.cpp index f6e257c54b..3a8fc34802 100644 --- a/components/detournavigator/chunkytrimesh.cpp +++ b/components/detournavigator/chunkytrimesh.cpp @@ -13,7 +13,7 @@ namespace DetourNavigator { Rect mBounds; std::ptrdiff_t mOffset; - unsigned char mFlags; + unsigned char mAreaTypes; }; template @@ -44,9 +44,9 @@ namespace DetourNavigator } void subdivide(std::vector& items, const std::size_t imin, const std::size_t imax, - const std::size_t trisPerChunk, const std::vector& inIndices, const std::vector& inFlags, + const std::size_t trisPerChunk, const std::vector& inIndices, const std::vector& inAreaTypes, std::size_t& curNode, std::vector& nodes, std::size_t& curTri, - std::vector& outIndices, std::vector& outFlags) + std::vector& outIndices, std::vector& outAreaTypes) { const auto inum = imax - imin; const auto icur = curNode; @@ -72,7 +72,7 @@ namespace DetourNavigator inIndices.begin() + items[i].mOffset * 3 + 3, outIndices.begin() + static_cast(curTri) * 3 ); - outFlags[curTri] = inFlags[static_cast(items[i].mOffset)]; + outAreaTypes[curTri] = inAreaTypes[static_cast(items[i].mOffset)]; curTri++; } } @@ -104,9 +104,9 @@ namespace DetourNavigator const auto isplit = imin + inum / 2; // Left - subdivide(items, imin, isplit, trisPerChunk, inIndices, inFlags, curNode, nodes, curTri, outIndices, outFlags); + subdivide(items, imin, isplit, trisPerChunk, inIndices, inAreaTypes, curNode, nodes, curTri, outIndices, outAreaTypes); // Right - subdivide(items, isplit, imax, trisPerChunk, inIndices, inFlags, curNode, nodes, curTri, outIndices, outFlags); + subdivide(items, isplit, imax, trisPerChunk, inIndices, inAreaTypes, curNode, nodes, curTri, outIndices, outAreaTypes); const auto iescape = static_cast(curNode) - static_cast(icur); // Negative index means escape. @@ -116,7 +116,7 @@ namespace DetourNavigator } ChunkyTriMesh::ChunkyTriMesh(const std::vector& verts, const std::vector& indices, - const std::vector& flags, const std::size_t trisPerChunk) + const std::vector& flags, const std::size_t trisPerChunk) : mMaxTrisPerChunk(0) { const auto trianglesCount = indices.size() / 3; @@ -128,7 +128,7 @@ namespace DetourNavigator mNodes.resize(nchunks * 4); mIndices.resize(trianglesCount * 3); - mFlags.resize(trianglesCount); + mAreaTypes.resize(trianglesCount); // Build tree std::vector items(trianglesCount); @@ -138,7 +138,7 @@ namespace DetourNavigator auto& item = items[i]; item.mOffset = static_cast(i); - item.mFlags = flags[i]; + item.mAreaTypes = flags[i]; // Calc triangle XZ bounds. const auto baseIndex = static_cast(indices[i * 3]) * 3; @@ -160,7 +160,7 @@ namespace DetourNavigator std::size_t curTri = 0; std::size_t curNode = 0; - subdivide(items, 0, trianglesCount, trisPerChunk, indices, flags, curNode, mNodes, curTri, mIndices, mFlags); + subdivide(items, 0, trianglesCount, trisPerChunk, indices, flags, curNode, mNodes, curTri, mIndices, mAreaTypes); items.clear(); diff --git a/components/detournavigator/chunkytrimesh.hpp b/components/detournavigator/chunkytrimesh.hpp index ddd0b93e67..c9d35f0865 100644 --- a/components/detournavigator/chunkytrimesh.hpp +++ b/components/detournavigator/chunkytrimesh.hpp @@ -1,6 +1,8 @@ #ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_CHUNKYTRIMESH_H #define OPENMW_COMPONENTS_DETOURNAVIGATOR_CHUNKYTRIMESH_H +#include "areatype.hpp" + #include #include @@ -24,7 +26,7 @@ namespace DetourNavigator struct Chunk { const int* const mIndices; - const unsigned char* const mFlags; + const AreaType* const mAreaTypes; const std::size_t mSize; }; @@ -42,7 +44,7 @@ namespace DetourNavigator /// Creates partitioned triangle mesh (AABB tree), /// where each node contains at max trisPerChunk triangles. ChunkyTriMesh(const std::vector& verts, const std::vector& tris, - const std::vector& flags, const std::size_t trisPerChunk); + const std::vector& flags, const std::size_t trisPerChunk); ChunkyTriMesh(const ChunkyTriMesh&) = delete; ChunkyTriMesh& operator=(const ChunkyTriMesh&) = delete; @@ -76,7 +78,7 @@ namespace DetourNavigator const auto& node = mNodes[chunkId]; return Chunk { mIndices.data() + node.mOffset * 3, - mFlags.data() + node.mOffset, + mAreaTypes.data() + node.mOffset, node.mSize }; } @@ -89,7 +91,7 @@ namespace DetourNavigator private: std::vector mNodes; std::vector mIndices; - std::vector mFlags; + std::vector mAreaTypes; std::size_t mMaxTrisPerChunk; }; } diff --git a/components/detournavigator/flags.hpp b/components/detournavigator/flags.hpp new file mode 100644 index 0000000000..21a1d7694c --- /dev/null +++ b/components/detournavigator/flags.hpp @@ -0,0 +1,15 @@ +#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_FLAGS_H +#define OPENMW_COMPONENTS_DETOURNAVIGATOR_FLAGS_H + +namespace DetourNavigator +{ + using Flags = unsigned short; + + enum Flag : Flags + { + Flag_none = 0, + Flag_walk = 1 << 0, + }; +} + +#endif diff --git a/components/detournavigator/makenavmesh.cpp b/components/detournavigator/makenavmesh.cpp index 4b77f45b76..454b88f9ea 100644 --- a/components/detournavigator/makenavmesh.cpp +++ b/components/detournavigator/makenavmesh.cpp @@ -8,6 +8,7 @@ #include "settingsutils.hpp" #include "sharednavmesh.hpp" #include "settingsutils.hpp" +#include "flags.hpp" #include #include @@ -99,7 +100,7 @@ namespace { const auto& chunkyMesh = recastMesh.getChunkyTriMesh(); - std::vector areas(chunkyMesh.getMaxTrisPerChunk(), RC_NULL_AREA); + std::vector areas(chunkyMesh.getMaxTrisPerChunk(), AreaType_null); const osg::Vec2f tileBoundsMin(config.bmin[0], config.bmin[2]); const osg::Vec2f tileBoundsMax(config.bmax[0], config.bmax[2]); std::vector cids; @@ -116,7 +117,7 @@ namespace areas.begin(), std::min(areas.begin() + static_cast(chunk.mSize), areas.end()), - RC_NULL_AREA + AreaType_null ); rcMarkWalkableTriangles( @@ -130,7 +131,7 @@ namespace ); for (std::size_t i = 0; i < chunk.mSize; ++i) - areas[i] &= chunk.mFlags[i]; + areas[i] = chunk.mAreaTypes[i]; rcClearUnwalkableTriangles( &context, @@ -186,8 +187,8 @@ namespace } for (int i = 0; i < polyMesh.npolys; ++i) - if (polyMesh.areas[i] == RC_WALKABLE_AREA) - polyMesh.flags[i] = 1; + if (polyMesh.areas[i] == AreaType_ground) + polyMesh.flags[i] = Flag_walk; dtNavMeshCreateParams params; params.verts = polyMesh.verts; diff --git a/components/detournavigator/navigator.cpp b/components/detournavigator/navigator.cpp index 0fc195675d..f6ead7c7db 100644 --- a/components/detournavigator/navigator.cpp +++ b/components/detournavigator/navigator.cpp @@ -29,7 +29,7 @@ namespace DetourNavigator bool Navigator::addObject(std::size_t id, const btCollisionShape& shape, const btTransform& transform) { - return mNavMeshManager.addObject(id, shape, transform, RC_WALKABLE_AREA); + return mNavMeshManager.addObject(id, shape, transform, AreaType_ground); } bool Navigator::addObject(std::size_t id, const ObjectShapes& shapes, const btTransform& transform) @@ -38,7 +38,7 @@ namespace DetourNavigator if (shapes.mAvoid) { const auto avoidId = reinterpret_cast(shapes.mAvoid); - if (mNavMeshManager.addObject(avoidId, *shapes.mAvoid, transform, RC_NULL_AREA)) + if (mNavMeshManager.addObject(avoidId, *shapes.mAvoid, transform, AreaType_null)) { updateAvoidShapeId(id, avoidId); result = true; @@ -49,7 +49,7 @@ namespace DetourNavigator bool Navigator::updateObject(std::size_t id, const btCollisionShape& shape, const btTransform& transform) { - return mNavMeshManager.updateObject(id, shape, transform, RC_WALKABLE_AREA); + return mNavMeshManager.updateObject(id, shape, transform, AreaType_ground); } bool Navigator::updateObject(std::size_t id, const ObjectShapes& shapes, const btTransform& transform) @@ -58,7 +58,7 @@ namespace DetourNavigator if (shapes.mAvoid) { const auto avoidId = reinterpret_cast(shapes.mAvoid); - if (mNavMeshManager.updateObject(avoidId, *shapes.mAvoid, transform, RC_NULL_AREA)) + if (mNavMeshManager.updateObject(avoidId, *shapes.mAvoid, transform, AreaType_null)) { updateAvoidShapeId(id, avoidId); result = true; diff --git a/components/detournavigator/navigator.hpp b/components/detournavigator/navigator.hpp index 39dd41a140..0f82bd7abe 100644 --- a/components/detournavigator/navigator.hpp +++ b/components/detournavigator/navigator.hpp @@ -15,8 +15,7 @@ namespace DetourNavigator ObjectShapes(const btCollisionShape& shape, const btCollisionShape* avoid) : mShape(shape), mAvoid(avoid) - { - } + {} }; class Navigator diff --git a/components/detournavigator/navmeshmanager.cpp b/components/detournavigator/navmeshmanager.cpp index 7ddaef55c7..265ef749f5 100644 --- a/components/detournavigator/navmeshmanager.cpp +++ b/components/detournavigator/navmeshmanager.cpp @@ -32,18 +32,18 @@ namespace DetourNavigator {} bool NavMeshManager::addObject(std::size_t id, const btCollisionShape& shape, const btTransform& transform, - const unsigned char flags) + const AreaType areaType) { - if (!mRecastMeshManager.addObject(id, shape, transform, flags)) + if (!mRecastMeshManager.addObject(id, shape, transform, areaType)) return false; addChangedTiles(shape, transform, ChangeType::add); return true; } bool NavMeshManager::updateObject(std::size_t id, const btCollisionShape& shape, const btTransform& transform, - const unsigned char flags) + const AreaType areaType) { - if (!mRecastMeshManager.updateObject(id, transform, flags)) + if (!mRecastMeshManager.updateObject(id, transform, areaType)) return false; addChangedTiles(shape, transform, ChangeType::mixed); return true; diff --git a/components/detournavigator/navmeshmanager.hpp b/components/detournavigator/navmeshmanager.hpp index fbbc81e6cf..25ee305c4f 100644 --- a/components/detournavigator/navmeshmanager.hpp +++ b/components/detournavigator/navmeshmanager.hpp @@ -24,10 +24,10 @@ namespace DetourNavigator NavMeshManager(const Settings& settings); bool addObject(std::size_t id, const btCollisionShape& shape, const btTransform& transform, - const unsigned char flags); + const AreaType areaType); bool updateObject(std::size_t id, const btCollisionShape& shape, const btTransform& transform, - const unsigned char flags); + const AreaType areaType); bool removeObject(std::size_t id); diff --git a/components/detournavigator/recastmesh.cpp b/components/detournavigator/recastmesh.cpp index fc23c1feaf..5a339d3427 100644 --- a/components/detournavigator/recastmesh.cpp +++ b/components/detournavigator/recastmesh.cpp @@ -7,15 +7,15 @@ namespace DetourNavigator { RecastMesh::RecastMesh(std::vector indices, std::vector vertices, - std::vector flags, const Settings& settings) + std::vector areaTypes, const Settings& settings) : mIndices(std::move(indices)) , mVertices(std::move(vertices)) - , mFlags(std::move(flags)) - , mChunkyTriMesh(mVertices, mIndices, mFlags, settings.mTrianglesPerChunk) + , mAreaTypes(std::move(areaTypes)) + , mChunkyTriMesh(mVertices, mIndices, mAreaTypes, settings.mTrianglesPerChunk) { - if (getTrianglesCount() != mFlags.size()) + if (getTrianglesCount() != mAreaTypes.size()) throw InvalidArgument("number of flags doesn't match number of triangles: triangles=" - + std::to_string(getTrianglesCount()) + ", flags=" + std::to_string(mFlags.size())); + + std::to_string(getTrianglesCount()) + ", areaTypes=" + std::to_string(mAreaTypes.size())); if (getVerticesCount()) rcCalcBounds(mVertices.data(), static_cast(getVerticesCount()), mBoundsMin.ptr(), mBoundsMax.ptr()); } diff --git a/components/detournavigator/recastmesh.hpp b/components/detournavigator/recastmesh.hpp index 59f97b2ee0..2e31cd27d2 100644 --- a/components/detournavigator/recastmesh.hpp +++ b/components/detournavigator/recastmesh.hpp @@ -1,6 +1,7 @@ #ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESH_H #define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESH_H +#include "areatype.hpp" #include "chunkytrimesh.hpp" #include @@ -16,7 +17,7 @@ namespace DetourNavigator { public: RecastMesh(std::vector indices, std::vector vertices, - std::vector flags, const Settings& settings); + std::vector areaTypes, const Settings& settings); const std::vector& getIndices() const { @@ -28,9 +29,9 @@ namespace DetourNavigator return mVertices; } - const std::vector& getFlags() const + const std::vector& getAreaTypes() const { - return mFlags; + return mAreaTypes; } std::size_t getVerticesCount() const @@ -61,7 +62,7 @@ namespace DetourNavigator private: std::vector mIndices; std::vector mVertices; - std::vector mFlags; + std::vector mAreaTypes; ChunkyTriMesh mChunkyTriMesh; osg::Vec3f mBoundsMin; osg::Vec3f mBoundsMax; diff --git a/components/detournavigator/recastmeshbuilder.cpp b/components/detournavigator/recastmeshbuilder.cpp index 229f420224..23a8bb83e6 100644 --- a/components/detournavigator/recastmeshbuilder.cpp +++ b/components/detournavigator/recastmeshbuilder.cpp @@ -36,51 +36,51 @@ namespace DetourNavigator } void RecastMeshBuilder::addObject(const btCollisionShape& shape, const btTransform& transform, - const unsigned char flags) + const AreaType areaType) { if (shape.isCompound()) - return addObject(static_cast(shape), transform, flags); + return addObject(static_cast(shape), transform, areaType); else if (shape.getShapeType() == TERRAIN_SHAPE_PROXYTYPE) - return addObject(static_cast(shape), transform, flags); + return addObject(static_cast(shape), transform, areaType); else if (shape.isConcave()) - return addObject(static_cast(shape), transform, flags); + return addObject(static_cast(shape), transform, areaType); else if (shape.getShapeType() == BOX_SHAPE_PROXYTYPE) - return addObject(static_cast(shape), transform, flags); + return addObject(static_cast(shape), transform, areaType); std::ostringstream message; message << "Unsupported shape type: " << BroadphaseNativeTypes(shape.getShapeType()); throw InvalidArgument(message.str()); } void RecastMeshBuilder::addObject(const btCompoundShape& shape, const btTransform& transform, - const unsigned char flags) + const AreaType areaType) { for (int i = 0, num = shape.getNumChildShapes(); i < num; ++i) - addObject(*shape.getChildShape(i), transform * shape.getChildTransform(i), flags); + addObject(*shape.getChildShape(i), transform * shape.getChildTransform(i), areaType); } void RecastMeshBuilder::addObject(const btConcaveShape& shape, const btTransform& transform, - const unsigned char flags) + const AreaType areaType) { return addObject(shape, transform, makeProcessTriangleCallback([&] (btVector3* triangle, int, int) { for (std::size_t i = 3; i > 0; --i) addTriangleVertex(transform(triangle[i - 1])); - mFlags.push_back(flags); + mAreaTypes.push_back(areaType); })); } void RecastMeshBuilder::addObject(const btHeightfieldTerrainShape& shape, const btTransform& transform, - const unsigned char flags) + const AreaType areaType) { return addObject(shape, transform, makeProcessTriangleCallback([&] (btVector3* triangle, int, int) { for (std::size_t i = 0; i < 3; ++i) addTriangleVertex(transform(triangle[i])); - mFlags.push_back(flags); + mAreaTypes.push_back(areaType); })); } - void RecastMeshBuilder::addObject(const btBoxShape& shape, const btTransform& transform, const unsigned char flags) + void RecastMeshBuilder::addObject(const btBoxShape& shape, const btTransform& transform, const AreaType areaType) { const auto indexOffset = int(mVertices.size() / 3); @@ -92,7 +92,7 @@ namespace DetourNavigator } for (int vertex = 0; vertex < 12; ++vertex) - mFlags.push_back(flags); + mAreaTypes.push_back(areaType); static const std::array indices {{ 0, 2, 3, @@ -115,14 +115,14 @@ namespace DetourNavigator std::shared_ptr RecastMeshBuilder::create() const { - return std::make_shared(mIndices, mVertices, mFlags, mSettings); + return std::make_shared(mIndices, mVertices, mAreaTypes, mSettings); } void RecastMeshBuilder::reset() { mIndices.clear(); mVertices.clear(); - mFlags.clear(); + mAreaTypes.clear(); } void RecastMeshBuilder::addObject(const btConcaveShape& shape, const btTransform& transform, diff --git a/components/detournavigator/recastmeshbuilder.hpp b/components/detournavigator/recastmeshbuilder.hpp index 770acbf9d8..2210933627 100644 --- a/components/detournavigator/recastmeshbuilder.hpp +++ b/components/detournavigator/recastmeshbuilder.hpp @@ -20,15 +20,15 @@ namespace DetourNavigator public: RecastMeshBuilder(const Settings& settings, const TileBounds& bounds); - void addObject(const btCollisionShape& shape, const btTransform& transform, const unsigned char flags); + void addObject(const btCollisionShape& shape, const btTransform& transform, const AreaType areaType); - void addObject(const btCompoundShape& shape, const btTransform& transform, const unsigned char flags); + void addObject(const btCompoundShape& shape, const btTransform& transform, const AreaType areaType); - void addObject(const btConcaveShape& shape, const btTransform& transform, const unsigned char flags); + void addObject(const btConcaveShape& shape, const btTransform& transform, const AreaType areaType); - void addObject(const btHeightfieldTerrainShape& shape, const btTransform& transform, const unsigned char flags); + void addObject(const btHeightfieldTerrainShape& shape, const btTransform& transform, const AreaType areaType); - void addObject(const btBoxShape& shape, const btTransform& transform, const unsigned char flags); + void addObject(const btBoxShape& shape, const btTransform& transform, const AreaType areaType); std::shared_ptr create() const; @@ -39,7 +39,7 @@ namespace DetourNavigator TileBounds mBounds; std::vector mIndices; std::vector mVertices; - std::vector mFlags; + std::vector mAreaTypes; void addObject(const btConcaveShape& shape, const btTransform& transform, btTriangleCallback&& callback); diff --git a/components/detournavigator/recastmeshmanager.cpp b/components/detournavigator/recastmeshmanager.cpp index 66009d8b5c..d511891942 100644 --- a/components/detournavigator/recastmeshmanager.cpp +++ b/components/detournavigator/recastmeshmanager.cpp @@ -12,20 +12,20 @@ namespace DetourNavigator } bool RecastMeshManager::addObject(std::size_t id, const btCollisionShape& shape, const btTransform& transform, - const unsigned char flags) + const AreaType areaType) { - if (!mObjects.emplace(id, RecastMeshObject(shape, transform, flags)).second) + if (!mObjects.emplace(id, RecastMeshObject(shape, transform, areaType)).second) return false; mShouldRebuild = true; return mShouldRebuild; } - bool RecastMeshManager::updateObject(std::size_t id, const btTransform& transform, const unsigned char flags) + bool RecastMeshManager::updateObject(std::size_t id, const btTransform& transform, const AreaType areaType) { const auto object = mObjects.find(id); if (object == mObjects.end()) return false; - if (!object->second.update(transform, flags)) + if (!object->second.update(transform, areaType)) return false; mShouldRebuild = true; return mShouldRebuild; @@ -59,7 +59,7 @@ namespace DetourNavigator return; mMeshBuilder.reset(); for (const auto& v : mObjects) - mMeshBuilder.addObject(v.second.getShape(), v.second.getTransform(), v.second.getFlags()); + mMeshBuilder.addObject(v.second.getShape(), v.second.getTransform(), v.second.getAreaType()); mShouldRebuild = false; } } diff --git a/components/detournavigator/recastmeshmanager.hpp b/components/detournavigator/recastmeshmanager.hpp index d475d494de..7900592950 100644 --- a/components/detournavigator/recastmeshmanager.hpp +++ b/components/detournavigator/recastmeshmanager.hpp @@ -26,9 +26,9 @@ namespace DetourNavigator RecastMeshManager(const Settings& settings, const TileBounds& bounds); bool addObject(std::size_t id, const btCollisionShape& shape, const btTransform& transform, - const unsigned char flags); + const AreaType areaType); - bool updateObject(std::size_t id, const btTransform& transform, const unsigned char flags); + bool updateObject(std::size_t id, const btTransform& transform, const AreaType areaType); boost::optional removeObject(std::size_t id); diff --git a/components/detournavigator/recastmeshobject.cpp b/components/detournavigator/recastmeshobject.cpp index 54fb25ea05..1aac9fd81d 100644 --- a/components/detournavigator/recastmeshobject.cpp +++ b/components/detournavigator/recastmeshobject.cpp @@ -9,15 +9,15 @@ namespace DetourNavigator { RecastMeshObject::RecastMeshObject(const btCollisionShape& shape, const btTransform& transform, - const unsigned char flags) + const AreaType areaType) : mShape(shape) , mTransform(transform) - , mFlags(flags) - , mChildren(makeChildrenObjects(shape, mFlags)) + , mAreaType(areaType) + , mChildren(makeChildrenObjects(shape, mAreaType)) { } - bool RecastMeshObject::update(const btTransform& transform, const unsigned char flags) + bool RecastMeshObject::update(const btTransform& transform, const AreaType areaType) { bool result = false; if (!(mTransform == transform)) @@ -25,42 +25,43 @@ namespace DetourNavigator mTransform = transform; result = true; } - if (mFlags != flags) + if (mAreaType != areaType) { - mFlags = flags; + mAreaType = areaType; result = true; } if (mShape.get().isCompound()) - result = updateCompoundObject(static_cast(mShape.get()), mFlags, mChildren) || result; + result = updateCompoundObject(static_cast(mShape.get()), mAreaType, mChildren) + || result; return result; } bool RecastMeshObject::updateCompoundObject(const btCompoundShape& shape, - const unsigned char flags, std::vector& children) + const AreaType areaType, std::vector& children) { assert(static_cast(shape.getNumChildShapes()) == children.size()); bool result = false; for (int i = 0, num = shape.getNumChildShapes(); i < num; ++i) { assert(shape.getChildShape(i) == std::addressof(children[static_cast(i)].mShape.get())); - result = children[static_cast(i)].update(shape.getChildTransform(i), flags) || result; + result = children[static_cast(i)].update(shape.getChildTransform(i), areaType) || result; } return result; } - std::vector makeChildrenObjects(const btCollisionShape& shape, const unsigned char flags) + std::vector makeChildrenObjects(const btCollisionShape& shape, const AreaType areaType) { if (shape.isCompound()) - return makeChildrenObjects(static_cast(shape), flags); + return makeChildrenObjects(static_cast(shape), areaType); else return std::vector(); } - std::vector makeChildrenObjects(const btCompoundShape& shape, const unsigned char flags) + std::vector makeChildrenObjects(const btCompoundShape& shape, const AreaType areaType) { std::vector result; for (int i = 0, num = shape.getNumChildShapes(); i < num; ++i) - result.emplace_back(*shape.getChildShape(i), shape.getChildTransform(i), flags); + result.emplace_back(*shape.getChildShape(i), shape.getChildTransform(i), areaType); return result; } } diff --git a/components/detournavigator/recastmeshobject.hpp b/components/detournavigator/recastmeshobject.hpp index bc7b54d5a0..aff4681222 100644 --- a/components/detournavigator/recastmeshobject.hpp +++ b/components/detournavigator/recastmeshobject.hpp @@ -1,6 +1,8 @@ #ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHOBJECT_H #define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTMESHOBJECT_H +#include "areatype.hpp" + #include #include @@ -14,9 +16,9 @@ namespace DetourNavigator class RecastMeshObject { public: - RecastMeshObject(const btCollisionShape& shape, const btTransform& transform, const unsigned char flags); + RecastMeshObject(const btCollisionShape& shape, const btTransform& transform, const AreaType areaType); - bool update(const btTransform& transform, const unsigned char flags); + bool update(const btTransform& transform, const AreaType areaType); const btCollisionShape& getShape() const { @@ -28,24 +30,24 @@ namespace DetourNavigator return mTransform; } - unsigned char getFlags() const + AreaType getAreaType() const { - return mFlags; + return mAreaType; } private: std::reference_wrapper mShape; btTransform mTransform; - unsigned char mFlags; + AreaType mAreaType; std::vector mChildren; - static bool updateCompoundObject(const btCompoundShape& shape, const unsigned char flags, + static bool updateCompoundObject(const btCompoundShape& shape, const AreaType areaType, std::vector& children); }; - std::vector makeChildrenObjects(const btCollisionShape& shape, const unsigned char flags); + std::vector makeChildrenObjects(const btCollisionShape& shape, const AreaType areaType); - std::vector makeChildrenObjects(const btCompoundShape& shape, const unsigned char flags); + std::vector makeChildrenObjects(const btCompoundShape& shape, const AreaType areaType); } #endif diff --git a/components/detournavigator/tilecachedrecastmeshmanager.cpp b/components/detournavigator/tilecachedrecastmeshmanager.cpp index a3dec79cd4..f044b3c43e 100644 --- a/components/detournavigator/tilecachedrecastmeshmanager.cpp +++ b/components/detournavigator/tilecachedrecastmeshmanager.cpp @@ -10,7 +10,7 @@ namespace DetourNavigator {} bool TileCachedRecastMeshManager::addObject(std::size_t id, const btCollisionShape& shape, - const btTransform& transform, const unsigned char flags) + const btTransform& transform, const AreaType areaType) { bool result = false; auto& tilesPositions = mObjectsTilesPositions[id]; @@ -27,7 +27,7 @@ namespace DetourNavigator tile = mTiles.insert(std::make_pair(tilePosition, CachedRecastMeshManager(mSettings, tileBounds))).first; } - if (tile->second.addObject(id, shape, transform, flags)) + if (tile->second.addObject(id, shape, transform, areaType)) { lock.unlock(); tilesPositions.push_back(tilePosition); @@ -40,7 +40,7 @@ namespace DetourNavigator } bool TileCachedRecastMeshManager::updateObject(std::size_t id, const btTransform& transform, - const unsigned char flags) + const AreaType areaType) { const auto object = mObjectsTilesPositions.find(id); if (object == mObjectsTilesPositions.end()) @@ -51,7 +51,7 @@ namespace DetourNavigator { const auto tile = mTiles.find(tilePosition); if (tile != mTiles.end()) - result = tile->second.updateObject(id, transform, flags) || result; + result = tile->second.updateObject(id, transform, areaType) || result; } lock.unlock(); if (result) diff --git a/components/detournavigator/tilecachedrecastmeshmanager.hpp b/components/detournavigator/tilecachedrecastmeshmanager.hpp index 37299e281b..32b06eadd6 100644 --- a/components/detournavigator/tilecachedrecastmeshmanager.hpp +++ b/components/detournavigator/tilecachedrecastmeshmanager.hpp @@ -15,9 +15,9 @@ namespace DetourNavigator TileCachedRecastMeshManager(const Settings& settings); bool addObject(std::size_t id, const btCollisionShape& shape, const btTransform& transform, - const unsigned char flags); + const AreaType areaType); - bool updateObject(std::size_t id, const btTransform& transform, const unsigned char flags); + bool updateObject(std::size_t id, const btTransform& transform, const AreaType areaType); boost::optional removeObject(std::size_t id);