Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt.c
| Show First 20 Lines • Show All 4,916 Lines • ▼ Show 20 Lines | return ((stroke_mode == BRUSH_STROKE_SMOOTH) || (cache && cache->alt_smooth) || | ||||
| ((brush->sculpt_tool == SCULPT_TOOL_MASK) && (brush->mask_tool == BRUSH_MASK_SMOOTH))); | ((brush->sculpt_tool == SCULPT_TOOL_MASK) && (brush->mask_tool == BRUSH_MASK_SMOOTH))); | ||||
| } | } | ||||
| static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *brush) | static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *brush) | ||||
| { | { | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| if (ss->kb || ss->modifiers_active) { | if (ss->kb || ss->modifiers_active) { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | ||||
| bool need_pmap = sculpt_any_smooth_mode(brush, ss->cache, 0); | bool need_pmap = sculpt_any_smooth_mode(brush, ss->cache, 0); | ||||
| BKE_sculpt_update_object_for_edit(depsgraph, ob, need_pmap, false); | BKE_sculpt_update_object_for_edit(depsgraph, ob, need_pmap, false); | ||||
| } | } | ||||
| } | } | ||||
| static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float *tmin) | static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float *tmin) | ||||
| { | { | ||||
| if (BKE_pbvh_node_get_tmin(node) < *tmin) { | if (BKE_pbvh_node_get_tmin(node) < *tmin) { | ||||
| ▲ Show 20 Lines • Show All 196 Lines • ▼ Show 20 Lines | static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession *ss) | ||||
| /* TODO: Shouldn't really have to do this at the start of every | /* TODO: Shouldn't really have to do this at the start of every | ||||
| * stroke, but sculpt would need some sort of notification when | * stroke, but sculpt would need some sort of notification when | ||||
| * changes are made to the texture. */ | * changes are made to the texture. */ | ||||
| sculpt_update_tex(scene, sd, ss); | sculpt_update_tex(scene, sd, ss); | ||||
| } | } | ||||
| static void sculpt_brush_stroke_init(bContext *C, wmOperator *op) | static void sculpt_brush_stroke_init(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| Sculpt *sd = CTX_data_tool_settings(C)->sculpt; | Sculpt *sd = CTX_data_tool_settings(C)->sculpt; | ||||
| SculptSession *ss = CTX_data_active_object(C)->sculpt; | SculptSession *ss = CTX_data_active_object(C)->sculpt; | ||||
| Brush *brush = BKE_paint_brush(&sd->paint); | Brush *brush = BKE_paint_brush(&sd->paint); | ||||
| int mode = RNA_enum_get(op->ptr, "mode"); | int mode = RNA_enum_get(op->ptr, "mode"); | ||||
| bool is_smooth; | bool is_smooth; | ||||
| bool need_mask = false; | bool need_mask = false; | ||||
| Show All 31 Lines | if (ob->runtime.bb) { | ||||
| BKE_pbvh_bounding_box(ob->sculpt->pbvh, bb_min, bb_max); | BKE_pbvh_bounding_box(ob->sculpt->pbvh, bb_min, bb_max); | ||||
| BKE_boundbox_init_from_minmax(ob->runtime.bb, bb_min, bb_max); | BKE_boundbox_init_from_minmax(ob->runtime.bb, bb_min, bb_max); | ||||
| } | } | ||||
| } | } | ||||
| static void sculpt_flush_update_step(bContext *C) | static void sculpt_flush_update_step(bContext *C) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| MultiresModifierData *mmd = ss->multires; | MultiresModifierData *mmd = ss->multires; | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| if (mmd != NULL) { | if (mmd != NULL) { | ||||
| multires_mark_as_modified(depsgraph, ob, MULTIRES_COORDS_MODIFIED); | multires_mark_as_modified(depsgraph, ob, MULTIRES_COORDS_MODIFIED); | ||||
| ▲ Show 20 Lines • Show All 552 Lines • ▼ Show 20 Lines | static void sculpt_dynamic_topology_disable_ex( | ||||
| * are re-evaluated and the PBVH is re-created */ | * are re-evaluated and the PBVH is re-created */ | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | ||||
| BKE_scene_graph_update_tagged(depsgraph, bmain); | BKE_scene_graph_update_tagged(depsgraph, bmain); | ||||
| } | } | ||||
| void sculpt_dynamic_topology_disable(bContext *C, SculptUndoNode *unode) | void sculpt_dynamic_topology_disable(bContext *C, SculptUndoNode *unode) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| sculpt_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, unode); | sculpt_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, unode); | ||||
| } | } | ||||
| static void sculpt_dynamic_topology_disable_with_undo(Main *bmain, | static void sculpt_dynamic_topology_disable_with_undo(Main *bmain, | ||||
| Depsgraph *depsgraph, | Depsgraph *depsgraph, | ||||
| Scene *scene, | Scene *scene, | ||||
| Show All 20 Lines | if (ss->bm == NULL) { | ||||
| sculpt_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN); | sculpt_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN); | ||||
| sculpt_undo_push_end(); | sculpt_undo_push_end(); | ||||
| } | } | ||||
| } | } | ||||
| static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(op)) | static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(op)) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| WM_cursor_wait(1); | WM_cursor_wait(1); | ||||
| if (ss->bm) { | if (ss->bm) { | ||||
| sculpt_dynamic_topology_disable_with_undo(bmain, depsgraph, scene, ob); | sculpt_dynamic_topology_disable_with_undo(bmain, depsgraph, scene, ob); | ||||
| ▲ Show 20 Lines • Show All 345 Lines • ▼ Show 20 Lines | else { | ||||
| reports, RPT_WARNING, "Dynamic Topology found: %s, disabled", message_unsupported); | reports, RPT_WARNING, "Dynamic Topology found: %s, disabled", message_unsupported); | ||||
| me->flag &= ~ME_SCULPT_DYNAMIC_TOPOLOGY; | me->flag &= ~ME_SCULPT_DYNAMIC_TOPOLOGY; | ||||
| } | } | ||||
| } | } | ||||
| /* Flush object mode. */ | /* Flush object mode. */ | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | ||||
| } | } | ||||
| void ED_object_sculptmode_exit_ex(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob) | void ED_object_sculptmode_exit_ex(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob) | ||||
brecht: Function is not used anywhere, remove it. | |||||
| { | { | ||||
| 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); | ||||
| MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob); | MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob); | ||||
| if (mmd) { | if (mmd) { | ||||
| multires_force_update(ob); | multires_force_update(ob); | ||||
| } | } | ||||
| Show All 28 Lines | #endif | ||||
| paint_cursor_delete_textures(); | paint_cursor_delete_textures(); | ||||
| /* Never leave derived meshes behind. */ | /* Never leave derived meshes behind. */ | ||||
| BKE_object_free_derived_caches(ob); | BKE_object_free_derived_caches(ob); | ||||
| /* Flush object mode. */ | /* Flush object mode. */ | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | ||||
| } | } | ||||
| static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op) | static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op) | ||||
Done Inline ActionsSame comment as enter. brecht: Same comment as enter. | |||||
| { | { | ||||
| struct wmMsgBus *mbus = CTX_wm_message_bus(C); | struct wmMsgBus *mbus = CTX_wm_message_bus(C); | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph_on_load(C); | Depsgraph *depsgraph = CTX_data_depsgraph_on_load(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ToolSettings *ts = scene->toolsettings; | ToolSettings *ts = scene->toolsettings; | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Object *ob = OBACT(view_layer); | Object *ob = OBACT(view_layer); | ||||
| Show All 29 Lines | static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) | ||||
| ot->name = "Sculpt Mode"; | ot->name = "Sculpt Mode"; | ||||
| ot->idname = "SCULPT_OT_sculptmode_toggle"; | ot->idname = "SCULPT_OT_sculptmode_toggle"; | ||||
| ot->description = "Toggle sculpt mode in 3D view"; | ot->description = "Toggle sculpt mode in 3D view"; | ||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = sculpt_mode_toggle_exec; | ot->exec = sculpt_mode_toggle_exec; | ||||
| ot->poll = ED_operator_object_active_editable_mesh; | ot->poll = ED_operator_object_active_editable_mesh; | ||||
| ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; | ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; | ||||
| } | } | ||||
| static bool sculpt_and_constant_or_manual_detail_poll(bContext *C) | static bool sculpt_and_constant_or_manual_detail_poll(bContext *C) | ||||
| { | { | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| Sculpt *sd = CTX_data_tool_settings(C)->sculpt; | Sculpt *sd = CTX_data_tool_settings(C)->sculpt; | ||||
| return sculpt_mode_poll(C) && ob->sculpt->bm && | return sculpt_mode_poll(C) && ob->sculpt->bm && | ||||
| ▲ Show 20 Lines • Show All 257 Lines • Show Last 20 Lines | |||||
Function is not used anywhere, remove it.