satForAxes<T extends num> method
Implementation
bool satForAxes<T extends num>(
List<T> axes, Vector3 v0, Vector3 v1, Vector3 v2, Vector3 extents) {
for (var i = 0, j = axes.length - 3; i <= j; i += 3) {
_testAxis.fromArray(axes, i);
// project the aabb onto the seperating axis
var r = extents.x * Math.abs(_testAxis.x) +
extents.y * Math.abs(_testAxis.y) +
extents.z * Math.abs(_testAxis.z);
// project all 3 vertices of the triangle onto the seperating axis
var p0 = v0.dot(_testAxis);
var p1 = v1.dot(_testAxis);
var p2 = v2.dot(_testAxis);
// actual test, basically see if either of the most extreme of the triangle points intersects r
if (Math.max(-Math.max3(p0, p1, p2), Math.min3(p0, p1, p2)) > r) {
// points of the projected triangle are outside the projected half-length of the aabb
// the axis is seperating and we can exit
return false;
}
}
return true;
}