Files
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

46 lines
1.2 KiB
C++

#ifndef OPENMW_COMPONENTS_SCENEUTIL_ANIMBLENDRULES_HPP
#define OPENMW_COMPONENTS_SCENEUTIL_ANIMBLENDRULES_HPP
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include <components/vfs/manager.hpp>
namespace SceneUtil
{
class AnimBlendRules
{
public:
struct BlendRule
{
std::string mFromGroup;
std::string mFromKey;
std::string mToGroup;
std::string mToKey;
float mDuration;
std::string mEasing;
};
AnimBlendRules() = default;
explicit AnimBlendRules(std::vector<BlendRule> rules);
void addOverrideRules(const AnimBlendRules& overrideRules);
std::optional<BlendRule> findBlendingRule(
std::string fromGroup, std::string fromKey, std::string toGroup, std::string toKey) const;
const std::vector<BlendRule>& getRules() const { return mRules; }
static std::shared_ptr<AnimBlendRules> fromFile(const VFS::Manager* vfs, VFS::Path::NormalizedView yamlpath);
private:
std::vector<BlendRule> mRules;
inline bool fitsRuleString(const std::string_view str, const std::string_view ruleStr) const;
};
}
#endif