فهرست منبع

Minor checks and cleanup on scene events handling

trethaller 6 سال پیش
والد
کامیت
0616c584bf
2فایلهای تغییر یافته به همراه10 افزوده شده و 7 حذف شده
  1. 8 4
      h3d/scene/Scene.hx
  2. 2 3
      hxd/SceneEvents.hx

+ 8 - 4
h3d/scene/Scene.hx

@@ -219,8 +219,9 @@ class Scene extends Object implements h3d.IDrawable implements hxd.SceneEvents.I
 				continue;
 				continue;
 			}
 			}
 
 
-			if( !event.propagate )
-				hitInteractives = [];
+			if( !event.propagate ) {
+				while( hitInteractives.length > 0 ) hitInteractives.pop();
+			}
 
 
 			return i;
 			return i;
 		}
 		}
@@ -252,13 +253,16 @@ class Scene extends Object implements h3d.IDrawable implements hxd.SceneEvents.I
 
 
 	@:allow(h3d)
 	@:allow(h3d)
 	function addEventTarget(i:Interactive) {
 	function addEventTarget(i:Interactive) {
+		if( interactives.indexOf(i) >= 0 ) throw "assert";
 		interactives.push(i);
 		interactives.push(i);
 	}
 	}
 
 
 	@:allow(h3d)
 	@:allow(h3d)
 	function removeEventTarget(i:Interactive) {
 	function removeEventTarget(i:Interactive) {
-		if( interactives.remove(i) && events != null )
-			@:privateAccess events.onRemove(i);
+		if( interactives.remove(i) ) {
+			if( events != null ) @:privateAccess events.onRemove(i);
+			hitInteractives.remove(i);
+		}
 	}
 	}
 
 
 	/**
 	/**

+ 2 - 3
hxd/SceneEvents.hx

@@ -188,20 +188,19 @@ class SceneEvents {
 							event.propagate = oldPropagate;
 							event.propagate = oldPropagate;
 							event.cancel = false;
 							event.cancel = false;
 						} else {
 						} else {
-							var o = overList[idx];
 							if ( idx < overIndex ) {
 							if ( idx < overIndex ) {
 								do {
 								do {
 									overList[idx] = overList[idx + 1];
 									overList[idx] = overList[idx + 1];
 									idx++;
 									idx++;
 								} while ( idx < overIndex );
 								} while ( idx < overIndex );
-								overList[overIndex] = o;
+								overList[overIndex] = i;
 								updateCursor = true;
 								updateCursor = true;
 							} else if ( idx > overIndex ) {
 							} else if ( idx > overIndex ) {
 								do {
 								do {
 									overList[idx] = overList[idx - 1];
 									overList[idx] = overList[idx - 1];
 									idx--;
 									idx--;
 								} while ( idx > overIndex );
 								} while ( idx > overIndex );
-								overList[overIndex] = o;
+								overList[overIndex] = i;
 								updateCursor = true;
 								updateCursor = true;
 							}
 							}
 							fillOver = i.propagateEvents;
 							fillOver = i.propagateEvents;