1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 10:23:52 +00:00

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.
This commit is contained in:
elsid 2019-02-22 11:34:53 +03:00
parent cb5a57e41b
commit 73734fc04d
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40
2 changed files with 19 additions and 3 deletions

View file

@ -120,4 +120,22 @@ namespace
EXPECT_EQ(manager.getMesh(TilePosition(0, -1)), nullptr); EXPECT_EQ(manager.getMesh(TilePosition(0, -1)), nullptr);
EXPECT_EQ(manager.getMesh(TilePosition(0, 0)), 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);
}
} }

View file

@ -46,13 +46,11 @@ namespace DetourNavigator
const auto onTilePosition = [&] (const TilePosition& tilePosition) const auto onTilePosition = [&] (const TilePosition& tilePosition)
{ {
if (currentTiles.count(tilePosition)) if (currentTiles.count(tilePosition))
{
if (updateTile(id, transform, areaType, tilePosition, tiles.get()))
{ {
newTiles.insert(tilePosition); newTiles.insert(tilePosition);
if (updateTile(id, transform, areaType, tilePosition, tiles.get()))
changedTiles.push_back(tilePosition); changedTiles.push_back(tilePosition);
} }
}
else if (addTile(id, shape, transform, areaType, tilePosition, border, tiles.get())) else if (addTile(id, shape, transform, areaType, tilePosition, border, tiles.get()))
{ {
newTiles.insert(tilePosition); newTiles.insert(tilePosition);