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.cc12
-rw-r--r--source/blender/editors/sculpt_paint/curves_sculpt_puff.cc10
-rw-r--r--source/blender/editors/sculpt_paint/curves_sculpt_slide.cc14
-rw-r--r--source/blender/editors/sculpt_paint/paint_hide.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c56
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c12
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.cc12
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.cc33
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_boundary.c12
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_brush_types.c46
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_cloth.c10
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_dyntopo.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_face_set.cc10
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_filter_mesh.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_geodesic.c23
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_paint_image.cc26
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_pose.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_smooth.c6
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_transform.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c22
23 files changed, 161 insertions, 169 deletions
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
index 0d2c2d3f0c9..322cdd1d8eb 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
@@ -90,7 +90,7 @@ struct AddOperationExecutor {
Object *surface_ob_eval_ = nullptr;
Mesh *surface_eval_ = nullptr;
- Span<MVert> surface_verts_eval_;
+ Span<float3> surface_positions_eval_;
Span<MLoop> surface_loops_eval_;
Span<MLoopTri> surface_looptris_eval_;
VArraySpan<float2> surface_uv_map_eval_;
@@ -142,7 +142,7 @@ struct AddOperationExecutor {
report_empty_evaluated_surface(stroke_extension.reports);
return;
}
- surface_verts_eval_ = surface_eval_->verts();
+ surface_positions_eval_ = surface_eval_->positions();
surface_loops_eval_ = surface_eval_->loops();
surface_looptris_eval_ = surface_eval_->looptris();
BKE_bvhtree_from_mesh_get(&surface_bvh_eval_, surface_eval_, BVHTREE_FROM_LOOPTRI, 2);
@@ -295,7 +295,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_verts_eval_, surface_loops_eval_, looptri, brush_pos_su);
+ surface_positions_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_);
@@ -420,9 +420,9 @@ struct AddOperationExecutor {
brush_radius_su,
[&](const int index, const float3 & /*co*/, const float /*dist_sq*/) {
const MLoopTri &looptri = surface_looptris_eval_[index];
- 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;
+ const float3 &v0_su = surface_positions_eval_[surface_loops_eval_[looptri.tri[0]].v];
+ const float3 &v1_su = surface_positions_eval_[surface_loops_eval_[looptri.tri[1]].v];
+ const float3 &v2_su = surface_positions_eval_[surface_loops_eval_[looptri.tri[2]].v];
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 b4e949106e7..465d3e4c0d1 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_puff.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_puff.cc
@@ -70,7 +70,7 @@ struct PuffOperationExecutor {
Object *surface_ob_ = nullptr;
Mesh *surface_ = nullptr;
- Span<MVert> surface_verts_;
+ Span<float3> surface_positions_;
Span<MLoop> surface_loops_;
Span<MLoopTri> surface_looptris_;
Span<float3> corner_normals_su_;
@@ -119,7 +119,7 @@ struct PuffOperationExecutor {
reinterpret_cast<const float3 *>(CustomData_get_layer(&surface_->ldata, CD_NORMAL)),
surface_->totloop};
- surface_verts_ = surface_->verts();
+ surface_positions_ = surface_->positions();
surface_loops_ = surface_->loops();
surface_looptris_ = surface_->looptris();
BKE_bvhtree_from_mesh_get(&surface_bvh_, surface_, BVHTREE_FROM_LOOPTRI, 2);
@@ -291,9 +291,9 @@ struct PuffOperationExecutor {
const MLoopTri &looptri = surface_looptris_[nearest.index];
const float3 closest_pos_su = nearest.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;
+ const float3 &v0_su = surface_positions_[surface_loops_[looptri.tri[0]].v];
+ const float3 &v1_su = surface_positions_[surface_loops_[looptri.tri[1]].v];
+ const float3 &v2_su = surface_positions_[surface_loops_[looptri.tri[2]].v];
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 ae89bc1c58b..199efab86a6 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc
@@ -104,7 +104,7 @@ struct SlideOperationExecutor {
Object *surface_ob_eval_ = nullptr;
Mesh *surface_eval_ = nullptr;
- Span<MVert> surface_verts_eval_;
+ Span<float3> surface_positions_eval_;
Span<MLoop> surface_loops_eval_;
Span<MLoopTri> surface_looptris_eval_;
VArraySpan<float2> surface_uv_map_eval_;
@@ -197,7 +197,7 @@ struct SlideOperationExecutor {
return;
}
surface_looptris_eval_ = surface_eval_->looptris();
- surface_verts_eval_ = surface_eval_->verts();
+ surface_positions_eval_ = surface_eval_->positions();
surface_loops_eval_ = surface_eval_->loops();
surface_uv_map_eval_ = surface_eval_->attributes().lookup<float2>(uv_map_name,
ATTR_DOMAIN_CORNER);
@@ -313,7 +313,7 @@ struct SlideOperationExecutor {
{
const float4x4 brush_transform_inv = brush_transform.inverted();
- const Span<MVert> verts_orig_su = surface_orig_->verts();
+ const Span<float3> positions_orig_su = surface_orig_->positions();
const Span<MLoop> loops_orig = surface_orig_->loops();
MutableSpan<float3> positions_orig_cu = curves_orig_->positions_for_write();
@@ -377,7 +377,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_verts_eval_, surface_loops_eval_, looptri_eval, hit_pos_eval_su);
+ surface_positions_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]],
@@ -404,9 +404,9 @@ struct SlideOperationExecutor {
const float3 new_first_pos_orig_cu =
transforms_.surface_to_curves *
attribute_math::mix3<float3>(bary_weights_orig,
- verts_orig_su[loops_orig[looptri_orig.tri[0]].v].co,
- verts_orig_su[loops_orig[looptri_orig.tri[1]].v].co,
- verts_orig_su[loops_orig[looptri_orig.tri[2]].v].co);
+ positions_orig_su[loops_orig[looptri_orig.tri[0]].v],
+ positions_orig_su[loops_orig[looptri_orig.tri[1]].v],
+ positions_orig_su[loops_orig[looptri_orig.tri[2]].v]);
/* Actually transform curve points. */
const float4x4 slide_transform = this->get_slide_transform(
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index 9e435ee0748..83be327fc38 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -68,14 +68,13 @@ static void partialvis_update_mesh(Object *ob,
float planes[4][4])
{
Mesh *me = ob->data;
- MVert *mvert;
+ const float(*positions)[3] = BKE_pbvh_get_positions(pbvh);
const float *paint_mask;
- const int *vert_indices;
int totvert, i;
bool any_changed = false, any_visible = false;
BKE_pbvh_node_num_verts(pbvh, node, NULL, &totvert);
- BKE_pbvh_node_get_verts(pbvh, node, &vert_indices, &mvert);
+ const int *vert_indices = BKE_pbvh_node_get_vert_indices(node);
paint_mask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK);
bool *hide_vert = CustomData_get_layer_named(&me->vdata, CD_PROP_BOOL, ".hide_vert");
@@ -87,11 +86,10 @@ static void partialvis_update_mesh(Object *ob,
SCULPT_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN);
for (i = 0; i < totvert; i++) {
- MVert *v = &mvert[vert_indices[i]];
float vmask = paint_mask ? paint_mask[vert_indices[i]] : 0;
/* Hide vertex if in the hide volume. */
- if (is_effected(area, planes, v->co, vmask)) {
+ if (is_effected(area, planes, positions[vert_indices[i]], vmask)) {
hide_vert[vert_indices[i]] = (action == PARTIALVIS_HIDE);
any_changed = true;
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index c85044bf915..47f1e7ec160 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -412,7 +412,7 @@ typedef struct ProjPaintState {
int totedge_eval;
int totvert_eval;
- const MVert *mvert_eval;
+ const float (*positions_eval)[3];
const float (*vert_normals)[3];
const MEdge *medge_eval;
const MPoly *mpoly_eval;
@@ -920,9 +920,9 @@ static bool project_bucket_point_occluded(const ProjPaintState *ps,
if (do_clip) {
const float *vtri_co[3] = {
- ps->mvert_eval[ps->mloop_eval[lt->tri[0]].v].co,
- ps->mvert_eval[ps->mloop_eval[lt->tri[1]].v].co,
- ps->mvert_eval[ps->mloop_eval[lt->tri[2]].v].co,
+ ps->positions_eval[ps->mloop_eval[lt->tri[0]].v],
+ ps->positions_eval[ps->mloop_eval[lt->tri[1]].v],
+ ps->positions_eval[ps->mloop_eval[lt->tri[2]].v],
};
isect_ret = project_paint_occlude_ptv_clip(
pixelScreenCo, UNPACK3(vtri_ss), UNPACK3(vtri_co), w, ps->is_ortho, ps->rv3d);
@@ -1734,9 +1734,9 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps,
/* In case the normalizing per pixel isn't optimal,
* we could cache or access from evaluated mesh. */
normal_tri_v3(no,
- ps->mvert_eval[lt_vtri[0]].co,
- ps->mvert_eval[lt_vtri[1]].co,
- ps->mvert_eval[lt_vtri[2]].co);
+ ps->positions_eval[lt_vtri[0]],
+ ps->positions_eval[lt_vtri[1]],
+ ps->positions_eval[lt_vtri[2]]);
}
if (UNLIKELY(ps->is_flip_object)) {
@@ -1751,9 +1751,9 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps,
/* Annoying but for the perspective view we need to get the pixels location in 3D space :/ */
float viewDirPersp[3];
const float *co1, *co2, *co3;
- co1 = ps->mvert_eval[lt_vtri[0]].co;
- co2 = ps->mvert_eval[lt_vtri[1]].co;
- co3 = ps->mvert_eval[lt_vtri[2]].co;
+ co1 = ps->positions_eval[lt_vtri[0]];
+ co2 = ps->positions_eval[lt_vtri[1]];
+ co3 = ps->positions_eval[lt_vtri[2]];
/* Get the direction from the viewPoint to the pixel and normalize */
viewDirPersp[0] = (ps->viewPos[0] - (w[0] * co1[0] + w[1] * co2[0] + w[2] * co3[0]));
@@ -3027,9 +3027,9 @@ static void project_paint_face_init(const ProjPaintState *ps,
const bool do_backfacecull = ps->do_backfacecull;
const bool do_clip = RV3D_CLIPPING_ENABLED(ps->v3d, ps->rv3d);
- vCo[0] = ps->mvert_eval[lt_vtri[0]].co;
- vCo[1] = ps->mvert_eval[lt_vtri[1]].co;
- vCo[2] = ps->mvert_eval[lt_vtri[2]].co;
+ vCo[0] = ps->positions_eval[lt_vtri[0]];
+ vCo[1] = ps->positions_eval[lt_vtri[1]];
+ vCo[2] = ps->positions_eval[lt_vtri[2]];
/* Use lt_uv_pxoffset instead of lt_tri_uv so we can offset the UV half a pixel
* this is done so we can avoid offsetting all the pixels by 0.5 which causes
@@ -3126,9 +3126,9 @@ static void project_paint_face_init(const ProjPaintState *ps,
* because it is a relatively expensive operation. */
if (do_clip || do_3d_mapping) {
interp_v3_v3v3v3(wco,
- ps->mvert_eval[lt_vtri[0]].co,
- ps->mvert_eval[lt_vtri[1]].co,
- ps->mvert_eval[lt_vtri[2]].co,
+ ps->positions_eval[lt_vtri[0]],
+ ps->positions_eval[lt_vtri[1]],
+ ps->positions_eval[lt_vtri[2]],
w);
if (do_clip && ED_view3d_clipping_test(ps->rv3d, wco, true)) {
/* Watch out that no code below this needs to run */
@@ -3789,7 +3789,6 @@ static void proj_paint_state_viewport_init(ProjPaintState *ps, const char symmet
static void proj_paint_state_screen_coords_init(ProjPaintState *ps, const int diameter)
{
- const MVert *mv;
float *projScreenCo;
float projMargin;
int a;
@@ -3800,8 +3799,8 @@ static void proj_paint_state_screen_coords_init(ProjPaintState *ps, const int di
projScreenCo = *ps->screenCoords;
if (ps->is_ortho) {
- for (a = 0, mv = ps->mvert_eval; a < ps->totvert_eval; a++, mv++, projScreenCo += 4) {
- mul_v3_m4v3(projScreenCo, ps->projectMat, mv->co);
+ for (a = 0; a < ps->totvert_eval; a++, projScreenCo += 4) {
+ mul_v3_m4v3(projScreenCo, ps->projectMat, ps->positions_eval[a]);
/* screen space, not clamped */
projScreenCo[0] = (float)(ps->winx * 0.5f) + (ps->winx * 0.5f) * projScreenCo[0];
@@ -3810,8 +3809,8 @@ static void proj_paint_state_screen_coords_init(ProjPaintState *ps, const int di
}
}
else {
- for (a = 0, mv = ps->mvert_eval; a < ps->totvert_eval; a++, mv++, projScreenCo += 4) {
- copy_v3_v3(projScreenCo, mv->co);
+ for (a = 0; a < ps->totvert_eval; a++, projScreenCo += 4) {
+ copy_v3_v3(projScreenCo, ps->positions_eval[a]);
projScreenCo[3] = 1.0f;
mul_m4_v4(ps->projectMat, projScreenCo);
@@ -3880,7 +3879,7 @@ static void proj_paint_state_cavity_init(ProjPaintState *ps)
for (a = 0, me = ps->medge_eval; a < ps->totedge_eval; a++, me++) {
float e[3];
- sub_v3_v3v3(e, ps->mvert_eval[me->v1].co, ps->mvert_eval[me->v2].co);
+ sub_v3_v3v3(e, ps->positions_eval[me->v1], ps->positions_eval[me->v2]);
normalize_v3(e);
add_v3_v3(edges[me->v2], e);
counter[me->v2]++;
@@ -3951,13 +3950,12 @@ static void proj_paint_state_vert_flags_init(ProjPaintState *ps)
{
if (ps->do_backfacecull && ps->do_mask_normal) {
float viewDirPersp[3];
- const MVert *mv;
float no[3];
int a;
ps->vertFlags = MEM_callocN(sizeof(char) * ps->totvert_eval, "paint-vertFlags");
- for (a = 0, mv = ps->mvert_eval; a < ps->totvert_eval; a++, mv++) {
+ for (a = 0; a < ps->totvert_eval; a++) {
copy_v3_v3(no, ps->vert_normals[a]);
if (UNLIKELY(ps->is_flip_object)) {
negate_v3(no);
@@ -3970,7 +3968,7 @@ static void proj_paint_state_vert_flags_init(ProjPaintState *ps)
}
}
else {
- sub_v3_v3v3(viewDirPersp, ps->viewPos, mv->co);
+ sub_v3_v3v3(viewDirPersp, ps->viewPos, ps->positions_eval[a]);
normalize_v3(viewDirPersp);
if (UNLIKELY(ps->is_flip_object)) {
negate_v3(viewDirPersp);
@@ -4057,7 +4055,7 @@ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *p
}
ps->mat_array[totmat - 1] = NULL;
- ps->mvert_eval = BKE_mesh_verts(ps->me_eval);
+ ps->positions_eval = BKE_mesh_positions(ps->me_eval);
ps->vert_normals = BKE_mesh_vertex_normals_ensure(ps->me_eval);
if (ps->do_mask_cavity) {
ps->medge_eval = BKE_mesh_edges(ps->me_eval);
@@ -5670,9 +5668,9 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po
UnifiedPaintSettings *ups = &ps->scene->toolsettings->unified_paint_settings;
interp_v3_v3v3v3(world,
- ps->mvert_eval[lt_vtri[0]].co,
- ps->mvert_eval[lt_vtri[1]].co,
- ps->mvert_eval[lt_vtri[2]].co,
+ ps->positions_eval[lt_vtri[0]],
+ ps->positions_eval[lt_vtri[1]],
+ ps->positions_eval[lt_vtri[2]],
w);
ups->average_stroke_counter++;
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index ce7db91571c..82ed4418362 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -1137,7 +1137,7 @@ static void sculpt_gesture_trim_geometry_generate(SculptGestureContext *sgcontex
const float(*ob_imat)[4] = vc->obact->world_to_object;
/* Write vertices coordinates for the front face. */
- MVert *verts = BKE_mesh_verts_for_write(trim_operation->mesh);
+ float(*positions)[3] = BKE_mesh_positions_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++) {
@@ -1149,7 +1149,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(verts[i].co, ob_imat, new_point);
+ mul_v3_m4v3(positions[i], ob_imat, new_point);
mul_v3_m4v3(trim_operation->true_mesh_co[i], ob_imat, new_point);
}
@@ -1164,7 +1164,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(verts[i + tot_screen_points].co, ob_imat, new_point);
+ mul_v3_m4v3(positions[i + tot_screen_points], ob_imat, new_point);
mul_v3_m4v3(trim_operation->true_mesh_co[i + tot_screen_points], ob_imat, new_point);
}
@@ -1346,9 +1346,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_verts_for_write(trim_mesh);
+ float(*positions)[3] = BKE_mesh_positions_for_write(trim_mesh);
for (int i = 0; i < trim_mesh->totvert; i++) {
- flip_v3_v3(verts[i].co, trim_operation->true_mesh_co[i], sgcontext->symmpass);
+ flip_v3_v3(positions[i], trim_operation->true_mesh_co[i], sgcontext->symmpass);
}
sculpt_gesture_trim_normals_update(sgcontext);
sculpt_gesture_apply_trim(sgcontext);
@@ -1457,7 +1457,7 @@ static void project_line_gesture_apply_task_cb(void *__restrict userdata,
continue;
}
add_v3_v3(vd.co, disp);
- if (vd.mvert) {
+ if (vd.mesh_positions) {
BKE_pbvh_vert_tag_update_normal(sgcontext->ss->pbvh, vd.vertex);
}
any_updated = true;
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index f87ca073c82..a33fa3b45ae 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -288,7 +288,7 @@ static void imapaint_pick_uv(
const MLoopTri *lt = BKE_mesh_runtime_looptri_ensure(me_eval);
const int tottri = BKE_mesh_runtime_looptri_len(me_eval);
- const MVert *mvert = BKE_mesh_verts(me_eval);
+ const float(*positions)[3] = BKE_mesh_positions(me_eval);
const MLoop *mloop = BKE_mesh_loops(me_eval);
const int *index_mp_to_orig = CustomData_get_layer(&me_eval->pdata, CD_ORIGINDEX);
@@ -317,7 +317,7 @@ static void imapaint_pick_uv(
float tri_co[3][3];
for (int j = 3; j--;) {
- copy_v3_v3(tri_co[j], mvert[mloop[lt->tri[j]].v].co);
+ copy_v3_v3(tri_co[j], positions[mloop[lt->tri[j]].v]);
}
if (mode == PAINT_CANVAS_SOURCE_MATERIAL) {
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc
index 8758d3fa83f..f9f22173c05 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.cc
+++ b/source/blender/editors/sculpt_paint/paint_vertex.cc
@@ -2065,7 +2065,7 @@ static void do_wpaint_brush_smear_task_cb_ex(void *__restrict userdata,
* Otherwise, take the current vert. */
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 = &ss->mvert[v_index];
+ const float3 &mv_curr = ss->positions[v_index];
/* If the vertex is selected */
if (!(use_face_sel || use_vert_sel) || select_vert[v_index]) {
@@ -2092,11 +2092,11 @@ static void do_wpaint_brush_smear_task_cb_ex(void *__restrict userdata,
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 = &ss->mvert[v_other_index];
+ const float3 &mv_other = ss->positions[v_other_index];
/* Get the direction from the selected vert to the neighbor. */
float other_dir[3];
- sub_v3_v3v3(other_dir, mv_curr->co, mv_other->co);
+ sub_v3_v3v3(other_dir, mv_curr, mv_other);
project_plane_v3_v3v3(other_dir, other_dir, cache->view_normal);
normalize_v3(other_dir);
@@ -3302,7 +3302,7 @@ static void do_vpaint_brush_smear(bContext *C,
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 = &ss->mvert[v_index];
+ const float3 &mv_curr = &ss->positions[v_index];
/* if the vertex is selected for painting. */
if (!use_vert_sel || select_vert[v_index]) {
@@ -3339,12 +3339,12 @@ static void do_vpaint_brush_smear(bContext *C,
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 = &ss->mvert[v_other_index];
+ const float3 &mv_other = &ss->positions[v_other_index];
/* Get the direction from the
* selected vert to the neighbor. */
float other_dir[3];
- sub_v3_v3v3(other_dir, mv_curr->co, mv_other->co);
+ sub_v3_v3v3(other_dir, mv_curr, mv_other);
project_plane_v3_v3v3(other_dir, other_dir, cache->view_normal);
normalize_v3(other_dir);
diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc
index 684fcdbff9e..3021e058719 100644
--- a/source/blender/editors/sculpt_paint/sculpt.cc
+++ b/source/blender/editors/sculpt_paint/sculpt.cc
@@ -106,10 +106,10 @@ const float *SCULPT_vertex_co_get(SculptSession *ss, PBVHVertRef vertex)
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES: {
if (ss->shapekey_active || ss->deform_modifiers_active) {
- const MVert *mverts = BKE_pbvh_get_verts(ss->pbvh);
- return mverts[vertex.i].co;
+ const float(*positions)[3] = BKE_pbvh_get_positions(ss->pbvh);
+ return positions[vertex.i];
}
- return ss->mvert[vertex.i].co;
+ return ss->positions[vertex.i];
}
case PBVH_BMESH:
return ((BMVert *)vertex.i)->co;
@@ -185,12 +185,12 @@ const float *SCULPT_vertex_co_for_grab_active_get(SculptSession *ss, PBVHVertRef
if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) {
/* Always grab active shape key if the sculpt happens on shapekey. */
if (ss->shapekey_active) {
- const MVert *mverts = BKE_pbvh_get_verts(ss->pbvh);
- return mverts[vertex.i].co;
+ const float(*positions)[3] = BKE_pbvh_get_positions(ss->pbvh);
+ return positions[vertex.i];
}
/* Sculpting on the base mesh. */
- return ss->mvert[vertex.i].co;
+ return ss->positions[vertex.i];
}
/* Everything else, such as sculpting on multires. */
@@ -271,14 +271,14 @@ void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3])
SCULPT_vertex_normal_get(ss, SCULPT_active_vertex_get(ss), normal);
}
-MVert *SCULPT_mesh_deformed_mverts_get(SculptSession *ss)
+float (*SCULPT_mesh_deformed_positions_get(SculptSession *ss))[3]
{
switch (BKE_pbvh_type(ss->pbvh)) {
case PBVH_FACES:
if (ss->shapekey_active || ss->deform_modifiers_active) {
- return BKE_pbvh_get_verts(ss->pbvh);
+ return BKE_pbvh_get_positions(ss->pbvh);
}
- return ss->mvert;
+ return ss->positions;
case PBVH_BMESH:
case PBVH_GRIDS:
return nullptr;
@@ -1500,7 +1500,7 @@ static void paint_mesh_restore_co_task_cb(void *__restrict userdata,
else {
copy_v3_v3(vd.fno, orig_data.no);
}
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -3134,7 +3134,7 @@ static void do_gravity_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], offset, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -3202,12 +3202,7 @@ 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 *verts = BKE_mesh_verts_for_write(me);
-
- for (a = 0; a < me->totvert; a++) {
- copy_v3_v3(verts[a].co, vertCos[a]);
- }
- BKE_mesh_tag_coords_changed(me);
+ BKE_mesh_vert_coords_apply(me, vertCos);
}
/* Apply new coords on active key block, no need to re-allocate kb->data here! */
@@ -3636,9 +3631,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_verts_for_write(me);
+ float(*positions)[3] = BKE_mesh_positions_for_write(me);
if (!ss->shapekey_active) {
- copy_v3_v3(verts[index].co, newco);
+ copy_v3_v3(positions[index], newco);
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_boundary.c b/source/blender/editors/sculpt_paint/sculpt_boundary.c
index 355f260ae11..bd8f678182f 100644
--- a/source/blender/editors/sculpt_paint/sculpt_boundary.c
+++ b/source/blender/editors/sculpt_paint/sculpt_boundary.c
@@ -700,7 +700,7 @@ static void do_boundary_brush_bend_task_cb_ex(void *__restrict userdata,
angle * boundary->edit_info[vd.index].strength_factor * mask * automask);
add_v3_v3(target_co, boundary->bend.pivot_positions[vd.index]);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -751,7 +751,7 @@ static void do_boundary_brush_slide_task_cb_ex(void *__restrict userdata,
boundary->edit_info[vd.index].strength_factor * disp * mask * automask *
strength);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -802,7 +802,7 @@ static void do_boundary_brush_inflate_task_cb_ex(void *__restrict userdata,
boundary->edit_info[vd.index].strength_factor * disp * mask * automask *
strength);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -850,7 +850,7 @@ static void do_boundary_brush_grab_task_cb_ex(void *__restrict userdata,
ss->cache->grab_delta_symmetry,
boundary->edit_info[vd.index].strength_factor * mask * automask * strength);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -909,7 +909,7 @@ static void do_boundary_brush_twist_task_cb_ex(void *__restrict userdata,
angle * mask * automask * boundary->edit_info[vd.index].strength_factor);
add_v3_v3(target_co, boundary->twist.pivot_position);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -968,7 +968,7 @@ static void do_boundary_brush_smooth_task_cb_ex(void *__restrict userdata,
madd_v3_v3v3fl(
target_co, vd.co, disp, boundary->edit_info[vd.index].strength_factor * mask * strength);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_brush_types.c b/source/blender/editors/sculpt_paint/sculpt_brush_types.c
index 666fa884e03..c24bdba662a 100644
--- a/source/blender/editors/sculpt_paint/sculpt_brush_types.c
+++ b/source/blender/editors/sculpt_paint/sculpt_brush_types.c
@@ -279,7 +279,7 @@ static void do_draw_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], offset, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -384,7 +384,7 @@ static void do_fill_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -489,7 +489,7 @@ static void do_scrape_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -614,7 +614,7 @@ static void do_clay_thumb_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -776,7 +776,7 @@ static void do_flatten_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -940,7 +940,7 @@ static void do_clay_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -1074,7 +1074,7 @@ static void do_clay_strips_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -1283,7 +1283,7 @@ static void do_snake_hook_brush_task_cb_ex(void *__restrict userdata,
copy_v3_v3(proxy[vd.i], disp);
}
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -1376,7 +1376,7 @@ static void do_thumb_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], cono, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -1462,7 +1462,7 @@ static void do_rotate_brush_task_cb_ex(void *__restrict userdata,
add_v3_v3(proxy[vd.i], ss->cache->location);
sub_v3_v3(proxy[vd.i], orig_data.co);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -1586,7 +1586,7 @@ static void do_layer_brush_task_cb_ex(void *__restrict userdata,
SCULPT_clip(sd, ss, vd.co, final_co);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -1666,7 +1666,7 @@ static void do_inflate_brush_task_cb_ex(void *__restrict userdata,
mul_v3_fl(val, fade * ss->cache->radius);
mul_v3_v3v3(proxy[vd.i], val, ss->cache->scale);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -1732,7 +1732,7 @@ static void do_nudge_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], cono, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -1833,7 +1833,7 @@ static void do_crease_brush_task_cb_ex(void *__restrict userdata,
add_v3_v3v3(proxy[vd.i], val1, val2);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -1959,7 +1959,7 @@ static void do_pinch_brush_task_cb_ex(void *__restrict userdata,
}
mul_v3_v3fl(proxy[vd.i], disp_center, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -2075,7 +2075,7 @@ static void do_grab_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -2190,7 +2190,7 @@ static void do_elastic_deform_brush_task_cb_ex(void *__restrict userdata,
copy_v3_v3(proxy[vd.i], final_disp);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -2275,7 +2275,7 @@ static void do_draw_sharp_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], offset, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -2395,7 +2395,7 @@ static void do_topology_slide_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], final_disp, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -2528,7 +2528,7 @@ static void do_topology_relax_task_cb_ex(void *__restrict userdata,
&automask_data);
SCULPT_relax_vertex(ss, &vd, fade * bstrength, false, vd.co);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -2616,7 +2616,7 @@ static void do_displacement_eraser_brush_task_cb_ex(void *__restrict userdata,
sub_v3_v3v3(disp, limit_co, vd.co);
mul_v3_v3fl(proxy[vd.i], disp, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -2735,7 +2735,7 @@ static void do_displacement_smear_brush_task_cb_ex(void *__restrict userdata,
add_v3_v3v3(new_co, ss->cache->limit_surface_co[vd.index], interp_limit_surface_disp);
interp_v3_v3v3(vd.co, vd.co, new_co, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -2863,7 +2863,7 @@ static void do_topology_rake_bmesh_task_cb_ex(void *__restrict userdata,
SCULPT_clip(sd, ss, vd.co, val);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c
index cf7e1d027f7..a5c469ca3a0 100644
--- a/source/blender/editors/sculpt_paint/sculpt_cloth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c
@@ -635,12 +635,12 @@ static void cloth_brush_collision_cb(void *userdata,
ClothBrushCollision *col = (ClothBrushCollision *)userdata;
CollisionModifierData *col_data = col->col_data;
MVertTri *verttri = &col_data->tri[index];
- MVert *mverts = col_data->x;
+ float(*positions)[3] = col_data->x;
float *tri[3], no[3], co[3];
- tri[0] = mverts[verttri->tri[0]].co;
- tri[1] = mverts[verttri->tri[1]].co;
- tri[2] = mverts[verttri->tri[2]].co;
+ tri[0] = positions[verttri->tri[0]];
+ tri[1] = positions[verttri->tri[1]];
+ tri[2] = positions[verttri->tri[2]];
float dist = 0.0f;
bool tri_hit = isect_ray_tri_watertight_v3(
@@ -783,7 +783,7 @@ static void do_cloth_brush_solve_simulation_task_cb_ex(
copy_v3_v3(vd.co, cloth_sim->pos[vd.index]);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
index 388f4111555..192a4545e94 100644
--- a/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_dyntopo.c
@@ -314,7 +314,7 @@ enum eDynTopoWarnFlag SCULPT_dynamic_topology_check(Scene *scene, Object *ob)
UNUSED_VARS_NDEBUG(ss);
for (int i = 0; i < CD_NUMTYPES; i++) {
- if (!ELEM(i, CD_MVERT, CD_MEDGE, CD_MFACE, CD_MLOOP, CD_MPOLY, CD_PAINT_MASK, CD_ORIGINDEX)) {
+ if (!ELEM(i, CD_MEDGE, CD_MFACE, CD_MLOOP, CD_MPOLY, CD_PAINT_MASK, CD_ORIGINDEX)) {
if (CustomData_has_layer(&me->vdata, i)) {
flag |= DYNTOPO_WARN_VDATA;
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc
index 40835172be9..fc373e63521 100644
--- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc
@@ -120,7 +120,7 @@ static void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata,
ss, &test, data->brush->falloff_shape);
const int thread_id = BLI_task_parallel_thread_id(tls);
- MVert *mvert = SCULPT_mesh_deformed_mverts_get(ss);
+ const float(*positions)[3] = SCULPT_mesh_deformed_positions_get(ss);
AutomaskingNodeData automask_data;
SCULPT_automasking_node_begin(
data->ob, ss, ss->cache->automasking, &automask_data, data->nodes[n]);
@@ -134,7 +134,7 @@ static void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata,
const MPoly *p = &ss->mpoly[vert_map->indices[j]];
float poly_center[3];
- BKE_mesh_calc_poly_center(p, &ss->mloop[p->loopstart], mvert, poly_center);
+ BKE_mesh_calc_poly_center(p, &ss->mloop[p->loopstart], positions, poly_center);
if (!sculpt_brush_test_sq_fn(&test, poly_center)) {
continue;
@@ -230,7 +230,7 @@ static void do_relax_face_sets_brush_task_cb_ex(void *__restrict userdata,
&automask_data);
SCULPT_relax_vertex(ss, &vd, fade * bstrength, relax_face_sets, vd.co);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -1242,8 +1242,8 @@ static void sculpt_face_set_edit_fair_face_set(Object *ob,
SCULPT_vertex_has_unique_face_set(ss, vertex);
}
- MVert *mvert = SCULPT_mesh_deformed_mverts_get(ss);
- BKE_mesh_prefair_and_fair_verts(mesh, mvert, fair_verts, fair_order);
+ float(*positions)[3] = SCULPT_mesh_deformed_positions_get(ss);
+ BKE_mesh_prefair_and_fair_verts(mesh, positions, fair_verts, fair_order);
MEM_freeN(fair_verts);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
index c158cf33f6d..5468f520f19 100644
--- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
+++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
@@ -529,7 +529,7 @@ static void mesh_filter_task_cb(void *__restrict userdata,
add_v3_v3v3(final_pos, orig_co, disp);
}
copy_v3_v3(vd.co, final_pos);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_geodesic.c b/source/blender/editors/sculpt_paint/sculpt_geodesic.c
index 5d74853be8c..0a5d2949ef0 100644
--- a/source/blender/editors/sculpt_paint/sculpt_geodesic.c
+++ b/source/blender/editors/sculpt_paint/sculpt_geodesic.c
@@ -34,8 +34,12 @@
#define SCULPT_GEODESIC_VERTEX_NONE -1
/* Propagate distance from v1 and v2 to v0. */
-static bool sculpt_geodesic_mesh_test_dist_add(
- MVert *mvert, const int v0, const int v1, const int v2, float *dists, GSet *initial_verts)
+static bool sculpt_geodesic_mesh_test_dist_add(const float (*positions)[3],
+ const int v0,
+ const int v1,
+ const int v2,
+ float *dists,
+ GSet *initial_verts)
{
if (BLI_gset_haskey(initial_verts, POINTER_FROM_INT(v0))) {
return false;
@@ -53,11 +57,11 @@ static bool sculpt_geodesic_mesh_test_dist_add(
return false;
}
dist0 = geodesic_distance_propagate_across_triangle(
- mvert[v0].co, mvert[v1].co, mvert[v2].co, dists[v1], dists[v2]);
+ positions[v0], positions[v1], positions[v2], dists[v1], dists[v2]);
}
else {
float vec[3];
- sub_v3_v3v3(vec, mvert[v1].co, mvert[v0].co);
+ sub_v3_v3v3(vec, positions[v1], positions[v0]);
dist0 = dists[v1] + len_v3(vec);
}
@@ -81,7 +85,7 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
const float limit_radius_sq = limit_radius * limit_radius;
- MVert *verts = SCULPT_mesh_deformed_mverts_get(ss);
+ float(*positions)[3] = SCULPT_mesh_deformed_positions_get(ss);
const MEdge *edges = BKE_mesh_edges(mesh);
const MPoly *polys = BKE_mesh_polys(mesh);
const MLoop *loops = BKE_mesh_loops(mesh);
@@ -135,9 +139,9 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
* number of vertices (usually just 1 or 2). */
GSET_ITER (gs_iter, initial_verts) {
const int v = POINTER_AS_INT(BLI_gsetIterator_getKey(&gs_iter));
- float *v_co = verts[v].co;
+ float *v_co = positions[v];
for (int i = 0; i < totvert; i++) {
- if (len_squared_v3v3(v_co, verts[i].co) <= limit_radius_sq) {
+ if (len_squared_v3v3(v_co, positions[i]) <= limit_radius_sq) {
BLI_BITMAP_ENABLE(affected_vertex, i);
}
}
@@ -167,7 +171,7 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
SWAP(int, v1, v2);
}
sculpt_geodesic_mesh_test_dist_add(
- verts, v2, v1, SCULPT_GEODESIC_VERTEX_NONE, dists, initial_verts);
+ positions, v2, v1, SCULPT_GEODESIC_VERTEX_NONE, dists, initial_verts);
}
if (ss->epmap[e].count != 0) {
@@ -184,7 +188,8 @@ static float *SCULPT_geodesic_mesh_create(Object *ob,
if (ELEM(v_other, v1, v2)) {
continue;
}
- if (sculpt_geodesic_mesh_test_dist_add(verts, v_other, v1, v2, dists, initial_verts)) {
+ if (sculpt_geodesic_mesh_test_dist_add(
+ positions, v_other, v1, v2, dists, initial_verts)) {
for (int edge_map_index = 0; edge_map_index < ss->vemap[v_other].count;
edge_map_index++) {
const int e_other = ss->vemap[v_other].indices[edge_map_index];
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 852b3c2719a..a06d6348a7d 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -991,7 +991,7 @@ void SCULPT_active_vertex_normal_get(SculptSession *ss, float normal[3]);
/* Returns PBVH deformed vertices array if shape keys or deform modifiers are used, otherwise
* returns mesh original vertices array. */
-struct MVert *SCULPT_mesh_deformed_mverts_get(SculptSession *ss);
+float (*SCULPT_mesh_deformed_positions_get(SculptSession *ss))[3];
/* Fake Neighbors */
diff --git a/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c b/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c
index fd8f5b8945c..ccee7814f83 100644
--- a/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c
+++ b/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c
@@ -201,7 +201,7 @@ static void do_multiplane_scrape_brush_task_cb_ex(void *__restrict userdata,
mul_v3_v3fl(proxy[vd.i], val, fade);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
index d3b3100458d..12f1104b403 100644
--- a/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_paint_image.cc
@@ -124,7 +124,7 @@ template<typename ImageBuffer> class PaintingKernel {
SculptSession *ss;
const Brush *brush;
const int thread_id;
- const MVert *mvert;
+ const float (*positions_)[3];
float4 brush_color;
float brush_strength;
@@ -139,8 +139,8 @@ template<typename ImageBuffer> class PaintingKernel {
explicit PaintingKernel(SculptSession *ss,
const Brush *brush,
const int thread_id,
- const MVert *mvert)
- : ss(ss), brush(brush), thread_id(thread_id), mvert(mvert)
+ const float (*positions)[3])
+ : ss(ss), brush(brush), thread_id(thread_id), positions_(positions)
{
init_brush_strength();
init_brush_test();
@@ -259,9 +259,9 @@ template<typename ImageBuffer> class PaintingKernel {
barycentric_weights.y,
1.0f - barycentric_weights.x - barycentric_weights.y);
interp_v3_v3v3v3(result,
- mvert[vert_indices[0]].co,
- mvert[vert_indices[1]].co,
- mvert[vert_indices[2]].co,
+ positions_[vert_indices[0]],
+ positions_[vert_indices[1]],
+ positions_[vert_indices[2]],
barycentric);
return result;
}
@@ -269,7 +269,7 @@ template<typename ImageBuffer> class PaintingKernel {
static std::vector<bool> init_triangle_brush_test(SculptSession *ss,
Triangles &triangles,
- const MVert *mvert)
+ const float (*positions)[3])
{
std::vector<bool> brush_test(triangles.size());
SculptBrushTest test;
@@ -283,10 +283,10 @@ static std::vector<bool> init_triangle_brush_test(SculptSession *ss,
for (int triangle_index = 0; triangle_index < triangles.size(); triangle_index++) {
TrianglePaintInput &triangle = triangles.get_paint_input(triangle_index);
- float3 triangle_min_bounds(mvert[triangle.vert_indices[0]].co);
+ float3 triangle_min_bounds(positions[triangle.vert_indices[0]]);
float3 triangle_max_bounds(triangle_min_bounds);
for (int i = 1; i < 3; i++) {
- const float3 &pos = mvert[triangle.vert_indices[i]].co;
+ const float3 &pos = positions[triangle.vert_indices[i]];
triangle_min_bounds.x = min_ff(triangle_min_bounds.x, pos.x);
triangle_min_bounds.y = min_ff(triangle_min_bounds.y, pos.y);
triangle_min_bounds.z = min_ff(triangle_min_bounds.z, pos.z);
@@ -312,12 +312,12 @@ static void do_paint_pixels(void *__restrict userdata,
NodeData &node_data = BKE_pbvh_pixels_node_data_get(*node);
const int thread_id = BLI_task_parallel_thread_id(tls);
- MVert *mvert = SCULPT_mesh_deformed_mverts_get(ss);
+ const float(*positions)[3] = SCULPT_mesh_deformed_positions_get(ss);
- std::vector<bool> brush_test = init_triangle_brush_test(ss, node_data.triangles, mvert);
+ std::vector<bool> brush_test = init_triangle_brush_test(ss, node_data.triangles, positions);
- PaintingKernel<ImageBufferFloat4> kernel_float4(ss, brush, thread_id, mvert);
- PaintingKernel<ImageBufferByte4> kernel_byte4(ss, brush, thread_id, mvert);
+ PaintingKernel<ImageBufferFloat4> kernel_float4(ss, brush, thread_id, positions);
+ PaintingKernel<ImageBufferByte4> kernel_byte4(ss, brush, thread_id, positions);
AutomaskingNodeData automask_data;
SCULPT_automasking_node_begin(ob, ss, ss->cache->automasking, &automask_data, data->nodes[n]);
diff --git a/source/blender/editors/sculpt_paint/sculpt_pose.c b/source/blender/editors/sculpt_paint/sculpt_pose.c
index 5f671c1f0e1..389a548fb2d 100644
--- a/source/blender/editors/sculpt_paint/sculpt_pose.c
+++ b/source/blender/editors/sculpt_paint/sculpt_pose.c
@@ -193,7 +193,7 @@ static void do_pose_brush_task_cb_ex(void *__restrict userdata,
float *target_co = SCULPT_brush_deform_target_vertex_co_get(ss, brush->deform_target, &vd);
copy_v3_v3(target_co, final_pos);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_smooth.c b/source/blender/editors/sculpt_paint/sculpt_smooth.c
index 09b1c69da45..5af8381f6da 100644
--- a/source/blender/editors/sculpt_paint/sculpt_smooth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_smooth.c
@@ -221,7 +221,7 @@ static void do_enhance_details_brush_task_cb_ex(void *__restrict userdata,
madd_v3_v3v3fl(disp, vd.co, ss->cache->detail_directions[vd.index], fade);
SCULPT_clip(sd, ss, vd.co, disp);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -319,7 +319,7 @@ static void do_smooth_brush_task_cb_ex(void *__restrict userdata,
sub_v3_v3v3(val, avg, vd.co);
madd_v3_v3v3fl(val, vd.co, val, fade);
SCULPT_clip(sd, ss, vd.co, val);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -489,7 +489,7 @@ static void SCULPT_do_surface_smooth_brush_laplacian_task_cb_ex(
SCULPT_surface_smooth_laplacian_step(
ss, disp, vd.co, ss->cache->surface_smooth_laplacian_disp, vd.vertex, orig_data.co, alpha);
madd_v3_v3fl(vd.co, disp, clamp_f(fade, 0.0f, 1.0f));
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_transform.c b/source/blender/editors/sculpt_paint/sculpt_transform.c
index 0463e8adbaf..b8ee3404159 100644
--- a/source/blender/editors/sculpt_paint/sculpt_transform.c
+++ b/source/blender/editors/sculpt_paint/sculpt_transform.c
@@ -173,7 +173,7 @@ static void sculpt_transform_task_cb(void *__restrict userdata,
mul_v3_fl(disp, 1.0f - fade);
add_v3_v3v3(vd.co, start_co, disp);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
@@ -247,7 +247,7 @@ static void sculpt_elastic_transform_task_cb(void *__restrict userdata,
copy_v3_v3(proxy[vd.i], final_disp);
- if (vd.mvert) {
+ if (vd.is_mesh) {
BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex);
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 833f62d4955..de0935a0e22 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -319,9 +319,8 @@ static void update_cb_partial(PBVHNode *node, void *userdata)
BKE_pbvh_node_mark_update(node);
}
int verts_num;
- const int *vert_indices;
BKE_pbvh_node_num_verts(data->pbvh, node, NULL, &verts_num);
- BKE_pbvh_node_get_verts(data->pbvh, node, &vert_indices, NULL);
+ const int *vert_indices = BKE_pbvh_node_get_vert_indices(node);
if (data->modified_mask_verts != NULL) {
for (int i = 0; i < verts_num; i++) {
if (data->modified_mask_verts[vert_indices[i]]) {
@@ -380,7 +379,6 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
Object *ob = BKE_view_layer_active_object_get(view_layer);
SculptSession *ss = ob->sculpt;
SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
- MVert *mvert;
int *index;
if (unode->maxvert) {
@@ -406,7 +404,7 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
/* No need for float comparison here (memory is exactly equal or not). */
index = unode->index;
- mvert = ss->mvert;
+ float(*positions)[3] = ss->positions;
if (ss->shapekey_active) {
float(*vertCos)[3];
@@ -433,7 +431,7 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
/* Propagate new coords to keyblock. */
SCULPT_vertcos_to_key(ob, ss->shapekey_active, vertCos);
- /* PBVH uses its own mvert array, so coords should be */
+ /* PBVH uses its own vertex array, so coords should be */
/* propagated to PBVH here. */
BKE_pbvh_vert_coords_apply(ss->pbvh, vertCos, ss->shapekey_active->totelem);
@@ -443,20 +441,20 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
if (unode->orig_co) {
if (ss->deform_modifiers_active) {
for (int i = 0; i < unode->totvert; i++) {
- sculpt_undo_restore_deformed(ss, unode, i, index[i], mvert[index[i]].co);
+ sculpt_undo_restore_deformed(ss, unode, i, index[i], positions[index[i]]);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, BKE_pbvh_make_vref(index[i]));
}
}
else {
for (int i = 0; i < unode->totvert; i++) {
- swap_v3_v3(mvert[index[i]].co, unode->orig_co[i]);
+ swap_v3_v3(positions[index[i]], unode->orig_co[i]);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, BKE_pbvh_make_vref(index[i]));
}
}
}
else {
for (int i = 0; i < unode->totvert; i++) {
- swap_v3_v3(mvert[index[i]].co, unode->co[i]);
+ swap_v3_v3(positions[index[i]], unode->co[i]);
BKE_pbvh_vert_tag_update_normal(ss->pbvh, BKE_pbvh_make_vref(index[i]));
}
}
@@ -1422,12 +1420,10 @@ static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode)
/* Already stored during allocation. */
}
else {
- MVert *mvert;
- const int *vert_indices;
int allvert;
BKE_pbvh_node_num_verts(pbvh, node, NULL, &allvert);
- BKE_pbvh_node_get_verts(pbvh, node, &vert_indices, &mvert);
+ const int *vert_indices = BKE_pbvh_node_get_vert_indices(node);
for (int i = 0; i < allvert; i++) {
BLI_BITMAP_SET(unode->vert_hidden, i, hide_vert[vert_indices[i]]);
}
@@ -1637,11 +1633,11 @@ SculptUndoNode *SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
memcpy(unode->grids, grids, sizeof(int) * totgrid);
}
else {
- const int *vert_indices, *loop_indices;
+ const int *loop_indices;
int allvert, allloop;
BKE_pbvh_node_num_verts(ss->pbvh, unode->node, NULL, &allvert);
- BKE_pbvh_node_get_verts(ss->pbvh, node, &vert_indices, NULL);
+ const int *vert_indices = BKE_pbvh_node_get_vert_indices(node);
memcpy(unode->index, vert_indices, sizeof(int) * allvert);
if (unode->loop_index) {