Fix #109885: Check if BVH tree is null in correct place #109892
@ -247,9 +247,11 @@ typedef struct BVHTreeFromPointCloud {
|
||||
const float (*coords)[3];
|
||||
} BVHTreeFromPointCloud;
|
||||
|
||||
BVHTree *BKE_bvhtree_from_pointcloud_get(struct BVHTreeFromPointCloud *data,
|
||||
const struct PointCloud *pointcloud,
|
||||
int tree_type);
|
||||
#ifdef __cplusplus
|
||||
[[nodiscard]] BVHTree *BKE_bvhtree_from_pointcloud_get(BVHTreeFromPointCloud *data,
|
||||
const PointCloud *pointcloud,
|
||||
int tree_type);
|
||||
#endif
|
||||
|
||||
void free_bvhtree_from_pointcloud(struct BVHTreeFromPointCloud *data);
|
||||
|
||||
|
@ -1369,9 +1369,9 @@ void free_bvhtree_from_mesh(BVHTreeFromMesh *data)
|
||||
/** \name Point Cloud BVH Building
|
||||
* \{ */
|
||||
|
||||
BVHTree *BKE_bvhtree_from_pointcloud_get(BVHTreeFromPointCloud *data,
|
||||
const PointCloud *pointcloud,
|
||||
const int tree_type)
|
||||
[[nodiscard]] BVHTree *BKE_bvhtree_from_pointcloud_get(BVHTreeFromPointCloud *data,
|
||||
const PointCloud *pointcloud,
|
||||
const int tree_type)
|
||||
{
|
||||
int tot_point = pointcloud->totpoint;
|
||||
BVHTree *tree = bvhtree_new_common(0.0f, tree_type, 6, tot_point, tot_point);
|
||||
|
@ -95,8 +95,8 @@ static bool calculate_pointcloud_proximity(const VArray<float3> &positions,
|
||||
MutableSpan<float3> r_locations)
|
||||
{
|
||||
BVHTreeFromPointCloud bvh_data;
|
||||
BKE_bvhtree_from_pointcloud_get(&bvh_data, &pointcloud, 2);
|
||||
if (bvh_data.tree == nullptr) {
|
||||
const BVHTree *tree = BKE_bvhtree_from_pointcloud_get(&bvh_data, &pointcloud, 2);
|
||||
if (tree == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -72,14 +72,19 @@ static void node_init(bNodeTree * /*tree*/, bNode *node)
|
||||
static void get_closest_pointcloud_points(const PointCloud &pointcloud,
|
||||
const VArray<float3> &positions,
|
||||
const IndexMask &mask,
|
||||
const MutableSpan<int> r_indices,
|
||||
const MutableSpan<float> r_distances_sq)
|
||||
MutableSpan<int> r_indices,
|
||||
MutableSpan<float> r_distances_sq)
|
||||
{
|
||||
BLI_assert(positions.size() >= r_indices.size());
|
||||
BLI_assert(pointcloud.totpoint > 0);
|
||||
|
||||
BVHTreeFromPointCloud tree_data;
|
||||
BKE_bvhtree_from_pointcloud_get(&tree_data, &pointcloud, 2);
|
||||
const BVHTree *tree = BKE_bvhtree_from_pointcloud_get(&tree_data, &pointcloud, 2);
|
||||
if (tree == nullptr) {
|
||||
r_indices.fill(0);
|
||||
r_distances_sq.fill(0.0f);
|
||||
return;
|
||||
}
|
||||
|
||||
mask.foreach_index([&](const int i) {
|
||||
BVHTreeNearest nearest;
|
||||
|
Loading…
Reference in New Issue
Block a user