mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 03:59:56 +00:00
Merge branch 'reduce_code_size' into 'master'
Reduce preprocessed code size See merge request OpenMW/openmw!2955
This commit is contained in:
commit
9c1a90daa5
30 changed files with 160 additions and 138 deletions
|
@ -45,13 +45,13 @@ if [[ "${GENERATE_ONLY}" ]]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
git remote add target "${CI_MERGE_REQUEST_SOURCE_PROJECT_URL:-https://gitlab.com/OpenMW/openmw.git}"
|
||||
git remote add target "${CI_MERGE_REQUEST_PROJECT_URL:-https://gitlab.com/OpenMW/openmw.git}"
|
||||
|
||||
TARGET_BRANCH="${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-master}"
|
||||
|
||||
git fetch target "${TARGET_BRANCH:?}"
|
||||
|
||||
BASE_VERSION=$(git merge-base "target/${TARGET_BRANCH:?}" HEAD)
|
||||
BASE_VERSION=$(git merge-base "target/${TARGET_BRANCH:?}" "${VERSION:?}")
|
||||
|
||||
# Save and use scripts from this commit because they may be absent or different in the base version
|
||||
cp scripts/preprocessed_file_size_stats.py scripts/preprocessed_file_size_stats.bak.py
|
||||
|
|
|
@ -279,7 +279,7 @@ namespace NavMeshTool
|
|||
return *it->second;
|
||||
}();
|
||||
|
||||
const TileCachedRecastMeshManager::UpdateGuard guard(navMeshInput.mTileCachedRecastMeshManager);
|
||||
const auto guard = navMeshInput.mTileCachedRecastMeshManager.makeUpdateGuard();
|
||||
|
||||
if (exterior)
|
||||
{
|
||||
|
@ -293,15 +293,15 @@ namespace NavMeshTool
|
|||
getAabb(cellPosition, minHeight, maxHeight), navMeshInput.mAabb, navMeshInput.mAabbInitialized);
|
||||
|
||||
navMeshInput.mTileCachedRecastMeshManager.addHeightfield(
|
||||
cellPosition, ESM::Land::REAL_SIZE, heightfieldShape, &guard);
|
||||
cellPosition, ESM::Land::REAL_SIZE, heightfieldShape, guard.get());
|
||||
|
||||
navMeshInput.mTileCachedRecastMeshManager.addWater(cellPosition, ESM::Land::REAL_SIZE, -1, &guard);
|
||||
navMeshInput.mTileCachedRecastMeshManager.addWater(cellPosition, ESM::Land::REAL_SIZE, -1, guard.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((cell.mData.mFlags & ESM::Cell::HasWater) != 0)
|
||||
navMeshInput.mTileCachedRecastMeshManager.addWater(
|
||||
cellPosition, std::numeric_limits<int>::max(), cell.mWater, &guard);
|
||||
cellPosition, std::numeric_limits<int>::max(), cell.mWater, guard.get());
|
||||
}
|
||||
|
||||
forEachObject(cell, esmData, vfs, bulletShapeManager, readers, [&](BulletObject object) {
|
||||
|
@ -319,13 +319,13 @@ namespace NavMeshTool
|
|||
object.getObjectTransform());
|
||||
|
||||
navMeshInput.mTileCachedRecastMeshManager.addObject(
|
||||
objectId, shape, transform, DetourNavigator::AreaType_ground, &guard);
|
||||
objectId, shape, transform, DetourNavigator::AreaType_ground, guard.get());
|
||||
|
||||
if (const btCollisionShape* avoid = object.getShapeInstance()->mAvoidCollisionShape.get())
|
||||
{
|
||||
const CollisionShape avoidShape(object.getShapeInstance(), *avoid, object.getObjectTransform());
|
||||
navMeshInput.mTileCachedRecastMeshManager.addObject(
|
||||
objectId, avoidShape, transform, DetourNavigator::AreaType_null, &guard);
|
||||
objectId, avoidShape, transform, DetourNavigator::AreaType_null, guard.get());
|
||||
}
|
||||
|
||||
data.mObjects.emplace_back(std::move(object));
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <components/detournavigator/debug.hpp>
|
||||
#include <components/detournavigator/heightfieldshape.hpp>
|
||||
#include <components/detournavigator/navigator.hpp>
|
||||
#include <components/detournavigator/navigatorimpl.hpp>
|
||||
#include <components/detournavigator/updateguard.hpp>
|
||||
#include <components/esm/records.hpp>
|
||||
#include <components/loadinglistener/loadinglistener.hpp>
|
||||
#include <components/misc/convert.hpp>
|
||||
|
|
|
@ -45,9 +45,9 @@
|
|||
#include <components/detournavigator/agentbounds.hpp>
|
||||
#include <components/detournavigator/debug.hpp>
|
||||
#include <components/detournavigator/navigator.hpp>
|
||||
#include <components/detournavigator/navigatorimpl.hpp>
|
||||
#include <components/detournavigator/settings.hpp>
|
||||
#include <components/detournavigator/stats.hpp>
|
||||
#include <components/detournavigator/updateguard.hpp>
|
||||
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/loadinglistener/loadinglistener.hpp>
|
||||
|
|
|
@ -340,36 +340,67 @@ elseif(NOT ANDROID)
|
|||
endif()
|
||||
|
||||
add_component_dir(detournavigator
|
||||
debug
|
||||
makenavmesh
|
||||
findsmoothpath
|
||||
recastmeshbuilder
|
||||
navmeshmanager
|
||||
navigatorimpl
|
||||
agentbounds
|
||||
areatype
|
||||
asyncnavmeshupdater
|
||||
recastmesh
|
||||
tilecachedrecastmeshmanager
|
||||
recastmeshobject
|
||||
navmeshtilescache
|
||||
settings
|
||||
navigator
|
||||
bounds
|
||||
changetype
|
||||
collisionshapetype
|
||||
commulativeaabb
|
||||
dbrefgeometryobject
|
||||
debug
|
||||
exceptions
|
||||
findrandompointaroundcircle
|
||||
raycast
|
||||
findsmoothpath
|
||||
flags
|
||||
generatenavmeshtile
|
||||
gettilespositions
|
||||
guardednavmeshcacheitem
|
||||
heightfieldshape
|
||||
makenavmesh
|
||||
navigator
|
||||
navigatorimpl
|
||||
navigatorstub
|
||||
navigatorutils
|
||||
navmeshcacheitem
|
||||
navmeshdata
|
||||
navmeshdb
|
||||
navmeshdbutils
|
||||
navmeshmanager
|
||||
navmeshtilescache
|
||||
navmeshtileview
|
||||
objectid
|
||||
objecttransform
|
||||
offmeshconnection
|
||||
offmeshconnectionsmanager
|
||||
preparednavmeshdata
|
||||
navmeshcacheitem
|
||||
navigatorutils
|
||||
generatenavmeshtile
|
||||
navmeshdb
|
||||
serialization
|
||||
navmeshdbutils
|
||||
preparednavmeshdatatuple
|
||||
raycast
|
||||
recast
|
||||
gettilespositions
|
||||
collisionshapetype
|
||||
stats
|
||||
commulativeaabb
|
||||
recastallocutils
|
||||
recastcontext
|
||||
recastglobalallocator
|
||||
recastmesh
|
||||
recastmeshbuilder
|
||||
recastmeshobject
|
||||
recastmeshprovider
|
||||
recastmeshtiles
|
||||
recastparams
|
||||
recasttempallocator
|
||||
ref
|
||||
serialization
|
||||
settings
|
||||
settingsutils
|
||||
sharednavmeshcacheitem
|
||||
stats
|
||||
status
|
||||
tilebounds
|
||||
tilecachedrecastmeshmanager
|
||||
tileposition
|
||||
tilespositionsrange
|
||||
updateguard
|
||||
version
|
||||
waitconditiontype
|
||||
)
|
||||
|
||||
add_component_dir(loadinglistener
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include <components/loadinglistener/loadinglistener.hpp>
|
||||
#include <components/misc/thread.hpp>
|
||||
|
||||
#include <BulletCollision/CollisionShapes/btBoxShape.h>
|
||||
|
||||
#include <DetourNavMesh.h>
|
||||
|
||||
#include <osg/io_utils>
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
#include "tileposition.hpp"
|
||||
#include "waitconditiontype.hpp"
|
||||
|
||||
#include <osg/Vec3f>
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_COMMULATIVEAABB_H
|
||||
|
||||
#include <BulletCollision/Gimpact/btBoxCollision.h>
|
||||
#include <LinearMath/btTransform.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
|
||||
#include "flags.hpp"
|
||||
|
||||
#include <optional>
|
||||
#include <osg/Vec3f>
|
||||
|
||||
#include <optional>
|
||||
|
||||
class dtNavMeshQuery;
|
||||
|
||||
namespace DetourNavigator
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <components/misc/convert.hpp>
|
||||
|
||||
#include <DetourCommon.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "settingsutils.hpp"
|
||||
#include "status.hpp"
|
||||
|
||||
#include <DetourCommon.h>
|
||||
#include <DetourNavMesh.h>
|
||||
#include <DetourNavMeshQuery.h>
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
|
||||
#include <osg/Vec3f>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include <functional>
|
||||
|
|
|
@ -7,10 +7,7 @@
|
|||
|
||||
#include <components/sceneutil/workqueue.hpp>
|
||||
|
||||
#include <osg/Vec3f>
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include <DetourNavMesh.h>
|
||||
#include <DetourNavMeshBuilder.h>
|
||||
#include <Recast.h>
|
||||
#include <RecastAlloc.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "objecttransform.hpp"
|
||||
#include "recastmeshtiles.hpp"
|
||||
#include "sharednavmeshcacheitem.hpp"
|
||||
#include "updateguard.hpp"
|
||||
#include "waitconditiontype.hpp"
|
||||
|
||||
#include <components/resource/bulletshape.hpp>
|
||||
|
@ -58,8 +59,6 @@ namespace DetourNavigator
|
|||
}
|
||||
};
|
||||
|
||||
class UpdateGuard;
|
||||
|
||||
/**
|
||||
* @brief Top level interface of detournavigator component. Navigator allows to build a scene with navmesh and find
|
||||
* a path for an agent there. Scene contains agents, geometry objects and water. Agent are distinguished only by
|
||||
|
@ -71,7 +70,7 @@ namespace DetourNavigator
|
|||
{
|
||||
virtual ~Navigator() = default;
|
||||
|
||||
virtual std::unique_ptr<const UpdateGuard> makeUpdateGuard() = 0;
|
||||
virtual ScopedUpdateGuard makeUpdateGuard() = 0;
|
||||
|
||||
/**
|
||||
* @brief addAgent should be called for each agent even if all of them has same half extents.
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "stats.hpp"
|
||||
|
||||
#include <components/esm3/loadpgrd.hpp>
|
||||
#include <components/misc/algorithm.hpp>
|
||||
#include <components/misc/convert.hpp>
|
||||
#include <components/misc/coordinateconverter.hpp>
|
||||
|
||||
|
@ -36,12 +35,12 @@ namespace DetourNavigator
|
|||
|
||||
void NavigatorImpl::setWorldspace(std::string_view worldspace, const UpdateGuard* guard)
|
||||
{
|
||||
mNavMeshManager.setWorldspace(worldspace, getImpl(guard));
|
||||
mNavMeshManager.setWorldspace(worldspace, guard);
|
||||
}
|
||||
|
||||
void NavigatorImpl::updateBounds(const osg::Vec3f& playerPosition, const UpdateGuard* guard)
|
||||
{
|
||||
mNavMeshManager.updateBounds(playerPosition, getImpl(guard));
|
||||
mNavMeshManager.updateBounds(playerPosition, guard);
|
||||
}
|
||||
|
||||
void NavigatorImpl::addObject(
|
||||
|
@ -55,12 +54,12 @@ namespace DetourNavigator
|
|||
{
|
||||
const CollisionShape collisionShape(
|
||||
shapes.mShapeInstance, *shapes.mShapeInstance->mCollisionShape, shapes.mTransform);
|
||||
bool result = mNavMeshManager.addObject(id, collisionShape, transform, AreaType_ground, getImpl(guard));
|
||||
bool result = mNavMeshManager.addObject(id, collisionShape, transform, AreaType_ground, guard);
|
||||
if (const btCollisionShape* const avoidShape = shapes.mShapeInstance->mAvoidCollisionShape.get())
|
||||
{
|
||||
const ObjectId avoidId(avoidShape);
|
||||
const CollisionShape avoidCollisionShape(shapes.mShapeInstance, *avoidShape, shapes.mTransform);
|
||||
if (mNavMeshManager.addObject(avoidId, avoidCollisionShape, transform, AreaType_null, getImpl(guard)))
|
||||
if (mNavMeshManager.addObject(avoidId, avoidCollisionShape, transform, AreaType_null, guard))
|
||||
{
|
||||
updateAvoidShapeId(id, avoidId, guard);
|
||||
result = true;
|
||||
|
@ -84,11 +83,11 @@ namespace DetourNavigator
|
|||
void NavigatorImpl::updateObject(
|
||||
const ObjectId id, const ObjectShapes& shapes, const btTransform& transform, const UpdateGuard* guard)
|
||||
{
|
||||
mNavMeshManager.updateObject(id, transform, AreaType_ground, getImpl(guard));
|
||||
mNavMeshManager.updateObject(id, transform, AreaType_ground, guard);
|
||||
if (const btCollisionShape* const avoidShape = shapes.mShapeInstance->mAvoidCollisionShape.get())
|
||||
{
|
||||
const ObjectId avoidId(avoidShape);
|
||||
if (mNavMeshManager.updateObject(avoidId, transform, AreaType_null, getImpl(guard)))
|
||||
if (mNavMeshManager.updateObject(avoidId, transform, AreaType_null, guard))
|
||||
updateAvoidShapeId(id, avoidId, guard);
|
||||
}
|
||||
}
|
||||
|
@ -101,35 +100,35 @@ namespace DetourNavigator
|
|||
|
||||
void NavigatorImpl::removeObject(const ObjectId id, const UpdateGuard* guard)
|
||||
{
|
||||
mNavMeshManager.removeObject(id, getImpl(guard));
|
||||
mNavMeshManager.removeObject(id, guard);
|
||||
const auto avoid = mAvoidIds.find(id);
|
||||
if (avoid != mAvoidIds.end())
|
||||
mNavMeshManager.removeObject(avoid->second, getImpl(guard));
|
||||
mNavMeshManager.removeObject(avoid->second, guard);
|
||||
const auto water = mWaterIds.find(id);
|
||||
if (water != mWaterIds.end())
|
||||
mNavMeshManager.removeObject(water->second, getImpl(guard));
|
||||
mNavMeshManager.removeObject(water->second, guard);
|
||||
mNavMeshManager.removeOffMeshConnections(id);
|
||||
}
|
||||
|
||||
void NavigatorImpl::addWater(const osg::Vec2i& cellPosition, int cellSize, float level, const UpdateGuard* guard)
|
||||
{
|
||||
mNavMeshManager.addWater(cellPosition, cellSize, level, getImpl(guard));
|
||||
mNavMeshManager.addWater(cellPosition, cellSize, level, guard);
|
||||
}
|
||||
|
||||
void NavigatorImpl::removeWater(const osg::Vec2i& cellPosition, const UpdateGuard* guard)
|
||||
{
|
||||
mNavMeshManager.removeWater(cellPosition, getImpl(guard));
|
||||
mNavMeshManager.removeWater(cellPosition, guard);
|
||||
}
|
||||
|
||||
void NavigatorImpl::addHeightfield(
|
||||
const osg::Vec2i& cellPosition, int cellSize, const HeightfieldShape& shape, const UpdateGuard* guard)
|
||||
{
|
||||
mNavMeshManager.addHeightfield(cellPosition, cellSize, shape, getImpl(guard));
|
||||
mNavMeshManager.addHeightfield(cellPosition, cellSize, shape, guard);
|
||||
}
|
||||
|
||||
void NavigatorImpl::removeHeightfield(const osg::Vec2i& cellPosition, const UpdateGuard* guard)
|
||||
{
|
||||
mNavMeshManager.removeHeightfield(cellPosition, getImpl(guard));
|
||||
mNavMeshManager.removeHeightfield(cellPosition, guard);
|
||||
}
|
||||
|
||||
void NavigatorImpl::addPathgrid(const ESM::Cell& cell, const ESM::Pathgrid& pathgrid)
|
||||
|
@ -152,7 +151,7 @@ namespace DetourNavigator
|
|||
void NavigatorImpl::update(const osg::Vec3f& playerPosition, const UpdateGuard* guard)
|
||||
{
|
||||
removeUnusedNavMeshes();
|
||||
mNavMeshManager.update(playerPosition, getImpl(guard));
|
||||
mNavMeshManager.update(playerPosition, guard);
|
||||
}
|
||||
|
||||
void NavigatorImpl::wait(WaitConditionType waitConditionType, Loading::Listener* listener)
|
||||
|
@ -196,7 +195,7 @@ namespace DetourNavigator
|
|||
auto inserted = ids.insert(std::make_pair(id, updateId));
|
||||
if (!inserted.second)
|
||||
{
|
||||
mNavMeshManager.removeObject(inserted.first->second, getImpl(guard));
|
||||
mNavMeshManager.removeObject(inserted.first->second, guard);
|
||||
inserted.first->second = updateId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,13 @@
|
|||
|
||||
#include "navigator.hpp"
|
||||
#include "navmeshmanager.hpp"
|
||||
#include "updateguard.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
|
@ -18,10 +22,7 @@ namespace DetourNavigator
|
|||
*/
|
||||
explicit NavigatorImpl(const Settings& settings, std::unique_ptr<NavMeshDb>&& db);
|
||||
|
||||
std::unique_ptr<const DetourNavigator::UpdateGuard> makeUpdateGuard() override
|
||||
{
|
||||
return std::make_unique<const UpdateGuard>(*this);
|
||||
}
|
||||
ScopedUpdateGuard makeUpdateGuard() override { return mNavMeshManager.makeUpdateGuard(); }
|
||||
|
||||
bool addAgent(const AgentBounds& agentBounds) override;
|
||||
|
||||
|
@ -94,23 +95,6 @@ namespace DetourNavigator
|
|||
|
||||
friend class UpdateGuard;
|
||||
};
|
||||
|
||||
class UpdateGuard
|
||||
{
|
||||
public:
|
||||
explicit UpdateGuard(NavigatorImpl& navigator)
|
||||
: mImpl(navigator.mNavMeshManager)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
NavMeshManager::UpdateGuard mImpl;
|
||||
|
||||
friend inline const NavMeshManager::UpdateGuard* getImpl(const UpdateGuard* guard)
|
||||
{
|
||||
return guard == nullptr ? nullptr : &guard->mImpl;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "navigator.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "stats.hpp"
|
||||
#include "updateguard.hpp"
|
||||
|
||||
namespace Loading
|
||||
{
|
||||
|
@ -17,7 +18,7 @@ namespace DetourNavigator
|
|||
public:
|
||||
NavigatorStub() = default;
|
||||
|
||||
std::unique_ptr<const UpdateGuard> makeUpdateGuard() override { return nullptr; }
|
||||
ScopedUpdateGuard makeUpdateGuard() override { return nullptr; }
|
||||
|
||||
bool addAgent(const AgentBounds& /*agentBounds*/) override { return true; }
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#include "navmeshmanager.hpp"
|
||||
#include "debug.hpp"
|
||||
#include "exceptions.hpp"
|
||||
#include "gettilespositions.hpp"
|
||||
#include "makenavmesh.hpp"
|
||||
#include "navmeshcacheitem.hpp"
|
||||
|
@ -8,9 +7,7 @@
|
|||
#include "settingsutils.hpp"
|
||||
#include "waitconditiontype.hpp"
|
||||
|
||||
#include <components/bullethelpers/heightfield.hpp>
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/misc/convert.hpp>
|
||||
|
||||
#include <osg/io_utils>
|
||||
|
||||
|
@ -67,7 +64,7 @@ namespace DetourNavigator
|
|||
{
|
||||
if (worldspace == mWorldspace)
|
||||
return;
|
||||
mRecastMeshManager.setWorldspace(worldspace, getImpl(guard));
|
||||
mRecastMeshManager.setWorldspace(worldspace, guard);
|
||||
for (auto& [agent, cache] : mCache)
|
||||
cache = std::make_shared<GuardedNavMeshCacheItem>(++mGenerationCounter, mSettings);
|
||||
mWorldspace = worldspace;
|
||||
|
@ -77,45 +74,45 @@ namespace DetourNavigator
|
|||
{
|
||||
const TilePosition playerTile = toNavMeshTilePosition(mSettings.mRecast, playerPosition);
|
||||
const TilesPositionsRange range = makeRange(playerTile, mSettings.mMaxTilesNumber);
|
||||
mRecastMeshManager.setRange(range, getImpl(guard));
|
||||
mRecastMeshManager.setRange(range, guard);
|
||||
}
|
||||
|
||||
bool NavMeshManager::addObject(const ObjectId id, const CollisionShape& shape, const btTransform& transform,
|
||||
const AreaType areaType, const UpdateGuard* guard)
|
||||
{
|
||||
return mRecastMeshManager.addObject(id, shape, transform, areaType, getImpl(guard));
|
||||
return mRecastMeshManager.addObject(id, shape, transform, areaType, guard);
|
||||
}
|
||||
|
||||
bool NavMeshManager::updateObject(
|
||||
const ObjectId id, const btTransform& transform, const AreaType areaType, const UpdateGuard* guard)
|
||||
{
|
||||
return mRecastMeshManager.updateObject(id, transform, areaType, getImpl(guard));
|
||||
return mRecastMeshManager.updateObject(id, transform, areaType, guard);
|
||||
}
|
||||
|
||||
void NavMeshManager::removeObject(const ObjectId id, const UpdateGuard* guard)
|
||||
{
|
||||
mRecastMeshManager.removeObject(id, getImpl(guard));
|
||||
mRecastMeshManager.removeObject(id, guard);
|
||||
}
|
||||
|
||||
void NavMeshManager::addWater(const osg::Vec2i& cellPosition, int cellSize, float level, const UpdateGuard* guard)
|
||||
{
|
||||
mRecastMeshManager.addWater(cellPosition, cellSize, level, getImpl(guard));
|
||||
mRecastMeshManager.addWater(cellPosition, cellSize, level, guard);
|
||||
}
|
||||
|
||||
void NavMeshManager::removeWater(const osg::Vec2i& cellPosition, const UpdateGuard* guard)
|
||||
{
|
||||
mRecastMeshManager.removeWater(cellPosition, getImpl(guard));
|
||||
mRecastMeshManager.removeWater(cellPosition, guard);
|
||||
}
|
||||
|
||||
void NavMeshManager::addHeightfield(
|
||||
const osg::Vec2i& cellPosition, int cellSize, const HeightfieldShape& shape, const UpdateGuard* guard)
|
||||
{
|
||||
mRecastMeshManager.addHeightfield(cellPosition, cellSize, shape, getImpl(guard));
|
||||
mRecastMeshManager.addHeightfield(cellPosition, cellSize, shape, guard);
|
||||
}
|
||||
|
||||
void NavMeshManager::removeHeightfield(const osg::Vec2i& cellPosition, const UpdateGuard* guard)
|
||||
{
|
||||
mRecastMeshManager.removeHeightfield(cellPosition, getImpl(guard));
|
||||
mRecastMeshManager.removeHeightfield(cellPosition, guard);
|
||||
}
|
||||
|
||||
void NavMeshManager::addAgent(const AgentBounds& agentBounds)
|
||||
|
@ -169,7 +166,7 @@ namespace DetourNavigator
|
|||
return;
|
||||
mLastRecastMeshManagerRevision = mRecastMeshManager.getRevision();
|
||||
mPlayerTile = playerTile;
|
||||
const auto changedTiles = mRecastMeshManager.takeChangedTiles(getImpl(guard));
|
||||
const auto changedTiles = mRecastMeshManager.takeChangedTiles(guard);
|
||||
const TilesPositionsRange range = mRecastMeshManager.getLimitedObjectsRange();
|
||||
for (const auto& [agentBounds, cached] : mCache)
|
||||
update(agentBounds, playerTile, range, cached, changedTiles);
|
||||
|
|
|
@ -20,25 +20,10 @@ namespace DetourNavigator
|
|||
class NavMeshManager
|
||||
{
|
||||
public:
|
||||
class UpdateGuard
|
||||
{
|
||||
public:
|
||||
explicit UpdateGuard(NavMeshManager& manager)
|
||||
: mImpl(manager.mRecastMeshManager)
|
||||
{
|
||||
}
|
||||
|
||||
friend const TileCachedRecastMeshManager::UpdateGuard* getImpl(const UpdateGuard* guard)
|
||||
{
|
||||
return guard == nullptr ? nullptr : &guard->mImpl;
|
||||
}
|
||||
|
||||
private:
|
||||
const TileCachedRecastMeshManager::UpdateGuard mImpl;
|
||||
};
|
||||
|
||||
explicit NavMeshManager(const Settings& settings, std::unique_ptr<NavMeshDb>&& db);
|
||||
|
||||
ScopedUpdateGuard makeUpdateGuard() { return mRecastMeshManager.makeUpdateGuard(); }
|
||||
|
||||
void setWorldspace(std::string_view worldspace, const UpdateGuard* guard);
|
||||
|
||||
void updateBounds(const osg::Vec3f& playerPosition, const UpdateGuard* guard);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_OBJECTID_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <unordered_map>
|
||||
#include <functional>
|
||||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECAST_H
|
||||
|
||||
#include <Recast.h>
|
||||
#include <RecastAlloc.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTALLOCUTILS_H
|
||||
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_RECASTALLOCUTILS_H
|
||||
|
||||
#include <RecastAlloc.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "recasttempallocator.hpp"
|
||||
|
||||
#include <RecastAlloc.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace DetourNavigator
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#include "recastmesh.hpp"
|
||||
#include "exceptions.hpp"
|
||||
|
||||
#include <Recast.h>
|
||||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
Mesh::Mesh(std::vector<int>&& indices, std::vector<float>&& vertices, std::vector<AreaType>&& areaTypes)
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include <LinearMath/btTransform.h>
|
||||
|
||||
#include <osg/Referenced>
|
||||
#include <osg/ref_ptr>
|
||||
|
||||
#include <functional>
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "recastallocutils.hpp"
|
||||
|
||||
#include <RecastAlloc.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "gettilespositions.hpp"
|
||||
#include "recastmeshbuilder.hpp"
|
||||
#include "settingsutils.hpp"
|
||||
#include "updateguard.hpp"
|
||||
|
||||
#include <components/bullethelpers/aabb.hpp>
|
||||
#include <components/misc/convert.hpp>
|
||||
|
@ -45,7 +46,7 @@ namespace DetourNavigator
|
|||
class MaybeLockGuard
|
||||
{
|
||||
public:
|
||||
explicit MaybeLockGuard(Mutex& mutex, const TileCachedRecastMeshManager::UpdateGuard* guard)
|
||||
explicit MaybeLockGuard(Mutex& mutex, const UpdateGuard* guard)
|
||||
: mImpl(guard == nullptr ? std::optional<std::unique_lock<Mutex>>(mutex) : std::nullopt)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -10,15 +10,24 @@
|
|||
#include "recastmesh.hpp"
|
||||
#include "recastmeshobject.hpp"
|
||||
#include "tileposition.hpp"
|
||||
#include "updateguard.hpp"
|
||||
#include "version.hpp"
|
||||
|
||||
#include <boost/geometry/geometries/box.hpp>
|
||||
#include <boost/geometry/geometries/point.hpp>
|
||||
#include <boost/geometry/index/rtree.hpp>
|
||||
|
||||
#include <LinearMath/btTransform.h>
|
||||
|
||||
#include <osg/Vec2i>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace DetourNavigator
|
||||
|
@ -28,20 +37,14 @@ namespace DetourNavigator
|
|||
class TileCachedRecastMeshManager
|
||||
{
|
||||
public:
|
||||
class UpdateGuard
|
||||
{
|
||||
public:
|
||||
explicit UpdateGuard(TileCachedRecastMeshManager& manager)
|
||||
: mImpl(manager.mMutex)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
const std::lock_guard<std::mutex> mImpl;
|
||||
};
|
||||
|
||||
explicit TileCachedRecastMeshManager(const RecastSettings& settings);
|
||||
|
||||
ScopedUpdateGuard makeUpdateGuard()
|
||||
{
|
||||
mMutex.lock();
|
||||
return ScopedUpdateGuard(&mUpdateGuard);
|
||||
}
|
||||
|
||||
void setRange(const TilesPositionsRange& range, const UpdateGuard* guard);
|
||||
|
||||
TilesPositionsRange getLimitedObjectsRange() const;
|
||||
|
@ -139,6 +142,7 @@ namespace DetourNavigator
|
|||
std::size_t mGeneration = 0;
|
||||
std::size_t mRevision = 0;
|
||||
mutable std::mutex mMutex;
|
||||
UpdateGuard mUpdateGuard{ mMutex };
|
||||
|
||||
inline static IndexPoint makeIndexPoint(const TilePosition& tilePosition);
|
||||
|
||||
|
|
31
components/detournavigator/updateguard.hpp
Normal file
31
components/detournavigator/updateguard.hpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_UPDATEGUARD_H
|
||||
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_UPDATEGUARD_H
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
namespace DetourNavigator
|
||||
{
|
||||
class UpdateGuard
|
||||
{
|
||||
public:
|
||||
explicit UpdateGuard(std::mutex& mutex)
|
||||
: mMutex(mutex)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
std::mutex& mMutex;
|
||||
|
||||
friend struct UnlockUpdateGuard;
|
||||
};
|
||||
|
||||
struct UnlockUpdateGuard
|
||||
{
|
||||
void operator()(UpdateGuard* value) const { value->mMutex.unlock(); }
|
||||
};
|
||||
|
||||
using ScopedUpdateGuard = std::unique_ptr<UpdateGuard, UnlockUpdateGuard>;
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue