mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 15:29:55 +00:00
Revert "Use ESM::RefId for worldspace in detournavigator"
This reverts commit b4ab153418
.
# Conflicts:
# apps/navmeshtool/worldspacedata.cpp
This commit is contained in:
parent
3780033837
commit
150e2ba885
23 changed files with 133 additions and 154 deletions
|
@ -8,7 +8,6 @@
|
|||
#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(const ESM::RefId& worldspace, const TilePosition& tilePosition,
|
||||
std::optional<NavMeshTileInfo> find(std::string_view 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(const ESM::RefId& worldspace, const TilePosition& tilePosition) override
|
||||
void ignore(std::string_view worldspace, const TilePosition& tilePosition) override
|
||||
{
|
||||
if (mRemoveUnusedTiles)
|
||||
{
|
||||
|
@ -131,7 +131,7 @@ namespace NavMeshTool
|
|||
report();
|
||||
}
|
||||
|
||||
void identity(const ESM::RefId& worldspace, const TilePosition& tilePosition, std::int64_t tileId) override
|
||||
void identity(std::string_view worldspace, const TilePosition& tilePosition, std::int64_t tileId) override
|
||||
{
|
||||
if (mRemoveUnusedTiles)
|
||||
{
|
||||
|
@ -142,7 +142,7 @@ namespace NavMeshTool
|
|||
report();
|
||||
}
|
||||
|
||||
void insert(const ESM::RefId& worldspace, const TilePosition& tilePosition, std::int64_t version,
|
||||
void insert(std::string_view 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(const ESM::RefId& worldspace, const TilePosition& tilePosition, std::int64_t tileId,
|
||||
void update(std::string_view 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(const ESM::RefId& worldspace, const TilesPositionsRange& range)
|
||||
void removeTilesOutsideRange(std::string_view worldspace, const TilesPositionsRange& range)
|
||||
{
|
||||
const std::lock_guard lock(mMutex);
|
||||
mTransaction.commit();
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#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>
|
||||
|
@ -30,6 +29,7 @@
|
|||
#include <osg/ref_ptr>
|
||||
|
||||
#include <algorithm>
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
@ -37,7 +37,6 @@
|
|||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace NavMeshTool
|
||||
{
|
||||
namespace
|
||||
|
@ -222,7 +221,7 @@ namespace NavMeshTool
|
|||
}
|
||||
|
||||
WorldspaceNavMeshInput::WorldspaceNavMeshInput(
|
||||
ESM::RefId worldspace, const DetourNavigator::RecastSettings& settings)
|
||||
std::string worldspace, const DetourNavigator::RecastSettings& settings)
|
||||
: mWorldspace(std::move(worldspace))
|
||||
, mTileCachedRecastMeshManager(settings)
|
||||
{
|
||||
|
@ -236,7 +235,7 @@ namespace NavMeshTool
|
|||
{
|
||||
Log(Debug::Info) << "Processing " << esmData.mCells.size() << " cells...";
|
||||
|
||||
std::map<ESM::RefId, std::unique_ptr<WorldspaceNavMeshInput>> navMeshInputs;
|
||||
std::map<std::string_view, std::unique_ptr<WorldspaceNavMeshInput>> navMeshInputs;
|
||||
WorldspaceData data;
|
||||
|
||||
std::size_t objectsCounter = 0;
|
||||
|
@ -264,17 +263,16 @@ 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);
|
||||
WorldspaceNavMeshInput& navMeshInput = [&]() -> WorldspaceNavMeshInput& {
|
||||
auto it = navMeshInputs.find(ESM::RefId::stringRefId(cell.mCellId.mWorldspace));
|
||||
auto it = navMeshInputs.find(cellNameLowerCase);
|
||||
if (it == navMeshInputs.end())
|
||||
{
|
||||
it = navMeshInputs
|
||||
.emplace(ESM::RefId::stringRefId(cell.mCellId.mWorldspace),
|
||||
std::make_unique<WorldspaceNavMeshInput>(
|
||||
ESM::RefId::stringRefId(cell.mCellId.mWorldspace), settings.mRecast))
|
||||
.emplace(cellNameLowerCase,
|
||||
std::make_unique<WorldspaceNavMeshInput>(cellNameLowerCase, settings.mRecast))
|
||||
.first;
|
||||
it->second->mTileCachedRecastMeshManager.setWorldspace(
|
||||
ESM::RefId::stringRefId(cell.mCellId.mWorldspace), nullptr);
|
||||
it->second->mTileCachedRecastMeshManager.setWorldspace(cellNameLowerCase, nullptr);
|
||||
}
|
||||
return *it->second;
|
||||
}();
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#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>
|
||||
|
@ -49,12 +48,12 @@ namespace NavMeshTool
|
|||
|
||||
struct WorldspaceNavMeshInput
|
||||
{
|
||||
ESM::RefId mWorldspace;
|
||||
std::string mWorldspace;
|
||||
TileCachedRecastMeshManager mTileCachedRecastMeshManager;
|
||||
btAABB mAabb;
|
||||
bool mAabbInitialized = false;
|
||||
|
||||
explicit WorldspaceNavMeshInput(ESM::RefId worldspace, const DetourNavigator::RecastSettings& settings);
|
||||
explicit WorldspaceNavMeshInput(std::string worldspace, const DetourNavigator::RecastSettings& settings);
|
||||
};
|
||||
|
||||
class BulletObject
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#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>
|
||||
|
@ -53,7 +52,7 @@ namespace
|
|||
OffMeshConnectionsManager mOffMeshConnectionsManager{ mSettings.mRecast };
|
||||
const AgentBounds mAgentBounds{ CollisionShapeType::Aabb, { 29, 29, 66 } };
|
||||
const TilePosition mPlayerTile{ 0, 0 };
|
||||
const ESM::RefId mWorldspace = ESM::RefId::stringRefId("sys::default");
|
||||
const std::string mWorldspace = "sys::default";
|
||||
const btBoxShape mBox{ btVector3(100, 100, 20) };
|
||||
Loading::Listener mListener;
|
||||
};
|
||||
|
|
|
@ -44,6 +44,7 @@ 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;
|
||||
|
@ -60,6 +61,7 @@ namespace
|
|||
|
||||
DetourNavigatorNavigatorTest()
|
||||
: mPlayerPosition(256, 256, 0)
|
||||
, mWorldspace("sys::default")
|
||||
, mStart(52, 460, 1)
|
||||
, mEnd(460, 52, 1)
|
||||
, mOut(mPath)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "generate.hpp"
|
||||
|
||||
#include <components/detournavigator/navmeshdb.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
#include <DetourAlloc.h>
|
||||
|
||||
|
@ -20,7 +19,7 @@ namespace
|
|||
|
||||
struct Tile
|
||||
{
|
||||
ESM::RefId mWorldspace;
|
||||
std::string mWorldspace;
|
||||
TilePosition mTilePosition;
|
||||
std::vector<std::byte> mInput;
|
||||
std::vector<std::byte> mData;
|
||||
|
@ -40,7 +39,7 @@ namespace
|
|||
|
||||
Tile insertTile(TileId tileId, TileVersion version)
|
||||
{
|
||||
ESM::RefId worldspace = ESM::RefId::stringRefId("sys::default");
|
||||
std::string worldspace = "sys::default";
|
||||
const TilePosition tilePosition{ 3, 4 };
|
||||
std::vector<std::byte> input = generateData();
|
||||
std::vector<std::byte> data = generateData();
|
||||
|
@ -90,7 +89,7 @@ namespace
|
|||
{
|
||||
const TileId tileId{ 53 };
|
||||
const TileVersion version{ 1 };
|
||||
const ESM::RefId worldspace = ESM::RefId::stringRefId("sys::default");
|
||||
const std::string worldspace = "sys::default";
|
||||
const TilePosition tilePosition{ 3, 4 };
|
||||
const std::vector<std::byte> input = generateData();
|
||||
const std::vector<std::byte> data = generateData();
|
||||
|
@ -102,7 +101,7 @@ namespace
|
|||
{
|
||||
const TileId tileId{ 53 };
|
||||
const TileVersion version{ 1 };
|
||||
const ESM::RefId worldspace = ESM::RefId::stringRefId("sys::default");
|
||||
const std::string worldspace = "sys::default";
|
||||
const TilePosition tilePosition{ 3, 4 };
|
||||
const std::vector<std::byte> input = generateData();
|
||||
const std::vector<std::byte> data = generateData();
|
||||
|
@ -114,7 +113,7 @@ namespace
|
|||
TEST_F(DetourNavigatorNavMeshDbTest, delete_tiles_at_should_remove_all_tiles_with_given_worldspace_and_position)
|
||||
{
|
||||
const TileVersion version{ 1 };
|
||||
const ESM::RefId worldspace = ESM::RefId::stringRefId("sys::default");
|
||||
const std::string worldspace = "sys::default";
|
||||
const TilePosition tilePosition{ 3, 4 };
|
||||
const std::vector<std::byte> input1 = generateData();
|
||||
const std::vector<std::byte> input2 = generateData();
|
||||
|
@ -131,7 +130,7 @@ namespace
|
|||
const TileId leftTileId{ 53 };
|
||||
const TileId removedTileId{ 54 };
|
||||
const TileVersion version{ 1 };
|
||||
const ESM::RefId worldspace = ESM::RefId::stringRefId("sys::default");
|
||||
const std::string worldspace = "sys::default";
|
||||
const TilePosition tilePosition{ 3, 4 };
|
||||
const std::vector<std::byte> leftInput = generateData();
|
||||
const std::vector<std::byte> removedInput = generateData();
|
||||
|
@ -149,7 +148,7 @@ namespace
|
|||
{
|
||||
TileId tileId{ 1 };
|
||||
const TileVersion version{ 1 };
|
||||
const ESM::RefId worldspace = ESM::RefId::stringRefId("sys::default");
|
||||
const std::string worldspace = "sys::default";
|
||||
const std::vector<std::byte> input = generateData();
|
||||
const std::vector<std::byte> data = generateData();
|
||||
for (int x = -2; x <= 2; ++x)
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include <components/detournavigator/debug.hpp>
|
||||
#include <components/detournavigator/settingsutils.hpp>
|
||||
#include <components/detournavigator/tilecachedrecastmeshmanager.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
#include <BulletCollision/CollisionShapes/btBoxShape.h>
|
||||
|
||||
|
@ -22,8 +21,6 @@ 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()
|
||||
{
|
||||
|
@ -37,7 +34,7 @@ namespace
|
|||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_for_empty_should_return_nullptr)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(0, 0)), nullptr);
|
||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(0, 0)), nullptr);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, get_revision_for_empty_should_return_zero)
|
||||
|
@ -68,14 +65,14 @@ namespace
|
|||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_object_should_add_tiles)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace(mWorldspace, nullptr);
|
||||
manager.setWorldspace("worldspace", 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(mWorldspace, TilePosition(x, y)), nullptr);
|
||||
ASSERT_NE(manager.getMesh("worldspace", TilePosition(x, y)), nullptr);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_object_should_return_add_changed_tiles)
|
||||
|
@ -148,25 +145,25 @@ namespace
|
|||
get_mesh_after_add_object_should_return_recast_mesh_for_each_used_tile)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace(mWorldspace, nullptr);
|
||||
manager.setWorldspace("worldspace", 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(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);
|
||||
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);
|
||||
}
|
||||
|
||||
TEST_F(
|
||||
DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_after_add_object_should_return_nullptr_for_unused_tile)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace(mWorldspace, nullptr);
|
||||
manager.setWorldspace("worldspace", 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(mWorldspace, TilePosition(1, 0)), nullptr);
|
||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(1, 0)), nullptr);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest,
|
||||
|
@ -186,23 +183,23 @@ namespace
|
|||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
|
||||
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground, 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);
|
||||
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);
|
||||
|
||||
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, 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);
|
||||
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);
|
||||
}
|
||||
|
||||
TEST_F(
|
||||
DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_for_moved_object_should_return_nullptr_for_unused_tile)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace(mWorldspace, nullptr);
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const btTransform transform(
|
||||
|
@ -210,48 +207,48 @@ namespace
|
|||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
|
||||
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground, nullptr);
|
||||
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(-1, -1)), nullptr);
|
||||
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(-1, 0)), nullptr);
|
||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
|
||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
|
||||
|
||||
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(1, 0)), nullptr);
|
||||
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(1, -1)), nullptr);
|
||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(1, 0)), nullptr);
|
||||
EXPECT_EQ(manager.getMesh("worldspace", 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(mWorldspace, nullptr);
|
||||
manager.setWorldspace("worldspace", 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(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);
|
||||
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);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest,
|
||||
get_mesh_for_not_changed_object_after_update_should_return_recast_mesh_for_same_tiles)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace(mWorldspace, nullptr);
|
||||
manager.setWorldspace("worldspace", 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(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);
|
||||
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);
|
||||
|
||||
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, 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);
|
||||
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);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest,
|
||||
|
@ -296,7 +293,7 @@ namespace
|
|||
get_revision_after_update_not_changed_object_should_return_same_value)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace(mWorldspace, nullptr);
|
||||
manager.setWorldspace("worldspace", 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);
|
||||
|
@ -342,19 +339,19 @@ namespace
|
|||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_water_for_not_max_int_should_add_new_tiles)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace(mWorldspace, nullptr);
|
||||
manager.setWorldspace("worldspace", 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(mWorldspace, TilePosition(x, y)), nullptr);
|
||||
ASSERT_NE(manager.getMesh("worldspace", TilePosition(x, y)), nullptr);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_water_for_max_int_should_not_add_new_tiles)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace(mWorldspace, nullptr);
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
ASSERT_TRUE(manager.addObject(
|
||||
|
@ -364,7 +361,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(mWorldspace, TilePosition(x, y)) != nullptr,
|
||||
ASSERT_EQ(manager.getMesh("worldspace", TilePosition(x, y)) != nullptr,
|
||||
-1 <= x && x <= 0 && -1 <= y && y <= 0);
|
||||
}
|
||||
|
||||
|
@ -393,20 +390,20 @@ namespace
|
|||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_water_for_existing_cell_should_remove_empty_tiles)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace(mWorldspace, nullptr);
|
||||
manager.setWorldspace("worldspace", 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(mWorldspace, TilePosition(x, y)), nullptr);
|
||||
ASSERT_EQ(manager.getMesh("worldspace", TilePosition(x, y)), nullptr);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_water_for_existing_cell_should_leave_not_empty_tiles)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace(mWorldspace, nullptr);
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||
ASSERT_TRUE(manager.addObject(
|
||||
|
@ -417,14 +414,14 @@ namespace
|
|||
manager.removeWater(cellPosition, nullptr);
|
||||
for (int x = -6; x < 6; ++x)
|
||||
for (int y = -6; y < 6; ++y)
|
||||
ASSERT_EQ(manager.getMesh(mWorldspace, TilePosition(x, y)) != nullptr,
|
||||
ASSERT_EQ(manager.getMesh("worldspace", 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(mWorldspace, nullptr);
|
||||
manager.setWorldspace("worldspace", nullptr);
|
||||
const osg::Vec2i cellPosition(0, 0);
|
||||
const int cellSize = 8192;
|
||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||
|
@ -435,21 +432,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(mWorldspace, TilePosition(x, y)), nullptr);
|
||||
ASSERT_NE(manager.getMesh("worldspace", TilePosition(x, y)), nullptr);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, set_new_worldspace_should_remove_tiles)
|
||||
{
|
||||
TileCachedRecastMeshManager manager(mSettings);
|
||||
manager.setWorldspace(mWorldspace, nullptr);
|
||||
manager.setWorldspace("worldspace", 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(mOtherWorldspace, nullptr);
|
||||
manager.setWorldspace("other", nullptr);
|
||||
for (int x = -1; x < 1; ++x)
|
||||
for (int y = -1; y < 1; ++y)
|
||||
ASSERT_EQ(manager.getMesh(mOtherWorldspace, TilePosition(x, y)), nullptr);
|
||||
ASSERT_EQ(manager.getMesh("other", TilePosition(x, y)), nullptr);
|
||||
}
|
||||
|
||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, set_bounds_should_add_changed_tiles)
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "version.hpp"
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <components/loadinglistener/loadinglistener.hpp>
|
||||
#include <components/misc/thread.hpp>
|
||||
|
||||
|
@ -136,7 +135,7 @@ namespace DetourNavigator
|
|||
}
|
||||
|
||||
Job::Job(const AgentBounds& agentBounds, std::weak_ptr<GuardedNavMeshCacheItem> navMeshCacheItem,
|
||||
const ESM::RefId& worldspace, const TilePosition& changedTile, ChangeType changeType, int distanceToPlayer,
|
||||
std::string_view worldspace, const TilePosition& changedTile, ChangeType changeType, int distanceToPlayer,
|
||||
std::chrono::steady_clock::time_point processTime)
|
||||
: mId(getNextJobId())
|
||||
, mAgentBounds(agentBounds)
|
||||
|
@ -169,7 +168,7 @@ namespace DetourNavigator
|
|||
}
|
||||
|
||||
void AsyncNavMeshUpdater::post(const AgentBounds& agentBounds, const SharedNavMeshCacheItem& navMeshCacheItem,
|
||||
const TilePosition& playerTile, const ESM::RefId& worldspace,
|
||||
const TilePosition& playerTile, std::string_view worldspace,
|
||||
const std::map<TilePosition, ChangeType>& changedTiles)
|
||||
{
|
||||
bool playerTileChanged = false;
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
#include "tileposition.hpp"
|
||||
#include "waitconditiontype.hpp"
|
||||
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
#include <osg/Vec3f>
|
||||
|
||||
#include <atomic>
|
||||
|
@ -51,7 +49,7 @@ namespace DetourNavigator
|
|||
const std::size_t mId;
|
||||
const AgentBounds mAgentBounds;
|
||||
const std::weak_ptr<GuardedNavMeshCacheItem> mNavMeshCacheItem;
|
||||
const ESM::RefId mWorldspace;
|
||||
const std::string mWorldspace;
|
||||
const TilePosition mChangedTile;
|
||||
const std::chrono::steady_clock::time_point mProcessTime;
|
||||
unsigned mTryNumber = 0;
|
||||
|
@ -65,7 +63,7 @@ namespace DetourNavigator
|
|||
std::unique_ptr<PreparedNavMeshData> mGeneratedNavMeshData;
|
||||
|
||||
Job(const AgentBounds& agentBounds, std::weak_ptr<GuardedNavMeshCacheItem> navMeshCacheItem,
|
||||
const ESM::RefId& worldspace, const TilePosition& changedTile, ChangeType changeType, int distanceToPlayer,
|
||||
std::string_view worldspace, const TilePosition& changedTile, ChangeType changeType, int distanceToPlayer,
|
||||
std::chrono::steady_clock::time_point processTime);
|
||||
};
|
||||
|
||||
|
@ -150,7 +148,7 @@ namespace DetourNavigator
|
|||
~AsyncNavMeshUpdater();
|
||||
|
||||
void post(const AgentBounds& agentBounds, const SharedNavMeshCacheItem& navMeshCacheItem,
|
||||
const TilePosition& playerTile, const ESM::RefId& worldspace,
|
||||
const TilePosition& playerTile, std::string_view worldspace,
|
||||
const std::map<TilePosition, ChangeType>& changedTiles);
|
||||
|
||||
void wait(WaitConditionType waitConditionType, Loading::Listener* listener);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "settings.hpp"
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
#include <osg/Vec3f>
|
||||
#include <osg/io_utils>
|
||||
|
@ -24,7 +23,7 @@ namespace DetourNavigator
|
|||
{
|
||||
struct Ignore
|
||||
{
|
||||
const ESM::RefId& mWorldspace;
|
||||
std::string_view mWorldspace;
|
||||
const TilePosition& mTilePosition;
|
||||
std::shared_ptr<NavMeshTileConsumer> mConsumer;
|
||||
|
||||
|
@ -36,7 +35,7 @@ namespace DetourNavigator
|
|||
};
|
||||
}
|
||||
|
||||
GenerateNavMeshTile::GenerateNavMeshTile(ESM::RefId worldspace, const TilePosition& tilePosition,
|
||||
GenerateNavMeshTile::GenerateNavMeshTile(std::string worldspace, const TilePosition& tilePosition,
|
||||
RecastMeshProvider recastMeshProvider, const AgentBounds& agentBounds,
|
||||
const DetourNavigator::Settings& settings, std::weak_ptr<NavMeshTileConsumer> consumer)
|
||||
: mWorldspace(std::move(worldspace))
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "recastmeshprovider.hpp"
|
||||
#include "tileposition.hpp"
|
||||
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <components/sceneutil/workqueue.hpp>
|
||||
|
||||
#include <osg/Vec3f>
|
||||
|
@ -39,18 +38,18 @@ namespace DetourNavigator
|
|||
virtual std::int64_t resolveMeshSource(const MeshSource& source) = 0;
|
||||
|
||||
virtual std::optional<NavMeshTileInfo> find(
|
||||
const ESM::RefId& worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
|
||||
std::string_view worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
|
||||
= 0;
|
||||
|
||||
virtual void ignore(const ESM::RefId& worldspace, const TilePosition& tilePosition) = 0;
|
||||
virtual void ignore(std::string_view worldspace, const TilePosition& tilePosition) = 0;
|
||||
|
||||
virtual void identity(const ESM::RefId& worldspace, const TilePosition& tilePosition, std::int64_t tileId) = 0;
|
||||
virtual void identity(std::string_view worldspace, const TilePosition& tilePosition, std::int64_t tileId) = 0;
|
||||
|
||||
virtual void insert(const ESM::RefId& worldspace, const TilePosition& tilePosition, std::int64_t version,
|
||||
virtual void insert(std::string_view worldspace, const TilePosition& tilePosition, std::int64_t version,
|
||||
const std::vector<std::byte>& input, PreparedNavMeshData& data)
|
||||
= 0;
|
||||
|
||||
virtual void update(const ESM::RefId& worldspace, const TilePosition& tilePosition, std::int64_t tileId,
|
||||
virtual void update(std::string_view worldspace, const TilePosition& tilePosition, std::int64_t tileId,
|
||||
std::int64_t version, PreparedNavMeshData& data)
|
||||
= 0;
|
||||
|
||||
|
@ -60,14 +59,14 @@ namespace DetourNavigator
|
|||
class GenerateNavMeshTile final : public SceneUtil::WorkItem
|
||||
{
|
||||
public:
|
||||
GenerateNavMeshTile(ESM::RefId worldspace, const TilePosition& tilePosition,
|
||||
GenerateNavMeshTile(std::string worldspace, const TilePosition& tilePosition,
|
||||
RecastMeshProvider recastMeshProvider, const AgentBounds& agentBounds, const Settings& settings,
|
||||
std::weak_ptr<NavMeshTileConsumer> consumer);
|
||||
|
||||
void doWork() final;
|
||||
|
||||
private:
|
||||
const ESM::RefId mWorldspace;
|
||||
const std::string mWorldspace;
|
||||
const TilePosition mTilePosition;
|
||||
const RecastMeshProvider mRecastMeshProvider;
|
||||
const AgentBounds mAgentBounds;
|
||||
|
|
|
@ -91,6 +91,8 @@ 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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -34,11 +34,16 @@ namespace DetourNavigator
|
|||
--it->second;
|
||||
}
|
||||
|
||||
void NavigatorImpl::setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard)
|
||||
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);
|
||||
}
|
||||
|
||||
void NavigatorImpl::updateBounds(const osg::Vec3f& playerPosition, const UpdateGuard* guard)
|
||||
{
|
||||
mNavMeshManager.updateBounds(playerPosition, getImpl(guard));
|
||||
|
|
|
@ -27,6 +27,8 @@ 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,6 +23,7 @@ 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,10 +1,8 @@
|
|||
#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>
|
||||
|
||||
|
@ -154,11 +152,6 @@ 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)
|
||||
|
@ -207,35 +200,34 @@ namespace DetourNavigator
|
|||
}
|
||||
|
||||
std::optional<Tile> NavMeshDb::findTile(
|
||||
const ESM::RefId& worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
|
||||
std::string_view 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, toLowerCaseString(worldspace), tilePosition, compressedInput))
|
||||
if (&row == request(*mDb, mFindTile, &row, 1, worldspace, tilePosition, compressedInput))
|
||||
return {};
|
||||
return result;
|
||||
}
|
||||
|
||||
std::optional<TileData> NavMeshDb::getTileData(
|
||||
const ESM::RefId& worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input)
|
||||
std::string_view 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, toLowerCaseString(worldspace), tilePosition, compressedInput))
|
||||
if (&row == request(*mDb, mGetTileData, &row, 1, worldspace, tilePosition, compressedInput))
|
||||
return {};
|
||||
result.mData = Misc::decompress(result.mData);
|
||||
return result;
|
||||
}
|
||||
|
||||
int NavMeshDb::insertTile(TileId tileId, const ESM::RefId& worldspace, const TilePosition& tilePosition,
|
||||
int NavMeshDb::insertTile(TileId tileId, std::string_view 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, toLowerCaseString(worldspace), tilePosition, version, compressedInput,
|
||||
compressedData);
|
||||
return execute(*mDb, mInsertTile, tileId, worldspace, tilePosition, version, compressedInput, compressedData);
|
||||
}
|
||||
|
||||
int NavMeshDb::updateTile(TileId tileId, TileVersion version, const std::vector<std::byte>& data)
|
||||
|
@ -244,20 +236,20 @@ namespace DetourNavigator
|
|||
return execute(*mDb, mUpdateTile, tileId, version, compressedData);
|
||||
}
|
||||
|
||||
int NavMeshDb::deleteTilesAt(const ESM::RefId& worldspace, const TilePosition& tilePosition)
|
||||
int NavMeshDb::deleteTilesAt(std::string_view worldspace, const TilePosition& tilePosition)
|
||||
{
|
||||
return execute(*mDb, mDeleteTilesAt, toLowerCaseString(worldspace), tilePosition);
|
||||
return execute(*mDb, mDeleteTilesAt, worldspace, tilePosition);
|
||||
}
|
||||
|
||||
int NavMeshDb::deleteTilesAtExcept(
|
||||
const ESM::RefId& worldspace, const TilePosition& tilePosition, TileId excludeTileId)
|
||||
std::string_view worldspace, const TilePosition& tilePosition, TileId excludeTileId)
|
||||
{
|
||||
return execute(*mDb, mDeleteTilesAtExcept, toLowerCaseString(worldspace), tilePosition, excludeTileId);
|
||||
return execute(*mDb, mDeleteTilesAtExcept, worldspace, tilePosition, excludeTileId);
|
||||
}
|
||||
|
||||
int NavMeshDb::deleteTilesOutsideRange(const ESM::RefId& worldspace, const TilesPositionsRange& range)
|
||||
int NavMeshDb::deleteTilesOutsideRange(std::string_view worldspace, const TilesPositionsRange& range)
|
||||
{
|
||||
return execute(*mDb, mDeleteTilesOutsideRange, toLowerCaseString(worldspace), range);
|
||||
return execute(*mDb, mDeleteTilesOutsideRange, worldspace, range);
|
||||
}
|
||||
|
||||
ShapeId NavMeshDb::getMaxShapeId()
|
||||
|
|
|
@ -25,11 +25,6 @@
|
|||
struct sqlite3;
|
||||
struct sqlite3_stmt;
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
struct RefId;
|
||||
}
|
||||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
using TileId = Misc::StrongTypedef<std::int64_t, struct TiledIdTag>;
|
||||
|
@ -153,21 +148,21 @@ namespace DetourNavigator
|
|||
TileId getMaxTileId();
|
||||
|
||||
std::optional<Tile> findTile(
|
||||
const ESM::RefId& worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input);
|
||||
std::string_view worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input);
|
||||
|
||||
std::optional<TileData> getTileData(
|
||||
const ESM::RefId& worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input);
|
||||
std::string_view worldspace, const TilePosition& tilePosition, const std::vector<std::byte>& input);
|
||||
|
||||
int insertTile(TileId tileId, const ESM::RefId& worldspace, const TilePosition& tilePosition,
|
||||
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 updateTile(TileId tileId, TileVersion version, const std::vector<std::byte>& data);
|
||||
|
||||
int deleteTilesAt(const ESM::RefId& worldspace, const TilePosition& tilePosition);
|
||||
int deleteTilesAt(std::string_view worldspace, const TilePosition& tilePosition);
|
||||
|
||||
int deleteTilesAtExcept(const ESM::RefId& worldspace, const TilePosition& tilePosition, TileId excludeTileId);
|
||||
int deleteTilesAtExcept(std::string_view worldspace, const TilePosition& tilePosition, TileId excludeTileId);
|
||||
|
||||
int deleteTilesOutsideRange(const ESM::RefId& worldspace, const TilesPositionsRange& range);
|
||||
int deleteTilesOutsideRange(std::string_view worldspace, const TilesPositionsRange& range);
|
||||
|
||||
ShapeId getMaxShapeId();
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include <components/bullethelpers/heightfield.hpp>
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <components/misc/convert.hpp>
|
||||
|
||||
#include <osg/io_utils>
|
||||
|
@ -64,7 +63,7 @@ namespace DetourNavigator
|
|||
{
|
||||
}
|
||||
|
||||
void NavMeshManager::setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard)
|
||||
void NavMeshManager::setWorldspace(std::string_view worldspace, const UpdateGuard* guard)
|
||||
{
|
||||
if (worldspace == mWorldspace)
|
||||
return;
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
#include "recastmeshtiles.hpp"
|
||||
#include "waitconditiontype.hpp"
|
||||
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
#include <osg/Vec3f>
|
||||
|
||||
#include <map>
|
||||
|
@ -41,7 +39,7 @@ namespace DetourNavigator
|
|||
|
||||
explicit NavMeshManager(const Settings& settings, std::unique_ptr<NavMeshDb>&& db);
|
||||
|
||||
void setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard);
|
||||
void setWorldspace(std::string_view worldspace, const UpdateGuard* guard);
|
||||
|
||||
void updateBounds(const osg::Vec3f& playerPosition, const UpdateGuard* guard);
|
||||
|
||||
|
@ -84,7 +82,7 @@ namespace DetourNavigator
|
|||
|
||||
private:
|
||||
const Settings& mSettings;
|
||||
ESM::RefId mWorldspace;
|
||||
std::string mWorldspace;
|
||||
TileCachedRecastMeshManager mRecastMeshManager;
|
||||
OffMeshConnectionsManager mOffMeshConnectionsManager;
|
||||
AsyncNavMeshUpdater mAsyncNavMeshUpdater;
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace DetourNavigator
|
|||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<RecastMesh> getMesh(const ESM::RefId& worldspace, const TilePosition& tilePosition) const
|
||||
std::shared_ptr<RecastMesh> getMesh(std::string_view worldspace, const TilePosition& tilePosition) const
|
||||
{
|
||||
return mImpl.get().getNewMesh(worldspace, tilePosition);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "settingsutils.hpp"
|
||||
|
||||
#include <components/bullethelpers/aabb.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <components/misc/convert.hpp>
|
||||
|
||||
#include <boost/geometry/geometry.hpp>
|
||||
|
@ -114,7 +113,7 @@ namespace DetourNavigator
|
|||
return getIntersection(mRange, objectsRange);
|
||||
}
|
||||
|
||||
void TileCachedRecastMeshManager::setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard)
|
||||
void TileCachedRecastMeshManager::setWorldspace(std::string_view worldspace, const UpdateGuard* guard)
|
||||
{
|
||||
const MaybeLockGuard lock(mMutex, guard);
|
||||
if (mWorldspace == worldspace)
|
||||
|
@ -323,7 +322,7 @@ namespace DetourNavigator
|
|||
}
|
||||
|
||||
std::shared_ptr<RecastMesh> TileCachedRecastMeshManager::getMesh(
|
||||
const ESM::RefId& worldspace, const TilePosition& tilePosition)
|
||||
std::string_view worldspace, const TilePosition& tilePosition)
|
||||
{
|
||||
{
|
||||
const std::lock_guard lock(mMutex);
|
||||
|
@ -347,7 +346,7 @@ namespace DetourNavigator
|
|||
}
|
||||
|
||||
std::shared_ptr<RecastMesh> TileCachedRecastMeshManager::getCachedMesh(
|
||||
const ESM::RefId& worldspace, const TilePosition& tilePosition) const
|
||||
std::string_view worldspace, const TilePosition& tilePosition) const
|
||||
{
|
||||
const std::lock_guard lock(mMutex);
|
||||
if (mWorldspace != worldspace)
|
||||
|
@ -359,7 +358,7 @@ namespace DetourNavigator
|
|||
}
|
||||
|
||||
std::shared_ptr<RecastMesh> TileCachedRecastMeshManager::getNewMesh(
|
||||
const ESM::RefId& worldspace, const TilePosition& tilePosition) const
|
||||
std::string_view worldspace, const TilePosition& tilePosition) const
|
||||
{
|
||||
{
|
||||
const std::lock_guard lock(mMutex);
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#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>
|
||||
|
@ -48,7 +46,7 @@ namespace DetourNavigator
|
|||
|
||||
TilesPositionsRange getLimitedObjectsRange() const;
|
||||
|
||||
void setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard);
|
||||
void setWorldspace(std::string_view worldspace, const UpdateGuard* guard);
|
||||
|
||||
bool addObject(ObjectId id, const CollisionShape& shape, const btTransform& transform, AreaType areaType,
|
||||
const UpdateGuard* guard);
|
||||
|
@ -66,11 +64,11 @@ namespace DetourNavigator
|
|||
|
||||
void removeHeightfield(const osg::Vec2i& cellPosition, const UpdateGuard* guard);
|
||||
|
||||
std::shared_ptr<RecastMesh> getMesh(const ESM::RefId& worldspace, const TilePosition& tilePosition);
|
||||
std::shared_ptr<RecastMesh> getMesh(std::string_view worldspace, const TilePosition& tilePosition);
|
||||
|
||||
std::shared_ptr<RecastMesh> getCachedMesh(const ESM::RefId& worldspace, const TilePosition& tilePosition) const;
|
||||
std::shared_ptr<RecastMesh> getCachedMesh(std::string_view worldspace, const TilePosition& tilePosition) const;
|
||||
|
||||
std::shared_ptr<RecastMesh> getNewMesh(const ESM::RefId& worldspace, const TilePosition& tilePosition) const;
|
||||
std::shared_ptr<RecastMesh> getNewMesh(std::string_view worldspace, const TilePosition& tilePosition) const;
|
||||
|
||||
std::size_t getRevision() const { return mRevision; }
|
||||
|
||||
|
@ -127,7 +125,7 @@ namespace DetourNavigator
|
|||
|
||||
const RecastSettings& mSettings;
|
||||
TilesPositionsRange mRange;
|
||||
ESM::RefId mWorldspace;
|
||||
std::string 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…
Reference in a new issue