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 /source/blender/blenkernel | |
parent | f4d597efffcb129614988f081d7f239ec1733642 (diff) |
Prevent crash on weight paint
Weight painting is still wrong, but it doesn't crash any more.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_paint.h | 7 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 30 |
2 files changed, 20 insertions, 17 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) { |