Pārlūkot izejas kodu

moved resPath from LinearAnimation to Animation

Nicolas Cannasse 6 gadi atpakaļ
vecāks
revīzija
0a74ad980c
2 mainītis faili ar 13 papildinājumiem un 16 dzēšanām
  1. 12 0
      h3d/anim/Animation.hx
  2. 1 16
      h3d/anim/LinearAnimation.hx

+ 12 - 0
h3d/anim/Animation.hx

@@ -24,6 +24,7 @@ class Animation implements hxd.impl.Serializable {
 	static inline var EPSILON = 0.000001;
 
 	@:s public var name : String;
+	@:s public var resourcePath : String;
 	@:s public var frameCount(default, null) : Int;
 	@:s public var sampling(default,null) : Float;
 	@:s public var frame(default, null) : Float;
@@ -116,6 +117,7 @@ class Animation implements hxd.impl.Serializable {
 		a.loop = loop;
 		a.pause = pause;
 		a.events = events;
+		a.resourcePath = resourcePath;
 		return a;
 	}
 
@@ -271,6 +273,16 @@ class Animation implements hxd.impl.Serializable {
 		super.unserialize(ctx);
 		if( objects == null ) objects = [];
 	}
+
+	function customSerialize(ctx:hxbit.Serializer) {
+	}
+
+	function customUnserialize(ctx:hxbit.Serializer) {
+		var l = cast(ctx, hxd.fmt.hsd.Serializer).loadAnimation(resourcePath);
+		var objects = [for( a in l.objects ) a.clone()];
+		l.clone(this);
+		this.objects = objects;
+	}
 	#end
 
 }

+ 1 - 16
h3d/anim/LinearAnimation.hx

@@ -24,6 +24,7 @@ class LinearFrame {
 }
 
 class LinearObject extends AnimatedObject {
+	public var hasPosition : Bool = true;
 	public var hasRotation : Bool;
 	public var hasScale : Bool;
 	public var frames : haxe.ds.Vector<LinearFrame>;
@@ -48,7 +49,6 @@ class LinearObject extends AnimatedObject {
 
 class LinearAnimation extends Animation {
 
-	@:s public var resPath : String;
 	var syncFrame : Float;
 
 	public function new(name,frame,sampling) {
@@ -98,8 +98,6 @@ class LinearAnimation extends Animation {
 		if( a == null )
 			a = new LinearAnimation(name, frameCount, sampling);
 		super.clone(a);
-		var la = Std.instance(a, LinearAnimation);
-		la.resPath = resPath;
 		return a;
 	}
 
@@ -288,17 +286,4 @@ class LinearAnimation extends Animation {
 	}
 	#end
 
-
-	#if (hxbit && !macro)
-	function customSerialize(ctx:hxbit.Serializer) {
-	}
-
-	function customUnserialize(ctx:hxbit.Serializer) {
-		var l = cast(ctx, hxd.fmt.hsd.Serializer).loadAnimation(resPath);
-		var objects = [for( a in l.objects ) a.clone()];
-		l.clone(this);
-		this.objects = objects;
-	}
-	#end
-
 }