[Bf-blender-cvs] [35b731c9c8b] blender2.8: Prevent crash on weight paint

Dalai Felinto noreply at git.blender.org
Thu Mar 30 11:42:23 CEST 2017


Commit: 35b731c9c8bdd996e9f418763f107a2e8e98516d
Author: Dalai Felinto
Date:   Thu Mar 30 11:18:57 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB35b731c9c8bdd996e9f418763f107a2e8e98516d

Prevent crash on weight paint

Weight painting is still wrong, but it doesn't crash any more.

===================================================================

M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/intern/paint.c
M	source/blender/draw/intern/draw_view.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/render/render_update.c
M	source/blender/editors/sculpt_paint/paint_utils.c
M	source/blender/editors/space_buttons/buttons_context.c
M	source/blender/editors/space_view3d/drawobject.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/editors/transform/transform_generics.c
M	source/blender/makesrna/intern/rna_brush.c
M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_texture.c

===================================================================

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;
 		cas

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list