ソースを参照

DirShadowMap.hx frustum debug with scene position offset.

clementlandrin 1 年間 前
コミット
fcb830f6a2
1 ファイル変更12 行追加6 行削除
  1. 12 6
      h3d/pass/DirShadowMap.hx

+ 12 - 6
h3d/pass/DirShadowMap.hx

@@ -408,24 +408,30 @@ class DirShadowMap extends Shadows {
 
 		// Near Plane
 		var last = nearPlaneCorner[nearPlaneCorner.length - 1];
-		g.moveTo(last.x,last.y,last.z);
+		inline function moveTo(x : Float, y : Float, z : Float) {
+			g.moveTo(x - ctx.scene.x, y - ctx.scene.y, z - ctx.scene.z);
+		}
+		inline function lineTo(x : Float, y : Float, z : Float) {
+			g.lineTo(x - ctx.scene.x, y - ctx.scene.y, z - ctx.scene.z);
+		}
+		moveTo(last.x,last.y,last.z);
 		for( fc in nearPlaneCorner ) {
-			g.lineTo(fc.x, fc.y, fc.z);
+			lineTo(fc.x, fc.y, fc.z);
 		}
 
 		// Far Plane
 		var last = farPlaneCorner[farPlaneCorner.length - 1];
-		g.moveTo(last.x,last.y,last.z);
+		moveTo(last.x,last.y,last.z);
 		for( fc in farPlaneCorner ) {
-			g.lineTo(fc.x, fc.y, fc.z);
+			lineTo(fc.x, fc.y, fc.z);
 		}
 
 		// Connections
 		for( i in 0 ... 4 ) {
 			var np = nearPlaneCorner[i];
 			var fp = farPlaneCorner[i];
-			g.moveTo(np.x, np.y, np.z);
-			g.lineTo(fp.x, fp.y, fp.z);
+			moveTo(np.x, np.y, np.z);
+			lineTo(fp.x, fp.y, fp.z);
 		}
 	}
 }