Files
ashlar/components/resource/animblendrulesmanager.hpp
Bret Curtis e8f6c25d1a Cache animation data as std::shared_ptr, dropping their osg::Object base
SceneUtil::KeyframeHolder and SceneUtil::AnimBlendRules are pure data — a
map of keyframe controllers and a vector of blend rules. Nothing attaches
them to a scene graph; both classes existed as osg::Object only because
the cache stored them via osg::ref_ptr. With the value-type seam from the
previous MR in place, they can be plain classes cached as
std::shared_ptr<const T>, and the TemplateRef pins in AnimBlendRulesManager
become an aliasing shared_ptr that keeps the cached base and override rules
alive while merged rules are in use.
2026-10-05 17:36:58 +02:00

35 lines
1.1 KiB
C++

#ifndef OPENMW_COMPONENTS_ANIMBLENDRULESMANAGER_H
#define OPENMW_COMPONENTS_ANIMBLENDRULESMANAGER_H
#include <memory>
#include <string>
#include <components/sceneutil/animblendrules.hpp>
#include "resourcemanager.hpp"
namespace Resource
{
/// @brief Managing of keyframe resources
/// @note May be used from any thread.
class AnimBlendRulesManager : public ResourceManager<std::shared_ptr<const SceneUtil::AnimBlendRules>>
{
public:
explicit AnimBlendRulesManager(const VFS::Manager* vfs, double expiryDelay);
~AnimBlendRulesManager() = default;
/// Retrieve a read-only keyframe resource by name (case-insensitive).
/// @note Throws an exception if the resource is not found.
std::shared_ptr<const SceneUtil::AnimBlendRules> getRules(
const VFS::Path::NormalizedView path, const VFS::Path::NormalizedView overridePath);
void reportStats(unsigned int frameNumber, osg::Stats* stats) const override;
private:
std::shared_ptr<const SceneUtil::AnimBlendRules> loadRules(VFS::Path::NormalizedView path);
};
}
#endif