1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 09:23:53 +00:00
openmw/components/detournavigator/cachedrecastmeshmanager.hpp
elsid 5db4898bec
Fix tile bounds scaling
OscillatingRecastMeshObject::update should be called with tile bounds in real
coordinates not in navmesh. But proper scaling was done only in
RecastMeshManager::getMesh and RecastMeshManager::updateObject used tile bounds
in navmesh coordinates.

Add a new function to create tile bounds with proper scaling and pass correct
value into RecastMeshManager constructor through CachedRecastMeshManager
constuctor from TileCachedRecastMeshManager member functions.
2021-11-05 22:48:45 +01:00

52 lines
1.6 KiB
C++

#ifndef OPENMW_COMPONENTS_DETOURNAVIGATOR_CACHEDRECASTMESHMANAGER_H
#define OPENMW_COMPONENTS_DETOURNAVIGATOR_CACHEDRECASTMESHMANAGER_H
#include "recastmeshmanager.hpp"
#include "version.hpp"
#include "heightfieldshape.hpp"
#include <components/misc/guarded.hpp>
#include <atomic>
namespace DetourNavigator
{
class CachedRecastMeshManager
{
public:
explicit CachedRecastMeshManager(const TileBounds& bounds, std::size_t generation);
bool addObject(const ObjectId id, const CollisionShape& shape, const btTransform& transform,
const AreaType areaType);
bool updateObject(const ObjectId id, const btTransform& transform, const AreaType areaType);
std::optional<RemovedRecastMeshObject> removeObject(const ObjectId id);
bool addWater(const osg::Vec2i& cellPosition, const int cellSize, const osg::Vec3f& shift);
std::optional<Cell> removeWater(const osg::Vec2i& cellPosition);
bool addHeightfield(const osg::Vec2i& cellPosition, int cellSize, const osg::Vec3f& shift,
const HeightfieldShape& shape);
std::optional<Cell> removeHeightfield(const osg::Vec2i& cellPosition);
std::shared_ptr<RecastMesh> getMesh();
std::shared_ptr<RecastMesh> getCachedMesh() const;
bool isEmpty() const;
void reportNavMeshChange(const Version& recastMeshVersion, const Version& navMeshVersion);
Version getVersion() const;
private:
RecastMeshManager mImpl;
Misc::ScopeGuarded<std::shared_ptr<RecastMesh>> mCached;
std::atomic_bool mOutdatedCache {true};
};
}
#endif