getRayTriangles method
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;
}