Explorar el Código

allow absolute shape interactive

Nicolas Cannasse hace 2 años
padre
commit
7cc7ab9f57
Se han modificado 2 ficheros con 11 adiciones y 6 borrados
  1. 5 2
      h3d/scene/Interactive.hx
  2. 6 4
      h3d/scene/Scene.hx

+ 5 - 2
h3d/scene/Interactive.hx

@@ -47,6 +47,10 @@ class Interactive extends Object implements hxd.SceneEvents.Interactive {
 	**/
 	public var showDebug(get, set) : Bool;
 
+	/**
+	 *  Tells if our shape is in absolute space (for example ObjectCollider) or relative to the interactive transform.
+	 */
+	public var isAbsoluteShape : Bool = false;
 
 	var scene : Scene;
 	var mouseDownButton : Int = -1;
@@ -76,8 +80,7 @@ class Interactive extends Object implements hxd.SceneEvents.Interactive {
 		debugObj = shape.makeDebugObj();
 		if( debugObj != null ) {
 			setupDebugMaterial(debugObj);
-
-			debugObj.ignoreParentTransform = true;
+			debugObj.ignoreParentTransform = isAbsoluteShape;
 			this.addChild(debugObj);
 		}
 		return debugObj != null;

+ 6 - 4
h3d/scene/Scene.hx

@@ -137,8 +137,10 @@ class Scene extends Object implements h3d.IDrawable implements hxd.SceneEvents.I
 					p = p.parent;
 				if( p != null ) continue;
 
-				var minv = i.getInvPos();
-				r.transform(minv);
+				if( !i.isAbsoluteShape ) {
+					var minv = i.getInvPos();
+					r.transform(minv);
+				}
 
 				// check for NaN
 				if( r.lx != r.lx ) {
@@ -460,9 +462,9 @@ class Scene extends Object implements h3d.IDrawable implements hxd.SceneEvents.I
 
 	var prevDB : h3d.mat.DepthBuffer;
 	var prevEngine = null;
-	/** 
+	/**
 		Temporarily overrides the output render target. This is useful for picture-in-picture rendering,
-		where the output render target has a different size from the window. 
+		where the output render target has a different size from the window.
 		`tex` must have a matching depthBuffer attached.
 		Call `setOutputTarget()` after `render()` has been called.
 	**/