forked from LeenkxTeam/LNXSDK
Object Occlusion Culling
This commit is contained in:
25
leenkx/Sources/iron/object/FrustumPlane.hx
Normal file
25
leenkx/Sources/iron/object/FrustumPlane.hx
Normal file
@ -0,0 +1,25 @@
|
||||
package iron.object;
|
||||
|
||||
import iron.math.Vec4;
|
||||
|
||||
class FrustumPlane {
|
||||
public var normal = new Vec4(1.0, 0.0, 0.0);
|
||||
public var constant = 0.0;
|
||||
|
||||
public function new() {}
|
||||
|
||||
public function normalize() {
|
||||
var inverseNormalLength = 1.0 / normal.length();
|
||||
normal.mult(inverseNormalLength);
|
||||
constant *= inverseNormalLength;
|
||||
}
|
||||
|
||||
public function distanceToSphere(sphereCenter: Vec4, sphereRadius: Float): Float {
|
||||
return (normal.dot(sphereCenter) + constant) - sphereRadius;
|
||||
}
|
||||
|
||||
public inline function setComponents(x: Float, y: Float, z: Float, w: Float) {
|
||||
normal.set(x, y, z);
|
||||
constant = w;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user