Bläddra i källkod

Adding inFrustum public method to h3d/scene/pbr/Light

clementlandrin 3 månader sedan
förälder
incheckning
604516f0b1
4 ändrade filer med 18 tillägg och 3 borttagningar
  1. 5 1
      h3d/scene/pbr/CapsuleLight.hx
  2. 3 0
      h3d/scene/pbr/Light.hx
  3. 5 1
      h3d/scene/pbr/PointLight.hx
  4. 5 1
      h3d/scene/pbr/SpotLight.hx

+ 5 - 1
h3d/scene/pbr/CapsuleLight.hx

@@ -91,10 +91,14 @@ class CapsuleLight extends Light {
 		// TODO optimize culling
 		s.r = range + length;
 
-		if( !ctx.camera.frustum.hasSphere(s) )
+		if( !inFrustum(ctx.camera.frustum) )
 			return;
 
 		super.emit(ctx);
 		ctx.emitPass(ctx.pbrLightPass, this);
 	}
+
+	override function inFrustum(frustum : h3d.col.Frustum) {
+		return frustum.hasSphere(s);
+	}
 }

+ 3 - 0
h3d/scene/pbr/Light.hx

@@ -41,4 +41,7 @@ class Light extends h3d.scene.Light {
 		return _color = v;
 	}
 
+	public function inFrustum(frustum : h3d.col.Frustum) {
+		return true;
+	}
 }

+ 5 - 1
h3d/scene/pbr/PointLight.hx

@@ -74,10 +74,14 @@ class PointLight extends Light {
 		s.z = absPos._43;
 		s.r = range;
 
-		if( !ctx.camera.frustum.hasSphere(s) )
+		if( !inFrustum(ctx.camera.frustum) )
 			return;
 
 		super.emit(ctx);
 		ctx.emitPass(ctx.pbrLightPass, this);
 	}
+
+	override function inFrustum(frustum : h3d.col.Frustum) {
+		return frustum.hasSphere(s);
+	}
 }

+ 5 - 1
h3d/scene/pbr/SpotLight.hx

@@ -143,10 +143,14 @@ class SpotLight extends Light {
 		s.z = absPos.tz + d.z;
 		s.r = range / 2.0;
 
-		if( !ctx.camera.frustum.hasSphere(s) )
+		if( !inFrustum(ctx.camera.frustum) )
 			return;
 
 		super.emit(ctx);
 		ctx.emitPass(ctx.pbrLightPass, this);
 	}
+
+	override function inFrustum(frustum : h3d.col.Frustum) {
+		return frustum.hasSphere(s);
+	}
 }