2015-05-12 03:02:15 +02:00
|
|
|
#ifndef OPENMW_COMPONENTS_BULLETSHAPEMANAGER_H
|
|
|
|
#define OPENMW_COMPONENTS_BULLETSHAPEMANAGER_H
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <osg/ref_ptr>
|
|
|
|
|
2015-11-16 23:30:10 +01:00
|
|
|
#include "bulletshape.hpp"
|
2016-02-06 16:57:54 +01:00
|
|
|
#include "resourcemanager.hpp"
|
2016-02-05 23:59:37 +01:00
|
|
|
|
2015-05-12 16:24:53 +02:00
|
|
|
namespace Resource
|
|
|
|
{
|
|
|
|
class SceneManager;
|
2015-12-01 23:04:02 +01:00
|
|
|
class NifFileManager;
|
2015-05-12 03:02:15 +02:00
|
|
|
|
|
|
|
class BulletShape;
|
|
|
|
class BulletShapeInstance;
|
|
|
|
|
2016-02-09 18:48:49 +01:00
|
|
|
class MultiObjectCache;
|
|
|
|
|
2016-02-06 00:15:12 +01: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 16:57:54 +01:00
|
|
|
class BulletShapeManager : public ResourceManager
|
2015-05-12 03:02:15 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-12-01 23:04:02 +01:00
|
|
|
BulletShapeManager(const VFS::Manager* vfs, SceneManager* sceneMgr, NifFileManager* nifFileManager);
|
2015-05-12 03:02:15 +02:00
|
|
|
~BulletShapeManager();
|
|
|
|
|
2016-02-09 18:48:49 +01:00
|
|
|
/// @note May return a null pointer if the object has no shape.
|
2016-02-06 23:30:41 +01:00
|
|
|
osg::ref_ptr<const BulletShape> getShape(const std::string& name);
|
|
|
|
|
2016-02-09 18:48:49 +01: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
|
2020-10-16 22:18:54 +04:00
|
|
|
void updateCache(double referenceTime) override;
|
2015-05-12 03:02:15 +02:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void clearCache() override;
|
2017-08-21 18:58:38 -04:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void reportStats(unsigned int frameNumber, osg::Stats *stats) const override;
|
2017-02-22 02:18:18 +01:00
|
|
|
|
2015-05-12 03:02:15 +02:00
|
|
|
private:
|
2016-02-09 18:48:49 +01:00
|
|
|
osg::ref_ptr<BulletShapeInstance> createInstance(const std::string& name);
|
|
|
|
|
|
|
|
osg::ref_ptr<MultiObjectCache> mInstanceCache;
|
2015-11-17 00:18:27 +01:00
|
|
|
SceneManager* mSceneManager;
|
2015-12-01 23:04:02 +01:00
|
|
|
NifFileManager* mNifFileManager;
|
2015-05-12 03:02:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|