Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/curves_sculpt_add.cc22
-rw-r--r--source/blender/editors/sculpt_paint/curves_sculpt_puff.cc15
-rw-r--r--source/blender/editors/sculpt_paint/curves_sculpt_slide.cc14
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c10
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c22
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c7
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.cc139
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc10
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c69
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c27
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_dyntopo.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_expand.c26
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_face_set.c13
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_geodesic.c18
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c2
16 files changed, 220 insertions, 178 deletions
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
index f6539284f74..3b13575f7bb 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
@@ -90,6 +90,8 @@ struct AddOperationExecutor {
Object *surface_ob_eval_ = nullptr;
Mesh *surface_eval_ = nullptr;
+ Span<MVert> surface_verts_eval_;
+ Span<MLoop> surface_loops_eval_;
Span<MLoopTri> surface_looptris_eval_;
VArraySpan<float2> surface_uv_map_eval_;
BVHTreeFromMesh surface_bvh_eval_;
@@ -140,6 +142,12 @@ struct AddOperationExecutor {
report_empty_evaluated_surface(stroke_extension.reports);
return;
}
+ surface_verts_eval_ = surface_eval_->vertices();
+ surface_loops_eval_ = surface_eval_->loops();
+ surface_looptris_eval_ = {BKE_mesh_runtime_looptri_ensure(surface_eval_),
+ BKE_mesh_runtime_looptri_len(surface_eval_)};
+ BKE_bvhtree_from_mesh_get(&surface_bvh_eval_, surface_eval_, BVHTREE_FROM_LOOPTRI, 2);
+ BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_eval_); });
curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt;
brush_ = BKE_paint_brush_for_read(&curves_sculpt_->paint);
@@ -179,12 +187,6 @@ struct AddOperationExecutor {
/* Use a pointer cast to avoid overflow warnings. */
RandomNumberGenerator rng{*(uint32_t *)(&time)};
- BKE_bvhtree_from_mesh_get(&surface_bvh_eval_, surface_eval_, BVHTREE_FROM_LOOPTRI, 2);
- BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_eval_); });
-
- surface_looptris_eval_ = {BKE_mesh_runtime_looptri_ensure(surface_eval_),
- BKE_mesh_runtime_looptri_len(surface_eval_)};
-
/* Sample points on the surface using one of multiple strategies. */
Vector<float2> sampled_uvs;
if (add_amount_ == 1) {
@@ -296,7 +298,7 @@ struct AddOperationExecutor {
const MLoopTri &looptri = surface_looptris_eval_[looptri_index];
const float3 brush_pos_su = ray_hit.co;
const float3 bary_coords = bke::mesh_surface_sample::compute_bary_coord_in_triangle(
- *surface_eval_, looptri, brush_pos_su);
+ surface_verts_eval_, surface_loops_eval_, looptri, brush_pos_su);
const float2 uv = bke::mesh_surface_sample::sample_corner_attrribute_with_bary_coords(
bary_coords, looptri, surface_uv_map_eval_);
@@ -421,9 +423,9 @@ struct AddOperationExecutor {
brush_radius_su,
[&](const int index, const float3 &UNUSED(co), const float UNUSED(dist_sq)) {
const MLoopTri &looptri = surface_looptris_eval_[index];
- const float3 v0_su = surface_eval_->mvert[surface_eval_->mloop[looptri.tri[0]].v].co;
- const float3 v1_su = surface_eval_->mvert[surface_eval_->mloop[looptri.tri[1]].v].co;
- const float3 v2_su = surface_eval_->mvert[surface_eval_->mloop[looptri.tri[2]].v].co;
+ const float3 v0_su = surface_verts_eval_[surface_loops_eval_[looptri.tri[0]].v].co;
+ const float3 v1_su = surface_verts_eval_[surface_loops_eval_[looptri.tri[1]].v].co;
+ const float3 v2_su = surface_verts_eval_[surface_loops_eval_[looptri.tri[2]].v].co;
float3 normal_su;
normal_tri_v3(normal_su, v0_su, v1_su, v2_su);
if (math::dot(normal_su, view_direction_su) >= 0.0f) {
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_puff.cc b/source/blender/editors/sculpt_paint/curves_sculpt_puff.cc
index 139e0d67e89..062bacc7add 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_puff.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_puff.cc
@@ -70,6 +70,8 @@ struct PuffOperationExecutor {
Object *surface_ob_ = nullptr;
Mesh *surface_ = nullptr;
+ Span<MVert> surface_verts_;
+ Span<MLoop> surface_loops_;
Span<MLoopTri> surface_looptris_;
Span<float3> corner_normals_su_;
BVHTreeFromMesh surface_bvh_;
@@ -117,11 +119,12 @@ struct PuffOperationExecutor {
reinterpret_cast<const float3 *>(CustomData_get_layer(&surface_->ldata, CD_NORMAL)),
surface_->totloop};
- BKE_bvhtree_from_mesh_get(&surface_bvh_, surface_, BVHTREE_FROM_LOOPTRI, 2);
- BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_); });
-
+ surface_verts_ = surface_->vertices();
+ surface_loops_ = surface_->loops();
surface_looptris_ = {BKE_mesh_runtime_looptri_ensure(surface_),
BKE_mesh_runtime_looptri_len(surface_)};
+ BKE_bvhtree_from_mesh_get(&surface_bvh_, surface_, BVHTREE_FROM_LOOPTRI, 2);
+ BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_); });
if (stroke_extension.is_first) {
this->initialize_segment_lengths();
@@ -289,9 +292,9 @@ struct PuffOperationExecutor {
const MLoopTri &looptri = surface_looptris_[nearest.index];
const float3 closest_pos_su = nearest.co;
- const float3 &v0_su = surface_->mvert[surface_->mloop[looptri.tri[0]].v].co;
- const float3 &v1_su = surface_->mvert[surface_->mloop[looptri.tri[1]].v].co;
- const float3 &v2_su = surface_->mvert[surface_->mloop[looptri.tri[2]].v].co;
+ const float3 &v0_su = surface_verts_[surface_loops_[looptri.tri[0]].v].co;
+ const float3 &v1_su = surface_verts_[surface_loops_[looptri.tri[1]].v].co;
+ const float3 &v2_su = surface_verts_[surface_loops_[looptri.tri[2]].v].co;
float3 bary_coords;
interp_weights_tri_v3(bary_coords, v0_su, v1_su, v2_su, closest_pos_su);
const float3 normal_su = geometry::compute_surface_point_normal(
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc b/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc
index 007bff0b170..e65d81a4225 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc
@@ -112,6 +112,8 @@ struct SlideOperationExecutor {
Object *surface_ob_eval_ = nullptr;
Mesh *surface_eval_ = nullptr;
+ Span<MVert> surface_verts_eval_;
+ Span<MLoop> surface_loops_eval_;
Span<MLoopTri> surface_looptris_eval_;
VArraySpan<float2> surface_uv_map_eval_;
BVHTreeFromMesh surface_bvh_eval_;
@@ -175,8 +177,8 @@ struct SlideOperationExecutor {
if (surface_orig_->totpoly == 0) {
report_empty_original_surface(stroke_extension.reports);
return;
- }
- surface_looptris_orig_ = {BKE_mesh_runtime_looptri_ensure(surface_orig_),
+ }
+ surface_looptris_orig_ = {BKE_mesh_runtime_looptri_ensure(surface_orig_),
BKE_mesh_runtime_looptri_len(surface_orig_)};
surface_uv_map_orig_ =
bke::mesh_attributes(*surface_orig_).lookup<float2>(uv_map_name, ATTR_DOMAIN_CORNER);
@@ -205,6 +207,8 @@ struct SlideOperationExecutor {
}
surface_looptris_eval_ = {BKE_mesh_runtime_looptri_ensure(surface_eval_),
BKE_mesh_runtime_looptri_len(surface_eval_)};
+ surface_verts_eval_ = surface_eval_->vertices();
+ surface_loops_eval_ = surface_eval_->loops();
surface_uv_map_eval_ =
bke::mesh_attributes(*surface_eval_).lookup<float2>(uv_map_name, ATTR_DOMAIN_CORNER);
if (surface_uv_map_eval_.is_empty()) {
@@ -319,8 +323,8 @@ struct SlideOperationExecutor {
{
const float4x4 brush_transform_inv = brush_transform.inverted();
- const Span<MVert> verts_orig_su{surface_orig_->mvert, surface_orig_->totvert};
- const Span<MLoop> loops_orig{surface_orig_->mloop, surface_orig_->totloop};
+ const Span<MVert> verts_orig_su = surface_orig_->vertices();
+ const Span<MLoop> loops_orig = surface_orig_->loops();
MutableSpan<float3> positions_orig_cu = curves_orig_->positions_for_write();
MutableSpan<float2> surface_uv_coords = curves_orig_->surface_uv_coords_for_write();
@@ -383,7 +387,7 @@ struct SlideOperationExecutor {
/* Compute the uv of the new surface position on the evaluated mesh. */
const MLoopTri &looptri_eval = surface_looptris_eval_[looptri_index_eval];
const float3 bary_weights_eval = bke::mesh_surface_sample::compute_bary_coord_in_triangle(
- *surface_eval_, looptri_eval, hit_pos_eval_su);
+ surface_verts_eval_, surface_loops_eval_, looptri_eval, hit_pos_eval_su);
const float2 uv = attribute_math::mix3(bary_weights_eval,
surface_uv_map_eval_[looptri_eval.tri[0]],
surface_uv_map_eval_[looptri_eval.tri[1]],
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index a1bb2bf41ea..f1e6c7bf8dd 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -4055,13 +4055,13 @@ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *p
}
ps->mat_array[totmat - 1] = NULL;
- ps->mvert_eval = ps->me_eval->mvert;
+ ps->mvert_eval = BKE_mesh_vertices(ps->me_eval);
ps->vert_normals = BKE_mesh_vertex_normals_ensure(ps->me_eval);
if (ps->do_mask_cavity) {
- ps->medge_eval = ps->me_eval->medge;
+ ps->medge_eval = BKE_mesh_edges(ps->me_eval);
}
- ps->mloop_eval = ps->me_eval->mloop;
- ps->mpoly_eval = ps->me_eval->mpoly;
+ ps->mloop_eval = BKE_mesh_loops(ps->me_eval);
+ ps->mpoly_eval = BKE_mesh_polygons(ps->me_eval);
ps->material_indices = (const int *)CustomData_get_layer_named(
&ps->me_eval->pdata, CD_PROP_INT32, "material_index");
@@ -4155,7 +4155,7 @@ static void proj_paint_face_lookup_init(const ProjPaintState *ps, ProjPaintFaceL
memset(face_lookup, 0, sizeof(*face_lookup));
if (ps->do_face_sel) {
face_lookup->index_mp_to_orig = CustomData_get_layer(&ps->me_eval->pdata, CD_ORIGINDEX);
- face_lookup->mpoly_orig = ((Mesh *)ps->ob->data)->mpoly;
+ face_lookup->mpoly_orig = BKE_mesh_polygons((Mesh *)ps->ob->data);
}
}
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index dcc6e734cf4..34c5fc3124c 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -1123,6 +1123,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
const float(*ob_imat)[4] = vc->obact->imat;
/* Write vertices coordinates for the front face. */
+ MVert *verts = BKE_mesh_vertices_for_write(trim_operation->mesh);
float depth_point[3];
madd_v3_v3v3fl(depth_point, shape_origin, shape_normal, depth_front);
for (int i = 0; i < tot_screen_points; i++) {
@@ -1134,7 +1135,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
ED_view3d_win_to_3d_on_plane(region, shape_plane, screen_points[i], false, new_point);
madd_v3_v3fl(new_point, shape_normal, depth_front);
}
- mul_v3_m4v3(trim_operation->mesh->mvert[i].co, ob_imat, new_point);
+ mul_v3_m4v3(verts[i].co, ob_imat, new_point);
mul_v3_m4v3(trim_operation->true_mesh_co[i], ob_imat, new_point);
}
@@ -1149,7 +1150,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
ED_view3d_win_to_3d_on_plane(region, shape_plane, screen_points[i], false, new_point);
madd_v3_v3fl(new_point, shape_normal, depth_back);
}
- mul_v3_m4v3(trim_operation->mesh->mvert[i + tot_screen_points].co, ob_imat, new_point);
+ mul_v3_m4v3(verts[i + tot_screen_points].co, ob_imat, new_point);
mul_v3_m4v3(trim_operation->true_mesh_co[i + tot_screen_points], ob_imat, new_point);
}
@@ -1159,10 +1160,12 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
BLI_polyfill_calc(screen_points, tot_screen_points, 0, r_tris);
/* Write the front face triangle indices. */
- MPoly *mp = trim_operation->mesh->mpoly;
- MLoop *ml = trim_operation->mesh->mloop;
+ MPoly *polys = BKE_mesh_polygons_for_write(trim_operation->mesh);
+ MLoop *loops = BKE_mesh_loops_for_write(trim_operation->mesh);
+ MPoly *mp = polys;
+ MLoop *ml = loops;
for (int i = 0; i < tot_tris_face; i++, mp++, ml += 3) {
- mp->loopstart = (int)(ml - trim_operation->mesh->mloop);
+ mp->loopstart = (int)(ml - loops);
mp->totloop = 3;
ml[0].v = r_tris[i][0];
ml[1].v = r_tris[i][1];
@@ -1171,7 +1174,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
/* Write the back face triangle indices. */
for (int i = 0; i < tot_tris_face; i++, mp++, ml += 3) {
- mp->loopstart = (int)(ml - trim_operation->mesh->mloop);
+ mp->loopstart = (int)(ml - loops);
mp->totloop = 3;
ml[0].v = r_tris[i][0] + tot_screen_points;
ml[1].v = r_tris[i][1] + tot_screen_points;
@@ -1182,7 +1185,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
/* Write the indices for the lateral triangles. */
for (int i = 0; i < tot_screen_points; i++, mp++, ml += 3) {
- mp->loopstart = (int)(ml - trim_operation->mesh->mloop);
+ mp->loopstart = (int)(ml - loops);
mp->totloop = 3;
int current_index = i;
int next_index = current_index + 1;
@@ -1195,7 +1198,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
}
for (int i = 0; i < tot_screen_points; i++, mp++, ml += 3) {
- mp->loopstart = (int)(ml - trim_operation->mesh->mloop);
+ mp->loopstart = (int)(ml - loops);
mp->totloop = 3;
int current_index = i;
int next_index = current_index + 1;
@@ -1330,8 +1333,9 @@ static void sculpt_gesture_trim_apply_for_symmetry_pass(bContext *UNUSED(C),
{
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)sgcontext->operation;
Mesh *trim_mesh = trim_operation->mesh;
+ MVert *verts = BKE_mesh_vertices_for_write(trim_mesh);
for (int i = 0; i < trim_mesh->totvert; i++) {
- flip_v3_v3(trim_mesh->mvert[i].co, trim_operation->true_mesh_co[i], sgcontext->symmpass);
+ flip_v3_v3(verts[i].co, trim_operation->true_mesh_co[i], sgcontext->symmpass);
}
sculpt_gesture_trim_normals_update(sgcontext);
sculpt_gesture_apply_trim(sgcontext);
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index adf21154842..7336166d651 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -30,6 +30,7 @@
#include "BKE_image.h"
#include "BKE_layer.h"
#include "BKE_material.h"
+#include "BKE_mesh.h"
#include "BKE_mesh_runtime.h"
#include "BKE_paint.h"
#include "BKE_report.h"
@@ -287,8 +288,8 @@ static void imapaint_pick_uv(
const MLoopTri *lt = BKE_mesh_runtime_looptri_ensure(me_eval);
const int tottri = me_eval->runtime.looptris.len;
- const MVert *mvert = me_eval->mvert;
- const MLoop *mloop = me_eval->mloop;
+ const MVert *mvert = BKE_mesh_vertices(me_eval);
+ const MLoop *mloop = BKE_mesh_loops(me_eval);
const int *index_mp_to_orig = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX);
/* get the needed opengl matrices */
@@ -702,7 +703,7 @@ static int vert_select_ungrouped_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
Mesh *me = ob->data;
- if (BLI_listbase_is_empty(&me->vertex_group_names) || (me->dvert == NULL)) {
+ if (BLI_listbase_is_empty(&me->vertex_group_names) || (BKE_mesh_deform_verts(me) == NULL)) {
BKE_report(op->reports, RPT_ERROR, "No weights/vertex groups on object");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc
index ccaf8b1ba37..c1a2a326d14 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.cc
+++ b/source/blender/editors/sculpt_paint/paint_vertex.cc
@@ -773,6 +773,8 @@ struct WeightPaintGroupData {
* paint stroke update - campbell */
struct WeightPaintInfo {
+ MutableSpan<MDeformVert> dvert;
+
int defbase_tot;
/* both must add up to 'defbase_tot' */
@@ -815,7 +817,7 @@ static void do_weight_paint_vertex_single(
float paintweight)
{
Mesh *me = (Mesh *)ob->data;
- MDeformVert *dv = &me->dvert[index];
+ MDeformVert *dv = &wpi->dvert[index];
bool topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
MDeformWeight *dw;
@@ -875,7 +877,7 @@ static void do_weight_paint_vertex_single(
/* get the mirror def vars */
if (index_mirr != -1) {
- dv_mirr = &me->dvert[index_mirr];
+ dv_mirr = &wpi->dvert[index_mirr];
if (wp->flag & VP_FLAG_VGROUP_RESTRICT) {
dw_mirr = BKE_defvert_find_index(dv_mirr, vgroup_mirr);
@@ -915,9 +917,9 @@ static void do_weight_paint_vertex_single(
if (!brush_use_accumulate(wp)) {
MDeformVert *dvert_prev = ob->sculpt->mode.wpaint.dvert_prev;
- MDeformVert *dv_prev = defweight_prev_init(dvert_prev, me->dvert, index);
+ MDeformVert *dv_prev = defweight_prev_init(dvert_prev, wpi->dvert.data(), index);
if (index_mirr != -1) {
- defweight_prev_init(dvert_prev, me->dvert, index_mirr);
+ defweight_prev_init(dvert_prev, wpi->dvert.data(), index_mirr);
}
weight_prev = BKE_defvert_find_weight(dv_prev, wpi->active.index);
@@ -1028,7 +1030,7 @@ static void do_weight_paint_vertex_multi(
float paintweight)
{
Mesh *me = (Mesh *)ob->data;
- MDeformVert *dv = &me->dvert[index];
+ MDeformVert *dv = &wpi->dvert[index];
bool topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0;
/* mirror vars */
@@ -1044,7 +1046,7 @@ static void do_weight_paint_vertex_multi(
index_mirr = mesh_get_x_mirror_vert(ob, nullptr, index, topology);
if (!ELEM(index_mirr, -1, index)) {
- dv_mirr = &me->dvert[index_mirr];
+ dv_mirr = &wpi->dvert[index_mirr];
}
else {
index_mirr = -1;
@@ -1071,9 +1073,9 @@ static void do_weight_paint_vertex_multi(
if (!brush_use_accumulate(wp)) {
MDeformVert *dvert_prev = ob->sculpt->mode.wpaint.dvert_prev;
- MDeformVert *dv_prev = defweight_prev_init(dvert_prev, me->dvert, index);
+ MDeformVert *dv_prev = defweight_prev_init(dvert_prev, wpi->dvert.data(), index);
if (index_mirr != -1) {
- defweight_prev_init(dvert_prev, me->dvert, index_mirr);
+ defweight_prev_init(dvert_prev, wpi->dvert.data(), index_mirr);
}
oldw = BKE_defvert_multipaint_collective_weight(
@@ -1235,6 +1237,8 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
}
Mesh *me = (Mesh *)ob->data;
+ const Span<MPoly> polys = me->polygons();
+ const Span<MLoop> loops = me->loops();
if (gmap->vert_to_loop == nullptr) {
gmap->vert_map_mem = nullptr;
@@ -1243,15 +1247,15 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
gmap->vert_to_poly = nullptr;
BKE_mesh_vert_loop_map_create(&gmap->vert_to_loop,
&gmap->vert_map_mem,
- me->mpoly,
- me->mloop,
+ polys.data(),
+ loops.data(),
me->totvert,
me->totpoly,
me->totloop);
BKE_mesh_vert_poly_map_create(&gmap->vert_to_poly,
&gmap->poly_map_mem,
- me->mpoly,
- me->mloop,
+ polys.data(),
+ loops.data(),
me->totvert,
me->totpoly,
me->totloop);
@@ -1900,7 +1904,7 @@ static void do_wpaint_precompute_weight_cb_ex(void *__restrict userdata,
const TaskParallelTLS *__restrict UNUSED(tls))
{
SculptThreadedTaskData *data = (SculptThreadedTaskData *)userdata;
- const MDeformVert *dv = &data->me->dvert[n];
+ const MDeformVert *dv = &data->wpi->dvert[n];
data->wpd->precomputed_weight[n] = wpaint_get_active_weight(dv, data->wpi);
}
@@ -1961,10 +1965,9 @@ static void do_wpaint_brush_blur_task_cb_ex(void *__restrict userdata,
if (sculpt_brush_test_sq_fn(&test, vd.co)) {
/* For grid based pbvh, take the vert whose loop corresponds to the current grid.
* Otherwise, take the current vert. */
- const int v_index = has_grids ? data->me->mloop[vd.grid_indices[vd.g]].v :
- vd.vert_indices[vd.i];
+ const int v_index = has_grids ? ss->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
const float grid_alpha = has_grids ? 1.0f / vd.gridsize : 1.0f;
- const char v_flag = data->me->mvert[v_index].flag;
+ const char v_flag = ss->mvert[v_index].flag;
/* If the vertex is selected */
if (!(use_face_sel || use_vert_sel) || v_flag & SELECT) {
/* Get the average poly weight */
@@ -1972,12 +1975,12 @@ static void do_wpaint_brush_blur_task_cb_ex(void *__restrict userdata,
float weight_final = 0.0f;
for (int j = 0; j < gmap->vert_to_poly[v_index].count; j++) {
const int p_index = gmap->vert_to_poly[v_index].indices[j];
- const MPoly *mp = &data->me->mpoly[p_index];
+ const MPoly *mp = &ss->mpoly[p_index];
total_hit_loops += mp->totloop;
for (int k = 0; k < mp->totloop; k++) {
const int l_index = mp->loopstart + k;
- const MLoop *ml = &data->me->mloop[l_index];
+ const MLoop *ml = &ss->mloop[l_index];
weight_final += data->wpd->precomputed_weight[ml->v];
}
}
@@ -2057,10 +2060,9 @@ static void do_wpaint_brush_smear_task_cb_ex(void *__restrict userdata,
if (sculpt_brush_test_sq_fn(&test, vd.co)) {
/* For grid based pbvh, take the vert whose loop corresponds to the current grid.
* Otherwise, take the current vert. */
- const int v_index = has_grids ? data->me->mloop[vd.grid_indices[vd.g]].v :
- vd.vert_indices[vd.i];
+ const int v_index = has_grids ? ss->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
const float grid_alpha = has_grids ? 1.0f / vd.gridsize : 1.0f;
- const MVert *mv_curr = &data->me->mvert[v_index];
+ const MVert *mv_curr = &ss->mvert[v_index];
/* If the vertex is selected */
if (!(use_face_sel || use_vert_sel) || mv_curr->flag & SELECT) {
@@ -2082,12 +2084,12 @@ static void do_wpaint_brush_smear_task_cb_ex(void *__restrict userdata,
float weight_final = 0.0;
for (int j = 0; j < gmap->vert_to_poly[v_index].count; j++) {
const int p_index = gmap->vert_to_poly[v_index].indices[j];
- const MPoly *mp = &data->me->mpoly[p_index];
- const MLoop *ml_other = &data->me->mloop[mp->loopstart];
+ const MPoly *mp = &ss->mpoly[p_index];
+ const MLoop *ml_other = &ss->mloop[mp->loopstart];
for (int k = 0; k < mp->totloop; k++, ml_other++) {
const uint v_other_index = ml_other->v;
if (v_other_index != v_index) {
- const MVert *mv_other = &data->me->mvert[v_other_index];
+ const MVert *mv_other = &ss->mvert[v_other_index];
/* Get the direction from the selected vert to the neighbor. */
float other_dir[3];
@@ -2164,11 +2166,10 @@ static void do_wpaint_brush_draw_task_cb_ex(void *__restrict userdata,
/* NOTE: grids are 1:1 with corners (aka loops).
* For multires, take the vert whose loop corresponds to the current grid.
* Otherwise, take the current vert. */
- const int v_index = has_grids ? data->me->mloop[vd.grid_indices[vd.g]].v :
- vd.vert_indices[vd.i];
+ const int v_index = has_grids ? ss->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
const float grid_alpha = has_grids ? 1.0f / vd.gridsize : 1.0f;
- const char v_flag = data->me->mvert[v_index].flag;
+ const char v_flag = ss->mvert[v_index].flag;
/* If the vertex is selected */
if (!(use_face_sel || use_vert_sel) || v_flag & SELECT) {
float brush_strength = cache->bstrength;
@@ -2232,13 +2233,12 @@ static void do_wpaint_brush_calc_average_weight_cb_ex(
1.0f;
if (angle_cos > 0.0 &&
BKE_brush_curve_strength(data->brush, sqrtf(test.dist), cache->radius) > 0.0) {
- const int v_index = has_grids ? data->me->mloop[vd.grid_indices[vd.g]].v :
- vd.vert_indices[vd.i];
- const char v_flag = data->me->mvert[v_index].flag;
+ const int v_index = has_grids ? ss->mloop[vd.grid_indices[vd.g]].v : vd.vert_indices[vd.i];
+ const char v_flag = ss->mvert[v_index].flag;
/* If the vertex is selected. */
if (!(use_face_sel || use_vert_sel) || v_flag & SELECT) {
- const MDeformVert *dv = &data->me->dvert[v_index];
+ const MDeformVert *dv = &data->wpi->dvert[v_index];
accum->len += 1;
accum->value += wpaint_get_active_weight(dv, data->wpi);
}
@@ -2510,7 +2510,11 @@ static void wpaint_stroke_update_step(bContext *C,
/* load projection matrix */
mul_m4_m4m4(mat, vc->rv3d->persmat, ob->obmat);
+ Mesh *mesh = static_cast<Mesh *>(ob->data);
+
/* *** setup WeightPaintInfo - pass onto do_weight_paint_vertex *** */
+ wpi.dvert = mesh->deform_verts_for_write();
+
wpi.defbase_tot = wpd->defbase_tot;
wpi.defbase_sel = wpd->defbase_sel;
wpi.defbase_tot_sel = wpd->defbase_tot_sel;
@@ -2532,7 +2536,7 @@ static void wpaint_stroke_update_step(bContext *C,
/* *** done setting up WeightPaintInfo *** */
if (wpd->precomputed_weight) {
- precompute_weight_values(C, ob, brush, wpd, &wpi, (Mesh *)ob->data);
+ precompute_weight_values(C, ob, brush, wpd, &wpi, mesh);
}
wpaint_do_symmetrical_brush_actions(C, ob, wp, sd, wpd, &wpi);
@@ -2545,9 +2549,9 @@ static void wpaint_stroke_update_step(bContext *C,
mul_v3_m4v3(loc_world, ob->obmat, ss->cache->true_location);
paint_last_stroke_update(scene, loc_world);
- BKE_mesh_batch_cache_dirty_tag((Mesh *)ob->data, BKE_MESH_BATCH_DIRTY_ALL);
+ BKE_mesh_batch_cache_dirty_tag(mesh, BKE_MESH_BATCH_DIRTY_ALL);
- DEG_id_tag_update((ID *)ob->data, 0);
+ DEG_id_tag_update(&mesh->id, 0);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
swap_m4m4(wpd->vc.rv3d->persmat, mat);
@@ -2980,10 +2984,10 @@ static void do_vpaint_brush_blur_loops(bContext *C,
if (sculpt_brush_test_sq_fn(&test, vd.co)) {
/* For grid based pbvh, take the vert whose loop corresponds to the current grid.
* Otherwise, take the current vert. */
- const int v_index = has_grids ? me->mloop[vd.grid_indices[vd.g]].v :
+ const int v_index = has_grids ? ss->mloop[vd.grid_indices[vd.g]].v :
vd.vert_indices[vd.i];
const float grid_alpha = has_grids ? 1.0f / vd.gridsize : 1.0f;
- const MVert *mv = &me->mvert[v_index];
+ const MVert *mv = &ss->mvert[v_index];
/* If the vertex is selected for painting. */
if (!use_vert_sel || mv->flag & SELECT) {
@@ -3006,7 +3010,7 @@ static void do_vpaint_brush_blur_loops(bContext *C,
for (int j = 0; j < gmap->vert_to_poly[v_index].count; j++) {
int p_index = gmap->vert_to_poly[v_index].indices[j];
- const MPoly *mp = &me->mpoly[p_index];
+ const MPoly *mp = &ss->mpoly[p_index];
if (!use_face_sel || mp->flag & ME_FACE_SEL) {
total_hit_loops += mp->totloop;
for (int k = 0; k < mp->totloop; k++) {
@@ -3040,8 +3044,8 @@ static void do_vpaint_brush_blur_loops(bContext *C,
for (int j = 0; j < gmap->vert_to_poly[v_index].count; j++) {
const int p_index = gmap->vert_to_poly[v_index].indices[j];
const int l_index = gmap->vert_to_loop[v_index].indices[j];
- BLI_assert(me->mloop[l_index].v == v_index);
- const MPoly *mp = &me->mpoly[p_index];
+ BLI_assert(ss->mloop[l_index].v == v_index);
+ const MPoly *mp = &ss->mpoly[p_index];
if (!use_face_sel || mp->flag & ME_FACE_SEL) {
Color color_orig(0, 0, 0, 0); /* unused when array is nullptr */
@@ -3122,10 +3126,10 @@ static void do_vpaint_brush_blur_verts(bContext *C,
if (sculpt_brush_test_sq_fn(&test, vd.co)) {
/* For grid based pbvh, take the vert whose loop corresponds to the current grid.
* Otherwise, take the current vert. */
- const int v_index = has_grids ? me->mloop[vd.grid_indices[vd.g]].v :
+ const int v_index = has_grids ? ss->mloop[vd.grid_indices[vd.g]].v :
vd.vert_indices[vd.i];
const float grid_alpha = has_grids ? 1.0f / vd.gridsize : 1.0f;
- const MVert *mv = &me->mvert[v_index];
+ const MVert *mv = &ss->mvert[v_index];
/* If the vertex is selected for painting. */
if (!use_vert_sel || mv->flag & SELECT) {
@@ -3148,12 +3152,12 @@ static void do_vpaint_brush_blur_verts(bContext *C,
for (int j = 0; j < gmap->vert_to_poly[v_index].count; j++) {
int p_index = gmap->vert_to_poly[v_index].indices[j];
- const MPoly *mp = &me->mpoly[p_index];
+ const MPoly *mp = &ss->mpoly[p_index];
if (!use_face_sel || mp->flag & ME_FACE_SEL) {
total_hit_loops += mp->totloop;
for (int k = 0; k < mp->totloop; k++) {
const uint l_index = mp->loopstart + k;
- const uint v_index = me->mloop[l_index].v;
+ const uint v_index = ss->mloop[l_index].v;
Color *col = lcol + v_index;
@@ -3184,9 +3188,9 @@ static void do_vpaint_brush_blur_verts(bContext *C,
for (int j = 0; j < gmap->vert_to_poly[v_index].count; j++) {
const int p_index = gmap->vert_to_poly[v_index].indices[j];
- BLI_assert(me->mloop[gmap->vert_to_loop[v_index].indices[j]].v == v_index);
+ BLI_assert(ss->mloop[gmap->vert_to_loop[v_index].indices[j]].v == v_index);
- const MPoly *mp = &me->mpoly[p_index];
+ const MPoly *mp = &ss->mpoly[p_index];
if (!use_face_sel || mp->flag & ME_FACE_SEL) {
Color color_orig(0, 0, 0, 0); /* unused when array is nullptr */
@@ -3273,10 +3277,10 @@ static void do_vpaint_brush_smear(bContext *C,
if (sculpt_brush_test_sq_fn(&test, vd.co)) {
/* For grid based pbvh, take the vert whose loop corresponds to the current grid.
* Otherwise, take the current vert. */
- const int v_index = has_grids ? me->mloop[vd.grid_indices[vd.g]].v :
+ const int v_index = has_grids ? ss->mloop[vd.grid_indices[vd.g]].v :
vd.vert_indices[vd.i];
const float grid_alpha = has_grids ? 1.0f / vd.gridsize : 1.0f;
- const MVert *mv_curr = &me->mvert[v_index];
+ const MVert *mv_curr = &ss->mvert[v_index];
/* if the vertex is selected for painting. */
if (!use_vert_sel || mv_curr->flag & SELECT) {
@@ -3305,15 +3309,15 @@ static void do_vpaint_brush_smear(bContext *C,
for (int j = 0; j < gmap->vert_to_poly[v_index].count; j++) {
const int p_index = gmap->vert_to_poly[v_index].indices[j];
const int l_index = gmap->vert_to_loop[v_index].indices[j];
- BLI_assert(me->mloop[l_index].v == v_index);
+ BLI_assert(ss->mloop[l_index].v == v_index);
UNUSED_VARS_NDEBUG(l_index);
- const MPoly *mp = &me->mpoly[p_index];
+ const MPoly *mp = &ss->mpoly[p_index];
if (!use_face_sel || mp->flag & ME_FACE_SEL) {
- const MLoop *ml_other = &me->mloop[mp->loopstart];
+ const MLoop *ml_other = &ss->mloop[mp->loopstart];
for (int k = 0; k < mp->totloop; k++, ml_other++) {
const uint v_other_index = ml_other->v;
if (v_other_index != v_index) {
- const MVert *mv_other = &me->mvert[v_other_index];
+ const MVert *mv_other = &ss->mvert[v_other_index];
/* Get the direction from the
* selected vert to the neighbor. */
@@ -3359,10 +3363,10 @@ static void do_vpaint_brush_smear(bContext *C,
else {
const int l_index = gmap->vert_to_loop[v_index].indices[j];
elem_index = l_index;
- BLI_assert(me->mloop[l_index].v == v_index);
+ BLI_assert(ss->mloop[l_index].v == v_index);
}
- const MPoly *mp = &me->mpoly[p_index];
+ const MPoly *mp = &ss->mpoly[p_index];
if (!use_face_sel || mp->flag & ME_FACE_SEL) {
/* Get the previous element color */
Color color_orig(0, 0, 0, 0); /* unused when array is nullptr */
@@ -3435,11 +3439,11 @@ static void calculate_average_color(VPaintData<Color, Traits, domain> *vpd,
BKE_pbvh_vertex_iter_begin (ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
/* Test to see if the vertex coordinates are within the spherical brush region. */
if (sculpt_brush_test_sq_fn(&test, vd.co)) {
- const int v_index = has_grids ? me->mloop[vd.grid_indices[vd.g]].v :
+ const int v_index = has_grids ? ss->mloop[vd.grid_indices[vd.g]].v :
vd.vert_indices[vd.i];
if (BKE_brush_curve_strength(brush, 0.0, cache->radius) > 0.0) {
/* If the vertex is selected for painting. */
- const MVert *mv = &me->mvert[v_index];
+ const MVert *mv = &ss->mvert[v_index];
if (!use_vert_sel || mv->flag & SELECT) {
accum2->len += gmap->vert_to_loop[v_index].count;
/* if a vertex is within the brush region, then add its color to the blend. */
@@ -3555,10 +3559,10 @@ static void vpaint_do_draw(bContext *C,
/* NOTE: Grids are 1:1 with corners (aka loops).
* For grid based pbvh, take the vert whose loop corresponds to the current grid.
* Otherwise, take the current vert. */
- const int v_index = has_grids ? me->mloop[vd.grid_indices[vd.g]].v :
+ const int v_index = has_grids ? ss->mloop[vd.grid_indices[vd.g]].v :
vd.vert_indices[vd.i];
const float grid_alpha = has_grids ? 1.0f / vd.gridsize : 1.0f;
- const MVert *mv = &me->mvert[v_index];
+ const MVert *mv = &ss->mvert[v_index];
/* If the vertex is selected for painting. */
if (!use_vert_sel || mv->flag & SELECT) {
@@ -3612,8 +3616,8 @@ static void vpaint_do_draw(bContext *C,
for (int j = 0; j < gmap->vert_to_poly[v_index].count; j++) {
const int p_index = gmap->vert_to_poly[v_index].indices[j];
const int l_index = gmap->vert_to_loop[v_index].indices[j];
- BLI_assert(me->mloop[l_index].v == v_index);
- const MPoly *mp = &me->mpoly[p_index];
+ BLI_assert(ss->mloop[l_index].v == v_index);
+ const MPoly *mp = &ss->mpoly[p_index];
if (!use_face_sel || mp->flag & ME_FACE_SEL) {
Color color_orig = Color(0, 0, 0, 0); /* unused when array is nullptr */
@@ -4084,27 +4088,30 @@ static bool vertex_color_set(Object *ob, ColorPaint4f paintcol_in, CustomDataLay
}
else {
Color *color_layer = static_cast<Color *>(layer->data);
+ const Span<MVert> verts = me->vertices();
+ const Span<MPoly> polys = me->polygons();
+ const Span<MLoop> loops = me->loops();
- const MPoly *mp = me->mpoly;
- for (int i = 0; i < me->totpoly; i++, mp++) {
- if (use_face_sel && !(mp->flag & ME_FACE_SEL)) {
+ for (const int i : polys.index_range()) {
+ const MPoly &poly = polys[i];
+ if (use_face_sel && !(poly.flag & ME_FACE_SEL)) {
continue;
}
int j = 0;
do {
- uint vidx = me->mloop[mp->loopstart + j].v;
+ uint vidx = loops[poly.loopstart + j].v;
- if (!(use_vert_sel && !(me->mvert[vidx].flag & SELECT))) {
+ if (!(use_vert_sel && !(verts[vidx].flag & SELECT))) {
if constexpr (domain == ATTR_DOMAIN_CORNER) {
- color_layer[mp->loopstart + j] = paintcol;
+ color_layer[poly.loopstart + j] = paintcol;
}
else {
color_layer[vidx] = paintcol;
}
}
j++;
- } while (j < mp->totloop);
+ } while (j < poly.totloop);
}
/* remove stale me->mcol, will be added later */
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc
index 8b726c7b942..7aa0adfc3d4 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc
+++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc
@@ -50,7 +50,7 @@ static bool vertex_weight_paint_mode_poll(bContext *C)
Object *ob = CTX_data_active_object(C);
Mesh *me = BKE_mesh_from_object(ob);
return (ob && (ELEM(ob->mode, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT))) &&
- (me && me->totpoly && me->dvert);
+ (me && me->totpoly && !me->deform_verts().is_empty());
}
static void tag_object_after_update(Object *object)
@@ -159,15 +159,15 @@ static IndexMask get_selected_indices(const Mesh &mesh,
Vector<int64_t> &indices)
{
using namespace blender;
- Span<MVert> verts(mesh.mvert, mesh.totvert);
- Span<MPoly> faces(mesh.mpoly, mesh.totpoly);
+ Span<MVert> verts = mesh.vertices();
+ Span<MPoly> polys = mesh.polygons();
bke::AttributeAccessor attributes = bke::mesh_attributes(mesh);
if (mesh.editflag & ME_EDIT_PAINT_FACE_SEL) {
const VArray<bool> selection = attributes.adapt_domain(
- VArray<bool>::ForFunc(faces.size(),
- [&](const int i) { return faces[i].flag & ME_FACE_SEL; }),
+ VArray<bool>::ForFunc(polys.size(),
+ [&](const int i) { return polys[i].flag & ME_FACE_SEL; }),
ATTR_DOMAIN_FACE,
domain);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
index d98660d8939..f40a287adf6 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c
@@ -168,8 +168,9 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *even
ED_view3d_viewcontext_init(C, &vc, depsgraph);
me = BKE_mesh_from_object(vc.obact);
+ const MDeformVert *dvert = BKE_mesh_deform_verts(me);
- if (me && me->dvert && vc.v3d && vc.rv3d && (me->vertex_group_active_index != 0)) {
+ if (me && dvert && vc.v3d && vc.rv3d && (me->vertex_group_active_index != 0)) {
const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
int v_idx_best = -1;
uint index;
@@ -200,7 +201,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *even
ToolSettings *ts = vc.scene->toolsettings;
Brush *brush = BKE_paint_brush(&ts->wpaint->paint);
const int vgroup_active = me->vertex_group_active_index - 1;
- float vgroup_weight = BKE_defvert_find_weight(&me->dvert[v_idx_best], vgroup_active);
+ float vgroup_weight = BKE_defvert_find_weight(&dvert[v_idx_best], vgroup_active);
const int defbase_tot = BLI_listbase_count(&me->vertex_group_names);
bool use_lock_relative = ts->wpaint_lock_relative;
bool *defbase_locked = NULL, *defbase_unlocked = NULL;
@@ -232,7 +233,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *even
bool is_normalized = ts->auto_normalize || use_lock_relative;
vgroup_weight = BKE_defvert_multipaint_collective_weight(
- &me->dvert[v_idx_best], defbase_tot, defbase_sel, defbase_tot_sel, is_normalized);
+ &dvert[v_idx_best], defbase_tot, defbase_sel, defbase_tot_sel, is_normalized);
}
MEM_freeN(defbase_sel);
@@ -243,7 +244,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, const wmEvent *even
defbase_tot, defbase_locked, defbase_unlocked, defbase_locked, defbase_unlocked);
vgroup_weight = BKE_defvert_lock_relative_weight(
- vgroup_weight, &me->dvert[v_idx_best], defbase_tot, defbase_locked, defbase_unlocked);
+ vgroup_weight, &dvert[v_idx_best], defbase_tot, defbase_locked, defbase_unlocked);
}
MEM_SAFE_FREE(defbase_locked);
@@ -316,8 +317,11 @@ static const EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C,
ED_view3d_viewcontext_init(C, &vc, depsgraph);
me = BKE_mesh_from_object(vc.obact);
+ const MPoly *polys = BKE_mesh_polygons(me);
+ const MLoop *loops = BKE_mesh_loops(me);
+ const MDeformVert *dverts = BKE_mesh_deform_verts(me);
- if (me && me->dvert && vc.v3d && vc.rv3d && me->vertex_group_names.first) {
+ if (me && dverts && vc.v3d && vc.rv3d && me->vertex_group_names.first) {
const int defbase_tot = BLI_listbase_count(&me->vertex_group_names);
const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
int *groups = MEM_callocN(defbase_tot * sizeof(int), "groups");
@@ -334,17 +338,17 @@ static const EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C,
if (use_vert_sel) {
if (ED_mesh_pick_vert(C, vc.obact, mval, ED_MESH_PICK_DEFAULT_VERT_DIST, true, &index)) {
- MDeformVert *dvert = &me->dvert[index];
+ const MDeformVert *dvert = &dverts[index];
found |= weight_paint_sample_enum_itemf__helper(dvert, defbase_tot, groups);
}
}
else {
if (ED_mesh_pick_face(C, vc.obact, mval, ED_MESH_PICK_DEFAULT_FACE_DIST, &index)) {
- const MPoly *mp = &me->mpoly[index];
+ const MPoly *mp = &polys[index];
uint fidx = mp->totloop - 1;
do {
- MDeformVert *dvert = &me->dvert[me->mloop[mp->loopstart + fidx].v];
+ const MDeformVert *dvert = &dverts[loops[mp->loopstart + fidx].v];
found |= weight_paint_sample_enum_itemf__helper(dvert, defbase_tot, groups);
} while (fidx--);
}
@@ -441,7 +445,12 @@ static bool weight_paint_set(Object *ob, float paintweight)
/* mutually exclusive, could be made into a */
const short paint_selmode = ME_EDIT_PAINT_SEL_MODE(me);
- if (me->totpoly == 0 || me->dvert == NULL || !me->mpoly) {
+ const MVert *verts = BKE_mesh_vertices(me);
+ const MPoly *polys = BKE_mesh_polygons(me);
+ const MLoop *loops = BKE_mesh_loops(me);
+ MDeformVert *dvert = BKE_mesh_deform_verts_for_write(me);
+
+ if (me->totpoly == 0 || dvert == NULL) {
return false;
}
@@ -453,9 +462,9 @@ static bool weight_paint_set(Object *ob, float paintweight)
}
struct WPaintPrev wpp;
- wpaint_prev_create(&wpp, me->dvert, me->totvert);
+ wpaint_prev_create(&wpp, dvert, me->totvert);
- for (index = 0, mp = me->mpoly; index < me->totpoly; index++, mp++) {
+ for (index = 0, mp = polys; index < me->totpoly; index++, mp++) {
uint fidx = mp->totloop - 1;
if ((paint_selmode == SCE_SELECT_FACE) && !(mp->flag & ME_FACE_SEL)) {
@@ -463,14 +472,14 @@ static bool weight_paint_set(Object *ob, float paintweight)
}
do {
- uint vidx = me->mloop[mp->loopstart + fidx].v;
+ uint vidx = loops[mp->loopstart + fidx].v;
- if (!me->dvert[vidx].flag) {
- if ((paint_selmode == SCE_SELECT_VERTEX) && !(me->mvert[vidx].flag & SELECT)) {
+ if (!dvert[vidx].flag) {
+ if ((paint_selmode == SCE_SELECT_VERTEX) && !(verts[vidx].flag & SELECT)) {
continue;
}
- dw = BKE_defvert_ensure_index(&me->dvert[vidx], vgroup_active);
+ dw = BKE_defvert_ensure_index(&dvert[vidx], vgroup_active);
if (dw) {
dw_prev = BKE_defvert_ensure_index(wpp.wpaint_prev + vidx, vgroup_active);
dw_prev->weight = dw->weight; /* set the undo weight */
@@ -482,11 +491,11 @@ static bool weight_paint_set(Object *ob, float paintweight)
if (j >= 0) {
/* copy, not paint again */
if (vgroup_mirror != -1) {
- dw = BKE_defvert_ensure_index(me->dvert + j, vgroup_mirror);
+ dw = BKE_defvert_ensure_index(dvert + j, vgroup_mirror);
dw_prev = BKE_defvert_ensure_index(wpp.wpaint_prev + j, vgroup_mirror);
}
else {
- dw = BKE_defvert_ensure_index(me->dvert + j, vgroup_active);
+ dw = BKE_defvert_ensure_index(dvert + j, vgroup_active);
dw_prev = BKE_defvert_ensure_index(wpp.wpaint_prev + j, vgroup_active);
}
dw_prev->weight = dw->weight; /* set the undo weight */
@@ -494,14 +503,14 @@ static bool weight_paint_set(Object *ob, float paintweight)
}
}
}
- me->dvert[vidx].flag = 1;
+ dvert[vidx].flag = 1;
}
} while (fidx--);
}
{
- MDeformVert *dv = me->dvert;
+ MDeformVert *dv = dvert;
for (index = me->totvert; index != 0; index--, dv++) {
dv->flag = 0;
}
@@ -574,6 +583,7 @@ typedef struct WPGradient_userData {
struct ARegion *region;
Scene *scene;
Mesh *me;
+ MDeformVert *dvert;
Brush *brush;
const float *sco_start; /* [2] */
const float *sco_end; /* [2] */
@@ -593,7 +603,6 @@ typedef struct WPGradient_userData {
static void gradientVert_update(WPGradient_userData *grad_data, int index)
{
- Mesh *me = grad_data->me;
WPGradient_vertStore *vs = &grad_data->vert_cache->elem[index];
/* Optionally restrict to assigned vertices only. */
@@ -617,7 +626,7 @@ static void gradientVert_update(WPGradient_userData *grad_data, int index)
alpha = BKE_brush_curve_strength_clamped(grad_data->brush, alpha, 1.0f);
if (alpha != 0.0f) {
- MDeformVert *dv = &me->dvert[index];
+ MDeformVert *dv = &grad_data->dvert[index];
MDeformWeight *dw = BKE_defvert_ensure_index(dv, grad_data->def_nr);
// dw->weight = alpha; // testing
int tool = grad_data->brush->blend;
@@ -631,7 +640,7 @@ static void gradientVert_update(WPGradient_userData *grad_data, int index)
vs->flag |= VGRAD_STORE_IS_MODIFIED;
}
else {
- MDeformVert *dv = &me->dvert[index];
+ MDeformVert *dv = &grad_data->dvert[index];
if (vs->flag & VGRAD_STORE_DW_EXIST) {
/* normally we NULL check, but in this case we know it exists */
MDeformWeight *dw = BKE_defvert_find_index(dv, grad_data->def_nr);
@@ -669,10 +678,9 @@ static void gradientVertInit__mapFunc(void *userData,
const float UNUSED(no[3]))
{
WPGradient_userData *grad_data = userData;
- Mesh *me = grad_data->me;
WPGradient_vertStore *vs = &grad_data->vert_cache->elem[index];
- if (grad_data->use_select && !(me->mvert[index].flag & SELECT)) {
+ if (grad_data->use_select && !(grad_data->dvert[index].flag & SELECT)) {
copy_v2_fl(vs->sco, FLT_MAX);
return;
}
@@ -693,7 +701,7 @@ static void gradientVertInit__mapFunc(void *userData,
return;
}
- MDeformVert *dv = &me->dvert[index];
+ MDeformVert *dv = &grad_data->dvert[index];
const MDeformWeight *dw = BKE_defvert_find_index(dv, grad_data->def_nr);
if (dw) {
vs->weight_orig = dw->weight;
@@ -727,8 +735,9 @@ static int paint_weight_gradient_modal(bContext *C, wmOperator *op, const wmEven
if (vert_cache != NULL) {
Mesh *me = ob->data;
if (vert_cache->wpp.wpaint_prev) {
- BKE_defvert_array_free_elems(me->dvert, me->totvert);
- BKE_defvert_array_copy(me->dvert, vert_cache->wpp.wpaint_prev, me->totvert);
+ MDeformVert *dvert = BKE_mesh_deform_verts_for_write(me);
+ BKE_defvert_array_free_elems(dvert, me->totvert);
+ BKE_defvert_array_copy(dvert, vert_cache->wpp.wpaint_prev, me->totvert);
wpaint_prev_destroy(&vert_cache->wpp);
}
MEM_freeN(vert_cache);
@@ -753,6 +762,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
Mesh *me = ob->data;
+ MDeformVert *dverts = BKE_mesh_deform_verts_for_write(me);
int x_start = RNA_int_get(op->ptr, "xstart");
int y_start = RNA_int_get(op->ptr, "ystart");
int x_end = RNA_int_get(op->ptr, "xend");
@@ -774,7 +784,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
data.is_init = true;
wpaint_prev_create(
- &((WPGradient_vertStoreBase *)gesture->user_data.data)->wpp, me->dvert, me->totvert);
+ &((WPGradient_vertStoreBase *)gesture->user_data.data)->wpp, dverts, me->totvert);
/* On initialization only, convert face -> vert sel. */
if (me->editflag & ME_EDIT_PAINT_FACE_SEL) {
@@ -797,6 +807,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
data.region = region;
data.scene = scene;
data.me = ob->data;
+ data.dvert = dverts;
data.sco_start = sco_start;
data.sco_end = sco_end;
data.sco_line_div = 1.0f / len_v2v2(sco_start, sco_end);
@@ -851,7 +862,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op)
const int vgroup_num = BLI_listbase_count(&me->vertex_group_names);
bool *vgroup_validmap = BKE_object_defgroup_validmap_get(ob, vgroup_num);
if (vgroup_validmap != NULL) {
- MDeformVert *dvert = me->dvert;
+ MDeformVert *dvert = dverts;
for (int i = 0; i < me->totvert; i++) {
if ((data.vert_cache->elem[i].flag & VGRAD_STORE_IS_MODIFIED) != 0) {
BKE_defvert_normalize_lock_single(&dvert[i], vgroup_validmap, vgroup_num, data.def_nr);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
index 5a63af4149a..ac16631f115 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c
@@ -59,7 +59,7 @@ bool ED_wpaint_ensure_data(bContext *C,
}
/* if nothing was added yet, we make dverts and a vertex deform group */
- if (!me->dvert) {
+ if (BKE_mesh_deform_verts(me) == NULL) {
BKE_object_defgroup_data_create(&me->id);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index a56755edf92..74fd2f904e5 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -600,10 +600,10 @@ void SCULPT_visibility_sync_all_vertex_to_face_sets(SculptSession *ss)
{
if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) {
for (int i = 0; i < ss->totfaces; i++) {
- MPoly *poly = &ss->mpoly[i];
+ const MPoly *poly = &ss->mpoly[i];
bool poly_visible = true;
for (int l = 0; l < poly->totloop; l++) {
- MLoop *loop = &ss->mloop[poly->loopstart + l];
+ const MLoop *loop = &ss->mloop[poly->loopstart + l];
if (!SCULPT_vertex_visible_get(ss, BKE_pbvh_make_vref(loop->v))) {
poly_visible = false;
}
@@ -644,9 +644,9 @@ static bool sculpt_check_unique_face_set_for_edge_in_base_mesh(SculptSession *ss
MeshElemMap *vert_map = &ss->pmap[v1];
int p1 = -1, p2 = -1;
for (int i = 0; i < ss->pmap[v1].count; i++) {
- MPoly *p = &ss->mpoly[vert_map->indices[i]];
+ const MPoly *p = &ss->mpoly[vert_map->indices[i]];
for (int l = 0; l < p->totloop; l++) {
- MLoop *loop = &ss->mloop[p->loopstart + l];
+ const MLoop *loop = &ss->mloop[p->loopstart + l];
if (loop->v == v2) {
if (p1 == -1) {
p1 = vert_map->indices[i];
@@ -3162,10 +3162,10 @@ void SCULPT_vertcos_to_key(Object *ob, KeyBlock *kb, const float (*vertCos)[3])
/* Modifying of basis key should update mesh. */
if (kb == me->key->refkey) {
- MVert *mvert = me->mvert;
+ MVert *verts = BKE_mesh_vertices_for_write(me);
- for (a = 0; a < me->totvert; a++, mvert++) {
- copy_v3_v3(mvert->co, vertCos[a]);
+ for (a = 0; a < me->totvert; a++) {
+ copy_v3_v3(verts[a].co, vertCos[a]);
}
BKE_mesh_tag_coords_changed(me);
}
@@ -3589,8 +3589,9 @@ static void sculpt_flush_pbvhvert_deform(Object *ob, PBVHVertexIter *vd)
copy_v3_v3(ss->deform_cos[index], vd->co);
copy_v3_v3(ss->orig_cos[index], newco);
+ MVert *verts = BKE_mesh_vertices_for_write(me);
if (!ss->shapekey_active) {
- copy_v3_v3(me->mvert[index].co, newco);
+ copy_v3_v3(verts[index].co, newco);
}
}
@@ -5908,21 +5909,25 @@ void SCULPT_boundary_info_ensure(Object *object)
}
Mesh *base_mesh = BKE_mesh_from_object(object);
+ const MEdge *edges = BKE_mesh_edges(base_mesh);
+ const MPoly *polys = BKE_mesh_polygons(base_mesh);
+ const MLoop *loops = BKE_mesh_loops(base_mesh);
+
ss->vertex_info.boundary = BLI_BITMAP_NEW(base_mesh->totvert, "Boundary info");
int *adjacent_faces_edge_count = MEM_calloc_arrayN(
base_mesh->totedge, sizeof(int), "Adjacent face edge count");
for (int p = 0; p < base_mesh->totpoly; p++) {
- MPoly *poly = &base_mesh->mpoly[p];
+ const MPoly *poly = &polys[p];
for (int l = 0; l < poly->totloop; l++) {
- MLoop *loop = &base_mesh->mloop[l + poly->loopstart];
+ const MLoop *loop = &loops[l + poly->loopstart];
adjacent_faces_edge_count[loop->e]++;
}
}
for (int e = 0; e < base_mesh->totedge; e++) {
if (adjacent_faces_edge_count[e] < 2) {
- MEdge *edge = &base_mesh->medge[e];
+ const MEdge *edge = &edges[e];
BLI_BITMAP_SET(ss->vertex_info.boundary, edge->v1, true);
BLI_BITMAP_SET(ss->vertex_info.boundary, edge->v2, true);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
index 000b69cc2ba..ad8a1cde9dc 100644
--- a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
@@ -210,8 +210,6 @@ static void SCULPT_dynamic_topology_disable_ex(
&geometry->ldata, &me->ldata, CD_MASK_MESH.lmask, CD_DUPLICATE, geometry->totloop);
CustomData_copy(
&geometry->pdata, &me->pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, geometry->totpoly);
-
- BKE_mesh_update_customdata_pointers(me, false);
}
else {
BKE_sculptsession_bm_to_me(ob, true);
diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c b/source/blender/editors/sculpt_paint/sculpt_expand.c
index 75cc966c0b2..63d5c14a931 100644
--- a/source/blender/editors/sculpt_paint/sculpt_expand.c
+++ b/source/blender/editors/sculpt_paint/sculpt_expand.c
@@ -690,7 +690,6 @@ static float *sculpt_expand_diagonals_falloff_create(Object *ob, const PBVHVertR
}
/* Propagate the falloff increasing the value by 1 each time a new vertex is visited. */
- Mesh *mesh = ob->data;
while (!BLI_gsqueue_is_empty(queue)) {
PBVHVertRef v_next;
BLI_gsqueue_pop(queue, &v_next);
@@ -698,9 +697,9 @@ static float *sculpt_expand_diagonals_falloff_create(Object *ob, const PBVHVertR
int v_next_i = BKE_pbvh_vertex_to_index(ss->pbvh, v_next);
for (int j = 0; j < ss->pmap[v_next_i].count; j++) {
- MPoly *p = &ss->mpoly[ss->pmap[v_next_i].indices[j]];
+ const MPoly *p = &ss->mpoly[ss->pmap[v_next_i].indices[j]];
for (int l = 0; l < p->totloop; l++) {
- const PBVHVertRef neighbor_v = BKE_pbvh_make_vref(mesh->mloop[p->loopstart + l].v);
+ const PBVHVertRef neighbor_v = BKE_pbvh_make_vref(ss->mloop[p->loopstart + l].v);
if (BLI_BITMAP_TEST(visited_vertices, neighbor_v.i)) {
continue;
}
@@ -777,11 +776,11 @@ static void sculpt_expand_grids_to_faces_falloff(SculptSession *ss,
Mesh *mesh,
ExpandCache *expand_cache)
{
-
+ const MPoly *polys = BKE_mesh_polygons(mesh);
const CCGKey *key = BKE_pbvh_get_grid_key(ss->pbvh);
for (int p = 0; p < mesh->totpoly; p++) {
- MPoly *poly = &mesh->mpoly[p];
+ const MPoly *poly = &polys[p];
float accum = 0.0f;
for (int l = 0; l < poly->totloop; l++) {
const int grid_loop_index = (poly->loopstart + l) * key->grid_area;
@@ -795,11 +794,14 @@ static void sculpt_expand_grids_to_faces_falloff(SculptSession *ss,
static void sculpt_expand_vertex_to_faces_falloff(Mesh *mesh, ExpandCache *expand_cache)
{
+ const MPoly *polys = BKE_mesh_polygons(mesh);
+ const MLoop *loops = BKE_mesh_loops(mesh);
+
for (int p = 0; p < mesh->totpoly; p++) {
- MPoly *poly = &mesh->mpoly[p];
+ const MPoly *poly = &polys[p];
float accum = 0.0f;
for (int l = 0; l < poly->totloop; l++) {
- MLoop *loop = &mesh->mloop[l + poly->loopstart];
+ const MLoop *loop = &loops[l + poly->loopstart];
accum += expand_cache->vert_falloff[loop->v];
}
expand_cache->face_falloff[p] = accum / poly->totloop;
@@ -1093,10 +1095,10 @@ static void sculpt_expand_snap_initialize_from_enabled(SculptSession *ss,
}
for (int p = 0; p < totface; p++) {
- MPoly *poly = &ss->mpoly[p];
+ const MPoly *poly = &ss->mpoly[p];
bool any_disabled = false;
for (int l = 0; l < poly->totloop; l++) {
- MLoop *loop = &ss->mloop[l + poly->loopstart];
+ const MLoop *loop = &ss->mloop[l + poly->loopstart];
if (!BLI_BITMAP_TEST(enabled_vertices, loop->v)) {
any_disabled = true;
break;
@@ -1938,6 +1940,8 @@ static void sculpt_expand_delete_face_set_id(int *r_face_sets,
{
const int totface = ss->totfaces;
MeshElemMap *pmap = ss->pmap;
+ const MPoly *polys = BKE_mesh_polygons(mesh);
+ const MLoop *loops = BKE_mesh_loops(mesh);
/* Check that all the face sets IDs in the mesh are not equal to `delete_id`
* before attempting to delete it. */
@@ -1972,9 +1976,9 @@ static void sculpt_expand_delete_face_set_id(int *r_face_sets,
while (BLI_LINKSTACK_SIZE(queue)) {
const int f_index = POINTER_AS_INT(BLI_LINKSTACK_POP(queue));
int other_id = delete_id;
- const MPoly *c_poly = &mesh->mpoly[f_index];
+ const MPoly *c_poly = &polys[f_index];
for (int l = 0; l < c_poly->totloop; l++) {
- const MLoop *c_loop = &mesh->mloop[c_poly->loopstart + l];
+ const MLoop *c_loop = &loops[c_poly->loopstart + l];
const MeshElemMap *vert_map = &pmap[c_loop->v];
for (int i = 0; i < vert_map->count; i++) {
diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c
index a2a34566bb6..c8e546ecef3 100644
--- a/source/blender/editors/sculpt_paint/sculpt_face_set.c
+++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c
@@ -1096,13 +1096,16 @@ static void sculpt_face_set_grow(Object *ob,
const bool modify_hidden)
{
Mesh *mesh = BKE_mesh_from_object(ob);
+ const MPoly *polys = BKE_mesh_polygons(mesh);
+ const MLoop *loops = BKE_mesh_loops(mesh);
+
for (int p = 0; p < mesh->totpoly; p++) {
if (!modify_hidden && prev_face_sets[p] <= 0) {
continue;
}
- const MPoly *c_poly = &mesh->mpoly[p];
+ const MPoly *c_poly = &polys[p];
for (int l = 0; l < c_poly->totloop; l++) {
- const MLoop *c_loop = &mesh->mloop[c_poly->loopstart + l];
+ const MLoop *c_loop = &loops[c_poly->loopstart + l];
const MeshElemMap *vert_map = &ss->pmap[c_loop->v];
for (int i = 0; i < vert_map->count; i++) {
const int neighbor_face_index = vert_map->indices[i];
@@ -1124,14 +1127,16 @@ static void sculpt_face_set_shrink(Object *ob,
const bool modify_hidden)
{
Mesh *mesh = BKE_mesh_from_object(ob);
+ const MPoly *polys = BKE_mesh_polygons(mesh);
+ const MLoop *loops = BKE_mesh_loops(mesh);
for (int p = 0; p < mesh->totpoly; p++) {
if (!modify_hidden && prev_face_sets[p] <= 0) {
continue;
}
if (abs(prev_face_sets[p]) == active_face_set_id) {
- const MPoly *c_poly = &mesh->mpoly[p];
+ const MPoly *c_poly = &polys[p];
for (int l = 0; l < c_poly->totloop; l++) {
- const MLoop *c_loop = &mesh->mloop[c_poly->loopstart + l];
+ const MLoop *c_loop = &loops[c_poly->loopstart + l];
const MeshElemMap *vert_map = &ss->pmap[c_loop->v];
for (int i = 0; i < vert_map->count; i++) {
const int neighbor_face_index = vert_map->indices[i];
diff --git a/source/blender/editors/sculpt_paint/sculpt_geodesic.c b/source/blender/editors/sculpt_paint/sculpt_geodesic.c
index ecf8c4586ae..4b871da1d02 100644
--- a/source/blender/editors/sculpt_paint/sculpt_geodesic.c
+++ b/source/blender/editors/sculpt_paint/sculpt_geodesic.c
@@ -37,7 +37,6 @@
#include "DEG_depsgraph.h"
#include "WM_api.h"
-#include "WM_message.h"
#include "WM_toolsystem.h"
#include "WM_types.h"
@@ -108,8 +107,10 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
const float limit_radius_sq = limit_radius * limit_radius;
- MEdge *edges = mesh->medge;
MVert *verts = SCULPT_mesh_deformed_mverts_get(ss);
+ const MEdge *edges = BKE_mesh_edges(mesh);
+ const MPoly *polys = BKE_mesh_polygons(mesh);
+ const MLoop *loops = BKE_mesh_loops(mesh);
float *dists = MEM_malloc_arrayN(totvert, sizeof(float), "distances");
BLI_bitmap *edge_tag = BLI_BITMAP_NEW(totedge, "edge tag");
@@ -117,16 +118,15 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
if (!ss->epmap) {
BKE_mesh_edge_poly_map_create(&ss->epmap,
&ss->epmap_mem,
- mesh->medge,
+ edges,
mesh->totedge,
- mesh->mpoly,
+ polys,
mesh->totpoly,
- mesh->mloop,
+ loops,
mesh->totloop);
}
if (!ss->vemap) {
- BKE_mesh_vert_edge_map_create(
- &ss->vemap, &ss->vemap_mem, mesh->medge, mesh->totvert, mesh->totedge);
+ BKE_mesh_vert_edge_map_create(&ss->vemap, &ss->vemap_mem, edges, mesh->totvert, mesh->totedge);
}
/* Both contain edge indices encoded as *void. */
@@ -202,10 +202,10 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
if (ss->face_sets[poly] <= 0) {
continue;
}
- const MPoly *mpoly = &mesh->mpoly[poly];
+ const MPoly *mpoly = &polys[poly];
for (int loop_index = 0; loop_index < mpoly->totloop; loop_index++) {
- const MLoop *mloop = &mesh->mloop[loop_index + mpoly->loopstart];
+ const MLoop *mloop = &loops[loop_index + mpoly->loopstart];
const int v_other = mloop->v;
if (ELEM(v_other, v1, v2)) {
continue;
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index e667f9ce2fc..07dbb5964bf 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -627,8 +627,6 @@ static void sculpt_undo_geometry_restore_data(SculptUndoNodeGeometry *geometry,
CustomData_copy(
&geometry->pdata, &mesh->pdata, CD_MASK_MESH.pmask, CD_DUPLICATE, geometry->totpoly);
- BKE_mesh_update_customdata_pointers(mesh, false);
-
BKE_mesh_runtime_clear_cache(mesh);
}