Fix update navmesh for not changed objects

When update method is called for not changed object befor this change
all object tiles were considered as not object tiles and were removed.
Also this marked those tiles as changed. This lead to alternation
between remove and add each tile update method was called. Problem was
detected by using Animated Containers mod.
pull/541/head
elsid 6 years ago
parent cb5a57e41b
commit 73734fc04d
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -120,4 +120,22 @@ namespace
EXPECT_EQ(manager.getMesh(TilePosition(0, -1)), nullptr);
EXPECT_EQ(manager.getMesh(TilePosition(0, 0)), nullptr);
}
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_for_not_changed_object_after_update_should_return_recast_mesh_for_same_tiles)
{
TileCachedRecastMeshManager manager(mSettings);
const btBoxShape boxShape(btVector3(20, 20, 100));
manager.addObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground);
EXPECT_NE(manager.getMesh(TilePosition(-1, -1)), nullptr);
EXPECT_NE(manager.getMesh(TilePosition(-1, 0)), nullptr);
EXPECT_NE(manager.getMesh(TilePosition(0, -1)), nullptr);
EXPECT_NE(manager.getMesh(TilePosition(0, 0)), nullptr);
manager.updateObject(ObjectId(1ul), boxShape, btTransform::getIdentity(), AreaType::AreaType_ground);
EXPECT_NE(manager.getMesh(TilePosition(-1, -1)), nullptr);
EXPECT_NE(manager.getMesh(TilePosition(-1, 0)), nullptr);
EXPECT_NE(manager.getMesh(TilePosition(0, -1)), nullptr);
EXPECT_NE(manager.getMesh(TilePosition(0, 0)), nullptr);
}
}

@ -47,11 +47,9 @@ namespace DetourNavigator
{
if (currentTiles.count(tilePosition))
{
newTiles.insert(tilePosition);
if (updateTile(id, transform, areaType, tilePosition, tiles.get()))
{
newTiles.insert(tilePosition);
changedTiles.push_back(tilePosition);
}
}
else if (addTile(id, shape, transform, areaType, tilePosition, border, tiles.get()))
{

Loading…
Cancel
Save