mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Merge branch 'detournavigator_ref_id' into 'master'
Use ESM::RefId for worldspace in detournavigator See merge request OpenMW/openmw!2562
This commit is contained in:
commit
4b6fd63044
@ -8,6 +8,7 @@
|
||||
#include <components/detournavigator/navmeshdb.hpp>
|
||||
#include <components/detournavigator/recastglobalallocator.hpp>
|
||||
#include <components/detournavigator/settings.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <components/esm3/readerscache.hpp>
|
||||
#include <components/esm3/variant.hpp>
|
||||
#include <components/esmloader/esmdata.hpp>
|
||||
|
@ -106,7 +106,7 @@ namespace NavMeshTool
|
||||
return DetourNavigator::resolveMeshSource(mDb, source, mNextShapeId);
|
||||
}
|
||||
|
||||
std::optional<NavMeshTileInfo> find(std::string_view worldspace, const TilePosition& tilePosition,
|
||||
std::optional<NavMeshTileInfo> find(const ESM::RefId& worldspace, const TilePosition& tilePosition,
|
||||
const std::vector<std::byte>& input) override
|
||||
{
|
||||
std::optional<NavMeshTileInfo> result;
|
||||
@ -121,7 +121,7 @@ namespace NavMeshTool
|
||||
return result;
|
||||
}
|
||||
|
||||
void ignore(std::string_view worldspace, const TilePosition& tilePosition) override
|
||||
void ignore(const 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(const 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(const 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(const 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(const ESM::RefId& worldspace, const TilesPositionsRange& range)
|
||||
{
|
||||
const std::lock_guard lock(mMutex);
|
||||
mTransaction.commit();
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <components/detournavigator/recastmesh.hpp>
|
||||
#include <components/detournavigator/settings.hpp>
|
||||
#include <components/detournavigator/tilecachedrecastmeshmanager.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <components/esm3/cellref.hpp>
|
||||
#include <components/esm3/esmreader.hpp>
|
||||
#include <components/esm3/loadcell.hpp>
|
||||
@ -29,7 +30,6 @@
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
#include <algorithm>
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
@ -37,6 +37,7 @@
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace NavMeshTool
|
||||
{
|
||||
namespace
|
||||
@ -221,7 +222,7 @@ namespace NavMeshTool
|
||||
}
|
||||
|
||||
WorldspaceNavMeshInput::WorldspaceNavMeshInput(
|
||||
std::string worldspace, const DetourNavigator::RecastSettings& settings)
|
||||
ESM::RefId worldspace, const DetourNavigator::RecastSettings& settings)
|
||||
: mWorldspace(std::move(worldspace))
|
||||
, mTileCachedRecastMeshManager(settings)
|
||||
{
|
||||
@ -235,7 +236,7 @@ namespace NavMeshTool
|
||||
{
|
||||
Log(Debug::Info) << "Processing " << esmData.mCells.size() << " cells...";
|
||||
|
||||
std::map<std::string_view, std::unique_ptr<WorldspaceNavMeshInput>> navMeshInputs;
|
||||
std::map<ESM::RefId, std::unique_ptr<WorldspaceNavMeshInput>> navMeshInputs;
|
||||
WorldspaceData data;
|
||||
|
||||
std::size_t objectsCounter = 0;
|
||||
@ -263,16 +264,15 @@ namespace NavMeshTool
|
||||
|
||||
const osg::Vec2i cellPosition(cell.mData.mX, cell.mData.mY);
|
||||
const std::size_t cellObjectsBegin = data.mObjects.size();
|
||||
const auto cellNameLowerCase = Misc::StringUtils::lowerCase(cell.mCellId.mWorldspace.getRefIdString());
|
||||
WorldspaceNavMeshInput& navMeshInput = [&]() -> WorldspaceNavMeshInput& {
|
||||
auto it = navMeshInputs.find(cellNameLowerCase);
|
||||
auto it = navMeshInputs.find(cell.mCellId.mWorldspace);
|
||||
if (it == navMeshInputs.end())
|
||||
{
|
||||
it = navMeshInputs
|
||||
.emplace(cellNameLowerCase,
|
||||
std::make_unique<WorldspaceNavMeshInput>(cellNameLowerCase, settings.mRecast))
|
||||
.emplace(cell.mCellId.mWorldspace,
|
||||
std::make_unique<WorldspaceNavMeshInput>(cell.mCellId.mWorldspace, settings.mRecast))
|
||||
.first;
|
||||
it->second->mTileCachedRecastMeshManager.setWorldspace(cellNameLowerCase, nullptr);
|
||||
it->second->mTileCachedRecastMeshManager.setWorldspace(cell.mCellId.mWorldspace, nullptr);
|
||||
}
|
||||
return *it->second;
|
||||
}();
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <components/bullethelpers/collisionobject.hpp>
|
||||
#include <components/detournavigator/tilecachedrecastmeshmanager.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <components/esm3/loadland.hpp>
|
||||
#include <components/misc/convert.hpp>
|
||||
#include <components/resource/bulletshape.hpp>
|
||||
@ -48,12 +49,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
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <components/detournavigator/makenavmesh.hpp>
|
||||
#include <components/detournavigator/navmeshdbutils.hpp>
|
||||
#include <components/detournavigator/serialization.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <components/loadinglistener/loadinglistener.hpp>
|
||||
|
||||
#include <BulletCollision/CollisionShapes/btBoxShape.h>
|
||||
@ -52,7 +53,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;
|
||||
};
|
||||
|
@ -40,7 +40,6 @@ namespace
|
||||
Settings mSettings = makeSettings();
|
||||
std::unique_ptr<Navigator> mNavigator;
|
||||
const osg::Vec3f mPlayerPosition;
|
||||
const std::string mWorldspace;
|
||||
const AgentBounds mAgentBounds{ CollisionShapeType::Aabb, { 29, 29, 66 } };
|
||||
osg::Vec3f mStart;
|
||||
osg::Vec3f mEnd;
|
||||
@ -57,7 +56,6 @@ namespace
|
||||
|
||||
DetourNavigatorNavigatorTest()
|
||||
: mPlayerPosition(256, 256, 0)
|
||||
, mWorldspace("sys::default")
|
||||
, mStart(52, 460, 1)
|
||||
, mEnd(460, 52, 1)
|
||||
, mOut(mPath)
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "generate.hpp"
|
||||
|
||||
#include <components/detournavigator/navmeshdb.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
#include <DetourAlloc.h>
|
||||
|
||||
@ -19,7 +20,7 @@ namespace
|
||||
|
||||
struct Tile
|
||||
{
|
||||
std::string mWorldspace;
|
||||
ESM::RefId mWorldspace;
|
||||
TilePosition mTilePosition;
|
||||
std::vector<std::byte> mInput;
|
||||
std::vector<std::byte> mData;
|
||||
@ -39,7 +40,7 @@ namespace
|
||||
|
||||
Tile insertTile(TileId tileId, TileVersion version)
|
||||
{
|
||||
std::string worldspace = "sys::default";
|
||||
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();
|
||||
@ -89,7 +90,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 +102,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 +114,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 +131,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 +149,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)
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
#include <components/detournavigator/settingsutils.hpp>
|
||||
#include <components/detournavigator/tilecachedrecastmeshmanager.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
#include <BulletCollision/CollisionShapes/btBoxShape.h>
|
||||
|
||||
@ -20,6 +21,8 @@ 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");
|
||||
const ESM::RefId mOtherWorldspace = ESM::RefId::stringRefId("other");
|
||||
|
||||
DetourNavigatorTileCachedRecastMeshManagerTest()
|
||||
{
|
||||
@ -33,7 +36,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)
|
||||
@ -64,14 +67,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)
|
||||
@ -141,25 +144,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,
|
||||
@ -170,7 +173,7 @@ namespace
|
||||
bounds.mMin = osg::Vec2f(-1000, -1000);
|
||||
bounds.mMax = osg::Vec2f(1000, 1000);
|
||||
manager.setBounds(bounds, nullptr);
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
manager.setWorldspace(mWorldspace, nullptr);
|
||||
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const btTransform transform(
|
||||
@ -178,23 +181,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(
|
||||
@ -202,48 +205,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,
|
||||
@ -288,7 +291,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);
|
||||
@ -334,19 +337,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(
|
||||
@ -356,7 +359,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);
|
||||
}
|
||||
|
||||
@ -385,20 +388,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(
|
||||
@ -409,14 +412,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));
|
||||
@ -427,21 +430,21 @@ 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);
|
||||
manager.setWorldspace(mOtherWorldspace, 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(mOtherWorldspace, TilePosition(x, y)), nullptr);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, set_bounds_should_add_changed_tiles)
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "version.hpp"
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <components/loadinglistener/loadinglistener.hpp>
|
||||
#include <components/misc/thread.hpp>
|
||||
|
||||
@ -135,7 +136,7 @@ namespace DetourNavigator
|
||||
}
|
||||
|
||||
Job::Job(const AgentBounds& agentBounds, std::weak_ptr<GuardedNavMeshCacheItem> navMeshCacheItem,
|
||||
std::string_view worldspace, const TilePosition& changedTile, ChangeType changeType, int distanceToPlayer,
|
||||
const ESM::RefId& worldspace, const TilePosition& changedTile, ChangeType changeType, int distanceToPlayer,
|
||||
std::chrono::steady_clock::time_point processTime)
|
||||
: mId(getNextJobId())
|
||||
, mAgentBounds(agentBounds)
|
||||
@ -168,7 +169,7 @@ namespace DetourNavigator
|
||||
}
|
||||
|
||||
void AsyncNavMeshUpdater::post(const AgentBounds& agentBounds, const SharedNavMeshCacheItem& navMeshCacheItem,
|
||||
const TilePosition& playerTile, std::string_view worldspace,
|
||||
const TilePosition& playerTile, const ESM::RefId& worldspace,
|
||||
const std::map<TilePosition, ChangeType>& changedTiles)
|
||||
{
|
||||
bool playerTileChanged = false;
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "tileposition.hpp"
|
||||
#include "waitconditiontype.hpp"
|
||||
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
#include <osg/Vec3f>
|
||||
|
||||
#include <atomic>
|
||||
@ -49,7 +51,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;
|
||||
const std::chrono::steady_clock::time_point mProcessTime;
|
||||
unsigned mTryNumber = 0;
|
||||
@ -63,7 +65,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, int distanceToPlayer,
|
||||
const ESM::RefId& worldspace, const TilePosition& changedTile, ChangeType changeType, int distanceToPlayer,
|
||||
std::chrono::steady_clock::time_point processTime);
|
||||
};
|
||||
|
||||
@ -148,7 +150,7 @@ namespace DetourNavigator
|
||||
~AsyncNavMeshUpdater();
|
||||
|
||||
void post(const AgentBounds& agentBounds, const SharedNavMeshCacheItem& navMeshCacheItem,
|
||||
const TilePosition& playerTile, std::string_view worldspace,
|
||||
const TilePosition& playerTile, const ESM::RefId& worldspace,
|
||||
const std::map<TilePosition, ChangeType>& changedTiles);
|
||||
|
||||
void wait(WaitConditionType waitConditionType, Loading::Listener* listener);
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "settings.hpp"
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
#include <osg/Vec3f>
|
||||
#include <osg/io_utils>
|
||||
@ -23,7 +24,7 @@ namespace DetourNavigator
|
||||
{
|
||||
struct Ignore
|
||||
{
|
||||
std::string_view mWorldspace;
|
||||
const ESM::RefId& mWorldspace;
|
||||
const TilePosition& mTilePosition;
|
||||
std::shared_ptr<NavMeshTileConsumer> mConsumer;
|
||||
|
||||
@ -35,7 +36,7 @@ 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))
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "recastmeshprovider.hpp"
|
||||
#include "tileposition.hpp"
|
||||
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <components/sceneutil/workqueue.hpp>
|
||||
|
||||
#include <osg/Vec3f>
|
||||
@ -38,18 +39,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)
|
||||
const 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(const 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(const 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(const 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(const ESM::RefId& worldspace, const TilePosition& tilePosition, std::int64_t tileId,
|
||||
std::int64_t version, PreparedNavMeshData& data)
|
||||
= 0;
|
||||
|
||||
@ -59,14 +60,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;
|
||||
|
@ -90,8 +90,6 @@ 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(const ESM::RefId& worldspace, const UpdateGuard* guard) = 0;
|
||||
|
||||
/**
|
||||
|
@ -33,14 +33,9 @@ namespace DetourNavigator
|
||||
--it->second;
|
||||
}
|
||||
|
||||
void NavigatorImpl::setWorldspace(std::string_view worldspace, const UpdateGuard* guard)
|
||||
{
|
||||
mNavMeshManager.setWorldspace(worldspace, getImpl(guard));
|
||||
}
|
||||
|
||||
void NavigatorImpl::setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard)
|
||||
{
|
||||
setWorldspace(Misc::StringUtils::lowerCase(worldspace.getRefIdString()), guard);
|
||||
mNavMeshManager.setWorldspace(worldspace, getImpl(guard));
|
||||
}
|
||||
|
||||
void NavigatorImpl::updateBounds(const osg::Vec3f& playerPosition, const UpdateGuard* guard)
|
||||
|
@ -27,8 +27,6 @@ namespace DetourNavigator
|
||||
|
||||
void removeAgent(const AgentBounds& agentBounds) override;
|
||||
|
||||
void setWorldspace(std::string_view worldspace, const UpdateGuard* guard) override;
|
||||
|
||||
void setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard) override;
|
||||
|
||||
void updateBounds(const osg::Vec3f& playerPosition, const UpdateGuard* guard) override;
|
||||
|
@ -23,7 +23,6 @@ namespace DetourNavigator
|
||||
|
||||
void removeAgent(const AgentBounds& /*agentBounds*/) override {}
|
||||
|
||||
void setWorldspace(std::string_view /*worldspace*/, const UpdateGuard* /*guard*/) override {}
|
||||
void setWorldspace(const ESM::RefId& /*worldspace*/, const UpdateGuard* /*guard*/) override {}
|
||||
|
||||
void addObject(const ObjectId /*id*/, const ObjectShapes& /*shapes*/, const btTransform& /*transform*/,
|
||||
|
@ -1,8 +1,10 @@
|
||||
#include "navmeshdb.hpp"
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <components/misc/compression.hpp>
|
||||
#include <components/misc/strings/format.hpp>
|
||||
#include <components/misc/strings/lower.hpp>
|
||||
#include <components/sqlite3/db.hpp>
|
||||
#include <components/sqlite3/request.hpp>
|
||||
|
||||
@ -152,6 +154,11 @@ namespace DetourNavigator
|
||||
if (const int ec = sqlite3_exec(&db, query.c_str(), nullptr, nullptr, nullptr); ec != SQLITE_OK)
|
||||
throw std::runtime_error("Failed set max page count: " + std::string(sqlite3_errmsg(&db)));
|
||||
}
|
||||
|
||||
std::string toLowerCaseString(const ESM::RefId& refId)
|
||||
{
|
||||
return Misc::StringUtils::lowerCase(refId.getRefIdString());
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& stream, ShapeType value)
|
||||
@ -200,34 +207,35 @@ namespace DetourNavigator
|
||||
}
|
||||
|
||||
std::optional<Tile> NavMeshDb::findTile(
|
||||
std::string_view worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
|
||||
const 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, toLowerCaseString(worldspace), tilePosition, compressedInput))
|
||||
return {};
|
||||
return result;
|
||||
}
|
||||
|
||||
std::optional<TileData> NavMeshDb::getTileData(
|
||||
std::string_view worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
|
||||
const 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, toLowerCaseString(worldspace), 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, const 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, toLowerCaseString(worldspace), tilePosition, version, compressedInput,
|
||||
compressedData);
|
||||
}
|
||||
|
||||
int NavMeshDb::updateTile(TileId tileId, TileVersion version, const std::vector<std::byte>& data)
|
||||
@ -236,20 +244,20 @@ namespace DetourNavigator
|
||||
return execute(*mDb, mUpdateTile, tileId, version, compressedData);
|
||||
}
|
||||
|
||||
int NavMeshDb::deleteTilesAt(std::string_view worldspace, const TilePosition& tilePosition)
|
||||
int NavMeshDb::deleteTilesAt(const ESM::RefId& worldspace, const TilePosition& tilePosition)
|
||||
{
|
||||
return execute(*mDb, mDeleteTilesAt, worldspace, tilePosition);
|
||||
return execute(*mDb, mDeleteTilesAt, toLowerCaseString(worldspace), tilePosition);
|
||||
}
|
||||
|
||||
int NavMeshDb::deleteTilesAtExcept(
|
||||
std::string_view worldspace, const TilePosition& tilePosition, TileId excludeTileId)
|
||||
const ESM::RefId& worldspace, const TilePosition& tilePosition, TileId excludeTileId)
|
||||
{
|
||||
return execute(*mDb, mDeleteTilesAtExcept, worldspace, tilePosition, excludeTileId);
|
||||
return execute(*mDb, mDeleteTilesAtExcept, toLowerCaseString(worldspace), tilePosition, excludeTileId);
|
||||
}
|
||||
|
||||
int NavMeshDb::deleteTilesOutsideRange(std::string_view worldspace, const TilesPositionsRange& range)
|
||||
int NavMeshDb::deleteTilesOutsideRange(const ESM::RefId& worldspace, const TilesPositionsRange& range)
|
||||
{
|
||||
return execute(*mDb, mDeleteTilesOutsideRange, worldspace, range);
|
||||
return execute(*mDb, mDeleteTilesOutsideRange, toLowerCaseString(worldspace), range);
|
||||
}
|
||||
|
||||
ShapeId NavMeshDb::getMaxShapeId()
|
||||
|
@ -25,6 +25,11 @@
|
||||
struct sqlite3;
|
||||
struct sqlite3_stmt;
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
struct RefId;
|
||||
}
|
||||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
using TileId = Misc::StrongTypedef<std::int64_t, struct TiledIdTag>;
|
||||
@ -148,21 +153,21 @@ namespace DetourNavigator
|
||||
TileId getMaxTileId();
|
||||
|
||||
std::optional<Tile> findTile(
|
||||
std::string_view worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input);
|
||||
const 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);
|
||||
const ESM::RefId& worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input);
|
||||
|
||||
int insertTile(TileId tileId, std::string_view worldspace, const TilePosition& tilePosition,
|
||||
int insertTile(TileId tileId, const 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(const ESM::RefId& worldspace, const TilePosition& tilePosition);
|
||||
|
||||
int deleteTilesAtExcept(std::string_view worldspace, const TilePosition& tilePosition, TileId excludeTileId);
|
||||
int deleteTilesAtExcept(const ESM::RefId& worldspace, const TilePosition& tilePosition, TileId excludeTileId);
|
||||
|
||||
int deleteTilesOutsideRange(std::string_view worldspace, const TilesPositionsRange& range);
|
||||
int deleteTilesOutsideRange(const ESM::RefId& worldspace, const TilesPositionsRange& range);
|
||||
|
||||
ShapeId getMaxShapeId();
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
#include <components/bullethelpers/heightfield.hpp>
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <components/misc/convert.hpp>
|
||||
|
||||
#include <osg/io_utils>
|
||||
@ -59,7 +60,7 @@ namespace DetourNavigator
|
||||
{
|
||||
}
|
||||
|
||||
void NavMeshManager::setWorldspace(std::string_view worldspace, const UpdateGuard* guard)
|
||||
void NavMeshManager::setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard)
|
||||
{
|
||||
if (worldspace == mWorldspace)
|
||||
return;
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "recastmeshtiles.hpp"
|
||||
#include "waitconditiontype.hpp"
|
||||
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
#include <osg/Vec3f>
|
||||
|
||||
#include <map>
|
||||
@ -39,7 +41,7 @@ namespace DetourNavigator
|
||||
|
||||
explicit NavMeshManager(const Settings& settings, std::unique_ptr<NavMeshDb>&& db);
|
||||
|
||||
void setWorldspace(std::string_view worldspace, const UpdateGuard* guard);
|
||||
void setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard);
|
||||
|
||||
void updateBounds(const osg::Vec3f& playerPosition, const UpdateGuard* guard);
|
||||
|
||||
@ -82,7 +84,7 @@ namespace DetourNavigator
|
||||
|
||||
private:
|
||||
const Settings& mSettings;
|
||||
std::string mWorldspace;
|
||||
ESM::RefId mWorldspace;
|
||||
TileCachedRecastMeshManager mRecastMeshManager;
|
||||
OffMeshConnectionsManager mOffMeshConnectionsManager;
|
||||
AsyncNavMeshUpdater mAsyncNavMeshUpdater;
|
||||
|
@ -20,7 +20,7 @@ namespace DetourNavigator
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<RecastMesh> getMesh(std::string_view worldspace, const TilePosition& tilePosition) const
|
||||
std::shared_ptr<RecastMesh> getMesh(const ESM::RefId& worldspace, const TilePosition& tilePosition) const
|
||||
{
|
||||
return mImpl.get().getNewMesh(worldspace, tilePosition);
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "settingsutils.hpp"
|
||||
|
||||
#include <components/bullethelpers/aabb.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <components/misc/convert.hpp>
|
||||
|
||||
#include <boost/geometry/geometry.hpp>
|
||||
@ -112,7 +113,7 @@ namespace DetourNavigator
|
||||
};
|
||||
}
|
||||
|
||||
void TileCachedRecastMeshManager::setWorldspace(std::string_view worldspace, const UpdateGuard* guard)
|
||||
void TileCachedRecastMeshManager::setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard)
|
||||
{
|
||||
const MaybeLockGuard lock(mMutex, guard);
|
||||
if (mWorldspace == worldspace)
|
||||
@ -321,7 +322,7 @@ namespace DetourNavigator
|
||||
}
|
||||
|
||||
std::shared_ptr<RecastMesh> TileCachedRecastMeshManager::getMesh(
|
||||
std::string_view worldspace, const TilePosition& tilePosition)
|
||||
const ESM::RefId& worldspace, const TilePosition& tilePosition)
|
||||
{
|
||||
{
|
||||
const std::lock_guard lock(mMutex);
|
||||
@ -345,7 +346,7 @@ namespace DetourNavigator
|
||||
}
|
||||
|
||||
std::shared_ptr<RecastMesh> TileCachedRecastMeshManager::getCachedMesh(
|
||||
std::string_view worldspace, const TilePosition& tilePosition) const
|
||||
const ESM::RefId& worldspace, const TilePosition& tilePosition) const
|
||||
{
|
||||
const std::lock_guard lock(mMutex);
|
||||
if (mWorldspace != worldspace)
|
||||
@ -357,7 +358,7 @@ namespace DetourNavigator
|
||||
}
|
||||
|
||||
std::shared_ptr<RecastMesh> TileCachedRecastMeshManager::getNewMesh(
|
||||
std::string_view worldspace, const TilePosition& tilePosition) const
|
||||
const ESM::RefId& worldspace, const TilePosition& tilePosition) const
|
||||
{
|
||||
{
|
||||
const std::lock_guard lock(mMutex);
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include "tileposition.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/box.hpp>
|
||||
#include <boost/geometry/geometries/point.hpp>
|
||||
#include <boost/geometry/index/rtree.hpp>
|
||||
@ -46,7 +48,7 @@ namespace DetourNavigator
|
||||
|
||||
TilesPositionsRange getRange() const;
|
||||
|
||||
void setWorldspace(std::string_view worldspace, const UpdateGuard* guard);
|
||||
void setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard);
|
||||
|
||||
bool addObject(ObjectId id, const CollisionShape& shape, const btTransform& transform, AreaType areaType,
|
||||
const UpdateGuard* guard);
|
||||
@ -64,11 +66,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(const ESM::RefId& worldspace, const TilePosition& tilePosition);
|
||||
|
||||
std::shared_ptr<RecastMesh> getCachedMesh(std::string_view worldspace, const TilePosition& tilePosition) const;
|
||||
std::shared_ptr<RecastMesh> getCachedMesh(const 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(const ESM::RefId& worldspace, const TilePosition& tilePosition) const;
|
||||
|
||||
std::size_t getRevision() const { return mRevision; }
|
||||
|
||||
@ -126,7 +128,7 @@ namespace DetourNavigator
|
||||
const RecastSettings& mSettings;
|
||||
TileBounds mBounds;
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user