updateTree method
void
updateTree()
Implementation
void updateTree() {
final tree = this.tree;
tree.reset();
tree.aabb.copy(aabb);
final scale = this.scale; // The local mesh AABB is scaled, but the octree AABB should be unscaled
tree.aabb.lowerBound.x *= 1 / scale.x;
tree.aabb.lowerBound.y *= 1 / scale.y;
tree.aabb.lowerBound.z *= 1 / scale.z;
tree.aabb.upperBound.x *= 1 / scale.x;
tree.aabb.upperBound.y *= 1 / scale.y;
tree.aabb.upperBound.z *= 1 / scale.z;
// Insert all triangles
final triangleAABB = AABB();
final a = Vec3();
final b = Vec3();
final c = Vec3();
final points = [a, b, c];
for (int i = 0; i < indices.length / 3; i++) {
// Get unscaled triangle verts
int i3 = i * 3;
_getUnscaledVertex(indices[i3], a);
_getUnscaledVertex(indices[i3 + 1], b);
_getUnscaledVertex(indices[i3 + 2], c);
triangleAABB.setFromPoints(points);
tree.insert(triangleAABB, i);
}
tree.removeEmptyNodes();
}