File: bulletshapemanager.hpp

package info (click to toggle)
openmw 0.49.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,992 kB
  • sloc: cpp: 372,479; xml: 2,149; sh: 1,403; python: 797; makefile: 26
file content (60 lines) | stat: -rw-r--r-- 2,085 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef OPENMW_COMPONENTS_BULLETSHAPEMANAGER_H
#define OPENMW_COMPONENTS_BULLETSHAPEMANAGER_H

#include <osg/ref_ptr>

#include <components/vfs/pathutil.hpp>

#include "bulletshape.hpp"
#include "resourcemanager.hpp"

namespace Resource
{
    class SceneManager;
    class NifFileManager;

    struct BulletShape;
    class BulletShapeInstance;

    class MultiObjectCache;

    /// 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.
    class BulletShapeManager : public ResourceManager
    {
    public:
        BulletShapeManager(
            const VFS::Manager* vfs, SceneManager* sceneMgr, NifFileManager* nifFileManager, double expiryDelay);
        ~BulletShapeManager();

        /// @note May return a null pointer if the object has no shape.
        osg::ref_ptr<const BulletShape> getShape(VFS::Path::NormalizedView name);

        /// 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(VFS::Path::NormalizedView name);

        /// @note May return a null pointer if the object has no shape.
        osg::ref_ptr<BulletShapeInstance> getInstance(VFS::Path::NormalizedView name);

        /// @see ResourceManager::updateCache
        void updateCache(double referenceTime) override;

        void clearCache() override;

        void reportStats(unsigned int frameNumber, osg::Stats* stats) const override;

    private:
        osg::ref_ptr<BulletShapeInstance> createInstance(VFS::Path::NormalizedView name);

        osg::ref_ptr<MultiObjectCache> mInstanceCache;
        SceneManager* mSceneManager;
        NifFileManager* mNifFileManager;
    };

}

#endif