2
0
Эх сурвалжийг харах

Fix alloc bounds for maskedBounds interactive
Quat : inlined initDirection

Tom Spira 2 жил өмнө
parent
commit
5c74aa0473

+ 1 - 1
h2d/Interactive.hx

@@ -96,7 +96,7 @@ class Interactive extends Object implements hxd.SceneEvents.Interactive {
 	}
 	}
 
 
 	override function draw( ctx : RenderContext ) {
 	override function draw( ctx : RenderContext ) {
-		maskedBounds = ctx.getCurrentRenderZone();
+		maskedBounds = ctx.getCurrentRenderZone(maskedBounds);
 		if( backgroundColor != null ) emitTile(ctx, h2d.Tile.fromColor(backgroundColor, Std.int(width), Std.int(height), (backgroundColor>>>24)/255 ));
 		if( backgroundColor != null ) emitTile(ctx, h2d.Tile.fromColor(backgroundColor, Std.int(width), Std.int(height), (backgroundColor>>>24)/255 ));
 	}
 	}
 
 

+ 5 - 2
h2d/RenderContext.hx

@@ -481,10 +481,13 @@ class RenderContext extends h3d.impl.RenderContext {
 		}
 		}
 	}
 	}
 
 
-	public function getCurrentRenderZone() {
+	public function getCurrentRenderZone( ?bounds : h2d.col.Bounds ) {
 		if( !hasRenderZone )
 		if( !hasRenderZone )
 			return null;
 			return null;
-		return h2d.col.Bounds.fromValues(renderX, renderY, renderW, renderH);
+		if( bounds == null )
+			bounds = new h2d.col.Bounds();
+		bounds.set(renderX, renderY, renderW, renderH);
+		return bounds;
 	}
 	}
 
 
 	/**
 	/**

+ 4 - 1
h3d/Quat.hx

@@ -77,7 +77,10 @@ class Quat {
 	public function initDirection( dir : Vector, ?up : Vector ) {
 	public function initDirection( dir : Vector, ?up : Vector ) {
 		// inlined version of initRotationMatrix(Matrix.lookAtX(dir))
 		// inlined version of initRotationMatrix(Matrix.lookAtX(dir))
 		var ax = dir.clone().normalized();
 		var ax = dir.clone().normalized();
-		var ay = up == null ? new Vector(-ax.y, ax.x, 0).normalized() : up.cross(ax).normalized();
+		var ay = new Vector(-ax.y, ax.x, 0);
+		if( up != null ) 
+			ay.load(up.cross(ax));
+		ay.normalize();
 		if( ay.lengthSq() < Math.EPSILON ) {
 		if( ay.lengthSq() < Math.EPSILON ) {
 			ay.x = ax.y;
 			ay.x = ax.y;
 			ay.y = ax.z;
 			ay.y = ax.z;