Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 8,324 Lines • ▼ Show 20 Lines | void ED_object_sculptmode_enter_ex(Main *bmain, | ||||
| ReportList *reports) | ReportList *reports) | ||||
| { | { | ||||
| const int mode_flag = OB_MODE_SCULPT; | const int mode_flag = OB_MODE_SCULPT; | ||||
| Mesh *me = BKE_mesh_from_object(ob); | Mesh *me = BKE_mesh_from_object(ob); | ||||
| /* Enter sculpt mode. */ | /* Enter sculpt mode. */ | ||||
| ob->mode |= mode_flag; | ob->mode |= mode_flag; | ||||
| MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob); | |||||
| /* Create sculpt mode session data. */ | /* Create sculpt mode session data. */ | ||||
| if (ob->sculpt) { | if (ob->sculpt) { | ||||
| BKE_sculptsession_free(ob); | BKE_sculptsession_free(ob); | ||||
| } | } | ||||
| /* Copy the current mesh visibility to the Face Sets. */ | BKE_sculpt_ensure_orig_mesh_data(scene, ob); | ||||
| BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(me); | |||||
| /* Mask layer is required for Multires. */ | |||||
| BKE_sculpt_mask_layers_ensure(ob, mmd); | |||||
| /* Tessfaces aren't used and will become invalid. */ | |||||
| BKE_mesh_tessface_clear(me); | |||||
| /* We always need to flush updates from depsgraph here, since at the very least | |||||
| * `BKE_sculpt_face_sets_ensure_from_base_mesh_visibility()` will have updated some data layer of | |||||
| * the mesh. | |||||
| * | |||||
| * All known potential sources of updates: | |||||
| * - Addition of, or changes to, the `CD_SCULPT_FACE_SETS` data layer | |||||
| * (`BKE_sculpt_face_sets_ensure_from_base_mesh_visibility`). | |||||
| * - Addition of a `CD_PAINT_MASK` data layer (`BKE_sculpt_mask_layers_ensure`). | |||||
| * - Object has any active modifier (modifier stack can be different in Sculpt mode). | |||||
| * - Multires: | |||||
| * + Differences of subdiv levels between sculpt and object modes | |||||
| * (`mmd->sculptlvl != mmd->lvl`). | |||||
| * + Addition of a `CD_GRID_PAINT_MASK` data layer (`BKE_sculpt_mask_layers_ensure`). | |||||
| */ | |||||
| DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | |||||
| BKE_scene_graph_evaluated_ensure(depsgraph, bmain); | BKE_scene_graph_evaluated_ensure(depsgraph, bmain); | ||||
| sculpt_init_session(depsgraph, scene, ob); | sculpt_init_session(depsgraph, scene, ob); | ||||
| if (!(fabsf(ob->scale[0] - ob->scale[1]) < 1e-4f && | if (!(fabsf(ob->scale[0] - ob->scale[1]) < 1e-4f && | ||||
| fabsf(ob->scale[1] - ob->scale[2]) < 1e-4f)) { | fabsf(ob->scale[1] - ob->scale[2]) < 1e-4f)) { | ||||
| BKE_report( | BKE_report( | ||||
| reports, RPT_WARNING, "Object has non-uniform scale, sculpting may be unpredictable"); | reports, RPT_WARNING, "Object has non-uniform scale, sculpting may be unpredictable"); | ||||
| } | } | ||||
| else if (is_negative_m4(ob->obmat)) { | else if (is_negative_m4(ob->obmat)) { | ||||
| BKE_report(reports, RPT_WARNING, "Object has negative scale, sculpting may be unpredictable"); | BKE_report(reports, RPT_WARNING, "Object has negative scale, sculpting may be unpredictable"); | ||||
| } | } | ||||
| Paint *paint = BKE_paint_get_active_from_paintmode(scene, PAINT_MODE_SCULPT); | Paint *paint = BKE_paint_get_active_from_paintmode(scene, PAINT_MODE_SCULPT); | ||||
| BKE_paint_init(bmain, scene, PAINT_MODE_SCULPT, PAINT_CURSOR_SCULPT); | BKE_paint_init(bmain, scene, PAINT_MODE_SCULPT, PAINT_CURSOR_SCULPT); | ||||
| paint_cursor_start(paint, SCULPT_mode_poll_view3d); | paint_cursor_start(paint, SCULPT_mode_poll_view3d); | ||||
| /* Check dynamic-topology flag; re-enter dynamic-topology mode when changing modes, | /* Check dynamic-topology flag; re-enter dynamic-topology mode when changing modes, | ||||
| * As long as no data was added that is not supported. */ | * As long as no data was added that is not supported. */ | ||||
| if (me->flag & ME_SCULPT_DYNAMIC_TOPOLOGY) { | if (me->flag & ME_SCULPT_DYNAMIC_TOPOLOGY) { | ||||
| MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob); | |||||
| const char *message_unsupported = NULL; | const char *message_unsupported = NULL; | ||||
| if (me->totloop != me->totpoly * 3) { | if (me->totloop != me->totpoly * 3) { | ||||
| message_unsupported = TIP_("non-triangle face"); | message_unsupported = TIP_("non-triangle face"); | ||||
| } | } | ||||
| else if (mmd != NULL) { | else if (mmd != NULL) { | ||||
| message_unsupported = TIP_("multi-res modifier"); | message_unsupported = TIP_("multi-res modifier"); | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 1,357 Lines • Show Last 20 Lines | |||||