Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt.c
| Show First 20 Lines • Show All 7,383 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| if (SCULPT_mode_poll(C) && ob->sculpt && ob->sculpt->pbvh) { | if (SCULPT_mode_poll(C) && ob->sculpt && ob->sculpt->pbvh) { | ||||
| return BKE_pbvh_type(ob->sculpt->pbvh) != PBVH_GRIDS; | return BKE_pbvh_type(ob->sculpt->pbvh) != PBVH_GRIDS; | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| static int sculpt_symmetrize_exec(bContext *C, wmOperator *UNUSED(op)) | static int sculpt_symmetrize_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| const Sculpt *sd = CTX_data_tool_settings(C)->sculpt; | const Sculpt *sd = CTX_data_tool_settings(C)->sculpt; | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| PBVH *pbvh = ss->pbvh; | PBVH *pbvh = ss->pbvh; | ||||
| if (!pbvh) { | if (!pbvh) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| Show All 34 Lines | switch (BKE_pbvh_type(pbvh)) { | ||||
| case PBVH_FACES: | case PBVH_FACES: | ||||
| /* Mesh Symmetrize. */ | /* Mesh Symmetrize. */ | ||||
| ED_sculpt_undo_geometry_begin(ob, "mesh symmetrize"); | ED_sculpt_undo_geometry_begin(ob, "mesh symmetrize"); | ||||
| Mesh *mesh = ob->data; | Mesh *mesh = ob->data; | ||||
| Mesh *mesh_mirror; | Mesh *mesh_mirror; | ||||
| MirrorModifierData mmd = {{0}}; | MirrorModifierData mmd = {{0}}; | ||||
| int axis = 0; | int axis = 0; | ||||
| mmd.flag = 0; | mmd.flag = 0; | ||||
| mmd.tolerance = 0.005f; | mmd.tolerance = RNA_float_get(op->ptr, "merge_tolerance"); | ||||
| switch (sd->symmetrize_direction) { | switch (sd->symmetrize_direction) { | ||||
| case BMO_SYMMETRIZE_NEGATIVE_X: | case BMO_SYMMETRIZE_NEGATIVE_X: | ||||
| axis = 0; | axis = 0; | ||||
| mmd.flag |= MOD_MIR_AXIS_X | MOD_MIR_BISECT_AXIS_X | MOD_MIR_BISECT_FLIP_AXIS_X; | mmd.flag |= MOD_MIR_AXIS_X | MOD_MIR_BISECT_AXIS_X | MOD_MIR_BISECT_FLIP_AXIS_X; | ||||
| break; | break; | ||||
| case BMO_SYMMETRIZE_NEGATIVE_Y: | case BMO_SYMMETRIZE_NEGATIVE_Y: | ||||
| axis = 1; | axis = 1; | ||||
| mmd.flag |= MOD_MIR_AXIS_Y | MOD_MIR_BISECT_AXIS_Y | MOD_MIR_BISECT_FLIP_AXIS_Y; | mmd.flag |= MOD_MIR_AXIS_Y | MOD_MIR_BISECT_AXIS_Y | MOD_MIR_BISECT_FLIP_AXIS_Y; | ||||
| Show All 40 Lines | static void SCULPT_OT_symmetrize(wmOperatorType *ot) | ||||
| /* Identifiers. */ | /* Identifiers. */ | ||||
| ot->name = "Symmetrize"; | ot->name = "Symmetrize"; | ||||
| ot->idname = "SCULPT_OT_symmetrize"; | ot->idname = "SCULPT_OT_symmetrize"; | ||||
| ot->description = "Symmetrize the topology modifications"; | ot->description = "Symmetrize the topology modifications"; | ||||
| /* API callbacks. */ | /* API callbacks. */ | ||||
| ot->exec = sculpt_symmetrize_exec; | ot->exec = sculpt_symmetrize_exec; | ||||
| ot->poll = sculpt_no_multires_poll; | ot->poll = sculpt_no_multires_poll; | ||||
| RNA_def_float(ot->srna, | |||||
| "merge_tolerance", | |||||
| 0.001f, | |||||
| 0.0f, | |||||
| 1.0f, | |||||
| "Merge Limit", | |||||
| "Distance within which symmetrical vertices are merged", | |||||
jbakker: "Distance within which symmetrical vertices are merged" | |||||
| 0.0f, | |||||
| FLT_MAX); | |||||
| } | } | ||||
| /**** Toggle operator for turning sculpt mode on or off ****/ | /**** Toggle operator for turning sculpt mode on or off ****/ | ||||
| static void sculpt_init_session(Depsgraph *depsgraph, Scene *scene, Object *ob) | static void sculpt_init_session(Depsgraph *depsgraph, Scene *scene, Object *ob) | ||||
| { | { | ||||
| /* Create persistent sculpt mode data. */ | /* Create persistent sculpt mode data. */ | ||||
| BKE_sculpt_toolsettings_data_ensure(scene); | BKE_sculpt_toolsettings_data_ensure(scene); | ||||
| ▲ Show 20 Lines • Show All 363 Lines • Show Last 20 Lines | |||||
"Distance within which symmetrical vertices are merged"