瀏覽代碼

changed Frustum.checkSphere to hasSphere, add hasBounds

ncannasse 9 年之前
父節點
當前提交
1db91be33d
共有 2 個文件被更改,包括 18 次插入2 次删除
  1. 17 1
      h3d/col/Frustum.hx
  2. 1 1
      h3d/pass/LightSystem.hx

+ 17 - 1
h3d/col/Frustum.hx

@@ -25,7 +25,7 @@ class Frustum {
 		pfar.normalize();
 	}
 
-	public function checkSphere( s : Sphere ) {
+	public function hasSphere( s : Sphere ) {
 		var p = s.getCenter();
 		if( pleft.distance(p) < -s.r ) return false;
 		if( pright.distance(p) < -s.r ) return false;
@@ -38,4 +38,20 @@ class Frustum {
 		return true;
 	}
 
+	public function hasBounds( b : Bounds ) @:privateAccess {
+		if( b.testPlane(pleft) < 0 )
+			return false;
+		if( b.testPlane(pright) < 0 )
+			return false;
+		if( b.testPlane(ptop) < 0 )
+			return false;
+		if( b.testPlane(ptop) < 0 )
+			return false;
+		if( b.testPlane(pnear) < 0 )
+			return false;
+		if( b.testPlane(pfar) < 0 )
+			return false;
+		return true;
+	}
+	
 }

+ 1 - 1
h3d/pass/LightSystem.hx

@@ -46,7 +46,7 @@ class LightSystem {
 			s.z = l.absPos._43;
 			s.r = l.cullingDistance;
 
-			if( !frustum.checkSphere(s) ) {
+			if( !frustum.hasSphere(s) ) {
 				if( prev == null )
 					ctx.lights = l.next;
 				else