26 lines
601 B
Haxe
26 lines
601 B
Haxe
|
|
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;
|
||
|
|
}
|
||
|
|
}
|