File tree Expand file tree Collapse file tree 1 file changed +19
-6
lines changed
src/geometry/accelerators Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,23 @@ class SpatialSubdivisionTree final
122122 }
123123 }
124124
125+ template <typename ObjectIntersect>
126+ std::invoke_result_t <ObjectIntersect, const std::vector<int >&> find_object_intersection (
127+ const numerical::Ray<N, T>& ray,
128+ const ObjectIntersect& object_intersect,
129+ const Box& box)
130+ {
131+ if (!box.object_indices .empty ())
132+ {
133+ const auto info = object_intersect (box.object_indices );
134+ if (info && box.parallelotope .inside (ray.point (std::get<0 >(*info))))
135+ {
136+ return info;
137+ }
138+ }
139+ return std::nullopt ;
140+ }
141+
125142public:
126143 class Objects
127144 {
@@ -177,13 +194,9 @@ class SpatialSubdivisionTree final
177194
178195 while (true )
179196 {
180- if (!box-> object_indices . empty ( ))
197+ if (const auto intersection = find_object_intersection (ray, object_intersect, *box ))
181198 {
182- const auto info = object_intersect (box->object_indices );
183- if (info && box->parallelotope .inside (ray.point (std::get<0 >(*info))))
184- {
185- return info;
186- }
199+ return intersection;
187200 }
188201
189202 const T next = box->parallelotope .intersect_farthest (local_ray).value_or (0 );
You can’t perform that action at this time.
0 commit comments