Explorar el Código

fixed removal of 2d display sometimes not working

Nicolas Cannasse hace 4 años
padre
commit
22c7bfe1cf
Se han modificado 1 ficheros con 9 adiciones y 3 borrados
  1. 9 3
      hrt/prefab/l3d/Instance.hx

+ 9 - 3
hrt/prefab/l3d/Instance.hx

@@ -38,7 +38,7 @@ class Instance extends Object3D {
 		}
 		}
 		else {
 		else {
 			var tile = unknown ? getDefaultTile().center() : findTile(kind.sheet, kind.idx.obj).center();
 			var tile = unknown ? getDefaultTile().center() : findTile(kind.sheet, kind.idx.obj).center();
-			var objFollow = new h2d.ObjectFollower(ctx.local3d, ctx.shared.root2d);
+			var objFollow = new h2d.ObjectFollower(ctx.local3d, ctx.local2d);
 			objFollow.followVisibility = true;
 			objFollow.followVisibility = true;
 			var bmp = new h2d.Bitmap(tile, objFollow);
 			var bmp = new h2d.Bitmap(tile, objFollow);
 			ctx.local2d = objFollow;
 			ctx.local2d = objFollow;
@@ -115,8 +115,14 @@ class Instance extends Object3D {
 		if(!super.removeInstance(ctx))
 		if(!super.removeInstance(ctx))
 			return false;
 			return false;
 		if(ctx.local2d != null ) {
 		if(ctx.local2d != null ) {
-			var pctx = ctx.shared.getContexts(parent)[0];
-			if( pctx != null && pctx.local2d != ctx.local2d ) ctx.local2d.remove();
+			var p = parent;
+			var pctx = null;
+			while( p != null ) {
+				pctx = ctx.shared.getContexts(p)[0];
+				if( pctx != null ) break;
+				p = p.parent;
+			}
+			if( ctx.local2d != (pctx == null ? ctx.shared.root2d : pctx.local2d) ) ctx.local2d.remove();
 		}
 		}
 		return true;
 		return true;
 	}
 	}