Fixed various memory leaks + ModelLoader cleanup

This commit is contained in:
Simon Lübeß
2021-10-14 20:47:25 +02:00
parent cd82a99450
commit 84df8c111b
5 changed files with 57 additions and 229 deletions
@@ -68,8 +68,7 @@ namespace GlitchyEngine.Renderer.Animation
class AnimationClip : RefCounter
{
private Skeleton _skeleton ~ _.ReleaseRef();
//public float FramesPerSecond;
public JointAnimation[] JointAnimations;
public JointAnimation[] JointAnimations ~ delete _;
public bool IsLooping;
public float Duration;
@@ -78,7 +77,7 @@ namespace GlitchyEngine.Renderer.Animation
[AllowAppend]
public this(Skeleton skeleton)
{
var jointAnimations = append JointAnimation[skeleton.Joints.Count];
var jointAnimations = new JointAnimation[skeleton.Joints.Count];
Log.EngineLogger.AssertDebug(skeleton != null);
@@ -91,7 +90,8 @@ namespace GlitchyEngine.Renderer.Animation
{
for(var jointAnimation in JointAnimations)
{
jointAnimation.Dispose();
//jointAnimation.Dispose();
delete jointAnimation;
}
}
}
@@ -186,11 +186,11 @@ namespace GlitchyEngine.Renderer.Animation
}
}
struct JointAnimation : IDisposable
class JointAnimation// : IDisposable
{
public JointAnimationChannel<Vector3> TranslationChannel;
public JointAnimationChannel<Quaternion> RotationChannel;
public JointAnimationChannel<Vector3> ScaleChannel;
public JointAnimationChannel<Vector3> TranslationChannel ~ delete _;
public JointAnimationChannel<Quaternion> RotationChannel ~ delete _;
public JointAnimationChannel<Vector3> ScaleChannel ~ delete _;
public float Duration
{
@@ -200,14 +200,14 @@ namespace GlitchyEngine.Renderer.Animation
TranslationChannel?.Duration ?? 0, RotationChannel?.Duration ?? 0), ScaleChannel?.Duration ?? 0);
}
}
/*
public void Dispose()
{
delete TranslationChannel;
delete RotationChannel;
delete ScaleChannel;
}
*/
public JointPose GetCurrentPose(float timeStamp)
{
JointPose result;
+24 -2
View File
@@ -1,7 +1,29 @@
using System;
using GlitchyEngine.World;
namespace GlitchyEngine.Renderer
{
public struct MeshComponent
public struct MeshComponent : IDisposableComponent
{
public GeometryBinding Mesh;
private GeometryBinding _mesh;
public GeometryBinding Mesh
{
[Inline]
get => _mesh;
set mut
{
if(_mesh == value)
return;
SetReference!(_mesh, value);
}
}
public static void DisposeComponent(void* component)
{
Self* self = (Self*)component;
ReleaseRefAndNullify!(self._mesh);
}
}
}