mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-15 15:19:55 +00:00
0479ebf5ae
When there is only one actor (player) on a scene and it moving to other cell first it will be removed from navigator then added. Remove cause navmesh removing for its half extents. After it is added navmesh for same half extents is created and added. While this all happens there are still jobs for old navmesh are processing. Old navmesh still exists because it is stored by shared pointer. So jobs take tiles from cache and place them into old navmesh. After that other jobs take same tiles from cache (half extents and coordinates are equal) and place them into other navmesh. dtNavMesh changes tile data on add and remove. Adding tile to two dtNavMesh corrupts tile in both nameshes.
74 lines
2.5 KiB
C++
74 lines
2.5 KiB
C++
#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_NAVMESHMANAGER_H
|
|
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_NAVMESHMANAGER_H
|
|
|
|
#include "asyncnavmeshupdater.hpp"
|
|
#include "cachedrecastmeshmanager.hpp"
|
|
#include "offmeshconnectionsmanager.hpp"
|
|
#include "sharednavmesh.hpp"
|
|
|
|
#include <BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h>
|
|
|
|
#include <osg/Vec3f>
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
|
|
class dtNavMesh;
|
|
|
|
namespace DetourNavigator
|
|
{
|
|
class NavMeshManager
|
|
{
|
|
public:
|
|
NavMeshManager(const Settings& settings);
|
|
|
|
bool addObject(const ObjectId id, const btCollisionShape& shape, const btTransform& transform,
|
|
const AreaType areaType);
|
|
|
|
bool updateObject(const ObjectId id, const btCollisionShape& shape, const btTransform& transform,
|
|
const AreaType areaType);
|
|
|
|
bool removeObject(const ObjectId id);
|
|
|
|
void addAgent(const osg::Vec3f& agentHalfExtents);
|
|
|
|
bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const btTransform& transform);
|
|
|
|
bool removeWater(const osg::Vec2i& cellPosition);
|
|
|
|
bool reset(const osg::Vec3f& agentHalfExtents);
|
|
|
|
void addOffMeshConnection(const ObjectId id, const osg::Vec3f& start, const osg::Vec3f& end);
|
|
|
|
void removeOffMeshConnection(const ObjectId id);
|
|
|
|
void update(osg::Vec3f playerPosition, const osg::Vec3f& agentHalfExtents);
|
|
|
|
void wait();
|
|
|
|
SharedNavMeshCacheItem getNavMesh(const osg::Vec3f& agentHalfExtents) const;
|
|
|
|
std::map<osg::Vec3f, SharedNavMeshCacheItem> getNavMeshes() const;
|
|
|
|
private:
|
|
const Settings& mSettings;
|
|
TileCachedRecastMeshManager mRecastMeshManager;
|
|
OffMeshConnectionsManager mOffMeshConnectionsManager;
|
|
AsyncNavMeshUpdater mAsyncNavMeshUpdater;
|
|
std::map<osg::Vec3f, SharedNavMeshCacheItem> mCache;
|
|
std::map<osg::Vec3f, std::map<TilePosition, ChangeType>> mChangedTiles;
|
|
std::size_t mGenerationCounter = 0;
|
|
std::map<osg::Vec3f, TilePosition> mPlayerTile;
|
|
std::map<osg::Vec3f, std::size_t> mLastRecastMeshManagerRevision;
|
|
|
|
void addChangedTiles(const btCollisionShape& shape, const btTransform& transform, const ChangeType changeType);
|
|
|
|
void addChangedTiles(const int cellSize, const btTransform& transform, const ChangeType changeType);
|
|
|
|
void addChangedTile(const TilePosition& tilePosition, const ChangeType changeType);
|
|
|
|
SharedNavMeshCacheItem getCached(const osg::Vec3f& agentHalfExtents) const;
|
|
};
|
|
}
|
|
|
|
#endif
|