blender-v3.6-release backports #110011

Merged
Philipp Oeser merged 23 commits from lichtwerk/blender:blender-v3.6-release into blender-v3.6-release 2023-07-12 15:46:03 +02:00
4 changed files with 18 additions and 11 deletions
Showing only changes of commit 696b1804dd - Show all commits

View File

@ -248,9 +248,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);

View File

@ -1350,9 +1350,9 @@ void free_bvhtree_from_mesh(struct 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_commom(0.0f, tree_type, 6, tot_point, tot_point);

View File

@ -96,8 +96,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;
}

View File

@ -70,14 +70,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;
}
for (const int i : mask) {
BVHTreeNearest nearest;