Properly computes the normal when placing bounding boxes in point clouds.
Not the most elegant solution, but it works decently well and fast. Ideally the same acceleration data structure would be used for finding nearest neighbors in the point cloud as for ray tracing, but it didn't look like it would have been quite a bit more work to extend nanort to do nearest neighbor searches.
In this case, a KDTree is created for fast nearest neighbor lookups. To estimate the normal, we find N closest points, fit a plane to the points and get the normal.
Properly computes the normal when placing bounding boxes in point clouds.
Not the most elegant solution, but it works decently well and fast. Ideally the same acceleration data structure would be used for finding nearest neighbors in the point cloud as for ray tracing, but it didn't look like it would have been quite a bit more work to extend nanort to do nearest neighbor searches.
In this case, a KDTree is created for fast nearest neighbor lookups. To estimate the normal, we find N closest points, fit a plane to the points and get the normal.