Browse Source

fixed recursive unbind() to prevent binding conflicts

Nicolas Cannasse 11 years ago
parent
commit
64a15ec49e
3 changed files with 16 additions and 2 deletions
  1. 8 0
      h3d/anim/Animation.hx
  2. 2 2
      h3d/anim/SimpleBlend.hx
  3. 6 0
      h3d/anim/Transition.hx

+ 8 - 0
h3d/anim/Animation.hx

@@ -67,6 +67,14 @@ class Animation {
 		return f;
 	}
 
+	public function unbind( objectName : String ) {
+		for( o in objects )
+			if( o.objectName == objectName ) {
+				objects.remove(o);
+				return;
+			}
+	}
+
 	/**
 		Register a callback function that will be called once when a frame is reached.
 	**/

+ 2 - 2
h3d/anim/SimpleBlend.hx

@@ -14,10 +14,10 @@ class SimpleBlend extends Transition {
 	function setupInstance() {
 		for( o in anim1.objects.copy() )
 			if( objectsMap.get(o.objectName) )
-				anim1.objects.remove(o);
+				anim1.unbind(o.objectName);
 		for( o in anim2.objects.copy() )
 			if( !objectsMap.get(o.objectName) )
-				anim2.objects.remove(o);
+				anim2.unbind(o.objectName);
 		isInstance = true;
 	}
 

+ 6 - 0
h3d/anim/Transition.hx

@@ -17,6 +17,12 @@ class Transition extends Animation {
 		this.anim2 = anim2;
 	}
 
+	override function unbind( objectName : String ) {
+		super.unbind(objectName);
+		anim1.unbind(objectName);
+		anim2.unbind(objectName);
+	}
+
 	override function setFrame( f : Float ) {
 		super.setFrame(f);
 		anim1.setFrame(frame % anim1.frameCount);