10 Commits
Author SHA1 Message Date
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
Bret Curtis d69b861fcb Restore TemplateRef as a nameable marker for scene dumps
Deleting the wrapper missed that it had a second job: being a type serialize.cpp could ignore by name, which a bare osg::Object parked in a user data container cannot be singled out for. Without it a scene dump hoists the entire template subtree into the user-data block and demotes the node's real children to bare UniqueID back-references, and no blunt filter can fix that because the same containers carry shaderPrefix, recordIndex and fileHash value objects that the dump should keep. TemplateMultiRef stays gone, the eight call sites still share one addTemplateRef helper that ignores a null template, and holding a ref_ptr<const osg::Object> means no call site needs a const_cast any more.
2026-09-20 12:18:52 +02:00
Bret Curtis 97fdafb0f9 Move addTemplateRef into clone.hpp and null-guard it
The helper lived in its own templateref.hpp, which no longer declared any TemplateRef type, so it now sits next to SceneUtil::CopyOp in clone.hpp where the shallow-copy safety contract it exists to serve is already documented; the file and its CMake entry are gone and the five call sites include clone.hpp instead. The helper also skips a null template rather than parking a null ref_ptr in the user data container, which AnimBlendRulesManager::getRules can hit today because it adds the override rules unconditionally while only dereferencing them under a null check.
2026-09-19 15:14:50 +02:00
Bret Curtis bad9b26804 Add SceneUtil::keepAlive helper for user-data lifetime pinning
Replace six scattered const_cast+addUserObject calls with one named helper
so the intent (pin a dependency's lifetime to owner's) is obvious and the
const_cast lives in exactly one commented place.

Rename keepAlive helper to addTemplateRef

Match the domain vocabulary used by the wrappers this replaces: the object
being pinned is the template, the owner is the shallow-cloned derivative.
Signature becomes addTemplateRef(osg::Object& derived, const osg::Object* tmpl).
2026-09-18 18:50:02 +02:00
Bret Curtis 586a9dafc3 Drop TemplateRef/TemplateMultiRef wrappers
Both were osg::Object subclasses whose only job was to hold a ref_ptr to another Object so it could be parked in a UserDataContainer. Since UserDataContainer already keeps a ref to any object handed to it, the wrapper is dead weight; add the referenced object directly with addUserObject instead. Nothing reads the wrappers back (no dynamic_cast hits on either type), so pure keep-alive semantics are preserved and no visitor logic changes; serializer ignore-list entries for the two class names are dropped alongside.
2026-09-18 18:50:02 +02:00
Bret Curtis 4addabaf95 Let the resource cache be told what it stores, and free its values from OSG
GenericObjectCache stored osg::ref_ptr<osg::Object>, so everything cached had to
derive from osg::Object whether that meant anything or not: NifFileHolder and
BgsmFileHolder existed for no other reason, Resource::BulletShape and
ESMTerrain::LandObject carried META_Object and a CopyOp constructor nothing ever
called, and every getter paid a static_cast on the way out. The cache and
MultiObjectCache now take their value type as a template parameter, ask "is
anything else holding this?" through a useCount overload rather than a base class
method, and constrain accept and releaseGLObjects so a value type with neither is
not an error. Both holders are deleted; BulletShape, BulletShapeInstance and
LandObject become plain classes held by std::shared_ptr across physics,
pathfinding, navmeshtool and terrain storage; MWPhysics::HeightField's
type-erased osg::Object keep-alive becomes the LandObject it was always holding;
every remaining manager names the type it actually caches through the
NodeResourceManager alias, which removes eight static_casts and stops
clang-format wrapping the declarations. The preloader needs two keep-alive sets
for now, because the render-owned entries are still osg::Object; they merge once
those move behind the render backend.
2026-09-18 16:10:18 +02:00
Sam Hellawell 00a7d0281f Cleanup, refactor, rename AnimBlendControllerBase -> AnimBlendController 2024-07-19 00:04:16 +01:00
Sam Hellawell 13e1df3bf0 Grammar cleanup, code cleanup, reduce logging, revert mRotation change 2024-07-19 00:04:16 +01:00
Sam Hellawell 28c8e6b1fe Cleanup loadRules method, smooth animation transitions game.rst docuemntation 2024-07-19 00:04:16 +01:00
Max YariandSam Hellawell 55ffb6d7d2 Animation blending implementation for NIF and osgAnimation through YAML files
Signed-off-by: Sam Hellawell <sshellawell@gmail.com>
2024-07-19 00:04:15 +01:00