[Bf-blender-cvs] [8dff7bb4eb1] refactor-mesh-position-generic: Merge branch 'master' into refactor-mesh-position-generic
Hans Goudey
noreply at git.blender.org
Tue Dec 13 05:12:32 CET 2022
Commit: 8dff7bb4eb1c2d6cf03e4bc1380c5c8c96395846
Author: Hans Goudey
Date: Mon Dec 12 21:58:24 2022 -0600
Branches: refactor-mesh-position-generic
https://developer.blender.org/rB8dff7bb4eb1c2d6cf03e4bc1380c5c8c96395846
Merge branch 'master' into refactor-mesh-position-generic
===================================================================
===================================================================
diff --cc source/blender/blenkernel/intern/mesh.cc
index f50d6651170,1fafec810ba..e7e5e26c573
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@@ -513,7 -511,25 +516,9 @@@ static int customdata_compare
}
/* At this point `l1` and `l2` have the same name and type, so they should be compared. */
+ found_corresponding_layer = true;
+
switch (l1->type) {
-
- case CD_MVERT: {
- MVert *v1 = (MVert *)l1->data;
- MVert *v2 = (MVert *)l2->data;
- int vtot = m1->totvert;
-
- for (j = 0; j < vtot; j++, v1++, v2++) {
- for (int k = 0; k < 3; k++) {
- if (compare_threshold_relative(v1->co[k], v2->co[k], thresh)) {
- return MESHCMP_VERTCOMISMATCH;
- }
- }
- }
- break;
- }
-
/* We're order-agnostic for edges here. */
case CD_MEDGE: {
MEdge *e1 = (MEdge *)l1->data;
diff --cc source/blender/modifiers/intern/MOD_array.cc
index a09756b03aa,1478ca0ecc5..92e8662af50
--- a/source/blender/modifiers/intern/MOD_array.cc
+++ b/source/blender/modifiers/intern/MOD_array.cc
@@@ -162,14 -161,16 +161,16 @@@ static void dm_mvert_map_doubles(int *d
source_end = source_start + source_verts_num;
/* build array of MVerts to be tested for merging */
- sorted_verts_target = MEM_malloc_arrayN(target_verts_num, sizeof(SortVertsElem), __func__);
- sorted_verts_source = MEM_malloc_arrayN(source_verts_num, sizeof(SortVertsElem), __func__);
+ SortVertsElem *sorted_verts_target = static_cast<SortVertsElem *>(
+ MEM_malloc_arrayN(target_verts_num, sizeof(SortVertsElem), __func__));
+ SortVertsElem *sorted_verts_source = static_cast<SortVertsElem *>(
+ MEM_malloc_arrayN(source_verts_num, sizeof(SortVertsElem), __func__));
/* Copy target vertices index and cos into SortVertsElem array */
- svert_from_mvert(sorted_verts_target, mverts + target_start, target_start, target_end);
+ svert_from_mvert(sorted_verts_target, positions, target_start, target_end);
/* Copy source vertices index and cos into SortVertsElem array */
- svert_from_mvert(sorted_verts_source, mverts + source_start, source_start, source_end);
+ svert_from_mvert(sorted_verts_source, positions, source_start, source_end);
/* sort arrays according to sum of vertex coordinates (sumco) */
qsort(sorted_verts_target, target_verts_num, sizeof(SortVertsElem), svert_sum_cmp);
diff --cc source/blender/modifiers/intern/MOD_screw.cc
index 2023d459f92,930fa0c1aab..5d7a652ff28
--- a/source/blender/modifiers/intern/MOD_screw.cc
+++ b/source/blender/modifiers/intern/MOD_screw.cc
@@@ -242,9 -241,11 +242,9 @@@ static Mesh *modifyMesh(ModifierData *m
MPoly *mp_new;
MLoop *ml_new;
MEdge *med_new, *med_new_firstloop;
- MVert *mv_new, *mv_new_base;
- const MVert *mv_orig;
Object *ob_axis = ltmd->ob_axis;
- ScrewVertConnect *vc, *vc_tmp, *vert_connect = NULL;
+ ScrewVertConnect *vc, *vc_tmp, *vert_connect = nullptr;
const char mpoly_flag = (ltmd->flag & MOD_SCREW_SMOOTH_SHADING) ? ME_SMOOTH : 0;
@@@ -379,9 -380,9 +379,9 @@@
const bool do_remove_doubles = (ltmd->flag & MOD_SCREW_MERGE) && (screw_ofs == 0.0f);
result = BKE_mesh_new_nomain_from_template(
- mesh, (int)maxVerts, (int)maxEdges, 0, (int)maxPolys * 4, (int)maxPolys);
+ mesh, int(maxVerts), int(maxEdges), 0, int(maxPolys) * 4, int(maxPolys));
- const MVert *mvert_orig = BKE_mesh_verts(mesh);
+ const float(*positions_orig)[3] = BKE_mesh_positions(mesh);
const MEdge *medge_orig = BKE_mesh_edges(mesh);
const MPoly *mpoly_orig = BKE_mesh_polys(mesh);
const MLoop *mloop_orig = BKE_mesh_loops(mesh);
@@@ -495,16 -503,17 +499,16 @@@
// printf("\n\n\n\n\nStarting Modifier\n");
/* set edge users */
med_new = medge_new;
- mv_new = mvert_new;
- if (ob_axis != NULL) {
+ if (ob_axis != nullptr) {
/* `mtx_tx` is initialized early on. */
- for (i = 0; i < totvert; i++, mv_new++, mv_orig++, vc++) {
- vc->co[0] = mv_new->co[0] = mv_orig->co[0];
- vc->co[1] = mv_new->co[1] = mv_orig->co[1];
- vc->co[2] = mv_new->co[2] = mv_orig->co[2];
+ for (i = 0; i < totvert; i++, vc++) {
+ vc->co[0] = positions_new[i][0] = positions_orig[i][0];
+ vc->co[1] = positions_new[i][1] = positions_orig[i][1];
+ vc->co[2] = positions_new[i][2] = positions_orig[i][2];
vc->flag = 0;
- vc->e[0] = vc->e[1] = NULL;
+ vc->e[0] = vc->e[1] = nullptr;
vc->v[0] = vc->v[1] = SV_UNUSED;
mul_m4_v3(mtx_tx, vc->co);
@@@ -516,13 -525,13 +520,13 @@@
}
}
else {
- for (i = 0; i < totvert; i++, mv_new++, mv_orig++, vc++) {
- vc->co[0] = mv_new->co[0] = mv_orig->co[0];
- vc->co[1] = mv_new->co[1] = mv_orig->co[1];
- vc->co[2] = mv_new->co[2] = mv_orig->co[2];
+ for (i = 0; i < totvert; i++, vc++) {
+ vc->co[0] = positions_new[i][0] = positions_orig[i][0];
+ vc->co[1] = positions_new[i][1] = positions_orig[i][1];
+ vc->co[2] = positions_new[i][2] = positions_orig[i][2];
vc->flag = 0;
- vc->e[0] = vc->e[1] = NULL;
+ vc->e[0] = vc->e[1] = nullptr;
vc->v[0] = vc->v[1] = SV_UNUSED;
/* Length in 2D, don't sqrt because this is only for comparison. */
@@@ -773,26 -785,27 +777,26 @@@
}
/* copy a slice */
- CustomData_copy_data(&mesh->vdata, &result->vdata, 0, (int)varray_stride, (int)totvert);
+ CustomData_copy_data(&mesh->vdata, &result->vdata, 0, int(varray_stride), int(totvert));
- mv_new_base = mvert_new;
- mv_new = &mvert_new[varray_stride]; /* advance to the next slice */
++ /* set location */
+ for (j = 0; j < totvert; j++) {
- const int vert_index_new = (int)varray_stride + (int)j;
++ const int vert_index_new = int(varray_stride) + int(j);
- for (j = 0; j < totvert; j++, mv_new_base++, mv_new++) {
-- /* set location */
- copy_v3_v3(mv_new->co, mv_new_base->co);
+ copy_v3_v3(positions_new[vert_index_new], positions_new[j]);
/* only need to set these if using non cleared memory */
// mv_new->mat_nr = mv_new->flag = 0;
- if (ob_axis != NULL) {
+ if (ob_axis != nullptr) {
- sub_v3_v3(mv_new->co, mtx_tx[3]);
+ sub_v3_v3(positions_new[vert_index_new], mtx_tx[3]);
- mul_m4_v3(mat, mv_new->co);
+ mul_m4_v3(mat, positions_new[vert_index_new]);
- add_v3_v3(mv_new->co, mtx_tx[3]);
+ add_v3_v3(positions_new[vert_index_new], mtx_tx[3]);
}
else {
- mul_m4_v3(mat, mv_new->co);
+ mul_m4_v3(mat, positions_new[vert_index_new]);
}
/* add the new edge */
@@@ -976,7 -989,7 +980,7 @@@
med_new++;
}
-- /* validate loop edges */
++/* validate loop edges */
#if 0
{
uint i = 0;
diff --cc source/blender/nodes/geometry/nodes/node_geo_set_position.cc
index 50739b83a61,e219d5bc0a1..e264675d83f
--- a/source/blender/nodes/geometry/nodes/node_geo_set_position.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_set_position.cc
@@@ -34,11 -41,39 +41,11 @@@ static void set_computed_position_and_o
const int grain_size = 10000;
switch (component.type()) {
- case GEO_COMPONENT_TYPE_MESH: {
- Mesh *mesh = static_cast<MeshComponent &>(component).get_for_write();
- MutableSpan<MVert> verts = mesh->verts_for_write();
- if (in_positions.is_same(positions_read_only)) {
- devirtualize_varray(in_offsets, [&](const auto in_offsets) {
- threading::parallel_for(
- selection.index_range(), grain_size, [&](const IndexRange range) {
- for (const int i : selection.slice(range)) {
- const float3 offset = in_offsets[i];
- add_v3_v3(verts[i].co, offset);
- }
- });
- });
- }
- else {
- devirtualize_varray2(
- in_positions, in_offsets, [&](const auto in_positions, const auto in_offsets) {
- threading::parallel_for(
- selection.index_range(), grain_size, [&](const IndexRange range) {
- for (const int i : selection.slice(range)) {
- const float3 new_position = in_positions[i] + in_offsets[i];
- copy_v3_v3(verts[i].co, new_position);
- }
- });
- });
- }
- break;
- }
case GEO_COMPONENT_TYPE_CURVE: {
- CurveComponent &curve_component = static_cast<CurveComponent &>(component);
- Curves &curves_id = *curve_component.get_for_write();
- bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry);
if (attributes.contains("handle_right") && attributes.contains("handle_left")) {
+ CurveComponent &curve_component = static_cast<CurveComponent &>(component);
+ Curves &curves_id = *curve_component.get_for_write();
+ bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry);
SpanAttributeWriter<float3> handle_right_attribute =
attributes.lookup_or_add_for_write_span<float3>("handle_right", ATTR_DOMAIN_POINT);
SpanAttributeWriter<float3> handle_left_attribute =
More information about the Bf-blender-cvs
mailing list