mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-25 14:36:49 +00:00
Use ESM::RefId for worldspace in detournavigator
This commit is contained in:
parent
114daa5938
commit
b4ab153418
23 changed files with 153 additions and 134 deletions
|
@ -8,6 +8,7 @@
|
||||||
#include <components/detournavigator/navmeshdb.hpp>
|
#include <components/detournavigator/navmeshdb.hpp>
|
||||||
#include <components/detournavigator/recastglobalallocator.hpp>
|
#include <components/detournavigator/recastglobalallocator.hpp>
|
||||||
#include <components/detournavigator/settings.hpp>
|
#include <components/detournavigator/settings.hpp>
|
||||||
|
#include <components/esm/refid.hpp>
|
||||||
#include <components/esm3/readerscache.hpp>
|
#include <components/esm3/readerscache.hpp>
|
||||||
#include <components/esm3/variant.hpp>
|
#include <components/esm3/variant.hpp>
|
||||||
#include <components/esmloader/esmdata.hpp>
|
#include <components/esmloader/esmdata.hpp>
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace NavMeshTool
|
||||||
return DetourNavigator::resolveMeshSource(mDb, source, mNextShapeId);
|
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
|
const std::vector<std::byte>& input) override
|
||||||
{
|
{
|
||||||
std::optional<NavMeshTileInfo> result;
|
std::optional<NavMeshTileInfo> result;
|
||||||
|
@ -121,7 +121,7 @@ namespace NavMeshTool
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ignore(std::string_view worldspace, const TilePosition& tilePosition) override
|
void ignore(const ESM::RefId& worldspace, const TilePosition& tilePosition) override
|
||||||
{
|
{
|
||||||
if (mRemoveUnusedTiles)
|
if (mRemoveUnusedTiles)
|
||||||
{
|
{
|
||||||
|
@ -131,7 +131,7 @@ namespace NavMeshTool
|
||||||
report();
|
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)
|
if (mRemoveUnusedTiles)
|
||||||
{
|
{
|
||||||
|
@ -142,7 +142,7 @@ namespace NavMeshTool
|
||||||
report();
|
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
|
const std::vector<std::byte>& input, PreparedNavMeshData& data) override
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
@ -158,7 +158,7 @@ namespace NavMeshTool
|
||||||
report();
|
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
|
std::int64_t version, PreparedNavMeshData& data) override
|
||||||
{
|
{
|
||||||
data.mUserId = static_cast<unsigned>(tileId);
|
data.mUserId = static_cast<unsigned>(tileId);
|
||||||
|
@ -217,7 +217,7 @@ namespace NavMeshTool
|
||||||
mDb.vacuum();
|
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);
|
const std::lock_guard lock(mMutex);
|
||||||
mTransaction.commit();
|
mTransaction.commit();
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <components/detournavigator/recastmesh.hpp>
|
#include <components/detournavigator/recastmesh.hpp>
|
||||||
#include <components/detournavigator/settings.hpp>
|
#include <components/detournavigator/settings.hpp>
|
||||||
#include <components/detournavigator/tilecachedrecastmeshmanager.hpp>
|
#include <components/detournavigator/tilecachedrecastmeshmanager.hpp>
|
||||||
|
#include <components/esm/refid.hpp>
|
||||||
#include <components/esm3/cellref.hpp>
|
#include <components/esm3/cellref.hpp>
|
||||||
#include <components/esm3/esmreader.hpp>
|
#include <components/esm3/esmreader.hpp>
|
||||||
#include <components/esm3/loadcell.hpp>
|
#include <components/esm3/loadcell.hpp>
|
||||||
|
@ -29,7 +30,6 @@
|
||||||
#include <osg/ref_ptr>
|
#include <osg/ref_ptr>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <components/esm/refid.hpp>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -37,6 +37,7 @@
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace NavMeshTool
|
namespace NavMeshTool
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
|
@ -221,7 +222,7 @@ namespace NavMeshTool
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldspaceNavMeshInput::WorldspaceNavMeshInput(
|
WorldspaceNavMeshInput::WorldspaceNavMeshInput(
|
||||||
std::string worldspace, const DetourNavigator::RecastSettings& settings)
|
ESM::RefId worldspace, const DetourNavigator::RecastSettings& settings)
|
||||||
: mWorldspace(std::move(worldspace))
|
: mWorldspace(std::move(worldspace))
|
||||||
, mTileCachedRecastMeshManager(settings)
|
, mTileCachedRecastMeshManager(settings)
|
||||||
{
|
{
|
||||||
|
@ -235,7 +236,7 @@ namespace NavMeshTool
|
||||||
{
|
{
|
||||||
Log(Debug::Info) << "Processing " << esmData.mCells.size() << " cells...";
|
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;
|
WorldspaceData data;
|
||||||
|
|
||||||
std::size_t objectsCounter = 0;
|
std::size_t objectsCounter = 0;
|
||||||
|
@ -263,16 +264,15 @@ namespace NavMeshTool
|
||||||
|
|
||||||
const osg::Vec2i cellPosition(cell.mData.mX, cell.mData.mY);
|
const osg::Vec2i cellPosition(cell.mData.mX, cell.mData.mY);
|
||||||
const std::size_t cellObjectsBegin = data.mObjects.size();
|
const std::size_t cellObjectsBegin = data.mObjects.size();
|
||||||
const auto cellNameLowerCase = Misc::StringUtils::lowerCase(cell.mCellId.mWorldspace.getRefIdString());
|
|
||||||
WorldspaceNavMeshInput& navMeshInput = [&]() -> WorldspaceNavMeshInput& {
|
WorldspaceNavMeshInput& navMeshInput = [&]() -> WorldspaceNavMeshInput& {
|
||||||
auto it = navMeshInputs.find(cellNameLowerCase);
|
auto it = navMeshInputs.find(cell.mCellId.mWorldspace);
|
||||||
if (it == navMeshInputs.end())
|
if (it == navMeshInputs.end())
|
||||||
{
|
{
|
||||||
it = navMeshInputs
|
it = navMeshInputs
|
||||||
.emplace(cellNameLowerCase,
|
.emplace(cell.mCellId.mWorldspace,
|
||||||
std::make_unique<WorldspaceNavMeshInput>(cellNameLowerCase, settings.mRecast))
|
std::make_unique<WorldspaceNavMeshInput>(cell.mCellId.mWorldspace, settings.mRecast))
|
||||||
.first;
|
.first;
|
||||||
it->second->mTileCachedRecastMeshManager.setWorldspace(cellNameLowerCase, nullptr);
|
it->second->mTileCachedRecastMeshManager.setWorldspace(cell.mCellId.mWorldspace, nullptr);
|
||||||
}
|
}
|
||||||
return *it->second;
|
return *it->second;
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <components/bullethelpers/collisionobject.hpp>
|
#include <components/bullethelpers/collisionobject.hpp>
|
||||||
#include <components/detournavigator/tilecachedrecastmeshmanager.hpp>
|
#include <components/detournavigator/tilecachedrecastmeshmanager.hpp>
|
||||||
|
#include <components/esm/refid.hpp>
|
||||||
#include <components/esm3/loadland.hpp>
|
#include <components/esm3/loadland.hpp>
|
||||||
#include <components/misc/convert.hpp>
|
#include <components/misc/convert.hpp>
|
||||||
#include <components/resource/bulletshape.hpp>
|
#include <components/resource/bulletshape.hpp>
|
||||||
|
@ -48,12 +49,12 @@ namespace NavMeshTool
|
||||||
|
|
||||||
struct WorldspaceNavMeshInput
|
struct WorldspaceNavMeshInput
|
||||||
{
|
{
|
||||||
std::string mWorldspace;
|
ESM::RefId mWorldspace;
|
||||||
TileCachedRecastMeshManager mTileCachedRecastMeshManager;
|
TileCachedRecastMeshManager mTileCachedRecastMeshManager;
|
||||||
btAABB mAabb;
|
btAABB mAabb;
|
||||||
bool mAabbInitialized = false;
|
bool mAabbInitialized = false;
|
||||||
|
|
||||||
explicit WorldspaceNavMeshInput(std::string worldspace, const DetourNavigator::RecastSettings& settings);
|
explicit WorldspaceNavMeshInput(ESM::RefId worldspace, const DetourNavigator::RecastSettings& settings);
|
||||||
};
|
};
|
||||||
|
|
||||||
class BulletObject
|
class BulletObject
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <components/detournavigator/makenavmesh.hpp>
|
#include <components/detournavigator/makenavmesh.hpp>
|
||||||
#include <components/detournavigator/navmeshdbutils.hpp>
|
#include <components/detournavigator/navmeshdbutils.hpp>
|
||||||
#include <components/detournavigator/serialization.hpp>
|
#include <components/detournavigator/serialization.hpp>
|
||||||
|
#include <components/esm/refid.hpp>
|
||||||
#include <components/loadinglistener/loadinglistener.hpp>
|
#include <components/loadinglistener/loadinglistener.hpp>
|
||||||
|
|
||||||
#include <BulletCollision/CollisionShapes/btBoxShape.h>
|
#include <BulletCollision/CollisionShapes/btBoxShape.h>
|
||||||
|
@ -52,7 +53,7 @@ namespace
|
||||||
OffMeshConnectionsManager mOffMeshConnectionsManager{ mSettings.mRecast };
|
OffMeshConnectionsManager mOffMeshConnectionsManager{ mSettings.mRecast };
|
||||||
const AgentBounds mAgentBounds{ CollisionShapeType::Aabb, { 29, 29, 66 } };
|
const AgentBounds mAgentBounds{ CollisionShapeType::Aabb, { 29, 29, 66 } };
|
||||||
const TilePosition mPlayerTile{ 0, 0 };
|
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) };
|
const btBoxShape mBox{ btVector3(100, 100, 20) };
|
||||||
Loading::Listener mListener;
|
Loading::Listener mListener;
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,7 +40,6 @@ namespace
|
||||||
Settings mSettings = makeSettings();
|
Settings mSettings = makeSettings();
|
||||||
std::unique_ptr<Navigator> mNavigator;
|
std::unique_ptr<Navigator> mNavigator;
|
||||||
const osg::Vec3f mPlayerPosition;
|
const osg::Vec3f mPlayerPosition;
|
||||||
const std::string mWorldspace;
|
|
||||||
const AgentBounds mAgentBounds{ CollisionShapeType::Aabb, { 29, 29, 66 } };
|
const AgentBounds mAgentBounds{ CollisionShapeType::Aabb, { 29, 29, 66 } };
|
||||||
osg::Vec3f mStart;
|
osg::Vec3f mStart;
|
||||||
osg::Vec3f mEnd;
|
osg::Vec3f mEnd;
|
||||||
|
@ -57,7 +56,6 @@ namespace
|
||||||
|
|
||||||
DetourNavigatorNavigatorTest()
|
DetourNavigatorNavigatorTest()
|
||||||
: mPlayerPosition(256, 256, 0)
|
: mPlayerPosition(256, 256, 0)
|
||||||
, mWorldspace("sys::default")
|
|
||||||
, mStart(52, 460, 1)
|
, mStart(52, 460, 1)
|
||||||
, mEnd(460, 52, 1)
|
, mEnd(460, 52, 1)
|
||||||
, mOut(mPath)
|
, mOut(mPath)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "generate.hpp"
|
#include "generate.hpp"
|
||||||
|
|
||||||
#include <components/detournavigator/navmeshdb.hpp>
|
#include <components/detournavigator/navmeshdb.hpp>
|
||||||
|
#include <components/esm/refid.hpp>
|
||||||
|
|
||||||
#include <DetourAlloc.h>
|
#include <DetourAlloc.h>
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ namespace
|
||||||
|
|
||||||
struct Tile
|
struct Tile
|
||||||
{
|
{
|
||||||
std::string mWorldspace;
|
ESM::RefId mWorldspace;
|
||||||
TilePosition mTilePosition;
|
TilePosition mTilePosition;
|
||||||
std::vector<std::byte> mInput;
|
std::vector<std::byte> mInput;
|
||||||
std::vector<std::byte> mData;
|
std::vector<std::byte> mData;
|
||||||
|
@ -39,7 +40,7 @@ namespace
|
||||||
|
|
||||||
Tile insertTile(TileId tileId, TileVersion version)
|
Tile insertTile(TileId tileId, TileVersion version)
|
||||||
{
|
{
|
||||||
std::string worldspace = "sys::default";
|
ESM::RefId worldspace = ESM::RefId::stringRefId("sys::default");
|
||||||
const TilePosition tilePosition{ 3, 4 };
|
const TilePosition tilePosition{ 3, 4 };
|
||||||
std::vector<std::byte> input = generateData();
|
std::vector<std::byte> input = generateData();
|
||||||
std::vector<std::byte> data = generateData();
|
std::vector<std::byte> data = generateData();
|
||||||
|
@ -89,7 +90,7 @@ namespace
|
||||||
{
|
{
|
||||||
const TileId tileId{ 53 };
|
const TileId tileId{ 53 };
|
||||||
const TileVersion version{ 1 };
|
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 TilePosition tilePosition{ 3, 4 };
|
||||||
const std::vector<std::byte> input = generateData();
|
const std::vector<std::byte> input = generateData();
|
||||||
const std::vector<std::byte> data = generateData();
|
const std::vector<std::byte> data = generateData();
|
||||||
|
@ -101,7 +102,7 @@ namespace
|
||||||
{
|
{
|
||||||
const TileId tileId{ 53 };
|
const TileId tileId{ 53 };
|
||||||
const TileVersion version{ 1 };
|
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 TilePosition tilePosition{ 3, 4 };
|
||||||
const std::vector<std::byte> input = generateData();
|
const std::vector<std::byte> input = generateData();
|
||||||
const std::vector<std::byte> data = 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)
|
TEST_F(DetourNavigatorNavMeshDbTest, delete_tiles_at_should_remove_all_tiles_with_given_worldspace_and_position)
|
||||||
{
|
{
|
||||||
const TileVersion version{ 1 };
|
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 TilePosition tilePosition{ 3, 4 };
|
||||||
const std::vector<std::byte> input1 = generateData();
|
const std::vector<std::byte> input1 = generateData();
|
||||||
const std::vector<std::byte> input2 = generateData();
|
const std::vector<std::byte> input2 = generateData();
|
||||||
|
@ -130,7 +131,7 @@ namespace
|
||||||
const TileId leftTileId{ 53 };
|
const TileId leftTileId{ 53 };
|
||||||
const TileId removedTileId{ 54 };
|
const TileId removedTileId{ 54 };
|
||||||
const TileVersion version{ 1 };
|
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 TilePosition tilePosition{ 3, 4 };
|
||||||
const std::vector<std::byte> leftInput = generateData();
|
const std::vector<std::byte> leftInput = generateData();
|
||||||
const std::vector<std::byte> removedInput = generateData();
|
const std::vector<std::byte> removedInput = generateData();
|
||||||
|
@ -148,7 +149,7 @@ namespace
|
||||||
{
|
{
|
||||||
TileId tileId{ 1 };
|
TileId tileId{ 1 };
|
||||||
const TileVersion version{ 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> input = generateData();
|
||||||
const std::vector<std::byte> data = generateData();
|
const std::vector<std::byte> data = generateData();
|
||||||
for (int x = -2; x <= 2; ++x)
|
for (int x = -2; x <= 2; ++x)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
#include <components/detournavigator/settingsutils.hpp>
|
#include <components/detournavigator/settingsutils.hpp>
|
||||||
#include <components/detournavigator/tilecachedrecastmeshmanager.hpp>
|
#include <components/detournavigator/tilecachedrecastmeshmanager.hpp>
|
||||||
|
#include <components/esm/refid.hpp>
|
||||||
|
|
||||||
#include <BulletCollision/CollisionShapes/btBoxShape.h>
|
#include <BulletCollision/CollisionShapes/btBoxShape.h>
|
||||||
|
|
||||||
|
@ -20,6 +21,8 @@ namespace
|
||||||
const ObjectTransform mObjectTransform{ ESM::Position{ { 0, 0, 0 }, { 0, 0, 0 } }, 0.0f };
|
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::BulletShape> mShape = new Resource::BulletShape;
|
||||||
const osg::ref_ptr<const Resource::BulletShapeInstance> mInstance = new Resource::BulletShapeInstance(mShape);
|
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()
|
DetourNavigatorTileCachedRecastMeshManagerTest()
|
||||||
{
|
{
|
||||||
|
@ -33,7 +36,7 @@ namespace
|
||||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_for_empty_should_return_nullptr)
|
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_for_empty_should_return_nullptr)
|
||||||
{
|
{
|
||||||
TileCachedRecastMeshManager manager(mSettings);
|
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)
|
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, get_revision_for_empty_should_return_zero)
|
||||||
|
@ -64,14 +67,14 @@ namespace
|
||||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_object_should_add_tiles)
|
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_object_should_add_tiles)
|
||||||
{
|
{
|
||||||
TileCachedRecastMeshManager manager(mSettings);
|
TileCachedRecastMeshManager manager(mSettings);
|
||||||
manager.setWorldspace("worldspace", nullptr);
|
manager.setWorldspace(mWorldspace, nullptr);
|
||||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||||
ASSERT_TRUE(manager.addObject(
|
ASSERT_TRUE(manager.addObject(
|
||||||
ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr));
|
ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr));
|
||||||
for (int x = -1; x < 1; ++x)
|
for (int x = -1; x < 1; ++x)
|
||||||
for (int y = -1; y < 1; ++y)
|
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)
|
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)
|
get_mesh_after_add_object_should_return_recast_mesh_for_each_used_tile)
|
||||||
{
|
{
|
||||||
TileCachedRecastMeshManager manager(mSettings);
|
TileCachedRecastMeshManager manager(mSettings);
|
||||||
manager.setWorldspace("worldspace", nullptr);
|
manager.setWorldspace(mWorldspace, nullptr);
|
||||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(-1, -1)), nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(-1, 0)), nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, -1)), nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, 0)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, 0)), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(
|
TEST_F(
|
||||||
DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_after_add_object_should_return_nullptr_for_unused_tile)
|
DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_after_add_object_should_return_nullptr_for_unused_tile)
|
||||||
{
|
{
|
||||||
TileCachedRecastMeshManager manager(mSettings);
|
TileCachedRecastMeshManager manager(mSettings);
|
||||||
manager.setWorldspace("worldspace", nullptr);
|
manager.setWorldspace(mWorldspace, nullptr);
|
||||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
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,
|
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest,
|
||||||
|
@ -170,7 +173,7 @@ namespace
|
||||||
bounds.mMin = osg::Vec2f(-1000, -1000);
|
bounds.mMin = osg::Vec2f(-1000, -1000);
|
||||||
bounds.mMax = osg::Vec2f(1000, 1000);
|
bounds.mMax = osg::Vec2f(1000, 1000);
|
||||||
manager.setBounds(bounds, nullptr);
|
manager.setBounds(bounds, nullptr);
|
||||||
manager.setWorldspace("worldspace", nullptr);
|
manager.setWorldspace(mWorldspace, nullptr);
|
||||||
|
|
||||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||||
const btTransform transform(
|
const btTransform transform(
|
||||||
|
@ -178,23 +181,23 @@ namespace
|
||||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||||
|
|
||||||
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground, nullptr);
|
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground, nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, -1)), nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, 0)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, 0)), nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(1, 0)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(1, 0)), nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(1, -1)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(1, -1)), nullptr);
|
||||||
|
|
||||||
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(-1, -1)), nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(-1, 0)), nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, -1)), nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, 0)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, 0)), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(
|
TEST_F(
|
||||||
DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_for_moved_object_should_return_nullptr_for_unused_tile)
|
DetourNavigatorTileCachedRecastMeshManagerTest, get_mesh_for_moved_object_should_return_nullptr_for_unused_tile)
|
||||||
{
|
{
|
||||||
TileCachedRecastMeshManager manager(mSettings);
|
TileCachedRecastMeshManager manager(mSettings);
|
||||||
manager.setWorldspace("worldspace", nullptr);
|
manager.setWorldspace(mWorldspace, nullptr);
|
||||||
|
|
||||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||||
const btTransform transform(
|
const btTransform transform(
|
||||||
|
@ -202,48 +205,48 @@ namespace
|
||||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||||
|
|
||||||
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground, nullptr);
|
manager.addObject(ObjectId(&boxShape), shape, transform, AreaType::AreaType_ground, nullptr);
|
||||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
|
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(-1, -1)), nullptr);
|
||||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
|
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(-1, 0)), nullptr);
|
||||||
|
|
||||||
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(1, 0)), nullptr);
|
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(1, 0)), nullptr);
|
||||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(1, -1)), nullptr);
|
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(1, -1)), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest,
|
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest,
|
||||||
get_mesh_for_removed_object_should_return_nullptr_for_all_previously_used_tiles)
|
get_mesh_for_removed_object_should_return_nullptr_for_all_previously_used_tiles)
|
||||||
{
|
{
|
||||||
TileCachedRecastMeshManager manager(mSettings);
|
TileCachedRecastMeshManager manager(mSettings);
|
||||||
manager.setWorldspace("worldspace", nullptr);
|
manager.setWorldspace(mWorldspace, nullptr);
|
||||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||||
manager.removeObject(ObjectId(&boxShape), nullptr);
|
manager.removeObject(ObjectId(&boxShape), nullptr);
|
||||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
|
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(-1, -1)), nullptr);
|
||||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
|
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(-1, 0)), nullptr);
|
||||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
|
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(0, -1)), nullptr);
|
||||||
EXPECT_EQ(manager.getMesh("worldspace", TilePosition(0, 0)), nullptr);
|
EXPECT_EQ(manager.getMesh(mWorldspace, TilePosition(0, 0)), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest,
|
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest,
|
||||||
get_mesh_for_not_changed_object_after_update_should_return_recast_mesh_for_same_tiles)
|
get_mesh_for_not_changed_object_after_update_should_return_recast_mesh_for_same_tiles)
|
||||||
{
|
{
|
||||||
TileCachedRecastMeshManager manager(mSettings);
|
TileCachedRecastMeshManager manager(mSettings);
|
||||||
manager.setWorldspace("worldspace", nullptr);
|
manager.setWorldspace(mWorldspace, nullptr);
|
||||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||||
|
|
||||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(-1, -1)), nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(-1, 0)), nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, -1)), nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, 0)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, 0)), nullptr);
|
||||||
|
|
||||||
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
manager.updateObject(ObjectId(&boxShape), btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, -1)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(-1, -1)), nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(-1, 0)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(-1, 0)), nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, -1)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, -1)), nullptr);
|
||||||
EXPECT_NE(manager.getMesh("worldspace", TilePosition(0, 0)), nullptr);
|
EXPECT_NE(manager.getMesh(mWorldspace, TilePosition(0, 0)), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest,
|
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest,
|
||||||
|
@ -288,7 +291,7 @@ namespace
|
||||||
get_revision_after_update_not_changed_object_should_return_same_value)
|
get_revision_after_update_not_changed_object_should_return_same_value)
|
||||||
{
|
{
|
||||||
TileCachedRecastMeshManager manager(mSettings);
|
TileCachedRecastMeshManager manager(mSettings);
|
||||||
manager.setWorldspace("worldspace", nullptr);
|
manager.setWorldspace(mWorldspace, nullptr);
|
||||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||||
manager.addObject(ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr);
|
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)
|
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_water_for_not_max_int_should_add_new_tiles)
|
||||||
{
|
{
|
||||||
TileCachedRecastMeshManager manager(mSettings);
|
TileCachedRecastMeshManager manager(mSettings);
|
||||||
manager.setWorldspace("worldspace", nullptr);
|
manager.setWorldspace(mWorldspace, nullptr);
|
||||||
const osg::Vec2i cellPosition(0, 0);
|
const osg::Vec2i cellPosition(0, 0);
|
||||||
const int cellSize = 8192;
|
const int cellSize = 8192;
|
||||||
manager.addWater(cellPosition, cellSize, 0.0f, nullptr);
|
manager.addWater(cellPosition, cellSize, 0.0f, nullptr);
|
||||||
for (int x = -1; x < 12; ++x)
|
for (int x = -1; x < 12; ++x)
|
||||||
for (int y = -1; y < 12; ++y)
|
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)
|
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, add_water_for_max_int_should_not_add_new_tiles)
|
||||||
{
|
{
|
||||||
TileCachedRecastMeshManager manager(mSettings);
|
TileCachedRecastMeshManager manager(mSettings);
|
||||||
manager.setWorldspace("worldspace", nullptr);
|
manager.setWorldspace(mWorldspace, nullptr);
|
||||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||||
ASSERT_TRUE(manager.addObject(
|
ASSERT_TRUE(manager.addObject(
|
||||||
|
@ -356,7 +359,7 @@ namespace
|
||||||
manager.addWater(cellPosition, cellSize, 0.0f, nullptr);
|
manager.addWater(cellPosition, cellSize, 0.0f, nullptr);
|
||||||
for (int x = -6; x < 6; ++x)
|
for (int x = -6; x < 6; ++x)
|
||||||
for (int y = -6; y < 6; ++y)
|
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);
|
-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)
|
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_water_for_existing_cell_should_remove_empty_tiles)
|
||||||
{
|
{
|
||||||
TileCachedRecastMeshManager manager(mSettings);
|
TileCachedRecastMeshManager manager(mSettings);
|
||||||
manager.setWorldspace("worldspace", nullptr);
|
manager.setWorldspace(mWorldspace, nullptr);
|
||||||
const osg::Vec2i cellPosition(0, 0);
|
const osg::Vec2i cellPosition(0, 0);
|
||||||
const int cellSize = 8192;
|
const int cellSize = 8192;
|
||||||
manager.addWater(cellPosition, cellSize, 0.0f, nullptr);
|
manager.addWater(cellPosition, cellSize, 0.0f, nullptr);
|
||||||
manager.removeWater(cellPosition, nullptr);
|
manager.removeWater(cellPosition, nullptr);
|
||||||
for (int x = -6; x < 6; ++x)
|
for (int x = -6; x < 6; ++x)
|
||||||
for (int y = -6; y < 6; ++y)
|
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)
|
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_water_for_existing_cell_should_leave_not_empty_tiles)
|
||||||
{
|
{
|
||||||
TileCachedRecastMeshManager manager(mSettings);
|
TileCachedRecastMeshManager manager(mSettings);
|
||||||
manager.setWorldspace("worldspace", nullptr);
|
manager.setWorldspace(mWorldspace, nullptr);
|
||||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||||
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
const CollisionShape shape(mInstance, boxShape, mObjectTransform);
|
||||||
ASSERT_TRUE(manager.addObject(
|
ASSERT_TRUE(manager.addObject(
|
||||||
|
@ -409,14 +412,14 @@ namespace
|
||||||
manager.removeWater(cellPosition, nullptr);
|
manager.removeWater(cellPosition, nullptr);
|
||||||
for (int x = -6; x < 6; ++x)
|
for (int x = -6; x < 6; ++x)
|
||||||
for (int y = -6; y < 6; ++y)
|
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);
|
-1 <= x && x <= 0 && -1 <= y && y <= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_object_should_not_remove_tile_with_water)
|
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, remove_object_should_not_remove_tile_with_water)
|
||||||
{
|
{
|
||||||
TileCachedRecastMeshManager manager(mSettings);
|
TileCachedRecastMeshManager manager(mSettings);
|
||||||
manager.setWorldspace("worldspace", nullptr);
|
manager.setWorldspace(mWorldspace, nullptr);
|
||||||
const osg::Vec2i cellPosition(0, 0);
|
const osg::Vec2i cellPosition(0, 0);
|
||||||
const int cellSize = 8192;
|
const int cellSize = 8192;
|
||||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||||
|
@ -427,21 +430,21 @@ namespace
|
||||||
manager.removeObject(ObjectId(&boxShape), nullptr);
|
manager.removeObject(ObjectId(&boxShape), nullptr);
|
||||||
for (int x = -1; x < 12; ++x)
|
for (int x = -1; x < 12; ++x)
|
||||||
for (int y = -1; y < 12; ++y)
|
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)
|
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, set_new_worldspace_should_remove_tiles)
|
||||||
{
|
{
|
||||||
TileCachedRecastMeshManager manager(mSettings);
|
TileCachedRecastMeshManager manager(mSettings);
|
||||||
manager.setWorldspace("worldspace", nullptr);
|
manager.setWorldspace(mWorldspace, nullptr);
|
||||||
const btBoxShape boxShape(btVector3(20, 20, 100));
|
const btBoxShape boxShape(btVector3(20, 20, 100));
|
||||||
const CollisionShape shape(nullptr, boxShape, mObjectTransform);
|
const CollisionShape shape(nullptr, boxShape, mObjectTransform);
|
||||||
ASSERT_TRUE(manager.addObject(
|
ASSERT_TRUE(manager.addObject(
|
||||||
ObjectId(&boxShape), shape, btTransform::getIdentity(), AreaType::AreaType_ground, nullptr));
|
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 x = -1; x < 1; ++x)
|
||||||
for (int y = -1; y < 1; ++y)
|
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)
|
TEST_F(DetourNavigatorTileCachedRecastMeshManagerTest, set_bounds_should_add_changed_tiles)
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "version.hpp"
|
#include "version.hpp"
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
|
#include <components/esm/refid.hpp>
|
||||||
#include <components/loadinglistener/loadinglistener.hpp>
|
#include <components/loadinglistener/loadinglistener.hpp>
|
||||||
#include <components/misc/thread.hpp>
|
#include <components/misc/thread.hpp>
|
||||||
|
|
||||||
|
@ -135,7 +136,7 @@ namespace DetourNavigator
|
||||||
}
|
}
|
||||||
|
|
||||||
Job::Job(const AgentBounds& agentBounds, std::weak_ptr<GuardedNavMeshCacheItem> navMeshCacheItem,
|
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)
|
std::chrono::steady_clock::time_point processTime)
|
||||||
: mId(getNextJobId())
|
: mId(getNextJobId())
|
||||||
, mAgentBounds(agentBounds)
|
, mAgentBounds(agentBounds)
|
||||||
|
@ -168,7 +169,7 @@ namespace DetourNavigator
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncNavMeshUpdater::post(const AgentBounds& agentBounds, const SharedNavMeshCacheItem& navMeshCacheItem,
|
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)
|
const std::map<TilePosition, ChangeType>& changedTiles)
|
||||||
{
|
{
|
||||||
bool playerTileChanged = false;
|
bool playerTileChanged = false;
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
#include "tileposition.hpp"
|
#include "tileposition.hpp"
|
||||||
#include "waitconditiontype.hpp"
|
#include "waitconditiontype.hpp"
|
||||||
|
|
||||||
|
#include <components/esm/refid.hpp>
|
||||||
|
|
||||||
#include <osg/Vec3f>
|
#include <osg/Vec3f>
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
@ -49,7 +51,7 @@ namespace DetourNavigator
|
||||||
const std::size_t mId;
|
const std::size_t mId;
|
||||||
const AgentBounds mAgentBounds;
|
const AgentBounds mAgentBounds;
|
||||||
const std::weak_ptr<GuardedNavMeshCacheItem> mNavMeshCacheItem;
|
const std::weak_ptr<GuardedNavMeshCacheItem> mNavMeshCacheItem;
|
||||||
const std::string mWorldspace;
|
const ESM::RefId mWorldspace;
|
||||||
const TilePosition mChangedTile;
|
const TilePosition mChangedTile;
|
||||||
const std::chrono::steady_clock::time_point mProcessTime;
|
const std::chrono::steady_clock::time_point mProcessTime;
|
||||||
unsigned mTryNumber = 0;
|
unsigned mTryNumber = 0;
|
||||||
|
@ -63,7 +65,7 @@ namespace DetourNavigator
|
||||||
std::unique_ptr<PreparedNavMeshData> mGeneratedNavMeshData;
|
std::unique_ptr<PreparedNavMeshData> mGeneratedNavMeshData;
|
||||||
|
|
||||||
Job(const AgentBounds& agentBounds, std::weak_ptr<GuardedNavMeshCacheItem> navMeshCacheItem,
|
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);
|
std::chrono::steady_clock::time_point processTime);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -148,7 +150,7 @@ namespace DetourNavigator
|
||||||
~AsyncNavMeshUpdater();
|
~AsyncNavMeshUpdater();
|
||||||
|
|
||||||
void post(const AgentBounds& agentBounds, const SharedNavMeshCacheItem& navMeshCacheItem,
|
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);
|
const std::map<TilePosition, ChangeType>& changedTiles);
|
||||||
|
|
||||||
void wait(WaitConditionType waitConditionType, Loading::Listener* listener);
|
void wait(WaitConditionType waitConditionType, Loading::Listener* listener);
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "settings.hpp"
|
#include "settings.hpp"
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
|
#include <components/esm/refid.hpp>
|
||||||
|
|
||||||
#include <osg/Vec3f>
|
#include <osg/Vec3f>
|
||||||
#include <osg/io_utils>
|
#include <osg/io_utils>
|
||||||
|
@ -23,7 +24,7 @@ namespace DetourNavigator
|
||||||
{
|
{
|
||||||
struct Ignore
|
struct Ignore
|
||||||
{
|
{
|
||||||
std::string_view mWorldspace;
|
const ESM::RefId& mWorldspace;
|
||||||
const TilePosition& mTilePosition;
|
const TilePosition& mTilePosition;
|
||||||
std::shared_ptr<NavMeshTileConsumer> mConsumer;
|
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,
|
RecastMeshProvider recastMeshProvider, const AgentBounds& agentBounds,
|
||||||
const DetourNavigator::Settings& settings, std::weak_ptr<NavMeshTileConsumer> consumer)
|
const DetourNavigator::Settings& settings, std::weak_ptr<NavMeshTileConsumer> consumer)
|
||||||
: mWorldspace(std::move(worldspace))
|
: mWorldspace(std::move(worldspace))
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "recastmeshprovider.hpp"
|
#include "recastmeshprovider.hpp"
|
||||||
#include "tileposition.hpp"
|
#include "tileposition.hpp"
|
||||||
|
|
||||||
|
#include <components/esm/refid.hpp>
|
||||||
#include <components/sceneutil/workqueue.hpp>
|
#include <components/sceneutil/workqueue.hpp>
|
||||||
|
|
||||||
#include <osg/Vec3f>
|
#include <osg/Vec3f>
|
||||||
|
@ -38,18 +39,18 @@ namespace DetourNavigator
|
||||||
virtual std::int64_t resolveMeshSource(const MeshSource& source) = 0;
|
virtual std::int64_t resolveMeshSource(const MeshSource& source) = 0;
|
||||||
|
|
||||||
virtual std::optional<NavMeshTileInfo> find(
|
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;
|
= 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)
|
const std::vector<std::byte>& input, PreparedNavMeshData& data)
|
||||||
= 0;
|
= 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)
|
std::int64_t version, PreparedNavMeshData& data)
|
||||||
= 0;
|
= 0;
|
||||||
|
|
||||||
|
@ -59,14 +60,14 @@ namespace DetourNavigator
|
||||||
class GenerateNavMeshTile final : public SceneUtil::WorkItem
|
class GenerateNavMeshTile final : public SceneUtil::WorkItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GenerateNavMeshTile(std::string worldspace, const TilePosition& tilePosition,
|
GenerateNavMeshTile(ESM::RefId worldspace, const TilePosition& tilePosition,
|
||||||
RecastMeshProvider recastMeshProvider, const AgentBounds& agentBounds, const Settings& settings,
|
RecastMeshProvider recastMeshProvider, const AgentBounds& agentBounds, const Settings& settings,
|
||||||
std::weak_ptr<NavMeshTileConsumer> consumer);
|
std::weak_ptr<NavMeshTileConsumer> consumer);
|
||||||
|
|
||||||
void doWork() final;
|
void doWork() final;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string mWorldspace;
|
const ESM::RefId mWorldspace;
|
||||||
const TilePosition mTilePosition;
|
const TilePosition mTilePosition;
|
||||||
const RecastMeshProvider mRecastMeshProvider;
|
const RecastMeshProvider mRecastMeshProvider;
|
||||||
const AgentBounds mAgentBounds;
|
const AgentBounds mAgentBounds;
|
||||||
|
|
|
@ -90,8 +90,6 @@ namespace DetourNavigator
|
||||||
* @brief setWorldspace should be called before adding object from new worldspace
|
* @brief setWorldspace should be called before adding object from new worldspace
|
||||||
* @param 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;
|
virtual void setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -33,14 +33,9 @@ namespace DetourNavigator
|
||||||
--it->second;
|
--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)
|
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)
|
void NavigatorImpl::updateBounds(const osg::Vec3f& playerPosition, const UpdateGuard* guard)
|
||||||
|
|
|
@ -27,8 +27,6 @@ namespace DetourNavigator
|
||||||
|
|
||||||
void removeAgent(const AgentBounds& agentBounds) override;
|
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 setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard) override;
|
||||||
|
|
||||||
void updateBounds(const osg::Vec3f& playerPosition, 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 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 setWorldspace(const ESM::RefId& /*worldspace*/, const UpdateGuard* /*guard*/) override {}
|
||||||
|
|
||||||
void addObject(const ObjectId /*id*/, const ObjectShapes& /*shapes*/, const btTransform& /*transform*/,
|
void addObject(const ObjectId /*id*/, const ObjectShapes& /*shapes*/, const btTransform& /*transform*/,
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#include "navmeshdb.hpp"
|
#include "navmeshdb.hpp"
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
|
#include <components/esm/refid.hpp>
|
||||||
#include <components/misc/compression.hpp>
|
#include <components/misc/compression.hpp>
|
||||||
#include <components/misc/strings/format.hpp>
|
#include <components/misc/strings/format.hpp>
|
||||||
|
#include <components/misc/strings/lower.hpp>
|
||||||
#include <components/sqlite3/db.hpp>
|
#include <components/sqlite3/db.hpp>
|
||||||
#include <components/sqlite3/request.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)
|
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)));
|
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)
|
std::ostream& operator<<(std::ostream& stream, ShapeType value)
|
||||||
|
@ -200,34 +207,35 @@ namespace DetourNavigator
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Tile> NavMeshDb::findTile(
|
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;
|
Tile result;
|
||||||
auto row = std::tie(result.mTileId, result.mVersion);
|
auto row = std::tie(result.mTileId, result.mVersion);
|
||||||
const std::vector<std::byte> compressedInput = Misc::compress(input);
|
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 {};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<TileData> NavMeshDb::getTileData(
|
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;
|
TileData result;
|
||||||
auto row = std::tie(result.mTileId, result.mVersion, result.mData);
|
auto row = std::tie(result.mTileId, result.mVersion, result.mData);
|
||||||
const std::vector<std::byte> compressedInput = Misc::compress(input);
|
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 {};
|
return {};
|
||||||
result.mData = Misc::decompress(result.mData);
|
result.mData = Misc::decompress(result.mData);
|
||||||
return result;
|
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)
|
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> compressedInput = Misc::compress(input);
|
||||||
const std::vector<std::byte> compressedData = Misc::compress(data);
|
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)
|
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);
|
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(
|
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()
|
ShapeId NavMeshDb::getMaxShapeId()
|
||||||
|
|
|
@ -25,6 +25,11 @@
|
||||||
struct sqlite3;
|
struct sqlite3;
|
||||||
struct sqlite3_stmt;
|
struct sqlite3_stmt;
|
||||||
|
|
||||||
|
namespace ESM
|
||||||
|
{
|
||||||
|
struct RefId;
|
||||||
|
}
|
||||||
|
|
||||||
namespace DetourNavigator
|
namespace DetourNavigator
|
||||||
{
|
{
|
||||||
using TileId = Misc::StrongTypedef<std::int64_t, struct TiledIdTag>;
|
using TileId = Misc::StrongTypedef<std::int64_t, struct TiledIdTag>;
|
||||||
|
@ -148,21 +153,21 @@ namespace DetourNavigator
|
||||||
TileId getMaxTileId();
|
TileId getMaxTileId();
|
||||||
|
|
||||||
std::optional<Tile> findTile(
|
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::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);
|
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 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();
|
ShapeId getMaxShapeId();
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include <components/bullethelpers/heightfield.hpp>
|
#include <components/bullethelpers/heightfield.hpp>
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
|
#include <components/esm/refid.hpp>
|
||||||
#include <components/misc/convert.hpp>
|
#include <components/misc/convert.hpp>
|
||||||
|
|
||||||
#include <osg/io_utils>
|
#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)
|
if (worldspace == mWorldspace)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include "recastmeshtiles.hpp"
|
#include "recastmeshtiles.hpp"
|
||||||
#include "waitconditiontype.hpp"
|
#include "waitconditiontype.hpp"
|
||||||
|
|
||||||
|
#include <components/esm/refid.hpp>
|
||||||
|
|
||||||
#include <osg/Vec3f>
|
#include <osg/Vec3f>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -39,7 +41,7 @@ namespace DetourNavigator
|
||||||
|
|
||||||
explicit NavMeshManager(const Settings& settings, std::unique_ptr<NavMeshDb>&& db);
|
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);
|
void updateBounds(const osg::Vec3f& playerPosition, const UpdateGuard* guard);
|
||||||
|
|
||||||
|
@ -82,7 +84,7 @@ namespace DetourNavigator
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Settings& mSettings;
|
const Settings& mSettings;
|
||||||
std::string mWorldspace;
|
ESM::RefId mWorldspace;
|
||||||
TileCachedRecastMeshManager mRecastMeshManager;
|
TileCachedRecastMeshManager mRecastMeshManager;
|
||||||
OffMeshConnectionsManager mOffMeshConnectionsManager;
|
OffMeshConnectionsManager mOffMeshConnectionsManager;
|
||||||
AsyncNavMeshUpdater mAsyncNavMeshUpdater;
|
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);
|
return mImpl.get().getNewMesh(worldspace, tilePosition);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "settingsutils.hpp"
|
#include "settingsutils.hpp"
|
||||||
|
|
||||||
#include <components/bullethelpers/aabb.hpp>
|
#include <components/bullethelpers/aabb.hpp>
|
||||||
|
#include <components/esm/refid.hpp>
|
||||||
#include <components/misc/convert.hpp>
|
#include <components/misc/convert.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/geometry.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);
|
const MaybeLockGuard lock(mMutex, guard);
|
||||||
if (mWorldspace == worldspace)
|
if (mWorldspace == worldspace)
|
||||||
|
@ -321,7 +322,7 @@ namespace DetourNavigator
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<RecastMesh> TileCachedRecastMeshManager::getMesh(
|
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);
|
const std::lock_guard lock(mMutex);
|
||||||
|
@ -345,7 +346,7 @@ namespace DetourNavigator
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<RecastMesh> TileCachedRecastMeshManager::getCachedMesh(
|
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);
|
const std::lock_guard lock(mMutex);
|
||||||
if (mWorldspace != worldspace)
|
if (mWorldspace != worldspace)
|
||||||
|
@ -357,7 +358,7 @@ namespace DetourNavigator
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<RecastMesh> TileCachedRecastMeshManager::getNewMesh(
|
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);
|
const std::lock_guard lock(mMutex);
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include "tileposition.hpp"
|
#include "tileposition.hpp"
|
||||||
#include "version.hpp"
|
#include "version.hpp"
|
||||||
|
|
||||||
|
#include <components/esm/refid.hpp>
|
||||||
|
|
||||||
#include <boost/geometry/geometries/box.hpp>
|
#include <boost/geometry/geometries/box.hpp>
|
||||||
#include <boost/geometry/geometries/point.hpp>
|
#include <boost/geometry/geometries/point.hpp>
|
||||||
#include <boost/geometry/index/rtree.hpp>
|
#include <boost/geometry/index/rtree.hpp>
|
||||||
|
@ -46,7 +48,7 @@ namespace DetourNavigator
|
||||||
|
|
||||||
TilesPositionsRange getRange() const;
|
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,
|
bool addObject(ObjectId id, const CollisionShape& shape, const btTransform& transform, AreaType areaType,
|
||||||
const UpdateGuard* guard);
|
const UpdateGuard* guard);
|
||||||
|
@ -64,11 +66,11 @@ namespace DetourNavigator
|
||||||
|
|
||||||
void removeHeightfield(const osg::Vec2i& cellPosition, const UpdateGuard* guard);
|
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; }
|
std::size_t getRevision() const { return mRevision; }
|
||||||
|
|
||||||
|
@ -126,7 +128,7 @@ namespace DetourNavigator
|
||||||
const RecastSettings& mSettings;
|
const RecastSettings& mSettings;
|
||||||
TileBounds mBounds;
|
TileBounds mBounds;
|
||||||
TilesPositionsRange mRange;
|
TilesPositionsRange mRange;
|
||||||
std::string mWorldspace;
|
ESM::RefId mWorldspace;
|
||||||
std::unordered_map<ObjectId, std::unique_ptr<ObjectData>> mObjects;
|
std::unordered_map<ObjectId, std::unique_ptr<ObjectData>> mObjects;
|
||||||
boost::geometry::index::rtree<ObjectIndexValue, boost::geometry::index::quadratic<16>> mObjectIndex;
|
boost::geometry::index::rtree<ObjectIndexValue, boost::geometry::index::quadratic<16>> mObjectIndex;
|
||||||
std::map<osg::Vec2i, WaterData> mWater;
|
std::map<osg::Vec2i, WaterData> mWater;
|
||||||
|
|
Loading…
Reference in a new issue