mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
Allow to create empty RecastMesh
This commit is contained in:
parent
dd5f4498f6
commit
937e8e1803
4 changed files with 17 additions and 8 deletions
|
@ -31,9 +31,11 @@ namespace
|
|||
}
|
||||
};
|
||||
|
||||
TEST_F(DetourNavigatorRecastMeshBuilderTest, create_for_empty_should_throw_exception)
|
||||
TEST_F(DetourNavigatorRecastMeshBuilderTest, create_for_empty_should_return_empty)
|
||||
{
|
||||
EXPECT_THROW(mBuilder.create(), std::invalid_argument);
|
||||
const auto recastMesh = mBuilder.create();
|
||||
EXPECT_EQ(recastMesh->getVertices(), std::vector<float>());
|
||||
EXPECT_EQ(recastMesh->getIndices(), std::vector<int>());
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorRecastMeshBuilderTest, add_bhv_triangle_mesh_shape)
|
||||
|
|
|
@ -120,7 +120,7 @@ namespace DetourNavigator
|
|||
const auto trianglesCount = indices.size() / 3;
|
||||
|
||||
if (trianglesCount == 0)
|
||||
throw InvalidArgument("ChunkyTriMesh tris should contain at least 3 values");
|
||||
return;
|
||||
|
||||
const auto nchunks = (trianglesCount + trisPerChunk - 1) / trisPerChunk;
|
||||
|
||||
|
|
|
@ -269,9 +269,6 @@ namespace DetourNavigator
|
|||
getRadius(settings, agentHalfExtents),
|
||||
" changedTile=", changedTile);
|
||||
|
||||
const auto& boundsMin = recastMesh.getBoundsMin();
|
||||
const auto& boundsMax = recastMesh.getBoundsMax();
|
||||
|
||||
auto& navMesh = navMeshCacheItem.mValue;
|
||||
const auto& params = *navMesh.lock()->getParams();
|
||||
const osg::Vec3f origin(params.orig[0], params.orig[1], params.orig[2]);
|
||||
|
@ -287,6 +284,15 @@ namespace DetourNavigator
|
|||
nullptr, nullptr));
|
||||
}
|
||||
|
||||
const auto& boundsMin = recastMesh.getBoundsMin();
|
||||
const auto& boundsMax = recastMesh.getBoundsMax();
|
||||
|
||||
if (boundsMin == boundsMax)
|
||||
{
|
||||
log("ignore add tile: recastMesh is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto tileBounds = makeTileBounds(settings, changedTile);
|
||||
const osg::Vec3f tileBorderMin(tileBounds.mMin.x(), boundsMin.y() - 1, tileBounds.mMin.y());
|
||||
const osg::Vec3f tileBorderMax(tileBounds.mMax.x(), boundsMax.y() + 1, tileBounds.mMax.y());
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace DetourNavigator
|
|||
, mVertices(std::move(vertices))
|
||||
, mChunkyTriMesh(mVertices, mIndices, settings.mTrianglesPerChunk)
|
||||
{
|
||||
if (getVerticesCount())
|
||||
rcCalcBounds(mVertices.data(), static_cast<int>(getVerticesCount()), mBoundsMin.ptr(), mBoundsMax.ptr());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue