diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_sculpt_paint.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_sculpt_paint.c | 104 |
1 files changed, 69 insertions, 35 deletions
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 6dbfc3634b2..06c0260d08f 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -39,6 +39,7 @@ #include "DNA_brush_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "DNA_workspace_types.h" #include "BKE_paint.h" #include "BKE_material.h" @@ -106,8 +107,10 @@ const EnumPropertyItem rna_enum_symmetrize_direction_items[] = { #include "BKE_DerivedMesh.h" #include "BKE_pointcache.h" #include "BKE_particle.h" -#include "BKE_depsgraph.h" #include "BKE_pbvh.h" +#include "BKE_object.h" + +#include "DEG_depsgraph.h" #include "GPU_buffers.h" @@ -152,10 +155,12 @@ static PointerRNA rna_ParticleBrush_curve_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_CurveMapping, NULL); } -static void rna_ParticleEdit_redo(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_ParticleEdit_redo(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *ob = (scene->basact) ? scene->basact->object : NULL; - PTCacheEdit *edit = PE_get_current(scene, ob); + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); + PTCacheEdit *edit = PE_get_current(scene, view_layer, ob); if (!edit) return; @@ -163,21 +168,23 @@ static void rna_ParticleEdit_redo(Main *UNUSED(bmain), Scene *scene, PointerRNA psys_free_path_cache(edit->psys, edit); } -static void rna_ParticleEdit_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_ParticleEdit_update(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *ob = (scene->basact) ? scene->basact->object : NULL; + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); - if (ob) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + if (ob) DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } + static void rna_ParticleEdit_tool_set(PointerRNA *ptr, int value) { ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data; /* redraw hair completely if weight brush is/was used */ - if ((pset->brushtype == PE_BRUSH_WEIGHT || value == PE_BRUSH_WEIGHT) && pset->scene) { - Object *ob = (pset->scene->basact) ? pset->scene->basact->object : NULL; + if ((pset->brushtype == PE_BRUSH_WEIGHT || value == PE_BRUSH_WEIGHT) && pset->view_layer) { + Object *ob = (pset->view_layer->basact) ? pset->view_layer->basact->object : NULL; if (ob) { - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, NULL); } } @@ -187,9 +194,10 @@ static void rna_ParticleEdit_tool_set(PointerRNA *ptr, int value) static const EnumPropertyItem *rna_ParticleEdit_tool_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *UNUSED(r_free)) { - Scene *scene = CTX_data_scene(C); - Object *ob = (scene->basact) ? scene->basact->object : NULL; + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); #if 0 + Scene *scene = CTX_data_scene(C); PTCacheEdit *edit = PE_get_current(scene, ob); ParticleSystem *psys = edit ? edit->psys : NULL; #else @@ -215,14 +223,14 @@ static int rna_ParticleEdit_editable_get(PointerRNA *ptr) { ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data; - return (pset->object && pset->scene && PE_get_current(pset->scene, pset->object)); + return (pset->object && pset->scene && PE_get_current(pset->scene, pset->view_layer, pset->object)); } static int rna_ParticleEdit_hair_get(PointerRNA *ptr) { ParticleEditSettings *pset = (ParticleEditSettings *)ptr->data; if (pset->scene) { - PTCacheEdit *edit = PE_get_current(pset->scene, pset->object); + PTCacheEdit *edit = PE_get_current(pset->scene, pset->view_layer, pset->object); return (edit && edit->psys); } @@ -257,12 +265,14 @@ static int rna_Brush_mode_poll(PointerRNA *ptr, PointerRNA value) return brush->ob_mode & mode; } -static void rna_Sculpt_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_Sculpt_update(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *ob = (scene->basact) ? scene->basact->object : NULL; + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); if (ob) { - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob); if (ob->sculpt) { @@ -272,11 +282,13 @@ static void rna_Sculpt_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNU } } -static void rna_Sculpt_ShowDiffuseColor_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_Sculpt_ShowDiffuseColor_update(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *ob = (scene->basact) ? scene->basact->object : NULL; + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); if (ob && ob->sculpt) { + Scene *scene = CTX_data_scene(C); Sculpt *sd = scene->toolsettings->sculpt; ob->sculpt->show_diffuse_color = ((sd->flags & SCULPT_SHOW_DIFFUSE) != 0); @@ -287,12 +299,14 @@ static void rna_Sculpt_ShowDiffuseColor_update(Main *UNUSED(bmain), Scene *scene } } -static void rna_Sculpt_ShowMask_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_Sculpt_ShowMask_update(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *object = (scene->basact) ? scene->basact->object : NULL; + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *object = OBACT(view_layer); if (object == NULL || object->sculpt == NULL) { return; } + Scene *scene = CTX_data_scene(C); Sculpt *sd = scene->toolsettings->sculpt; object->sculpt->show_mask = ((sd->flags & SCULPT_HIDE_MASK) == 0); if (object->sculpt->pbvh != NULL) { @@ -347,9 +361,11 @@ static void rna_ImaPaint_viewport_update(Main *UNUSED(bmain), Scene *UNUSED(scen WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); } -static void rna_ImaPaint_mode_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_ImaPaint_mode_update(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *ob = OBACT; + Scene *scene = CTX_data_scene(C);\ + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); if (ob && ob->type == OB_MESH) { /* of course we need to invalidate here */ @@ -362,9 +378,11 @@ static void rna_ImaPaint_mode_update(Main *UNUSED(bmain), Scene *scene, PointerR } } -static void rna_ImaPaint_stencil_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_ImaPaint_stencil_update(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *ob = OBACT; + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); if (ob && ob->type == OB_MESH) { GPU_drawobject_free(ob->derivedFinal); @@ -373,22 +391,27 @@ static void rna_ImaPaint_stencil_update(Main *UNUSED(bmain), Scene *scene, Point } } -static void rna_ImaPaint_canvas_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_ImaPaint_canvas_update(bContext *C, PointerRNA *UNUSED(ptr)) { - Object *ob = OBACT; + const WorkSpace *workspace = CTX_wm_workspace(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); + Object *ob = OBACT(view_layer); + Object *obedit = ((workspace->object_mode & OB_MODE_EDIT) && BKE_object_is_in_editmode(ob)) ? ob : NULL; bScreen *sc; Image *ima = scene->toolsettings->imapaint.canvas; for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { - SpaceLink *sl; - for (sl = sa->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_IMAGE) { - SpaceImage *sima = (SpaceImage *)sl; + SpaceLink *slink; + for (slink = sa->spacedata.first; slink; slink = slink->next) { + if (slink->spacetype == SPACE_IMAGE) { + SpaceImage *sima = (SpaceImage *)slink; if (!sima->pin) - ED_space_image_set(sima, scene, scene->obedit, ima); + ED_space_image_set(sima, scene, obedit, ima); } } } @@ -600,17 +623,20 @@ static void rna_def_sculpt(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Use Deform Only", "Use only deformation modifiers (temporary disable all " "constructive modifiers except multi-resolution)"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update"); prop = RNA_def_property(srna, "show_diffuse_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SHOW_DIFFUSE); RNA_def_property_ui_text(prop, "Show Diffuse Color", "Show diffuse color of object and overlay sculpt mask on top of it"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowDiffuseColor_update"); prop = RNA_def_property(srna, "show_mask", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flags", SCULPT_HIDE_MASK); RNA_def_property_ui_text(prop, "Show Mask", "Show mask as overlay on object"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowMask_update"); prop = RNA_def_property(srna, "detail_size", PROP_FLOAT, PROP_PIXEL); @@ -636,6 +662,7 @@ static void rna_def_sculpt(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Smooth Shading", "Show faces in dynamic-topology mode with smooth " "shading rather than flat shaded"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update"); prop = RNA_def_property(srna, "symmetrize_direction", PROP_ENUM, PROP_NONE); @@ -761,12 +788,12 @@ static void rna_def_image_paint(BlenderRNA *brna) prop = RNA_def_property(srna, "stencil_image", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "stencil"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Stencil Image", "Image used as stencil"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_stencil_update"); prop = RNA_def_property(srna, "canvas", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Canvas", "Image used as canvas"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_canvas_update"); @@ -808,6 +835,7 @@ static void rna_def_image_paint(BlenderRNA *brna) RNA_def_property_range(prop, 512, 16384); prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_enum_items(prop, paint_type_items); RNA_def_property_ui_text(prop, "Mode", "Mode of operation for projection painting"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_mode_update"); @@ -887,6 +915,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_property_enum_bitflag_sdna(prop, NULL, "selectmode"); RNA_def_property_enum_items(prop, select_mode_items); RNA_def_property_ui_text(prop, "Selection Mode", "Particle select and display mode"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ParticleEdit_update"); prop = RNA_def_property(srna, "use_preserve_length", PROP_BOOLEAN, PROP_NONE); @@ -909,6 +938,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) prop = RNA_def_property(srna, "use_fade_time", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_FADE_TIME); RNA_def_property_ui_text(prop, "Fade Time", "Fade paths and keys further away from current frame"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ParticleEdit_update"); prop = RNA_def_property(srna, "use_auto_velocity", PROP_BOOLEAN, PROP_NONE); @@ -916,6 +946,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Auto Velocity", "Calculate point velocities automatically"); prop = RNA_def_property(srna, "show_particles", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PE_DRAW_PART); RNA_def_property_ui_text(prop, "Draw Particles", "Draw actual particles"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ParticleEdit_redo"); @@ -936,6 +967,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Brush", ""); prop = RNA_def_property(srna, "draw_step", PROP_INT, PROP_NONE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_range(prop, 1, 10); RNA_def_property_ui_text(prop, "Steps", "How many steps to draw the path with"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ParticleEdit_redo"); @@ -943,9 +975,11 @@ static void rna_def_particle_edit(BlenderRNA *brna) prop = RNA_def_property(srna, "fade_frames", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 1, 100); RNA_def_property_ui_text(prop, "Frames", "How many frames to fade"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ParticleEdit_update"); prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_enum_sdna(prop, NULL, "edittype"); RNA_def_property_enum_items(prop, edit_type_items); RNA_def_property_ui_text(prop, "Type", ""); @@ -966,7 +1000,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Object", "The edited object"); prop = RNA_def_property(srna, "shape_object", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Shape Object", "Outer shape to use for tools"); RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Mesh_object_poll"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_ParticleEdit_redo"); |