2015-05-12 01:02:15 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_BULLETSHAPEMANAGER_H
|
|
|
|
#define OPENMW_COMPONENTS_BULLETSHAPEMANAGER_H
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <osg/ref_ptr>
|
|
|
|
|
2015-11-16 22:30:10 +00:00
|
|
|
#include "bulletshape.hpp"
|
2016-02-06 15:57:54 +00:00
|
|
|
#include "resourcemanager.hpp"
|
2016-02-05 22:59:37 +00:00
|
|
|
|
2015-05-12 14:24:53 +00:00
|
|
|
namespace Resource
|
|
|
|
{
|
|
|
|
class SceneManager;
|
2015-12-01 22:04:02 +00:00
|
|
|
class NifFileManager;
|
2015-05-12 01:02:15 +00:00
|
|
|
|
|
|
|
class BulletShape;
|
|
|
|
class BulletShapeInstance;
|
|
|
|
|
2016-02-09 17:48:49 +00:00
|
|
|
class MultiObjectCache;
|
|
|
|
|
2016-02-05 23:15:12 +00:00
|
|
|
/// Handles loading, caching and "instancing" of bullet shapes.
|
|
|
|
/// A shape 'instance' is a clone of another shape, with the goal of setting a different scale on this instance.
|
|
|
|
/// @note May be used from any thread.
|
2016-02-06 15:57:54 +00:00
|
|
|
class BulletShapeManager : public ResourceManager
|
2015-05-12 01:02:15 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-12-01 22:04:02 +00:00
|
|
|
BulletShapeManager(const VFS::Manager* vfs, SceneManager* sceneMgr, NifFileManager* nifFileManager);
|
2015-05-12 01:02:15 +00:00
|
|
|
~BulletShapeManager();
|
|
|
|
|
2016-02-09 17:48:49 +00:00
|
|
|
/// @note May return a null pointer if the object has no shape.
|
2016-02-06 22:30:41 +00:00
|
|
|
osg::ref_ptr<const BulletShape> getShape(const std::string& name);
|
|
|
|
|
2016-02-09 17:48:49 +00:00
|
|
|
/// Create an instance of the given shape and cache it for later use, so that future calls to getInstance() can simply return
|
|
|
|
/// the cached instance instead of having to create a new one.
|
|
|
|
/// @note The returned ref_ptr may be kept by the caller to ensure that the instance stays in cache for as long as needed.
|
|
|
|
osg::ref_ptr<BulletShapeInstance> cacheInstance(const std::string& name);
|
|
|
|
|
|
|
|
/// @note May return a null pointer if the object has no shape.
|
|
|
|
osg::ref_ptr<BulletShapeInstance> getInstance(const std::string& name);
|
|
|
|
|
|
|
|
/// @see ResourceManager::updateCache
|
|
|
|
virtual void updateCache(double referenceTime);
|
2015-05-12 01:02:15 +00:00
|
|
|
|
2017-08-21 22:58:38 +00:00
|
|
|
virtual void clearCache();
|
|
|
|
|
2017-03-07 03:02:06 +00:00
|
|
|
void reportStats(unsigned int frameNumber, osg::Stats *stats) const;
|
2017-02-22 01:18:18 +00:00
|
|
|
|
2015-05-12 01:02:15 +00:00
|
|
|
private:
|
2016-02-09 17:48:49 +00:00
|
|
|
osg::ref_ptr<BulletShapeInstance> createInstance(const std::string& name);
|
|
|
|
|
|
|
|
osg::ref_ptr<MultiObjectCache> mInstanceCache;
|
2015-11-16 23:18:27 +00:00
|
|
|
SceneManager* mSceneManager;
|
2015-12-01 22:04:02 +00:00
|
|
|
NifFileManager* mNifFileManager;
|
2015-05-12 01:02:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|