Reference fixes

This commit is contained in:
Simon Lübeß
2021-09-11 12:57:44 +02:00
parent da24643c64
commit cb51880925
2 changed files with 30 additions and 5 deletions
@@ -66,14 +66,27 @@ namespace GlitchyEngine.Renderer.Animation
class AnimationClip : RefCounted class AnimationClip : RefCounted
{ {
public Skeleton Skeleton ~ _.ReleaseRef(); private Skeleton _skeleton ~ _.ReleaseRef();
public float FramesPerSecond; public float FramesPerSecond;
public JointAnimation[] JointAnimations; public JointAnimation[] JointAnimations;
public bool IsLooping; public bool IsLooping;
public float Duration; 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() public ~this()
{ {
for(var jointAnimation in JointAnimations) for(var jointAnimation in JointAnimations)
@@ -87,8 +100,18 @@ namespace GlitchyEngine.Renderer.Animation
public enum InterpolationMode public enum InterpolationMode
{ {
/**
* No keyframe interpolation.
* The keyframe with the greates timestamp that is smaller than the current time will be used.
*/
Step, Step,
/**
* Linear interpolation between the two keyframes that are closest to the current time.
*/
Linear, Linear,
/**
* Cubic spline interpolation between the two keyframes that are closest to the current time.
*/
CubicSpline CubicSpline
} }
@@ -26,15 +26,17 @@ namespace GlitchyEngine.Renderer.Animation
public class SkeletonPose public class SkeletonPose
{ {
public Skeleton Skeleton ~ _.ReleaseRef(); private Skeleton _skeleton ~ _.ReleaseRef();
public JointPose[] LocalPose ~ delete _; public JointPose[] LocalPose ~ delete _;
public Matrix[] GlobalPose ~ delete _; public Matrix[] GlobalPose ~ delete _;
public Skeleton Skeleton => _skeleton;
public this(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]; LocalPose = new JointPose[jointCount];
GlobalPose = new Matrix[jointCount]; GlobalPose = new Matrix[jointCount];