From cb518809255ca55ee42b1f9ff0956db0f1e5417b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20L=C3=BCbe=C3=9F?= Date: Sat, 11 Sep 2021 12:57:44 +0200 Subject: [PATCH] Reference fixes --- .../src/Renderer/Animation/AnimationClip.bf | 27 +++++++++++++++++-- .../src/Renderer/Animation/Skeleton.bf | 8 +++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/GlitchyEngine/src/Renderer/Animation/AnimationClip.bf b/GlitchyEngine/src/Renderer/Animation/AnimationClip.bf index 7d95fc1..c918190 100644 --- a/GlitchyEngine/src/Renderer/Animation/AnimationClip.bf +++ b/GlitchyEngine/src/Renderer/Animation/AnimationClip.bf @@ -66,14 +66,27 @@ namespace GlitchyEngine.Renderer.Animation class AnimationClip : RefCounted { - public Skeleton Skeleton ~ _.ReleaseRef(); + private Skeleton _skeleton ~ _.ReleaseRef(); public float FramesPerSecond; public JointAnimation[] JointAnimations; public bool IsLooping; public float Duration; - // TODO: check + public Skeleton Skeleton + { + get => _skeleton; + set + { + if(_skeleton == value) + return; + _skeleton?.ReleaseRef(); + _skeleton = value; + _skeleton?.AddRef(); + } + } + + // TODO: check public ~this() { for(var jointAnimation in JointAnimations) @@ -87,8 +100,18 @@ namespace GlitchyEngine.Renderer.Animation public enum InterpolationMode { + /** + * No keyframe interpolation. + * The keyframe with the greates timestamp that is smaller than the current time will be used. + */ Step, + /** + * Linear interpolation between the two keyframes that are closest to the current time. + */ Linear, + /** + * Cubic spline interpolation between the two keyframes that are closest to the current time. + */ CubicSpline } diff --git a/GlitchyEngine/src/Renderer/Animation/Skeleton.bf b/GlitchyEngine/src/Renderer/Animation/Skeleton.bf index 7446b25..10128bf 100644 --- a/GlitchyEngine/src/Renderer/Animation/Skeleton.bf +++ b/GlitchyEngine/src/Renderer/Animation/Skeleton.bf @@ -26,15 +26,17 @@ namespace GlitchyEngine.Renderer.Animation public class SkeletonPose { - public Skeleton Skeleton ~ _.ReleaseRef(); + private Skeleton _skeleton ~ _.ReleaseRef(); public JointPose[] LocalPose ~ delete _; public Matrix[] GlobalPose ~ delete _; + public Skeleton Skeleton => _skeleton; + public this(Skeleton skeleton) { - Skeleton = skeleton; + _skeleton = skeleton..AddRef(); - int jointCount = Skeleton.Joints.Count; + int jointCount = _skeleton.Joints.Count; LocalPose = new JointPose[jointCount]; GlobalPose = new Matrix[jointCount];