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/paint_mask.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c54
1 files changed, 30 insertions, 24 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 89bbf2a3c92..332a0830081 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -152,7 +152,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
BKE_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode);
- SCULPT_undo_push_begin(ob, "Mask flood fill");
+ SCULPT_undo_push_begin(ob, op);
MaskTaskData data = {
.ob = ob,
@@ -663,7 +663,7 @@ static bool sculpt_gesture_is_effected_lasso(SculptGestureContext *sgcontext, co
static bool sculpt_gesture_is_vertex_effected(SculptGestureContext *sgcontext, PBVHVertexIter *vd)
{
float vertex_normal[3];
- SCULPT_vertex_normal_get(sgcontext->ss, vd->index, vertex_normal);
+ SCULPT_vertex_normal_get(sgcontext->ss, vd->vertex, vertex_normal);
float dot = dot_v3v3(sgcontext->view_normal, vertex_normal);
const bool is_effected_front_face = !(sgcontext->front_faces_only && dot < 0.0f);
@@ -687,10 +687,10 @@ static bool sculpt_gesture_is_vertex_effected(SculptGestureContext *sgcontext, P
return false;
}
-static void sculpt_gesture_apply(bContext *C, SculptGestureContext *sgcontext)
+static void sculpt_gesture_apply(bContext *C, SculptGestureContext *sgcontext, wmOperator *op)
{
SculptGestureOperation *operation = sgcontext->operation;
- SCULPT_undo_push_begin(CTX_data_active_object(C), "Sculpt Gesture Apply");
+ SCULPT_undo_push_begin(CTX_data_active_object(C), op);
operation->sculpt_gesture_begin(C, sgcontext);
@@ -743,7 +743,7 @@ static void face_set_gesture_apply_task_cb(void *__restrict userdata,
BKE_pbvh_vertex_iter_begin (sgcontext->ss->pbvh, node, vd, PBVH_ITER_UNIQUE) {
if (sculpt_gesture_is_vertex_effected(sgcontext, &vd)) {
- SCULPT_vertex_face_set_set(sgcontext->ss, vd.index, face_set_operation->new_face_set_id);
+ SCULPT_vertex_face_set_set(sgcontext->ss, vd.vertex, face_set_operation->new_face_set_id);
any_updated = true;
}
}
@@ -1025,7 +1025,9 @@ static void sculpt_gesture_trim_calculate_depth(SculptGestureContext *sgcontext)
trim_operation->depth_back = -FLT_MAX;
for (int i = 0; i < totvert; i++) {
- const float *vco = SCULPT_vertex_co_get(ss, i);
+ PBVHVertRef vertex = BKE_pbvh_index_to_vertex(ss->pbvh, i);
+
+ const float *vco = SCULPT_vertex_co_get(ss, vertex);
/* Convert the coordinates to world space to calculate the depth. When generating the trimming
* mesh, coordinates are first calculated in world space, then converted to object space to
* store them. */
@@ -1121,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_verts_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++) {
@@ -1132,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);
}
@@ -1147,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);
}
@@ -1157,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_polys_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];
@@ -1169,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;
@@ -1180,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;
@@ -1193,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;
@@ -1328,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_verts_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);
@@ -1437,7 +1443,7 @@ static void project_line_gesture_apply_task_cb(void *__restrict userdata,
}
add_v3_v3(vd.co, disp);
if (vd.mvert) {
- BKE_pbvh_vert_mark_update(sgcontext->ss->pbvh, vd.index);
+ BKE_pbvh_vert_tag_update_normal(sgcontext->ss->pbvh, vd.vertex);
}
any_updated = true;
}
@@ -1500,7 +1506,7 @@ static int paint_mask_gesture_box_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
sculpt_gesture_init_mask_properties(sgcontext, op);
- sculpt_gesture_apply(C, sgcontext);
+ sculpt_gesture_apply(C, sgcontext, op);
sculpt_gesture_context_free(sgcontext);
return OPERATOR_FINISHED;
}
@@ -1512,7 +1518,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
sculpt_gesture_init_mask_properties(sgcontext, op);
- sculpt_gesture_apply(C, sgcontext);
+ sculpt_gesture_apply(C, sgcontext, op);
sculpt_gesture_context_free(sgcontext);
return OPERATOR_FINISHED;
}
@@ -1524,7 +1530,7 @@ static int paint_mask_gesture_line_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
sculpt_gesture_init_mask_properties(sgcontext, op);
- sculpt_gesture_apply(C, sgcontext);
+ sculpt_gesture_apply(C, sgcontext, op);
sculpt_gesture_context_free(sgcontext);
return OPERATOR_FINISHED;
}
@@ -1536,7 +1542,7 @@ static int face_set_gesture_box_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
sculpt_gesture_init_face_set_properties(sgcontext, op);
- sculpt_gesture_apply(C, sgcontext);
+ sculpt_gesture_apply(C, sgcontext, op);
sculpt_gesture_context_free(sgcontext);
return OPERATOR_FINISHED;
}
@@ -1548,7 +1554,7 @@ static int face_set_gesture_lasso_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
sculpt_gesture_init_face_set_properties(sgcontext, op);
- sculpt_gesture_apply(C, sgcontext);
+ sculpt_gesture_apply(C, sgcontext, op);
sculpt_gesture_context_free(sgcontext);
return OPERATOR_FINISHED;
}
@@ -1573,7 +1579,7 @@ static int sculpt_trim_gesture_box_exec(bContext *C, wmOperator *op)
}
sculpt_gesture_init_trim_properties(sgcontext, op);
- sculpt_gesture_apply(C, sgcontext);
+ sculpt_gesture_apply(C, sgcontext, op);
sculpt_gesture_context_free(sgcontext);
return OPERATOR_FINISHED;
}
@@ -1614,7 +1620,7 @@ static int sculpt_trim_gesture_lasso_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
sculpt_gesture_init_trim_properties(sgcontext, op);
- sculpt_gesture_apply(C, sgcontext);
+ sculpt_gesture_apply(C, sgcontext, op);
sculpt_gesture_context_free(sgcontext);
return OPERATOR_FINISHED;
}
@@ -1643,7 +1649,7 @@ static int project_gesture_line_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
sculpt_gesture_init_project_properties(sgcontext, op);
- sculpt_gesture_apply(C, sgcontext);
+ sculpt_gesture_apply(C, sgcontext, op);
sculpt_gesture_context_free(sgcontext);
return OPERATOR_FINISHED;
}