diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-03-30 12:18:57 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-03-30 12:25:53 +0300 |
commit | 35b731c9c8bdd996e9f418763f107a2e8e98516d (patch) | |
tree | af1dfeda74693aae40f962958ef61d8c195ad691 | |
parent | f4d597efffcb129614988f081d7f239ec1733642 (diff) |
Prevent crash on weight paint
Weight painting is still wrong, but it doesn't crash any more.
-rw-r--r-- | source/blender/blenkernel/BKE_paint.h | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 30 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_view.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 6 | ||||
-rw-r--r-- | source/blender/editors/render/render_update.c | 9 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_utils.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_buttons/buttons_context.c | 14 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 2 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_generics.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_brush.c | 31 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 15 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_texture.c | 18 |
14 files changed, 95 insertions, 54 deletions
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 0a3cc950f32..f72c4ad9dac 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -52,6 +52,7 @@ struct PaletteColor; struct PBVH; struct ReportList; struct Scene; +struct SceneLayer; struct Sculpt; struct StrokeCache; struct Tex; @@ -89,8 +90,8 @@ typedef enum OverlayControlFlags { PAINT_OVERLAY_OVERRIDE_PRIMARY | \ PAINT_OVERLAY_OVERRIDE_CURSOR) -void BKE_paint_invalidate_overlay_tex(struct Scene *scene, const struct Tex *tex); -void BKE_paint_invalidate_cursor_overlay(struct Scene *scene, struct CurveMapping *curve); +void BKE_paint_invalidate_overlay_tex(struct Scene *scene, struct SceneLayer *sl, const struct Tex *tex); +void BKE_paint_invalidate_cursor_overlay(struct Scene *scene, struct SceneLayer *sl, struct CurveMapping *curve); void BKE_paint_invalidate_overlay_all(void); OverlayControlFlags BKE_paint_get_overlay_flags(void); void BKE_paint_reset_overlay_invalid(OverlayControlFlags flag); @@ -120,7 +121,7 @@ void BKE_paint_cavity_curve_preset(struct Paint *p, int preset); short BKE_paint_object_mode_from_paint_mode(PaintMode mode); struct Paint *BKE_paint_get_active_from_paintmode(struct Scene *sce, PaintMode mode); -struct Paint *BKE_paint_get_active(struct Scene *sce); +struct Paint *BKE_paint_get_active(struct Scene *sce, struct SceneLayer *sl); struct Paint *BKE_paint_get_active_from_context(const struct bContext *C); PaintMode BKE_paintmode_get_active_from_context(const struct bContext *C); struct Brush *BKE_paint_brush(struct Paint *paint); diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 6b954f060d3..ff29c1c3895 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -73,9 +73,9 @@ const char PAINT_CURSOR_TEXTURE_PAINT[3] = {255, 255, 255}; static OverlayControlFlags overlay_flags = 0; -void BKE_paint_invalidate_overlay_tex(Scene *scene, const Tex *tex) +void BKE_paint_invalidate_overlay_tex(Scene *scene, SceneLayer *sl, const Tex *tex) { - Paint *p = BKE_paint_get_active(scene); + Paint *p = BKE_paint_get_active(scene, sl); Brush *br = p->brush; if (!br) @@ -87,9 +87,9 @@ void BKE_paint_invalidate_overlay_tex(Scene *scene, const Tex *tex) overlay_flags |= PAINT_INVALID_OVERLAY_TEXTURE_SECONDARY; } -void BKE_paint_invalidate_cursor_overlay(Scene *scene, CurveMapping *curve) +void BKE_paint_invalidate_cursor_overlay(Scene *scene, SceneLayer *sl, CurveMapping *curve) { - Paint *p = BKE_paint_get_active(scene); + Paint *p = BKE_paint_get_active(scene, sl); Brush *br = p->brush; if (br && br->curve == curve) @@ -155,13 +155,13 @@ Paint *BKE_paint_get_active_from_paintmode(Scene *sce, PaintMode mode) return NULL; } -Paint *BKE_paint_get_active(Scene *sce) +Paint *BKE_paint_get_active(Scene *sce, SceneLayer *sl) { - if (sce) { + if (sce && sl) { ToolSettings *ts = sce->toolsettings; - if (sce->basact && sce->basact->object) { - switch (sce->basact->object->mode) { + if (sl->basact && sl->basact->object) { + switch (sl->basact->object->mode) { case OB_MODE_SCULPT: return &ts->sculpt->paint; case OB_MODE_VERTEX_PAINT: @@ -187,14 +187,15 @@ Paint *BKE_paint_get_active(Scene *sce) Paint *BKE_paint_get_active_from_context(const bContext *C) { Scene *sce = CTX_data_scene(C); + SceneLayer *sl = CTX_data_scene_layer(C); SpaceImage *sima; - if (sce) { + if (sce && sl) { ToolSettings *ts = sce->toolsettings; Object *obact = NULL; - if (sce->basact && sce->basact->object) - obact = sce->basact->object; + if (sl->basact && sl->basact->object) + obact = sl->basact->object; if ((sima = CTX_wm_space_image(C)) != NULL) { if (obact && obact->mode == OB_MODE_EDIT) { @@ -237,14 +238,15 @@ Paint *BKE_paint_get_active_from_context(const bContext *C) PaintMode BKE_paintmode_get_active_from_context(const bContext *C) { Scene *sce = CTX_data_scene(C); + SceneLayer *sl = CTX_data_scene_layer(C); SpaceImage *sima; - if (sce) { + if (sce && sl) { ToolSettings *ts = sce->toolsettings; Object *obact = NULL; - if (sce->basact && sce->basact->object) - obact = sce->basact->object; + if (sl->basact && sl->basact->object) + obact = sl->basact->object; if ((sima = CTX_wm_space_image(C)) != NULL) { if (obact && obact->mode == OB_MODE_EDIT) { diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index 80828d2f11c..3ce1d92ed3a 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -604,7 +604,7 @@ static bool is_cursor_visible(Scene *scene, SceneLayer *sl) } /* exception: object in texture paint mode, clone brush, use_clone_layer disabled */ else if (ob->mode & OB_MODE_TEXTURE_PAINT) { - const Paint *p = BKE_paint_get_active(scene); + const Paint *p = BKE_paint_get_active(scene, sl); if (p && p->brush && p->brush->imagepaint_tool == PAINT_TOOL_CLONE) { if ((scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE) == 0) { diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 22951411d45..74a156f1355 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -5192,7 +5192,8 @@ static int ui_do_but_COLOR( if (!event->ctrl) { float color[3]; Scene *scene = CTX_data_scene(C); - Paint *paint = BKE_paint_get_active(scene); + SceneLayer *sl = CTX_data_scene_layer(C); + Paint *paint = BKE_paint_get_active(scene, sl); Brush *brush = BKE_paint_brush(paint); if (brush->flag & BRUSH_USE_GRADIENT) { @@ -6100,6 +6101,7 @@ static int ui_do_but_CURVE( int mx, my, a; bool changed = false; Scene *scene = CTX_data_scene(C); + SceneLayer *sl = CTX_data_scene_layer(C); mx = event->x; my = event->y; @@ -6228,7 +6230,7 @@ static int ui_do_but_CURVE( } else { curvemapping_changed(cumap, true); /* remove doubles */ - BKE_paint_invalidate_cursor_overlay(scene, cumap); + BKE_paint_invalidate_cursor_overlay(scene, sl, cumap); } } diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index f11a8177bf8..899b9e0ece7 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -48,6 +48,7 @@ #include "BKE_context.h" #include "BKE_DerivedMesh.h" #include "BKE_icons.h" +#include "BKE_layer.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_node.h" @@ -374,6 +375,7 @@ static void texture_changed(Main *bmain, Tex *tex) Lamp *la; World *wo; Scene *scene; + SceneLayer *sl; Object *ob; bNode *node; bool texture_draw = false; @@ -382,8 +384,11 @@ static void texture_changed(Main *bmain, Tex *tex) BKE_icon_changed(BKE_icon_id_ensure(&tex->id)); /* paint overlays */ - for (scene = bmain->scene.first; scene; scene = scene->id.next) - BKE_paint_invalidate_overlay_tex(scene, tex); + for (scene = bmain->scene.first; scene; scene = scene->id.next) { + for (sl = scene->render_layers.first; sl; sl = sl->next) { + BKE_paint_invalidate_overlay_tex(scene, sl, tex); + } + } /* find materials */ for (ma = bmain->mat.first; ma; ma = ma->id.next) { diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 23c0f680a64..7c3aca80ada 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -556,8 +556,9 @@ static int brush_curve_preset_exec(bContext *C, wmOperator *op) if (br) { Scene *scene = CTX_data_scene(C); + SceneLayer *sl = CTX_data_scene_layer(C); BKE_brush_curve_preset(br, RNA_enum_get(op->ptr, "shape")); - BKE_paint_invalidate_cursor_overlay(scene, br->curve); + BKE_paint_invalidate_cursor_overlay(scene, sl, br->curve); } return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 3727c29d9d0..f6e0d7100e9 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -370,7 +370,7 @@ static int buttons_context_path_particle(ButsContextPath *path) return 0; } -static int buttons_context_path_brush(ButsContextPath *path) +static int buttons_context_path_brush(const bContext *C, ButsContextPath *path) { Scene *scene; Brush *br = NULL; @@ -384,8 +384,10 @@ static int buttons_context_path_brush(ButsContextPath *path) else if (buttons_context_path_scene(path)) { scene = path->ptr[path->len - 1].data; - if (scene) - br = BKE_paint_brush(BKE_paint_get_active(scene)); + if (scene) { + SceneLayer *sl = CTX_data_scene_layer(C); + br = BKE_paint_brush(BKE_paint_get_active(scene, sl)); + } if (br) { RNA_id_pointer_create((ID *)br, &path->ptr[path->len]); @@ -399,7 +401,7 @@ static int buttons_context_path_brush(ButsContextPath *path) return 0; } -static int buttons_context_path_texture(ButsContextPath *path, ButsContextTexture *ct) +static int buttons_context_path_texture(const bContext *C, ButsContextPath *path, ButsContextTexture *ct) { if (ct) { /* new shading system */ @@ -417,7 +419,7 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur if (id) { if (GS(id->name) == ID_BR) - buttons_context_path_brush(path); + buttons_context_path_brush(C, path); else if (GS(id->name) == ID_MA) buttons_context_path_material(path, false, true); else if (GS(id->name) == ID_WO) @@ -650,7 +652,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma found = buttons_context_path_material(path, false, (sbuts->texuser != NULL)); break; case BCONTEXT_TEXTURE: - found = buttons_context_path_texture(path, sbuts->texuser); + found = buttons_context_path_texture(C, path, sbuts->texuser); break; case BCONTEXT_BONE: found = buttons_context_path_bone(path); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index be0a612a8d8..da261d437c9 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -4359,7 +4359,7 @@ static void draw_mesh_fancy(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); - if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene))) { + if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene, sl))) { GPUVertexAttribs gattribs; float planes[4][4]; float (*fpl)[4] = NULL; @@ -4451,7 +4451,7 @@ static void draw_mesh_fancy(Scene *scene, SceneLayer *sl, ARegion *ar, View3D *v glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); - if (ob->sculpt && (p = BKE_paint_get_active(scene))) { + if (ob->sculpt && (p = BKE_paint_get_active(scene, sl))) { float planes[4][4]; float (*fpl)[4] = NULL; const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING); @@ -4838,7 +4838,7 @@ static void draw_mesh_fancy_new(Scene *scene, SceneLayer *sl, ARegion *ar, View3 glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); - if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene))) { + if ((v3d->flag2 & V3D_SHOW_SOLID_MATCAP) && ob->sculpt && (p = BKE_paint_get_active(scene, sl))) { GPUVertexAttribs gattribs; float planes[4][4]; float (*fpl)[4] = NULL; @@ -4927,7 +4927,7 @@ static void draw_mesh_fancy_new(Scene *scene, SceneLayer *sl, ARegion *ar, View3 glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); - if (ob->sculpt && (p = BKE_paint_get_active(scene))) { + if (ob->sculpt && (p = BKE_paint_get_active(scene, sl))) { float planes[4][4]; float (*fpl)[4] = NULL; const bool fast = (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index eef040053e9..9fac823a84f 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1497,7 +1497,7 @@ static bool is_cursor_visible(Scene *scene, SceneLayer *sl) } /* exception: object in texture paint mode, clone brush, use_clone_layer disabled */ else if (ob->mode & OB_MODE_TEXTURE_PAINT) { - const Paint *p = BKE_paint_get_active(scene); + const Paint *p = BKE_paint_get_active(scene, sl); if (p && p->brush && p->brush->imagepaint_tool == PAINT_TOOL_CLONE) { if ((scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE) == 0) { diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 3ece7f40b92..3eda8992826 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1786,7 +1786,7 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]) } } else if (t->options & CTX_PAINT_CURVE) { - Paint *p = BKE_paint_get_active(t->scene); + Paint *p = BKE_paint_get_active(t->scene, t->sl); Brush *br = p->brush; PaintCurve *pc = br->paint_curve; copy_v3_v3(r_center, pc->points[pc->add_index - 1].bez.vec[1]); diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index ac348c1750c..a51e7bfe6d8 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -360,17 +360,19 @@ static void rna_Brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerR /*WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL); */ } -static void rna_Brush_main_tex_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Brush_main_tex_update(Main *bmain, bContext *C, Scene *scene, PointerRNA *ptr) { + SceneLayer *sl = CTX_data_scene_layer(C); Brush *br = (Brush *)ptr->data; - BKE_paint_invalidate_overlay_tex(scene, br->mtex.tex); + BKE_paint_invalidate_overlay_tex(scene, sl, br->mtex.tex); rna_Brush_update(bmain, scene, ptr); } -static void rna_Brush_secondary_tex_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Brush_secondary_tex_update(Main *bmain, bContext *C, Scene *scene, PointerRNA *ptr) { + SceneLayer *sl = CTX_data_scene_layer(C); Brush *br = (Brush *)ptr->data; - BKE_paint_invalidate_overlay_tex(scene, br->mask_mtex.tex); + BKE_paint_invalidate_overlay_tex(scene, sl, br->mask_mtex.tex); rna_Brush_update(bmain, scene, ptr); } @@ -426,14 +428,16 @@ static void rna_Brush_icon_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi WM_main_add_notifier(NC_BRUSH | NA_EDITED, br); } -static void rna_TextureSlot_brush_angle_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_TextureSlot_brush_angle_update(Main *bmain, bContext *C, Scene *scene, PointerRNA *ptr) { MTex *mtex = ptr->data; /* skip invalidation of overlay for stencil mode */ - if (mtex->mapping != MTEX_MAP_MODE_STENCIL) - BKE_paint_invalidate_overlay_tex(scene, mtex->tex); + if (mtex->mapping != MTEX_MAP_MODE_STENCIL) { + SceneLayer *sl = CTX_data_scene_layer(C); + BKE_paint_invalidate_overlay_tex(scene, sl, mtex->tex); + } - rna_TextureSlot_update(bmain, scene, ptr); + rna_TextureSlot_update(bmain, C, scene, ptr); } static void rna_Brush_set_size(PointerRNA *ptr, int value) @@ -647,39 +651,46 @@ static void rna_def_brush_texture_slot(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "rot"); RNA_def_property_range(prop, 0, M_PI * 2); RNA_def_property_ui_text(prop, "Angle", "Brush texture rotation"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_TextureSlot_brush_angle_update"); prop = RNA_def_property(srna, "map_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode"); RNA_def_property_enum_items(prop, prop_map_mode_items); RNA_def_property_ui_text(prop, "Mode", ""); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "tex_paint_map_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode"); RNA_def_property_enum_items(prop, prop_tex_paint_map_mode_items); RNA_def_property_ui_text(prop, "Mode", ""); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "mask_map_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "brush_map_mode"); RNA_def_property_enum_items(prop, prop_mask_paint_map_mode_items); RNA_def_property_ui_text(prop, "Mode", ""); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "use_rake", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "brush_angle_mode", MTEX_ANGLE_RAKE); RNA_def_property_ui_text(prop, "Rake", ""); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "use_random", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "brush_angle_mode", MTEX_ANGLE_RANDOM); RNA_def_property_ui_text(prop, "Random", ""); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "random_angle", PROP_FLOAT, PROP_ANGLE); RNA_def_property_range(prop, 0, M_PI * 2); RNA_def_property_ui_text(prop, "Random Angle", "Brush texture random angle"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); TEXTURE_CAPABILITY(has_texture_angle_source, "Has Texture Angle Source"); @@ -1338,7 +1349,7 @@ static void rna_def_brush(BlenderRNA *brna) prop = RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "mtex.tex"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Texture", ""); RNA_def_property_update(prop, NC_TEXTURE, "rna_Brush_main_tex_update"); @@ -1350,7 +1361,7 @@ static void rna_def_brush(BlenderRNA *brna) prop = RNA_def_property(srna, "mask_texture", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "mask_mtex.tex"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Mask Texture", ""); RNA_def_property_update(prop, NC_TEXTURE, "rna_Brush_secondary_tex_update"); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index b904b65a37a..c79f6c3bd9a 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -236,7 +236,7 @@ int rna_object_shapekey_index_set(struct ID *id, PointerRNA value, int current); /* named internal so as not to conflict with obj.update() rna func */ void rna_Object_internal_update_data(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr); void rna_Mesh_update_draw(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr); -void rna_TextureSlot_update(struct Main *bmain, struct Scene *scene, struct PointerRNA *ptr); +void rna_TextureSlot_update(struct Main *bmain, struct bContext *C, struct Scene *scene, struct PointerRNA *ptr); /* basic poll functions for object types */ int rna_Armature_object_poll(struct PointerRNA *ptr, struct PointerRNA value); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 13a51988989..1108f2b7cb5 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1995,9 +1995,10 @@ static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, cons } } -static void rna_UnifiedPaintSettings_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +static void rna_UnifiedPaintSettings_update(Main *UNUSED(bmain), bContext *C, Scene *scene, PointerRNA *UNUSED(ptr)) { - Brush *br = BKE_paint_brush(BKE_paint_get_active(scene)); + SceneLayer *sl = CTX_data_scene_layer(C); + Brush *br = BKE_paint_brush(BKE_paint_get_active(scene, sl)); WM_main_add_notifier(NC_BRUSH | NA_EDITED, br); } @@ -2020,11 +2021,11 @@ static void rna_UnifiedPaintSettings_unprojected_radius_set(PointerRNA *ptr, flo ups->unprojected_radius = value; } -static void rna_UnifiedPaintSettings_radius_update(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_UnifiedPaintSettings_radius_update(Main *bmain, bContext *C, Scene *scene, PointerRNA *ptr) { /* changing the unified size should invalidate the overlay but also update the brush */ BKE_paint_invalidate_overlay_all(); - rna_UnifiedPaintSettings_update(bmain, scene, ptr); + rna_UnifiedPaintSettings_update(bmain, C, scene, ptr); } static char *rna_UnifiedPaintSettings_path(PointerRNA *UNUSED(ptr)) @@ -3737,6 +3738,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna) * from the active brush */ prop = RNA_def_property(srna, "size", PROP_INT, PROP_PIXEL); RNA_def_property_int_funcs(prop, NULL, "rna_UnifiedPaintSettings_size_set", NULL); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS * 10); RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, -1); RNA_def_property_ui_text(prop, "Radius", "Radius of the brush"); @@ -3744,6 +3746,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "unprojected_radius", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_funcs(prop, NULL, "rna_UnifiedPaintSettings_unprojected_radius_set", NULL); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_range(prop, 0.001, FLT_MAX); RNA_def_property_ui_range(prop, 0.001, 1, 0, -1); RNA_def_property_ui_text(prop, "Unprojected Radius", "Radius of brush in Blender units"); @@ -3751,6 +3754,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "alpha"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_float_default(prop, 0.5f); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3); @@ -3759,6 +3763,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "weight"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_float_default(prop, 0.5f); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.001, 3); @@ -3766,12 +3771,14 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update"); prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_float_sdna(prop, NULL, "rgb"); RNA_def_property_ui_text(prop, "Color", ""); RNA_def_property_update(prop, 0, "rna_UnifiedPaintSettings_update"); prop = RNA_def_property(srna, "secondary_color", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_float_sdna(prop, NULL, "secondary_rgb"); RNA_def_property_ui_text(prop, "Secondary Color", ""); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 1e88585a286..3a3359e1008 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -225,7 +225,7 @@ static void rna_Texture_type_set(PointerRNA *ptr, int value) BKE_texture_type_set(tex, value); } -void rna_TextureSlot_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) +void rna_TextureSlot_update(Main *UNUSED(bmain), bContext *C, Scene *scene, PointerRNA *ptr) { ID *id = ptr->id.data; @@ -246,7 +246,8 @@ void rna_TextureSlot_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) case ID_BR: { MTex *mtex = ptr->data; - BKE_paint_invalidate_overlay_tex(scene, mtex->tex); + SceneLayer *sl = CTX_data_scene_layer(C); + BKE_paint_invalidate_overlay_tex(scene, sl, mtex->tex); WM_main_add_notifier(NC_BRUSH, id); break; } @@ -645,7 +646,7 @@ static void rna_def_mtex(BlenderRNA *brna) prop = RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tex"); RNA_def_property_struct_type(prop, "Texture"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Texture", "Texture data-block used by this texture slot"); RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, "rna_TextureSlot_update"); @@ -653,6 +654,7 @@ static void rna_def_mtex(BlenderRNA *brna) RNA_def_property_string_funcs(prop, "rna_TextureSlot_name_get", "rna_TextureSlot_name_length", NULL); RNA_def_property_ui_text(prop, "Name", "Texture slot name"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_struct_name_property(srna, prop); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); @@ -660,12 +662,13 @@ static void rna_def_mtex(BlenderRNA *brna) prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "ofs"); RNA_def_property_ui_range(prop, -10, 10, 10, RNA_TRANSLATION_PREC_DEFAULT); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Offset", "Fine tune of the texture mapping X, Y and Z locations"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); - RNA_def_property_flag(prop, PROP_PROPORTIONAL); + RNA_def_property_flag(prop, PROP_PROPORTIONAL | PROP_CONTEXT_UPDATE); RNA_def_property_ui_range(prop, -100, 100, 10, 2); RNA_def_property_ui_text(prop, "Size", "Set scaling for the texture's X, Y and Z sizes"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); @@ -673,6 +676,7 @@ static void rna_def_mtex(BlenderRNA *brna) prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "r"); RNA_def_property_array(prop, 3); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Color", "Default color for textures that don't return RGB or when RGB to intensity is enabled"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); @@ -680,26 +684,31 @@ static void rna_def_mtex(BlenderRNA *brna) prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "blendtype"); RNA_def_property_enum_items(prop, blend_type_items); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Blend Type", "Mode used to apply the texture"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "use_stencil", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_STENCIL); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Stencil", "Use this texture as a blending value on the next texture"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_NEGATIVE); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "Negate", "Invert the values of the texture to reverse its effect"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "use_rgb_to_intensity", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "texflag", MTEX_RGBTOINT); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_ui_text(prop, "RGB to Intensity", "Convert texture RGB values to intensity (gray) values"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); prop = RNA_def_property(srna, "default_value", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "def_var"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Default Value", "Value to use for Ref, Spec, Amb, Emit, Alpha, RayMir, TransLu and Hard"); @@ -708,6 +717,7 @@ static void rna_def_mtex(BlenderRNA *brna) prop = RNA_def_property(srna, "output_node", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "which_output"); RNA_def_property_enum_items(prop, output_node_items); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_enum_funcs(prop, "rna_TextureSlot_output_node_get", NULL, "rna_TextureSlot_output_node_itemf"); RNA_def_property_ui_text(prop, "Output Node", "Which output node to use, for node-based textures"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); |