[Bf-blender-cvs] [b15b49ffb90] refactor-mesh-position-generic: Merge branch 'master' into refactor-mesh-position-generic
Hans Goudey
noreply at git.blender.org
Thu Nov 17 06:20:03 CET 2022
Commit: b15b49ffb905285ce2db1e1894b36cdb1463e802
Author: Hans Goudey
Date: Wed Nov 16 22:36:06 2022 -0600
Branches: refactor-mesh-position-generic
https://developer.blender.org/rBb15b49ffb905285ce2db1e1894b36cdb1463e802
Merge branch 'master' into refactor-mesh-position-generic
===================================================================
===================================================================
diff --cc source/blender/blenkernel/BKE_bvhutils.h
index bf4d99a9fac,fdc8f9c270f..64d53613538
--- a/source/blender/blenkernel/BKE_bvhutils.h
+++ b/source/blender/blenkernel/BKE_bvhutils.h
@@@ -120,9 -123,9 +123,9 @@@ BVHTree *bvhtree_from_editmesh_verts_ex
* (else will be computed from mask).
*/
BVHTree *bvhtree_from_mesh_verts_ex(struct BVHTreeFromMesh *data,
- const struct MVert *vert,
+ const float (*positions)[3],
int verts_num,
- const BLI_bitmap *verts_mask,
+ const blender::BitVector<> &verts_mask,
int verts_num_active,
float epsilon,
int tree_type,
@@@ -151,10 -154,10 +154,10 @@@ BVHTree *bvhtree_from_editmesh_edges_ex
* (else will be computed from mask).
*/
BVHTree *bvhtree_from_mesh_edges_ex(struct BVHTreeFromMesh *data,
- const struct MVert *vert,
+ const float (*positions)[3],
const struct MEdge *edge,
int edges_num,
- const BLI_bitmap *edges_mask,
+ const blender::BitVector<> &edges_mask,
int edges_num_active,
float epsilon,
int tree_type,
diff --cc source/blender/blenkernel/BKE_mesh.h
index ebc3c31c08b,1eadc3a39b0..9e34868e4f3
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@@ -631,8 -599,10 +600,10 @@@ void BKE_lnor_space_custom_normal_to_da
* Compute split normals, i.e. vertex normals associated with each poly (hence 'loop normals').
* Useful to materialize sharp edges (or non-smooth faces) without actually modifying the geometry
* (splitting edges).
+ *
+ * \param loop_to_poly_map: Optional pre-created map from loops to their polygon.
*/
-void BKE_mesh_normals_loop_split(const struct MVert *mverts,
+void BKE_mesh_normals_loop_split(const float (*positions)[3],
const float (*vert_normals)[3],
int numVerts,
const struct MEdge *medges,
@@@ -645,11 -615,11 +616,11 @@@
int numPolys,
bool use_split_normals,
float split_angle,
+ const int *loop_to_poly_map,
MLoopNorSpaceArray *r_lnors_spacearr,
- short (*clnors_data)[2],
- int *r_loop_to_poly);
+ short (*clnors_data)[2]);
-void BKE_mesh_normals_loop_custom_set(const struct MVert *mverts,
+void BKE_mesh_normals_loop_custom_set(const float (*positions)[3],
const float (*vert_normals)[3],
int numVerts,
struct MEdge *medges,
diff --cc source/blender/blenkernel/intern/bvhutils.cc
index bb536188c9e,b897a990aab..7edc8316c07
--- a/source/blender/blenkernel/intern/bvhutils.cc
+++ b/source/blender/blenkernel/intern/bvhutils.cc
@@@ -28,7 -29,8 +29,9 @@@
#include "MEM_guardedalloc.h"
+ using blender::BitVector;
+using blender::float3;
+ using blender::IndexRange;
using blender::Span;
using blender::VArray;
@@@ -702,33 -703,33 +704,33 @@@ static BVHTree *bvhtree_from_editmesh_v
static BVHTree *bvhtree_from_mesh_verts_create_tree(float epsilon,
int tree_type,
int axis,
- const MVert *vert,
+ const float (*positions)[3],
const int verts_num,
- const BLI_bitmap *verts_mask,
+ const BitVector<> &verts_mask,
int verts_num_active)
{
- BVHTree *tree = nullptr;
-
- if (verts_mask) {
+ if (!verts_mask.is_empty()) {
BLI_assert(IN_RANGE_INCL(verts_num_active, 0, verts_num));
}
else {
verts_num_active = verts_num;
}
+ if (verts_num_active == 0) {
+ return nullptr;
+ }
- if (verts_num_active) {
- tree = BLI_bvhtree_new(verts_num_active, epsilon, tree_type, axis);
+ BVHTree *tree = BLI_bvhtree_new(verts_num_active, epsilon, tree_type, axis);
+ if (!tree) {
+ return nullptr;
+ }
- if (tree) {
- for (int i = 0; i < verts_num; i++) {
- if (verts_mask && !BLI_BITMAP_TEST_BOOL(verts_mask, i)) {
- continue;
- }
- BLI_bvhtree_insert(tree, i, positions[i], 1);
- }
- BLI_assert(BLI_bvhtree_get_len(tree) == verts_num_active);
+ for (int i = 0; i < verts_num; i++) {
+ if (!verts_mask.is_empty() && !verts_mask[i]) {
+ continue;
}
- BLI_bvhtree_insert(tree, i, vert[i].co, 1);
++ BLI_bvhtree_insert(tree, i, positions[i], 1);
}
+ BLI_assert(BLI_bvhtree_get_len(tree) == verts_num_active);
return tree;
}
@@@ -761,24 -761,23 +762,23 @@@ BVHTree *bvhtree_from_editmesh_verts
}
BVHTree *bvhtree_from_mesh_verts_ex(BVHTreeFromMesh *data,
- const MVert *vert,
+ const float (*positions)[3],
const int verts_num,
- const BLI_bitmap *verts_mask,
+ const BitVector<> &verts_mask,
int verts_num_active,
float epsilon,
int tree_type,
int axis)
{
- BVHTree *tree = nullptr;
- tree = bvhtree_from_mesh_verts_create_tree(
+ BVHTree *tree = bvhtree_from_mesh_verts_create_tree(
- epsilon, tree_type, axis, vert, verts_num, verts_mask, verts_num_active);
+ epsilon, tree_type, axis, positions, verts_num, verts_mask, verts_num_active);
bvhtree_balance(tree, false);
if (data) {
/* Setup BVHTreeFromMesh */
bvhtree_from_mesh_setup_data(
- tree, BVHTREE_FROM_VERTS, positions, nullptr, nullptr, nullptr, nullptr, nullptr, data);
- tree, BVHTREE_FROM_VERTS, vert, nullptr, nullptr, nullptr, nullptr, data);
++ tree, BVHTREE_FROM_VERTS, positions, nullptr, nullptr, nullptr, nullptr, data);
}
return tree;
@@@ -829,10 -829,10 +830,10 @@@ static BVHTree *bvhtree_from_editmesh_e
return tree;
}
-static BVHTree *bvhtree_from_mesh_edges_create_tree(const MVert *vert,
+static BVHTree *bvhtree_from_mesh_edges_create_tree(const float (*positions)[3],
const MEdge *edge,
const int edge_num,
- const BLI_bitmap *edges_mask,
+ const BitVector<> &edges_mask,
int edges_num_active,
float epsilon,
int tree_type,
@@@ -846,22 -844,25 +845,25 @@@
else {
edges_num_active = edge_num;
}
+ if (edges_num_active == 0) {
+ return nullptr;
+ }
- if (edges_num_active) {
- /* Create a BVH-tree of the given target */
- tree = BLI_bvhtree_new(edges_num_active, epsilon, tree_type, axis);
- if (tree) {
- for (int i = 0; i < edge_num; i++) {
- if (edges_mask && !BLI_BITMAP_TEST_BOOL(edges_mask, i)) {
- continue;
- }
- float co[2][3];
- copy_v3_v3(co[0], positions[edge[i].v1]);
- copy_v3_v3(co[1], positions[edge[i].v2]);
+ /* Create a BVH-tree of the given target */
+ BVHTree *tree = BLI_bvhtree_new(edges_num_active, epsilon, tree_type, axis);
+ if (!tree) {
+ return nullptr;
+ }
- BLI_bvhtree_insert(tree, i, co[0], 2);
- }
+ for (int i = 0; i < edge_num; i++) {
+ if (!edges_mask.is_empty() && !edges_mask[i]) {
+ continue;
}
+ float co[2][3];
- copy_v3_v3(co[0], vert[edge[i].v1].co);
- copy_v3_v3(co[1], vert[edge[i].v2].co);
++ copy_v3_v3(co[0], positions[edge[i].v1]);
++ copy_v3_v3(co[1], positions[edge[i].v2]);
+
+ BLI_bvhtree_insert(tree, i, co[0], 2);
}
return tree;
@@@ -895,25 -895,24 +896,24 @@@ BVHTree *bvhtree_from_editmesh_edges
}
BVHTree *bvhtree_from_mesh_edges_ex(BVHTreeFromMesh *data,
- const MVert *vert,
+ const float (*positions)[3],
const MEdge *edge,
const int edges_num,
- const BLI_bitmap *edges_mask,
+ const BitVector<> &edges_mask,
int edges_num_active,
float epsilon,
int tree_type,
int axis)
{
- BVHTree *tree = nullptr;
- tree = bvhtree_from_mesh_edges_create_tree(
+ BVHTree *tree = bvhtree_from_mesh_edges_create_tree(
- vert, edge, edges_num, edges_mask, edges_num_active, epsilon, tree_type, axis);
+ positions, edge, edges_num, edges_mask, edges_num_active, epsilon, tree_type, axis);
bvhtree_balance(tree, false);
if (data) {
/* Setup BVHTreeFromMesh */
bvhtree_from_mesh_setup_data(
- tree, BVHTREE_FROM_EDGES, positions, edg
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list