getSphereTriangles method

List<Triangle> getSphereTriangles(
  1. Sphere sphere,
  2. List<Triangle> triangles
)

Implementation

List<Triangle> getSphereTriangles(Sphere sphere, List<Triangle> triangles) {
  for (int i = 0; i < subTrees.length; i++) {
    Octree subTree = subTrees[i];
    if (!sphere.intersectsBox(subTree.box)) continue;
    if (subTree.triangles.isNotEmpty) {
      for (int j = 0; j < subTree.triangles.length; j++) {
        if (!triangles.contains(subTree.triangles[j])) {
          triangles.add(subTree.triangles[j]);
        }
      }
    } else {
      subTree.getSphereTriangles(sphere, triangles);
    }
  }

  return triangles;
}