[Bf-blender-cvs] [75f551facaf] master: GPencil: Fix wrong Brush texture for pinned materials

Antonioya noreply at git.blender.org
Sun Apr 7 17:02:20 CEST 2019


Commit: 75f551facaf0a103b169ccc955b57099bd33a16a
Author: Antonioya
Date:   Sun Apr 7 17:02:13 2019 +0200
Branches: master
https://developer.blender.org/rB75f551facaf0a103b169ccc955b57099bd33a16a

GPencil: Fix wrong Brush texture for pinned materials

If the Brush had a pinned material with texture, but the material slot was in a different material, the texture was not working.

The material was not recovered from brush, but from object.

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

M	source/blender/draw/engines/gpencil/gpencil_engine.c

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 3a74e44836d..c5546a55dda 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -22,8 +22,10 @@
 #include "DRW_engine.h"
 #include "DRW_render.h"
 
+#include "BKE_gpencil.h"
 #include "BKE_library.h"
 #include "BKE_object.h"
+#include "BKE_paint.h"
 #include "BKE_shader_fx.h"
 
 #include "DNA_gpencil_types.h"
@@ -302,7 +304,9 @@ void GPENCIL_cache_init(void *vedata)
 	GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
 	const DRWContextState *draw_ctx = DRW_context_state_get();
 	Scene *scene = draw_ctx->scene;
+	ToolSettings *ts = scene->toolsettings;
 	View3D *v3d = draw_ctx->v3d;
+	Brush *brush = BKE_paint_brush(&ts->gp_paint->paint);
 
 	/* Special handling for when active object is GP object (e.g. for draw mode) */
 	Object *obact = draw_ctx->obact;
@@ -311,7 +315,15 @@ void GPENCIL_cache_init(void *vedata)
 
 	if (obact && (obact->type == OB_GPENCIL) && (obact->data)) {
 		obact_gpd = (bGPdata *)obact->data;
-		gp_style = BKE_material_gpencil_settings_get(obact, obact->actcol);
+		/* use the brush material */
+		Material *ma = BKE_gpencil_get_material_for_brush(obact, brush);
+		if (ma != NULL) {
+			gp_style = ma->gp_style;
+		}
+		/* this is not common, but avoid any special situations when brush could be without material */
+		if (gp_style == NULL) {
+			gp_style = BKE_material_gpencil_settings_get(obact, obact->actcol);
+		}
 	}
 
 	if (!stl->g_data) {



More information about the Bf-blender-cvs mailing list