1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-29 17:45:34 +00:00

Use ESM::RefId for worldspace type

This commit is contained in:
elsid 2024-05-19 14:26:28 +02:00
parent 5d28164416
commit 9854d42d56
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
26 changed files with 161 additions and 169 deletions

View file

@ -106,8 +106,8 @@ namespace NavMeshTool
return DetourNavigator::resolveMeshSource(mDb, source, mNextShapeId);
}
std::optional<NavMeshTileInfo> find(std::string_view worldspace, const TilePosition& tilePosition,
const std::vector<std::byte>& input) override
std::optional<NavMeshTileInfo> find(
ESM::RefId worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input) override
{
std::optional<NavMeshTileInfo> result;
std::lock_guard lock(mMutex);
@ -121,7 +121,7 @@ namespace NavMeshTool
return result;
}
void ignore(std::string_view worldspace, const TilePosition& tilePosition) override
void ignore(ESM::RefId worldspace, const TilePosition& tilePosition) override
{
if (mRemoveUnusedTiles)
{
@ -131,7 +131,7 @@ namespace NavMeshTool
report();
}
void identity(std::string_view worldspace, const TilePosition& tilePosition, std::int64_t tileId) override
void identity(ESM::RefId worldspace, const TilePosition& tilePosition, std::int64_t tileId) override
{
if (mRemoveUnusedTiles)
{
@ -142,7 +142,7 @@ namespace NavMeshTool
report();
}
void insert(std::string_view worldspace, const TilePosition& tilePosition, std::int64_t version,
void insert(ESM::RefId worldspace, const TilePosition& tilePosition, std::int64_t version,
const std::vector<std::byte>& input, PreparedNavMeshData& data) override
{
{
@ -158,7 +158,7 @@ namespace NavMeshTool
report();
}
void update(std::string_view worldspace, const TilePosition& tilePosition, std::int64_t tileId,
void update(ESM::RefId worldspace, const TilePosition& tilePosition, std::int64_t tileId,
std::int64_t version, PreparedNavMeshData& data) override
{
data.mUserId = static_cast<unsigned>(tileId);
@ -217,7 +217,7 @@ namespace NavMeshTool
mDb.vacuum();
}
void removeTilesOutsideRange(std::string_view worldspace, const TilesPositionsRange& range)
void removeTilesOutsideRange(ESM::RefId worldspace, const TilesPositionsRange& range)
{
const std::lock_guard lock(mMutex);
mTransaction.commit();

View file

@ -234,8 +234,8 @@ namespace NavMeshTool
}
WorldspaceNavMeshInput::WorldspaceNavMeshInput(
std::string worldspace, const DetourNavigator::RecastSettings& settings)
: mWorldspace(std::move(worldspace))
ESM::RefId worldspace, const DetourNavigator::RecastSettings& settings)
: mWorldspace(worldspace)
, mTileCachedRecastMeshManager(settings)
{
mAabb.m_min = btVector3(0, 0, 0);
@ -248,7 +248,7 @@ namespace NavMeshTool
{
Log(Debug::Info) << "Processing " << esmData.mCells.size() << " cells...";
std::map<std::string_view, std::unique_ptr<WorldspaceNavMeshInput>> navMeshInputs;
std::unordered_map<ESM::RefId, std::unique_ptr<WorldspaceNavMeshInput>> navMeshInputs;
WorldspaceData data;
std::size_t objectsCounter = 0;
@ -276,8 +276,7 @@ namespace NavMeshTool
const osg::Vec2i cellPosition(cell.mData.mX, cell.mData.mY);
const std::size_t cellObjectsBegin = data.mObjects.size();
const auto cellWorldspace = Misc::StringUtils::lowerCase(
(cell.isExterior() ? ESM::Cell::sDefaultWorldspaceId : cell.mId).serializeText());
const ESM::RefId cellWorldspace = cell.isExterior() ? ESM::Cell::sDefaultWorldspaceId : cell.mId;
WorldspaceNavMeshInput& navMeshInput = [&]() -> WorldspaceNavMeshInput& {
auto it = navMeshInputs.find(cellWorldspace);
if (it == navMeshInputs.end())

View file

@ -48,12 +48,12 @@ namespace NavMeshTool
struct WorldspaceNavMeshInput
{
std::string mWorldspace;
ESM::RefId mWorldspace;
TileCachedRecastMeshManager mTileCachedRecastMeshManager;
btAABB mAabb;
bool mAabbInitialized = false;
explicit WorldspaceNavMeshInput(std::string worldspace, const DetourNavigator::RecastSettings& settings);
explicit WorldspaceNavMeshInput(ESM::RefId worldspace, const DetourNavigator::RecastSettings& settings);
};
class BulletObject

View file

@ -591,9 +591,7 @@ namespace MWWorld
else
unloadCell(cell, navigatorUpdateGuard.get());
}
mNavigator.setWorldspace(
mWorld.getWorldModel().getExterior(playerCellIndex).getCell()->getWorldSpace().serializeText(),
navigatorUpdateGuard.get());
mNavigator.setWorldspace(playerCellIndex.mWorldspace, navigatorUpdateGuard.get());
mNavigator.updateBounds(pos, navigatorUpdateGuard.get());
mCurrentGridCenter = osg::Vec2i(playerCellX, playerCellY);
@ -696,7 +694,7 @@ namespace MWWorld
CellStore& cell = mWorld.getWorldModel().getExterior(
ESM::ExteriorCellLocation(it->mData.mX, it->mData.mY, ESM::Cell::sDefaultWorldspaceId));
mNavigator.setWorldspace(cell.getCell()->getWorldSpace().serializeText(), navigatorUpdateGuard.get());
mNavigator.setWorldspace(cell.getCell()->getWorldSpace(), navigatorUpdateGuard.get());
const osg::Vec3f position
= osg::Vec3f(it->mData.mX + 0.5f, it->mData.mY + 0.5f, 0) * Constants::CellSizeInUnits;
mNavigator.updateBounds(position, navigatorUpdateGuard.get());
@ -753,7 +751,7 @@ namespace MWWorld
+ std::to_string(cells.getIntSize()) + ")...");
CellStore& cell = mWorld.getWorldModel().getInterior(it->mName);
mNavigator.setWorldspace(cell.getCell()->getWorldSpace().serializeText(), navigatorUpdateGuard.get());
mNavigator.setWorldspace(cell.getCell()->getWorldSpace(), navigatorUpdateGuard.get());
ESM::Position position;
mWorld.findInteriorPosition(it->mName, position);
mNavigator.updateBounds(position.asVec3(), navigatorUpdateGuard.get());
@ -906,7 +904,7 @@ namespace MWWorld
loadingListener->setProgressRange(cell.count());
mNavigator.setWorldspace(cell.getCell()->getWorldSpace().serializeText(), navigatorUpdateGuard.get());
mNavigator.setWorldspace(cell.getCell()->getWorldSpace(), navigatorUpdateGuard.get());
mNavigator.updateBounds(position.asVec3(), navigatorUpdateGuard.get());
// Load cell.

View file

@ -52,7 +52,7 @@ namespace
OffMeshConnectionsManager mOffMeshConnectionsManager{ mSettings.mRecast };
const AgentBounds mAgentBounds{ CollisionShapeType::Aabb, { 29, 29, 66 } };
const TilePosition mPlayerTile{ 0, 0 };
const std::string mWorldspace = "sys::default";
const ESM::RefId mWorldspace = ESM::RefId::stringRefId("sys::default");
const btBoxShape mBox{ btVector3(100, 100, 20) };
Loading::Listener mListener;
};
@ -310,7 +310,7 @@ namespace
AsyncNavMeshUpdater updater(mSettings, mRecastMeshManager, mOffMeshConnectionsManager, std::move(db));
const TileId nextTileId(dbPtr->getMaxTileId() + 1);
ASSERT_EQ(dbPtr->insertTile(nextTileId, "worldspace", TilePosition{}, TileVersion{ 1 }, {}, {}), 1);
ASSERT_EQ(dbPtr->insertTile(nextTileId, mWorldspace, TilePosition{}, TileVersion{ 1 }, {}, {}), 1);
const auto navMeshCacheItem = std::make_shared<GuardedNavMeshCacheItem>(1, mSettings);
const TilePosition tilePosition{ 0, 0 };
@ -385,7 +385,7 @@ namespace
const AgentBounds mAgentBounds{ CollisionShapeType::Aabb, osg::Vec3f(1, 1, 1) };
const std::shared_ptr<GuardedNavMeshCacheItem> mNavMeshCacheItemPtr;
const std::weak_ptr<GuardedNavMeshCacheItem> mNavMeshCacheItem = mNavMeshCacheItemPtr;
const std::string_view mWorldspace = "worldspace";
const ESM::RefId mWorldspace = ESM::RefId::stringRefId("worldspace");
const TilePosition mChangedTile{ 0, 0 };
const std::chrono::steady_clock::time_point mProcessTime{};
const TilePosition mPlayerTile{ 0, 0 };
@ -397,20 +397,23 @@ namespace
std::list<Job> jobs;
SpatialJobQueue queue;
queue.push(jobs.emplace(jobs.end(), mAgentBounds, mNavMeshCacheItem, "worldspace1", mChangedTile,
ChangeType::remove, mProcessTime));
queue.push(jobs.emplace(jobs.end(), mAgentBounds, mNavMeshCacheItem, "worldspace2", mChangedTile,
ChangeType::update, mProcessTime));
const ESM::RefId worldspace1 = ESM::RefId::stringRefId("worldspace1");
const ESM::RefId worldspace2 = ESM::RefId::stringRefId("worldspace2");
queue.push(jobs.emplace(
jobs.end(), mAgentBounds, mNavMeshCacheItem, worldspace1, mChangedTile, ChangeType::remove, mProcessTime));
queue.push(jobs.emplace(
jobs.end(), mAgentBounds, mNavMeshCacheItem, worldspace2, mChangedTile, ChangeType::update, mProcessTime));
ASSERT_EQ(queue.size(), 2);
const auto job1 = queue.pop(mChangedTile);
ASSERT_TRUE(job1.has_value());
EXPECT_EQ((*job1)->mWorldspace, "worldspace1");
EXPECT_EQ((*job1)->mWorldspace, worldspace1);
const auto job2 = queue.pop(mChangedTile);
ASSERT_TRUE(job2.has_value());
EXPECT_EQ((*job2)->mWorldspace, "worldspace2");
EXPECT_EQ((*job2)->mWorldspace, worldspace2);
EXPECT_EQ(queue.size(), 0);
}

View file

@ -8,7 +8,6 @@
#include <gtest/gtest.h>
#include <limits>
#include <numeric>
#include <random>
namespace
@ -19,7 +18,7 @@ namespace
struct Tile
{
std::string mWorldspace;
ESM::RefId mWorldspace;
TilePosition mTilePosition;
std::vector<std::byte> mInput;
std::vector<std::byte> mData;
@ -39,12 +38,12 @@ namespace
Tile insertTile(TileId tileId, TileVersion version)
{
std::string worldspace = "sys::default";
const ESM::RefId worldspace = ESM::RefId::stringRefId("sys::default");
const TilePosition tilePosition{ 3, 4 };
std::vector<std::byte> input = generateData();
std::vector<std::byte> data = generateData();
EXPECT_EQ(mDb.insertTile(tileId, worldspace, tilePosition, version, input, data), 1);
return { std::move(worldspace), tilePosition, std::move(input), std::move(data) };
return { worldspace, tilePosition, std::move(input), std::move(data) };
}
};
@ -89,7 +88,7 @@ namespace
{
const TileId tileId{ 53 };
const TileVersion version{ 1 };
const std::string worldspace = "sys::default";
const ESM::RefId worldspace = ESM::RefId::stringRefId("sys::default");
const TilePosition tilePosition{ 3, 4 };
const std::vector<std::byte> input = generateData();
const std::vector<std::byte> data = generateData();
@ -101,7 +100,7 @@ namespace
{
const TileId tileId{ 53 };
const TileVersion version{ 1 };
const std::string worldspace = "sys::default";
const ESM::RefId worldspace = ESM::RefId::stringRefId("sys::default");
const TilePosition tilePosition{ 3, 4 };
const std::vector<std::byte> input = generateData();
const std::vector<std::byte> data = generateData();
@ -113,7 +112,7 @@ namespace
TEST_F(DetourNavigatorNavMeshDbTest, delete_tiles_at_should_remove_all_tiles_with_given_worldspace_and_position)
{
const TileVersion version{ 1 };
const std::string worldspace = "sys::default";
const ESM::RefId worldspace = ESM::RefId::stringRefId("sys::default");
const TilePosition tilePosition{ 3, 4 };
const std::vector<std::byte> input1 = generateData();
const std::vector<std::byte> input2 = generateData();
@ -130,7 +129,7 @@ namespace
const TileId leftTileId{ 53 };
const TileId removedTileId{ 54 };
const TileVersion version{ 1 };
const std::string worldspace = "sys::default";
const ESM::RefId worldspace = ESM::RefId::stringRefId("sys::default");
const TilePosition tilePosition{ 3, 4 };
const std::vector<std::byte> leftInput = generateData();
const std::vector<std::byte> removedInput = generateData();
@ -148,7 +147,7 @@ namespace
{
TileId tileId{ 1 };
const TileVersion version{ 1 };
const std::string worldspace = "sys::default";
const ESM::RefId worldspace = ESM::RefId::stringRefId("sys::default");
const std::vector<std::byte> input = generateData();
const std::vector<std::byte> data = generateData();
for (int x = -2; x <= 2; ++x)

View file

@ -21,6 +21,7 @@ namespace
const ObjectTransform mObjectTransform{ ESM::Position{ { 0, 0, 0 }, { 0, 0, 0 } }, 0.0f };
const osg::ref_ptr<const Resource::BulletShape> mShape = new Resource::BulletShape;
const osg::ref_ptr<const Resource::BulletShapeInstance> mInstance = new Resource::BulletShapeInstance(mShape);
const ESM::RefId mWorldspace = ESM::RefId::stringRefId("worldspace");
DetourNavigatorTileCachedRecastMeshManagerTest()
{
@ -34,7 +35,7 @@ namespace
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_for_empty_should_return_nullptr)
{
TileCachedRecastMeshManager manager(mSettings);
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(0, 0)), nullptr);
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(0, 0)), nullptr);
}
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, get_revision_for_empty_should_return_zero)
@ -65,14 +66,14 @@ namespace
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_object_should_add_tiles)
{
TileCachedRecastMeshManager manager(mSettings);
manager.setWorldspace("worldspace", nullptr);
manager.setWorldspace(mWorldspace, nullptr);
const btBoxShape boxShape(btVector3(20, 20, 100));
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
ASSERT_TRUE(manager.addObject(
ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr));
for (int x = -1; x < 1; ++x)
for (int y = -1; y < 1; ++y)
ASSERT_NE(manager.getMesh("worldspace", TilePosition(x, y)), nullptr);
ASSERT_NE(manager.getMesh(mWorldspace, TilePosition(x, y)), nullptr);
}
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_object_should_return_add_changed_tiles)
@ -145,25 +146,25 @@ namespace
get_mesh_after_add_object_should_return_recast_mesh_for_each_used_tile)
{
TileCachedRecastMeshManager manager(mSettings);
manager.setWorldspace("worldspace", nullptr);
manager.setWorldspace(mWorldspace, nullptr);
const btBoxShape boxShape(btVector3(20, 20, 100));
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, 0)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(-1, -1)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(-1, 0)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, -1)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, 0)), nullptr);
}
TEST_F(
DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_after_add_object_should_return_nullptr_for_unused_tile)
{
TileCachedRecastMeshManager manager(mSettings);
manager.setWorldspace("worldspace", nullptr);
manager.setWorldspace(mWorldspace, nullptr);
const btBoxShape boxShape(btVector3(20, 20, 100));
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(1, 0)), nullptr);
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(1, 0)), nullptr);
}
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest,
@ -175,7 +176,7 @@ namespace
.mEnd = TilePosition(1, 1),
};
manager.setRange(range, nullptr);
manager.setWorldspace("worldspace", nullptr);
manager.setWorldspace(mWorldspace, nullptr);
const btBoxShape boxShape(btVector3(20, 20, 100));
const btTransform transform(
@ -183,23 +184,23 @@ namespace
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground, nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, 0)), nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(1, 0)), nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(1, -1)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, -1)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, 0)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(1, 0)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(1, -1)), nullptr);
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, 0)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(-1, -1)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(-1, 0)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, -1)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, 0)), nullptr);
}
TEST_F(
DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_for_moved_object_should_return_nullptr_for_unused_tile)
{
TileCachedRecastMeshManager manager(mSettings);
manager.setWorldspace("worldspace", nullptr);
manager.setWorldspace(mWorldspace, nullptr);
const btBoxShape boxShape(btVector3(20, 20, 100));
const btTransform transform(
@ -207,48 +208,48 @@ namespace
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground, nullptr);
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(-1, -1)), nullptr);
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(-1, 0)), nullptr);
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(1, 0)), nullptr);
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(1, -1)), nullptr);
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(1, 0)), nullptr);
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(1, -1)), nullptr);
}
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest,
get_mesh_for_removed_object_should_return_nullptr_for_all_previously_used_tiles)
{
TileCachedRecastMeshManager manager(mSettings);
manager.setWorldspace("worldspace", nullptr);
manager.setWorldspace(mWorldspace, nullptr);
const btBoxShape boxShape(btVector3(20, 20, 100));
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
manager.removeObject(ObjectId(&boxShape), nullptr);
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(0, 0)), nullptr);
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(-1, -1)), nullptr);
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(-1, 0)), nullptr);
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(0, -1)), nullptr);
EXPECT_EQ(manager.getMesh(mWorldspace, 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);
manager.setWorldspace("worldspace", nullptr);
manager.setWorldspace(mWorldspace, nullptr);
const btBoxShape boxShape(btVector3(20, 20, 100));
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, 0)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(-1, -1)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(-1, 0)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, -1)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, 0)), nullptr);
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, 0)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(-1, -1)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(-1, 0)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, -1)), nullptr);
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, 0)), nullptr);
}
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest,
@ -293,7 +294,7 @@ namespace
get_revision_after_update_not_changed_object_should_return_same_value)
{
TileCachedRecastMeshManager manager(mSettings);
manager.setWorldspace("worldspace", nullptr);
manager.setWorldspace(mWorldspace, nullptr);
const btBoxShape boxShape(btVector3(20, 20, 100));
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
@ -339,19 +340,19 @@ namespace
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_water_for_not_max_int_should_add_new_tiles)
{
TileCachedRecastMeshManager manager(mSettings);
manager.setWorldspace("worldspace", nullptr);
manager.setWorldspace(mWorldspace, nullptr);
const osg::Vec2i cellPosition(0, 0);
const int cellSize = 8192;
manager.addWater(cellPosition, cellSize, 0.0f, nullptr);
for (int x = -1; x < 12; ++x)
for (int y = -1; y < 12; ++y)
ASSERT_NE(manager.getMesh("worldspace", TilePosition(x, y)), nullptr);
ASSERT_NE(manager.getMesh(mWorldspace, TilePosition(x, y)), nullptr);
}
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_water_for_max_int_should_not_add_new_tiles)
{
TileCachedRecastMeshManager manager(mSettings);
manager.setWorldspace("worldspace", nullptr);
manager.setWorldspace(mWorldspace, nullptr);
const btBoxShape boxShape(btVector3(20, 20, 100));
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
ASSERT_TRUE(manager.addObject(
@ -361,7 +362,7 @@ namespace
manager.addWater(cellPosition, cellSize, 0.0f, nullptr);
for (int x = -6; x < 6; ++x)
for (int y = -6; y < 6; ++y)
ASSERT_EQ(manager.getMesh("worldspace", TilePosition(x, y)) != nullptr,
ASSERT_EQ(manager.getMesh(mWorldspace, TilePosition(x, y)) != nullptr,
-1 <= x && x <= 0 && -1 <= y && y <= 0);
}
@ -390,20 +391,20 @@ namespace
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_water_for_existing_cell_should_remove_empty_tiles)
{
TileCachedRecastMeshManager manager(mSettings);
manager.setWorldspace("worldspace", nullptr);
manager.setWorldspace(mWorldspace, nullptr);
const osg::Vec2i cellPosition(0, 0);
const int cellSize = 8192;
manager.addWater(cellPosition, cellSize, 0.0f, nullptr);
manager.removeWater(cellPosition, nullptr);
for (int x = -6; x < 6; ++x)
for (int y = -6; y < 6; ++y)
ASSERT_EQ(manager.getMesh("worldspace", TilePosition(x, y)), nullptr);
ASSERT_EQ(manager.getMesh(mWorldspace, TilePosition(x, y)), nullptr);
}
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_water_for_existing_cell_should_leave_not_empty_tiles)
{
TileCachedRecastMeshManager manager(mSettings);
manager.setWorldspace("worldspace", nullptr);
manager.setWorldspace(mWorldspace, nullptr);
const btBoxShape boxShape(btVector3(20, 20, 100));
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
ASSERT_TRUE(manager.addObject(
@ -414,14 +415,14 @@ namespace
manager.removeWater(cellPosition, nullptr);
for (int x = -6; x < 6; ++x)
for (int y = -6; y < 6; ++y)
ASSERT_EQ(manager.getMesh("worldspace", TilePosition(x, y)) != nullptr,
ASSERT_EQ(manager.getMesh(mWorldspace, TilePosition(x, y)) != nullptr,
-1 <= x && x <= 0 && -1 <= y && y <= 0);
}
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_object_should_not_remove_tile_with_water)
{
TileCachedRecastMeshManager manager(mSettings);
manager.setWorldspace("worldspace", nullptr);
manager.setWorldspace(mWorldspace, nullptr);
const osg::Vec2i cellPosition(0, 0);
const int cellSize = 8192;
const btBoxShape boxShape(btVector3(20, 20, 100));
@ -432,21 +433,22 @@ namespace
manager.removeObject(ObjectId(&boxShape), nullptr);
for (int x = -1; x < 12; ++x)
for (int y = -1; y < 12; ++y)
ASSERT_NE(manager.getMesh("worldspace", TilePosition(x, y)), nullptr);
ASSERT_NE(manager.getMesh(mWorldspace, TilePosition(x, y)), nullptr);
}
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, set_new_worldspace_should_remove_tiles)
{
TileCachedRecastMeshManager manager(mSettings);
manager.setWorldspace("worldspace", nullptr);
manager.setWorldspace(mWorldspace, nullptr);
const btBoxShape boxShape(btVector3(20, 20, 100));
const CollisionShape shape(nullptr, boxShape, mObjectTransform);
ASSERT_TRUE(manager.addObject(
ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr));
manager.setWorldspace("other", nullptr);
const ESM::RefId otherWorldspace(ESM::FormId::fromUint32(0x1));
manager.setWorldspace(ESM::FormId::fromUint32(0x1), nullptr);
for (int x = -1; x < 1; ++x)
for (int y = -1; y < 1; ++y)
ASSERT_EQ(manager.getMesh("other", TilePosition(x, y)), nullptr);
ASSERT_EQ(manager.getMesh(otherWorldspace, TilePosition(x, y)), nullptr);
}
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, set_range_should_add_changed_tiles)
@ -475,8 +477,7 @@ namespace
{
TileCachedRecastMeshManager manager(mSettings);
const std::string_view worldspace = "worldspace";
manager.setWorldspace(worldspace, nullptr);
manager.setWorldspace(mWorldspace, nullptr);
const btBoxShape boxShape(btVector3(100, 100, 20));
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
@ -489,9 +490,9 @@ namespace
const TilePosition tilePosition(0, 0);
ASSERT_EQ(manager.getCachedMesh(worldspace, tilePosition), nullptr);
ASSERT_NE(manager.getMesh(worldspace, tilePosition), nullptr);
ASSERT_NE(manager.getCachedMesh(worldspace, tilePosition), nullptr);
ASSERT_EQ(manager.getCachedMesh(mWorldspace, tilePosition), nullptr);
ASSERT_NE(manager.getMesh(mWorldspace, tilePosition), nullptr);
ASSERT_NE(manager.getCachedMesh(mWorldspace, tilePosition), nullptr);
const TilesPositionsRange range2{
.mBegin = TilePosition(-1, -1),
@ -500,6 +501,6 @@ namespace
manager.takeChangedTiles(nullptr);
manager.setRange(range2, nullptr);
ASSERT_EQ(manager.getCachedMesh(worldspace, tilePosition), nullptr);
ASSERT_EQ(manager.getCachedMesh(mWorldspace, tilePosition), nullptr);
}
}

View file

@ -91,7 +91,7 @@ namespace DetourNavigator
}
Job::Job(const AgentBounds& agentBounds, std::weak_ptr<GuardedNavMeshCacheItem> navMeshCacheItem,
std::string_view worldspace, const TilePosition& changedTile, ChangeType changeType,
ESM::RefId worldspace, const TilePosition& changedTile, ChangeType changeType,
std::chrono::steady_clock::time_point processTime)
: mId(getNextJobId())
, mAgentBounds(agentBounds)
@ -261,8 +261,7 @@ namespace DetourNavigator
}
void AsyncNavMeshUpdater::post(const AgentBounds& agentBounds, const SharedNavMeshCacheItem& navMeshCacheItem,
const TilePosition& playerTile, std::string_view worldspace,
const std::map<TilePosition, ChangeType>& changedTiles)
const TilePosition& playerTile, ESM::RefId worldspace, const std::map<TilePosition, ChangeType>& changedTiles)
{
bool playerTileChanged = false;
{

View file

@ -50,7 +50,7 @@ namespace DetourNavigator
const std::size_t mId;
const AgentBounds mAgentBounds;
const std::weak_ptr<GuardedNavMeshCacheItem> mNavMeshCacheItem;
const std::string mWorldspace;
const ESM::RefId mWorldspace;
const TilePosition mChangedTile;
std::chrono::steady_clock::time_point mProcessTime;
ChangeType mChangeType;
@ -61,7 +61,7 @@ namespace DetourNavigator
std::unique_ptr<PreparedNavMeshData> mGeneratedNavMeshData;
Job(const AgentBounds& agentBounds, std::weak_ptr<GuardedNavMeshCacheItem> navMeshCacheItem,
std::string_view worldspace, const TilePosition& changedTile, ChangeType changeType,
ESM::RefId worldspace, const TilePosition& changedTile, ChangeType changeType,
std::chrono::steady_clock::time_point processTime);
};
@ -199,7 +199,7 @@ namespace DetourNavigator
~AsyncNavMeshUpdater();
void post(const AgentBounds& agentBounds, const SharedNavMeshCacheItem& navMeshCacheItem,
const TilePosition& playerTile, std::string_view worldspace,
const TilePosition& playerTile, ESM::RefId worldspace,
const std::map<TilePosition, ChangeType>& changedTiles);
void wait(WaitConditionType waitConditionType, Loading::Listener* listener);

View file

@ -22,7 +22,7 @@ namespace DetourNavigator
{
struct Ignore
{
std::string_view mWorldspace;
ESM::RefId mWorldspace;
const TilePosition& mTilePosition;
std::shared_ptr<NavMeshTileConsumer> mConsumer;
@ -34,10 +34,10 @@ namespace DetourNavigator
};
}
GenerateNavMeshTile::GenerateNavMeshTile(std::string worldspace, const TilePosition& tilePosition,
GenerateNavMeshTile::GenerateNavMeshTile(ESM::RefId worldspace, const TilePosition& tilePosition,
RecastMeshProvider recastMeshProvider, const AgentBounds& agentBounds,
const DetourNavigator::Settings& settings, std::weak_ptr<NavMeshTileConsumer> consumer)
: mWorldspace(std::move(worldspace))
: mWorldspace(worldspace)
, mTilePosition(tilePosition)
, mRecastMeshProvider(recastMeshProvider)
, mAgentBounds(agentBounds)

View file

@ -35,18 +35,18 @@ namespace DetourNavigator
virtual std::int64_t resolveMeshSource(const MeshSource& source) = 0;
virtual std::optional<NavMeshTileInfo> find(
std::string_view worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
ESM::RefId worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
= 0;
virtual void ignore(std::string_view worldspace, const TilePosition& tilePosition) = 0;
virtual void ignore(ESM::RefId worldspace, const TilePosition& tilePosition) = 0;
virtual void identity(std::string_view worldspace, const TilePosition& tilePosition, std::int64_t tileId) = 0;
virtual void identity(ESM::RefId worldspace, const TilePosition& tilePosition, std::int64_t tileId) = 0;
virtual void insert(std::string_view worldspace, const TilePosition& tilePosition, std::int64_t version,
virtual void insert(ESM::RefId worldspace, const TilePosition& tilePosition, std::int64_t version,
const std::vector<std::byte>& input, PreparedNavMeshData& data)
= 0;
virtual void update(std::string_view worldspace, const TilePosition& tilePosition, std::int64_t tileId,
virtual void update(ESM::RefId worldspace, const TilePosition& tilePosition, std::int64_t tileId,
std::int64_t version, PreparedNavMeshData& data)
= 0;
@ -56,14 +56,14 @@ namespace DetourNavigator
class GenerateNavMeshTile final : public SceneUtil::WorkItem
{
public:
GenerateNavMeshTile(std::string worldspace, const TilePosition& tilePosition,
GenerateNavMeshTile(ESM::RefId worldspace, const TilePosition& tilePosition,
RecastMeshProvider recastMeshProvider, const AgentBounds& agentBounds, const Settings& settings,
std::weak_ptr<NavMeshTileConsumer> consumer);
void doWork() final;
private:
const std::string mWorldspace;
const ESM::RefId mWorldspace;
const TilePosition mTilePosition;
const RecastMeshProvider mRecastMeshProvider;
const AgentBounds mAgentBounds;

View file

@ -520,9 +520,8 @@ namespace DetourNavigator
}
}
std::unique_ptr<PreparedNavMeshData> prepareNavMeshTileData(const RecastMesh& recastMesh,
std::string_view worldspace, const TilePosition& tilePosition, const AgentBounds& agentBounds,
const RecastSettings& settings)
std::unique_ptr<PreparedNavMeshData> prepareNavMeshTileData(const RecastMesh& recastMesh, ESM::RefId worldspace,
const TilePosition& tilePosition, const AgentBounds& agentBounds, const RecastSettings& settings)
{
RecastContext context(worldspace, tilePosition, agentBounds);

View file

@ -4,6 +4,8 @@
#include "recastmesh.hpp"
#include "tileposition.hpp"
#include <components/esm/refid.hpp>
#include <memory>
#include <vector>
@ -41,9 +43,8 @@ namespace DetourNavigator
&& recastMesh.getHeightfields().empty() && recastMesh.getFlatHeightfields().empty();
}
std::unique_ptr<PreparedNavMeshData> prepareNavMeshTileData(const RecastMesh& recastMesh,
std::string_view worldspace, const TilePosition& tilePosition, const AgentBounds& agentBounds,
const RecastSettings& settings);
std::unique_ptr<PreparedNavMeshData> prepareNavMeshTileData(const RecastMesh& recastMesh, ESM::RefId worldspace,
const TilePosition& tilePosition, const AgentBounds& agentBounds, const RecastSettings& settings);
NavMeshData makeNavMeshTileData(const PreparedNavMeshData& data,
const std::vector<OffMeshConnection>& offMeshConnections, const AgentBounds& agentBounds,

View file

@ -91,7 +91,7 @@ namespace DetourNavigator
* @brief setWorldspace should be called before adding object from new worldspace
* @param worldspace
*/
virtual void setWorldspace(std::string_view worldspace, const UpdateGuard* guard) = 0;
virtual void setWorldspace(ESM::RefId worldspace, const UpdateGuard* guard) = 0;
/**
* @brief updateBounds should be called before adding object from loading cell

View file

@ -33,7 +33,7 @@ namespace DetourNavigator
--it->second;
}
void NavigatorImpl::setWorldspace(std::string_view worldspace, const UpdateGuard* guard)
void NavigatorImpl::setWorldspace(ESM::RefId worldspace, const UpdateGuard* guard)
{
mNavMeshManager.setWorldspace(worldspace, guard);
}

View file

@ -8,7 +8,6 @@
#include <map>
#include <memory>
#include <optional>
#include <string_view>
#include <unordered_map>
namespace DetourNavigator
@ -28,7 +27,7 @@ namespace DetourNavigator
void removeAgent(const AgentBounds& agentBounds) override;
void setWorldspace(std::string_view worldspace, const UpdateGuard* guard) override;
void setWorldspace(ESM::RefId worldspace, const UpdateGuard* guard) override;
void updateBounds(const osg::Vec3f& playerPosition, const UpdateGuard* guard) override;

View file

@ -24,7 +24,7 @@ namespace DetourNavigator
void removeAgent(const AgentBounds& /*agentBounds*/) override {}
void setWorldspace(std::string_view /*worldspace*/, const UpdateGuard* /*guard*/) override {}
void setWorldspace(ESM::RefId /*worldspace*/, const UpdateGuard* /*guard*/) override {}
void addObject(const ObjectId /*id*/, const ObjectShapes& /*shapes*/, const btTransform& /*transform*/,
const UpdateGuard* /*guard*/) override

View file

@ -200,34 +200,35 @@ namespace DetourNavigator
}
std::optional<Tile> NavMeshDb::findTile(
std::string_view worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
ESM::RefId worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
{
Tile result;
auto row = std::tie(result.mTileId, result.mVersion);
const std::vector<std::byte> compressedInput = Misc::compress(input);
if (&row == request(*mDb, mFindTile, &row, 1, worldspace, tilePosition, compressedInput))
if (&row == request(*mDb, mFindTile, &row, 1, worldspace.serializeText(), tilePosition, compressedInput))
return {};
return result;
}
std::optional<TileData> NavMeshDb::getTileData(
std::string_view worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
ESM::RefId worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
{
TileData result;
auto row = std::tie(result.mTileId, result.mVersion, result.mData);
const std::vector<std::byte> compressedInput = Misc::compress(input);
if (&row == request(*mDb, mGetTileData, &row, 1, worldspace, tilePosition, compressedInput))
if (&row == request(*mDb, mGetTileData, &row, 1, worldspace.serializeText(), tilePosition, compressedInput))
return {};
result.mData = Misc::decompress(result.mData);
return result;
}
int NavMeshDb::insertTile(TileId tileId, std::string_view worldspace, const TilePosition& tilePosition,
int NavMeshDb::insertTile(TileId tileId, ESM::RefId worldspace, const TilePosition& tilePosition,
TileVersion version, const std::vector<std::byte>& input, const std::vector<std::byte>& data)
{
const std::vector<std::byte> compressedInput = Misc::compress(input);
const std::vector<std::byte> compressedData = Misc::compress(data);
return execute(*mDb, mInsertTile, tileId, worldspace, tilePosition, version, compressedInput, compressedData);
return execute(*mDb, mInsertTile, tileId, worldspace.serializeText(), tilePosition, version, compressedInput,
compressedData);
}
int NavMeshDb::updateTile(TileId tileId, TileVersion version, const std::vector<std::byte>& data)
@ -236,20 +237,19 @@ namespace DetourNavigator
return execute(*mDb, mUpdateTile, tileId, version, compressedData);
}
int NavMeshDb::deleteTilesAt(std::string_view worldspace, const TilePosition& tilePosition)
int NavMeshDb::deleteTilesAt(ESM::RefId worldspace, const TilePosition& tilePosition)
{
return execute(*mDb, mDeleteTilesAt, worldspace, tilePosition);
return execute(*mDb, mDeleteTilesAt, worldspace.serializeText(), tilePosition);
}
int NavMeshDb::deleteTilesAtExcept(
std::string_view worldspace, const TilePosition& tilePosition, TileId excludeTileId)
int NavMeshDb::deleteTilesAtExcept(ESM::RefId worldspace, const TilePosition& tilePosition, TileId excludeTileId)
{
return execute(*mDb, mDeleteTilesAtExcept, worldspace, tilePosition, excludeTileId);
return execute(*mDb, mDeleteTilesAtExcept, worldspace.serializeText(), tilePosition, excludeTileId);
}
int NavMeshDb::deleteTilesOutsideRange(std::string_view worldspace, const TilesPositionsRange& range)
int NavMeshDb::deleteTilesOutsideRange(ESM::RefId worldspace, const TilesPositionsRange& range)
{
return execute(*mDb, mDeleteTilesOutsideRange, worldspace, range);
return execute(*mDb, mDeleteTilesOutsideRange, worldspace.serializeText(), range);
}
ShapeId NavMeshDb::getMaxShapeId()

View file

@ -2,10 +2,10 @@
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_NAVMESHDB_H
#include "tileposition.hpp"
#include "tilespositionsrange.hpp"
#include <components/detournavigator/tilespositionsrange.hpp>
#include <components/esm/refid.hpp>
#include <components/misc/strongtypedef.hpp>
#include <components/sqlite3/db.hpp>
#include <components/sqlite3/statement.hpp>
#include <components/sqlite3/transaction.hpp>
@ -13,13 +13,8 @@
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <memory>
#include <optional>
#include <stdexcept>
#include <string_view>
#include <tuple>
#include <utility>
#include <vector>
struct sqlite3;
@ -148,21 +143,21 @@ namespace DetourNavigator
TileId getMaxTileId();
std::optional<Tile> findTile(
std::string_view worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input);
ESM::RefId worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input);
std::optional<TileData> getTileData(
std::string_view worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input);
ESM::RefId worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input);
int insertTile(TileId tileId, std::string_view worldspace, const TilePosition& tilePosition,
TileVersion version, const std::vector<std::byte>& input, const std::vector<std::byte>& data);
int insertTile(TileId tileId, ESM::RefId worldspace, const TilePosition& tilePosition, TileVersion version,
const std::vector<std::byte>& input, const std::vector<std::byte>& data);
int updateTile(TileId tileId, TileVersion version, const std::vector<std::byte>& data);
int deleteTilesAt(std::string_view worldspace, const TilePosition& tilePosition);
int deleteTilesAt(ESM::RefId worldspace, const TilePosition& tilePosition);
int deleteTilesAtExcept(std::string_view worldspace, const TilePosition& tilePosition, TileId excludeTileId);
int deleteTilesAtExcept(ESM::RefId worldspace, const TilePosition& tilePosition, TileId excludeTileId);
int deleteTilesOutsideRange(std::string_view worldspace, const TilesPositionsRange& range);
int deleteTilesOutsideRange(ESM::RefId worldspace, const TilesPositionsRange& range);
ShapeId getMaxShapeId();

View file

@ -58,7 +58,7 @@ namespace DetourNavigator
{
}
void NavMeshManager::setWorldspace(std::string_view worldspace, const UpdateGuard* guard)
void NavMeshManager::setWorldspace(ESM::RefId worldspace, const UpdateGuard* guard)
{
if (worldspace == mWorldspace)
return;

View file

@ -24,7 +24,7 @@ namespace DetourNavigator
ScopedUpdateGuard makeUpdateGuard() { return mRecastMeshManager.makeUpdateGuard(); }
void setWorldspace(std::string_view worldspace, const UpdateGuard* guard);
void setWorldspace(ESM::RefId worldspace, const UpdateGuard* guard);
void updateBounds(const osg::Vec3f& playerPosition, const UpdateGuard* guard);
@ -67,7 +67,7 @@ namespace DetourNavigator
private:
const Settings& mSettings;
std::string mWorldspace;
ESM::RefId mWorldspace;
TileCachedRecastMeshManager mRecastMeshManager;
OffMeshConnectionsManager mOffMeshConnectionsManager;
AsyncNavMeshUpdater mAsyncNavMeshUpdater;

View file

@ -24,7 +24,7 @@ namespace DetourNavigator
}
std::string formatPrefix(
std::string_view worldspace, const TilePosition& tilePosition, const AgentBounds& agentBounds)
ESM::RefId worldspace, const TilePosition& tilePosition, const AgentBounds& agentBounds)
{
std::ostringstream stream;
stream << "Worldspace: " << worldspace << "; tile position: " << tilePosition.x() << ", "
@ -34,7 +34,7 @@ namespace DetourNavigator
}
RecastContext::RecastContext(
std::string_view worldspace, const TilePosition& tilePosition, const AgentBounds& agentBounds)
ESM::RefId worldspace, const TilePosition& tilePosition, const AgentBounds& agentBounds)
: mPrefix(formatPrefix(worldspace, tilePosition, agentBounds))
{
}

View file

@ -3,6 +3,8 @@
#include "tileposition.hpp"
#include <components/esm/refid.hpp>
#include <string>
#include <Recast.h>
@ -14,8 +16,7 @@ namespace DetourNavigator
class RecastContext final : public rcContext
{
public:
explicit RecastContext(
std::string_view worldspace, const TilePosition& tilePosition, const AgentBounds& agentBounds);
explicit RecastContext(ESM::RefId worldspace, const TilePosition& tilePosition, const AgentBounds& agentBounds);
const std::string& getPrefix() const { return mPrefix; }

View file

@ -20,7 +20,7 @@ namespace DetourNavigator
{
}
std::shared_ptr<RecastMesh> getMesh(std::string_view worldspace, const TilePosition& tilePosition) const
std::shared_ptr<RecastMesh> getMesh(ESM::RefId worldspace, const TilePosition& tilePosition) const
{
return mImpl.get().getNewMesh(worldspace, tilePosition);
}

View file

@ -142,7 +142,7 @@ namespace DetourNavigator
return {};
}
void TileCachedRecastMeshManager::setWorldspace(std::string_view worldspace, const UpdateGuard* guard)
void TileCachedRecastMeshManager::setWorldspace(ESM::RefId worldspace, const UpdateGuard* guard)
{
const MaybeLockGuard lock(mMutex, guard);
if (mWorldspace == worldspace)
@ -351,7 +351,7 @@ namespace DetourNavigator
}
std::shared_ptr<RecastMesh> TileCachedRecastMeshManager::getMesh(
std::string_view worldspace, const TilePosition& tilePosition)
ESM::RefId worldspace, const TilePosition& tilePosition)
{
{
const std::lock_guard lock(mMutex);
@ -375,7 +375,7 @@ namespace DetourNavigator
}
std::shared_ptr<RecastMesh> TileCachedRecastMeshManager::getCachedMesh(
std::string_view worldspace, const TilePosition& tilePosition) const
ESM::RefId worldspace, const TilePosition& tilePosition) const
{
const std::lock_guard lock(mMutex);
if (mWorldspace != worldspace)
@ -387,7 +387,7 @@ namespace DetourNavigator
}
std::shared_ptr<RecastMesh> TileCachedRecastMeshManager::getNewMesh(
std::string_view worldspace, const TilePosition& tilePosition) const
ESM::RefId worldspace, const TilePosition& tilePosition) const
{
{
const std::lock_guard lock(mMutex);

View file

@ -25,8 +25,6 @@
#include <memory>
#include <mutex>
#include <optional>
#include <string>
#include <string_view>
#include <unordered_map>
namespace DetourNavigator
@ -49,7 +47,7 @@ namespace DetourNavigator
TilesPositionsRange getLimitedObjectsRange() const;
void setWorldspace(std::string_view worldspace, const UpdateGuard* guard);
void setWorldspace(ESM::RefId worldspace, const UpdateGuard* guard);
bool addObject(ObjectId id, const CollisionShape& shape, const btTransform& transform, AreaType areaType,
const UpdateGuard* guard);
@ -67,11 +65,11 @@ namespace DetourNavigator
void removeHeightfield(const osg::Vec2i& cellPosition, const UpdateGuard* guard);
std::shared_ptr<RecastMesh> getMesh(std::string_view worldspace, const TilePosition& tilePosition);
std::shared_ptr<RecastMesh> getMesh(ESM::RefId worldspace, const TilePosition& tilePosition);
std::shared_ptr<RecastMesh> getCachedMesh(std::string_view worldspace, const TilePosition& tilePosition) const;
std::shared_ptr<RecastMesh> getCachedMesh(ESM::RefId worldspace, const TilePosition& tilePosition) const;
std::shared_ptr<RecastMesh> getNewMesh(std::string_view worldspace, const TilePosition& tilePosition) const;
std::shared_ptr<RecastMesh> getNewMesh(ESM::RefId worldspace, const TilePosition& tilePosition) const;
std::size_t getRevision() const { return mRevision; }
@ -130,7 +128,7 @@ namespace DetourNavigator
const RecastSettings& mSettings;
TilesPositionsRange mRange;
std::string mWorldspace;
ESM::RefId mWorldspace;
std::unordered_map<ObjectId, std::unique_ptr<ObjectData>> mObjects;
boost::geometry::index::rtree<ObjectIndexValue, boost::geometry::index::quadratic<16>> mObjectIndex;
std::map<osg::Vec2i, WaterData> mWater;