getRayTriangles method
List<Triangle>
getRayTriangles(
- Ray ray,
- List<Triangle> triangles
)
Implementation
List<Triangle> getRayTriangles(Ray ray, List<Triangle> triangles) {
for (int i = 0; i < subTrees.length; i++) {
Octree subTree = subTrees[i];
if (!ray.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.getRayTriangles(ray, triangles);
}
}
return triangles;
}