SceneUtil::WorkQueue is a thread pool with no scene graph in it, so neither it nor WorkItem needs an OSG base class to be reference counted; both now use std::shared_ptr and workqueue.hpp, workqueue.cpp and generatenavmeshtile.hpp end up with no reference to osg at all. Because osg::ref_ptr can re-adopt a raw pointer and std::shared_ptr cannot without minting a second control block, the places that passed the queue around as WorkQueue* now pass const std::shared_ptr<WorkQueue>& instead, which is RenderingManager::getWorkQueue and the World, WindowManager, MapWindow and GlobalMap constructors. The non-owning WorkQueue& parameters in UnrefQueue, WorkThread and navmeshtool are unchanged, and WorkItem gains the virtual destructor it used to inherit.
85 lines
2.0 KiB
C++
85 lines
2.0 KiB
C++
#ifndef OPENMW_MWRENDER_NAVMESH_H
|
|
#define OPENMW_MWRENDER_NAVMESH_H
|
|
|
|
#include <components/detournavigator/tileposition.hpp>
|
|
#include <components/detournavigator/version.hpp>
|
|
#include <components/misc/guarded.hpp>
|
|
#include <components/settings/navmeshrendermode.hpp>
|
|
|
|
#include <osg/ref_ptr>
|
|
|
|
#include <cstddef>
|
|
#include <map>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
class dtNavMesh;
|
|
|
|
namespace osg
|
|
{
|
|
class Group;
|
|
class Geometry;
|
|
class StateSet;
|
|
}
|
|
|
|
namespace DetourNavigator
|
|
{
|
|
class NavMeshCacheItem;
|
|
struct Settings;
|
|
}
|
|
|
|
namespace SceneUtil
|
|
{
|
|
class WorkQueue;
|
|
}
|
|
|
|
namespace MWRender
|
|
{
|
|
class NavMesh
|
|
{
|
|
public:
|
|
explicit NavMesh(const osg::ref_ptr<osg::Group>& root, const std::shared_ptr<SceneUtil::WorkQueue>& workQueue,
|
|
bool enabled, Settings::NavMeshRenderMode mode);
|
|
~NavMesh();
|
|
|
|
bool toggle();
|
|
|
|
void update(const std::shared_ptr<Misc::ScopeGuarded<DetourNavigator::NavMeshCacheItem>>& navMesh,
|
|
std::size_t id, const DetourNavigator::Settings& settings);
|
|
|
|
void reset();
|
|
|
|
void enable();
|
|
|
|
void disable();
|
|
|
|
bool isEnabled() const { return mEnabled; }
|
|
|
|
void setMode(Settings::NavMeshRenderMode value);
|
|
|
|
private:
|
|
struct Tile
|
|
{
|
|
DetourNavigator::Version mVersion;
|
|
osg::ref_ptr<osg::Group> mGroup;
|
|
};
|
|
|
|
struct LessByTilePosition;
|
|
struct CreateNavMeshTileGroups;
|
|
struct DeallocateCreateNavMeshTileGroups;
|
|
|
|
osg::ref_ptr<osg::Group> mRootNode;
|
|
std::shared_ptr<SceneUtil::WorkQueue> mWorkQueue;
|
|
osg::ref_ptr<osg::StateSet> mGroupStateSet;
|
|
osg::ref_ptr<osg::StateSet> mDebugDrawStateSet;
|
|
bool mEnabled;
|
|
Settings::NavMeshRenderMode mMode;
|
|
std::size_t mId;
|
|
DetourNavigator::Version mVersion;
|
|
std::map<DetourNavigator::TilePosition, Tile> mTiles;
|
|
std::vector<std::shared_ptr<CreateNavMeshTileGroups>> mWorkItems;
|
|
};
|
|
}
|
|
|
|
#endif
|