[Bf-blender-cvs] [89aa1a7f603] greasepencil-object: Merge branch 'master' into greasepencil-object

Antonio Vazquez noreply at git.blender.org
Tue Dec 10 19:45:58 CET 2019


Commit: 89aa1a7f60382beceea2285744f0319bb304ff5e
Author: Antonio Vazquez
Date:   Tue Dec 10 19:45:16 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rB89aa1a7f60382beceea2285744f0319bb304ff5e

Merge branch 'master' into greasepencil-object

 Conflicts:
	source/blender/blenkernel/intern/paint.c

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



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

diff --cc source/blender/blenkernel/intern/paint.c
index 7c41d78576c,584f1ab1b0c..9b5862105de
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@@ -901,25 -702,32 +906,35 @@@ bool BKE_paint_ensure(ToolSettings *ts
  {
    Paint *paint = NULL;
    if (*r_paint) {
-     /* Note: 'ts->imapaint' is ignored, it's not allocated. */
-     BLI_assert(ELEM(*r_paint,
-                     &ts->gp_paint->paint,
-                     &ts->gp_vertexpaint->paint,
-                     &ts->gp_sculptpaint->paint,
-                     &ts->gp_weightpaint->paint,
-                     &ts->sculpt->paint,
-                     &ts->vpaint->paint,
-                     &ts->wpaint->paint,
-                     &ts->uvsculpt->paint));
+     /* Tool offset should never be 0 for initialized paint settings, so it's a reliable way to
+      * check if already initialized. */
+     if ((*r_paint)->runtime.tool_offset == 0) {
+       /* Currently only image painting is initialized this way, others have to be allocated. */
+       BLI_assert(ELEM(*r_paint, (Paint *)&ts->imapaint));
  
+       BKE_paint_runtime_init(ts, *r_paint);
+     }
+     else {
+       BLI_assert(ELEM(*r_paint,
+                       /* Cast is annoying, but prevent NULL-pointer access. */
+                       (Paint *)ts->gp_paint,
++                      (Paint *)ts->gp_vertexpaint->paint,
++                      (Paint *)ts->gp_sculptpaint->paint,
++                      (Paint *)ts->gp_weightpaint->paint,
+                       (Paint *)ts->sculpt,
+                       (Paint *)ts->vpaint,
+                       (Paint *)ts->wpaint,
+                       (Paint *)ts->uvsculpt,
+                       (Paint *)&ts->imapaint));
  #ifdef DEBUG
-     struct Paint paint_test = **r_paint;
-     BKE_paint_runtime_init(ts, *r_paint);
-     /* Swap so debug doesn't hide errors when release fails. */
-     SWAP(Paint, **r_paint, paint_test);
-     BLI_assert(paint_test.runtime.ob_mode == (*r_paint)->runtime.ob_mode);
-     BLI_assert(paint_test.runtime.tool_offset == (*r_paint)->runtime.tool_offset);
+       struct Paint paint_test = **r_paint;
+       BKE_paint_runtime_init(ts, *r_paint);
+       /* Swap so debug doesn't hide errors when release fails. */
+       SWAP(Paint, **r_paint, paint_test);
+       BLI_assert(paint_test.runtime.ob_mode == (*r_paint)->runtime.ob_mode);
+       BLI_assert(paint_test.runtime.tool_offset == (*r_paint)->runtime.tool_offset);
  #endif
+     }
      return true;
    }



More information about the Bf-blender-cvs mailing list