mirror of
https://github.com/blender/blender
synced 2026-09-26 16:15:47 +03:00
Cleanup: Remove redundant function prefixes in sculpt_trim.cc
This PR strips the `sculpt_gesture_trim` prefix and other similar prefixes from the `sculpt_trim.cc` code, as it is already contained within the `blender::ed::sculpt_paint::trim` namespace. Pull Request: https://projects.blender.org/blender/blender/pulls/119680
This commit is contained in:
parent
9edb2784da
commit
130ce5f53d
1 changed files with 52 additions and 61 deletions
|
|
@ -46,7 +46,7 @@ enum class OperationType {
|
|||
|
||||
/* Intersect is not exposed in the UI because it does not work correctly with symmetry (it deletes
|
||||
* the symmetrical part of the mesh in the first symmetry pass). */
|
||||
static EnumPropertyItem prop_trim_operation_types[] = {
|
||||
static EnumPropertyItem operation_types[] = {
|
||||
{int(OperationType::Difference),
|
||||
"DIFFERENCE",
|
||||
0,
|
||||
|
|
@ -65,7 +65,7 @@ enum class OrientationType {
|
|||
View = 0,
|
||||
Surface = 1,
|
||||
};
|
||||
static EnumPropertyItem prop_trim_orientation_types[] = {
|
||||
static EnumPropertyItem orientation_types[] = {
|
||||
{int(OrientationType::View),
|
||||
"VIEW",
|
||||
0,
|
||||
|
|
@ -84,13 +84,13 @@ enum class ExtrudeMode {
|
|||
Fixed = 1,
|
||||
};
|
||||
|
||||
static EnumPropertyItem prop_trim_extrude_modes[] = {
|
||||
static EnumPropertyItem extrude_modes[] = {
|
||||
{int(ExtrudeMode::Project), "PROJECT", 0, "Project", "Project back faces when extruding"},
|
||||
{int(ExtrudeMode::Fixed), "FIXED", 0, "Fixed", "Extrude back faces by fixed amount"},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
struct SculptGestureTrimOperation {
|
||||
struct TrimOperation {
|
||||
gesture::Operation op;
|
||||
|
||||
Mesh *mesh;
|
||||
|
|
@ -106,10 +106,9 @@ struct SculptGestureTrimOperation {
|
|||
ExtrudeMode extrude_mode;
|
||||
};
|
||||
|
||||
static void sculpt_gesture_trim_normals_update(gesture::GestureData &gesture_data)
|
||||
static void update_normals(gesture::GestureData &gesture_data)
|
||||
{
|
||||
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)
|
||||
gesture_data.operation;
|
||||
TrimOperation *trim_operation = (TrimOperation *)gesture_data.operation;
|
||||
Mesh *trim_mesh = trim_operation->mesh;
|
||||
|
||||
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(trim_mesh);
|
||||
|
|
@ -141,12 +140,11 @@ static void sculpt_gesture_trim_normals_update(gesture::GestureData &gesture_dat
|
|||
|
||||
/* Get the origin and normal that are going to be used for calculating the depth and position the
|
||||
* trimming geometry. */
|
||||
static void sculpt_gesture_trim_shape_origin_normal_get(gesture::GestureData &gesture_data,
|
||||
float *r_origin,
|
||||
float *r_normal)
|
||||
static void get_origin_and_normal(gesture::GestureData &gesture_data,
|
||||
float *r_origin,
|
||||
float *r_normal)
|
||||
{
|
||||
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)
|
||||
gesture_data.operation;
|
||||
TrimOperation *trim_operation = (TrimOperation *)gesture_data.operation;
|
||||
/* Use the view origin and normal in world space. The trimming mesh coordinates are
|
||||
* calculated in world space, aligned to the view, and then converted to object space to
|
||||
* store them in the final trimming mesh which is going to be used in the boolean operation.
|
||||
|
|
@ -171,10 +169,9 @@ static void sculpt_gesture_trim_shape_origin_normal_get(gesture::GestureData &ge
|
|||
}
|
||||
}
|
||||
|
||||
static void sculpt_gesture_trim_calculate_depth(gesture::GestureData &gesture_data)
|
||||
static void calculate_depth(gesture::GestureData &gesture_data)
|
||||
{
|
||||
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)
|
||||
gesture_data.operation;
|
||||
TrimOperation *trim_operation = (TrimOperation *)gesture_data.operation;
|
||||
|
||||
SculptSession *ss = gesture_data.ss;
|
||||
ViewContext *vc = &gesture_data.vc;
|
||||
|
|
@ -184,7 +181,7 @@ static void sculpt_gesture_trim_calculate_depth(gesture::GestureData &gesture_da
|
|||
float shape_plane[4];
|
||||
float shape_origin[3];
|
||||
float shape_normal[3];
|
||||
sculpt_gesture_trim_shape_origin_normal_get(gesture_data, shape_origin, shape_normal);
|
||||
get_origin_and_normal(gesture_data, shape_origin, shape_normal);
|
||||
plane_from_point_normal_v3(shape_plane, shape_origin, shape_normal);
|
||||
|
||||
trim_operation->depth_front = FLT_MAX;
|
||||
|
|
@ -255,10 +252,9 @@ static void sculpt_gesture_trim_calculate_depth(gesture::GestureData &gesture_da
|
|||
}
|
||||
}
|
||||
|
||||
static void sculpt_gesture_trim_geometry_generate(gesture::GestureData &gesture_data)
|
||||
static void generate_geometry(gesture::GestureData &gesture_data)
|
||||
{
|
||||
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)
|
||||
gesture_data.operation;
|
||||
TrimOperation *trim_operation = (TrimOperation *)gesture_data.operation;
|
||||
ViewContext *vc = &gesture_data.vc;
|
||||
ARegion *region = vc->region;
|
||||
|
||||
|
|
@ -289,7 +285,7 @@ static void sculpt_gesture_trim_geometry_generate(gesture::GestureData &gesture_
|
|||
float shape_origin[3];
|
||||
float shape_normal[3];
|
||||
float shape_plane[4];
|
||||
sculpt_gesture_trim_shape_origin_normal_get(gesture_data, shape_origin, shape_normal);
|
||||
get_origin_and_normal(gesture_data, shape_origin, shape_normal);
|
||||
plane_from_point_normal_v3(shape_plane, shape_origin, shape_normal);
|
||||
|
||||
const float(*ob_imat)[4] = vc->obact->world_to_object().ptr();
|
||||
|
|
@ -424,13 +420,12 @@ static void sculpt_gesture_trim_geometry_generate(gesture::GestureData &gesture_
|
|||
|
||||
bke::mesh_smooth_set(*trim_operation->mesh, false);
|
||||
bke::mesh_calc_edges(*trim_operation->mesh, false, false);
|
||||
sculpt_gesture_trim_normals_update(gesture_data);
|
||||
update_normals(gesture_data);
|
||||
}
|
||||
|
||||
static void sculpt_gesture_trim_geometry_free(gesture::GestureData &gesture_data)
|
||||
static void free_geometry(gesture::GestureData &gesture_data)
|
||||
{
|
||||
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)
|
||||
gesture_data.operation;
|
||||
TrimOperation *trim_operation = (TrimOperation *)gesture_data.operation;
|
||||
BKE_id_free(nullptr, trim_operation->mesh);
|
||||
MEM_freeN(trim_operation->true_mesh_co);
|
||||
}
|
||||
|
|
@ -440,10 +435,9 @@ static int bm_face_isect_pair(BMFace *f, void * /*user_data*/)
|
|||
return BM_elem_flag_test(f, BM_ELEM_DRAW) ? 1 : 0;
|
||||
}
|
||||
|
||||
static void sculpt_gesture_apply_trim(gesture::GestureData &gesture_data)
|
||||
static void apply_trim(gesture::GestureData &gesture_data)
|
||||
{
|
||||
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)
|
||||
gesture_data.operation;
|
||||
TrimOperation *trim_operation = (TrimOperation *)gesture_data.operation;
|
||||
Mesh *sculpt_mesh = BKE_mesh_from_object(gesture_data.vc.obact);
|
||||
Mesh *trim_mesh = trim_operation->mesh;
|
||||
|
||||
|
|
@ -532,34 +526,32 @@ static void sculpt_gesture_apply_trim(gesture::GestureData &gesture_data)
|
|||
result, static_cast<Mesh *>(gesture_data.vc.obact->data), gesture_data.vc.obact);
|
||||
}
|
||||
|
||||
static void sculpt_gesture_trim_begin(bContext &C, gesture::GestureData &gesture_data)
|
||||
static void gesture_begin(bContext &C, gesture::GestureData &gesture_data)
|
||||
{
|
||||
Object *object = gesture_data.vc.obact;
|
||||
SculptSession *ss = object->sculpt;
|
||||
|
||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(&C);
|
||||
sculpt_gesture_trim_calculate_depth(gesture_data);
|
||||
sculpt_gesture_trim_geometry_generate(gesture_data);
|
||||
calculate_depth(gesture_data);
|
||||
generate_geometry(gesture_data);
|
||||
SCULPT_topology_islands_invalidate(ss);
|
||||
BKE_sculpt_update_object_for_edit(depsgraph, gesture_data.vc.obact, false);
|
||||
undo::push_node(gesture_data.vc.obact, nullptr, undo::Type::Geometry);
|
||||
}
|
||||
|
||||
static void sculpt_gesture_trim_apply_for_symmetry_pass(bContext & /*C*/,
|
||||
gesture::GestureData &gesture_data)
|
||||
static void gesture_apply_for_symmetry_pass(bContext & /*C*/, gesture::GestureData &gesture_data)
|
||||
{
|
||||
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)
|
||||
gesture_data.operation;
|
||||
TrimOperation *trim_operation = (TrimOperation *)gesture_data.operation;
|
||||
Mesh *trim_mesh = trim_operation->mesh;
|
||||
MutableSpan<float3> positions = trim_mesh->vert_positions_for_write();
|
||||
for (int i = 0; i < trim_mesh->verts_num; i++) {
|
||||
flip_v3_v3(positions[i], trim_operation->true_mesh_co[i], gesture_data.symmpass);
|
||||
}
|
||||
sculpt_gesture_trim_normals_update(gesture_data);
|
||||
sculpt_gesture_apply_trim(gesture_data);
|
||||
update_normals(gesture_data);
|
||||
apply_trim(gesture_data);
|
||||
}
|
||||
|
||||
static void sculpt_gesture_trim_end(bContext & /*C*/, gesture::GestureData &gesture_data)
|
||||
static void gesture_end(bContext & /*C*/, gesture::GestureData &gesture_data)
|
||||
{
|
||||
Object *object = gesture_data.vc.obact;
|
||||
Mesh *mesh = (Mesh *)object->data;
|
||||
|
|
@ -570,24 +562,23 @@ static void sculpt_gesture_trim_end(bContext & /*C*/, gesture::GestureData &gest
|
|||
face_set::initialize_none_to_id(mesh, next_face_set_id);
|
||||
}
|
||||
|
||||
sculpt_gesture_trim_geometry_free(gesture_data);
|
||||
free_geometry(gesture_data);
|
||||
|
||||
undo::push_node(gesture_data.vc.obact, nullptr, undo::Type::Geometry);
|
||||
BKE_mesh_batch_cache_dirty_tag(mesh, BKE_MESH_BATCH_DIRTY_ALL);
|
||||
DEG_id_tag_update(&gesture_data.vc.obact->id, ID_RECALC_GEOMETRY);
|
||||
}
|
||||
|
||||
static void sculpt_gesture_init_trim_properties(gesture::GestureData &gesture_data, wmOperator &op)
|
||||
static void init_operation(gesture::GestureData &gesture_data, wmOperator &op)
|
||||
{
|
||||
gesture_data.operation = reinterpret_cast<gesture::Operation *>(
|
||||
MEM_cnew<SculptGestureTrimOperation>(__func__));
|
||||
MEM_cnew<TrimOperation>(__func__));
|
||||
|
||||
SculptGestureTrimOperation *trim_operation = (SculptGestureTrimOperation *)
|
||||
gesture_data.operation;
|
||||
TrimOperation *trim_operation = (TrimOperation *)gesture_data.operation;
|
||||
|
||||
trim_operation->op.begin = sculpt_gesture_trim_begin;
|
||||
trim_operation->op.apply_for_symmetry_pass = sculpt_gesture_trim_apply_for_symmetry_pass;
|
||||
trim_operation->op.end = sculpt_gesture_trim_end;
|
||||
trim_operation->op.begin = gesture_begin;
|
||||
trim_operation->op.apply_for_symmetry_pass = gesture_apply_for_symmetry_pass;
|
||||
trim_operation->op.end = gesture_end;
|
||||
|
||||
trim_operation->mode = OperationType(RNA_enum_get(op.ptr, "trim_mode"));
|
||||
trim_operation->use_cursor_depth = RNA_boolean_get(op.ptr, "use_cursor_depth");
|
||||
|
|
@ -600,11 +591,11 @@ static void sculpt_gesture_init_trim_properties(gesture::GestureData &gesture_da
|
|||
}
|
||||
}
|
||||
|
||||
static void sculpt_trim_gesture_operator_properties(wmOperatorType *ot)
|
||||
static void operator_properties(wmOperatorType *ot)
|
||||
{
|
||||
RNA_def_enum(ot->srna,
|
||||
"trim_mode",
|
||||
prop_trim_operation_types,
|
||||
operation_types,
|
||||
int(OperationType::Difference),
|
||||
"Trim Mode",
|
||||
nullptr);
|
||||
|
|
@ -616,19 +607,19 @@ static void sculpt_trim_gesture_operator_properties(wmOperatorType *ot)
|
|||
"Use cursor location and radius for the dimensions and position of the trimming shape");
|
||||
RNA_def_enum(ot->srna,
|
||||
"trim_orientation",
|
||||
prop_trim_orientation_types,
|
||||
orientation_types,
|
||||
int(OrientationType::View),
|
||||
"Shape Orientation",
|
||||
nullptr);
|
||||
RNA_def_enum(ot->srna,
|
||||
"trim_extrude_mode",
|
||||
prop_trim_extrude_modes,
|
||||
extrude_modes,
|
||||
int(ExtrudeMode::Fixed),
|
||||
"Extrude Mode",
|
||||
nullptr);
|
||||
}
|
||||
|
||||
static int sculpt_trim_gesture_box_exec(bContext *C, wmOperator *op)
|
||||
static int gesture_box_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *object = CTX_data_active_object(C);
|
||||
SculptSession *ss = object->sculpt;
|
||||
|
|
@ -647,12 +638,12 @@ static int sculpt_trim_gesture_box_exec(bContext *C, wmOperator *op)
|
|||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
sculpt_gesture_init_trim_properties(*gesture_data, *op);
|
||||
init_operation(*gesture_data, *op);
|
||||
gesture::apply(*C, *gesture_data, *op);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int sculpt_trim_gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
static int gesture_box_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
|
@ -675,7 +666,7 @@ static int sculpt_trim_gesture_box_invoke(bContext *C, wmOperator *op, const wmE
|
|||
return WM_gesture_box_invoke(C, op, event);
|
||||
}
|
||||
|
||||
static int sculpt_trim_gesture_lasso_exec(bContext *C, wmOperator *op)
|
||||
static int gesture_lasso_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
Object *object = CTX_data_active_object(C);
|
||||
|
|
@ -697,12 +688,12 @@ static int sculpt_trim_gesture_lasso_exec(bContext *C, wmOperator *op)
|
|||
if (!gesture_data) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
sculpt_gesture_init_trim_properties(*gesture_data, *op);
|
||||
init_operation(*gesture_data, *op);
|
||||
gesture::apply(*C, *gesture_data, *op);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int sculpt_trim_gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
static int gesture_lasso_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
|
@ -731,9 +722,9 @@ void SCULPT_OT_trim_lasso_gesture(wmOperatorType *ot)
|
|||
ot->idname = "SCULPT_OT_trim_lasso_gesture";
|
||||
ot->description = "Trims the mesh within the lasso as you move the brush";
|
||||
|
||||
ot->invoke = sculpt_trim_gesture_lasso_invoke;
|
||||
ot->invoke = gesture_lasso_invoke;
|
||||
ot->modal = WM_gesture_lasso_modal;
|
||||
ot->exec = sculpt_trim_gesture_lasso_exec;
|
||||
ot->exec = gesture_lasso_exec;
|
||||
|
||||
ot->poll = SCULPT_mode_poll_view3d;
|
||||
|
||||
|
|
@ -743,7 +734,7 @@ void SCULPT_OT_trim_lasso_gesture(wmOperatorType *ot)
|
|||
WM_operator_properties_gesture_lasso(ot);
|
||||
gesture::operator_properties(ot, gesture::ShapeType::Lasso);
|
||||
|
||||
sculpt_trim_gesture_operator_properties(ot);
|
||||
operator_properties(ot);
|
||||
}
|
||||
|
||||
void SCULPT_OT_trim_box_gesture(wmOperatorType *ot)
|
||||
|
|
@ -752,9 +743,9 @@ void SCULPT_OT_trim_box_gesture(wmOperatorType *ot)
|
|||
ot->idname = "SCULPT_OT_trim_box_gesture";
|
||||
ot->description = "Trims the mesh within the box as you move the brush";
|
||||
|
||||
ot->invoke = sculpt_trim_gesture_box_invoke;
|
||||
ot->invoke = gesture_box_invoke;
|
||||
ot->modal = WM_gesture_box_modal;
|
||||
ot->exec = sculpt_trim_gesture_box_exec;
|
||||
ot->exec = gesture_box_exec;
|
||||
|
||||
ot->poll = SCULPT_mode_poll_view3d;
|
||||
|
||||
|
|
@ -764,6 +755,6 @@ void SCULPT_OT_trim_box_gesture(wmOperatorType *ot)
|
|||
WM_operator_properties_border(ot);
|
||||
gesture::operator_properties(ot, gesture::ShapeType::Box);
|
||||
|
||||
sculpt_trim_gesture_operator_properties(ot);
|
||||
operator_properties(ot);
|
||||
}
|
||||
} // namespace blender::ed::sculpt_paint::trim
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue