[Bf-blender-cvs] [23da07bf451] sculpt-dev: Sculpt: Fixed tooltips for brush channes in RNA

Joseph Eagar noreply at git.blender.org
Fri Oct 1 04:14:07 CEST 2021


Commit: 23da07bf4510ddabac259053235ead408d68f70d
Author: Joseph Eagar
Date:   Thu Sep 30 19:11:14 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB23da07bf4510ddabac259053235ead408d68f70d

Sculpt: Fixed tooltips for brush channes in RNA

* BrushChannel now uses its refine callback to
  generate new structs for individual BrushChannelType's.
  - It generates a .value member that's a copy of
    one of the exisitng float_ bool_ enum_ etc_value members.
  - Haven't figured out how to delete the XXX_value members
    yet though.

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

M	intern/ghost/intern/GHOST_Context.h
M	intern/ghost/intern/GHOST_ContextWGL.cpp
M	intern/ghost/intern/GHOST_WindowWin32.cpp
M	release/scripts/startup/bl_ui/properties_paint_common.py
M	source/blender/blenkernel/BKE_brush_engine.h
M	source/blender/blenkernel/intern/brush_channel_define.h
M	source/blender/blenkernel/intern/brush_engine.c
M	source/blender/blenkernel/intern/brush_engine_presets.c
M	source/blender/blenkernel/intern/dyntopo.c
M	source/blender/gpu/opengl/gl_shader.cc
M	source/blender/makesdna/DNA_sculpt_brush_types.h
M	source/blender/makesrna/intern/rna_brush_engine.c
M	source/creator/creator.c

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

diff --git a/intern/ghost/intern/GHOST_Context.h b/intern/ghost/intern/GHOST_Context.h
index 810b78a7d39..b4c31a55e5f 100644
--- a/intern/ghost/intern/GHOST_Context.h
+++ b/intern/ghost/intern/GHOST_Context.h
@@ -31,6 +31,14 @@
 
 #include <cstdlib>  // for NULL
 
+#if defined(__clang__) || defined(__GCC__)
+#  define ATTR_NO_ASAN __attribute__((no_sanitize("address")))
+#elif _MSC_VER
+#  define ATTR_NO_ASAN __declspec(no_sanitize_address)
+#else
+#  define ATTR_NO_ASAN
+#endif
+
 class GHOST_Context : public GHOST_IContext {
  public:
   /**
diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp
index b412e52a5f7..85054a67fe4 100644
--- a/intern/ghost/intern/GHOST_ContextWGL.cpp
+++ b/intern/ghost/intern/GHOST_ContextWGL.cpp
@@ -31,6 +31,7 @@
 #include <cstdio>
 #include <vector>
 
+
 HGLRC GHOST_ContextWGL::s_sharedHGLRC = NULL;
 int GHOST_ContextWGL::s_sharedCount = 0;
 
@@ -143,7 +144,8 @@ GHOST_TSuccess GHOST_ContextWGL::releaseDrawingContext()
 /* Ron Fosner's code for weighting pixel formats and forcing software.
  * See http://www.opengl.org/resources/faq/technical/weight.cpp
  */
-static int weight_pixel_format(PIXELFORMATDESCRIPTOR &pfd, PIXELFORMATDESCRIPTOR &preferredPFD)
+ATTR_NO_ASAN static int weight_pixel_format(PIXELFORMATDESCRIPTOR &pfd,
+                                            PIXELFORMATDESCRIPTOR &preferredPFD)
 {
   int weight = 0;
 
@@ -178,7 +180,7 @@ static int weight_pixel_format(PIXELFORMATDESCRIPTOR &pfd, PIXELFORMATDESCRIPTOR
  * A modification of Ron Fosner's replacement for ChoosePixelFormat
  * returns 0 on error, else returns the pixel format number to be used
  */
-static int choose_pixel_format_legacy(HDC hDC, PIXELFORMATDESCRIPTOR &preferredPFD)
+ATTR_NO_ASAN static int choose_pixel_format_legacy(HDC hDC, PIXELFORMATDESCRIPTOR &preferredPFD)
 {
   int iPixelFormat = 0;
   int weight = 0;
@@ -231,7 +233,7 @@ static int choose_pixel_format_legacy(HDC hDC, PIXELFORMATDESCRIPTOR &preferredP
  * There is no generic way to clone the lpParam parameter,
  * so the caller is responsible for cloning it themselves.
  */
-static HWND clone_window(HWND hWnd, LPVOID lpParam)
+ATTR_NO_ASAN static HWND clone_window(HWND hWnd, LPVOID lpParam)
 {
   int count;
 
@@ -282,7 +284,7 @@ static HWND clone_window(HWND hWnd, LPVOID lpParam)
   return hwndCloned;
 }
 
-void GHOST_ContextWGL::initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD)
+ATTR_NO_ASAN void GHOST_ContextWGL::initContextWGLEW(PIXELFORMATDESCRIPTOR &preferredPFD)
 {
   HWND dummyHWND = NULL;
 
@@ -365,7 +367,7 @@ finalize:
   }
 }
 
-static void makeAttribList(std::vector<int> &out, bool stereoVisual, bool needAlpha)
+ATTR_NO_ASAN static void makeAttribList(std::vector<int> &out, bool stereoVisual, bool needAlpha)
 {
   out.clear();
   out.reserve(30);
@@ -401,7 +403,7 @@ static void makeAttribList(std::vector<int> &out, bool stereoVisual, bool needAl
   out.push_back(0);
 }
 
-int GHOST_ContextWGL::_choose_pixel_format_arb_1(bool stereoVisual, bool needAlpha)
+ATTR_NO_ASAN int GHOST_ContextWGL::_choose_pixel_format_arb_1(bool stereoVisual, bool needAlpha)
 {
   std::vector<int> iAttributes;
 
@@ -453,7 +455,7 @@ int GHOST_ContextWGL::_choose_pixel_format_arb_1(bool stereoVisual, bool needAlp
   return iPixelFormat;
 }
 
-int GHOST_ContextWGL::choose_pixel_format_arb(bool stereoVisual, bool needAlpha)
+ATTR_NO_ASAN int GHOST_ContextWGL::choose_pixel_format_arb(bool stereoVisual, bool needAlpha)
 {
   int iPixelFormat;
 
@@ -470,7 +472,7 @@ int GHOST_ContextWGL::choose_pixel_format_arb(bool stereoVisual, bool needAlpha)
   return iPixelFormat;
 }
 
-int GHOST_ContextWGL::choose_pixel_format(bool stereoVisual, bool needAlpha)
+ATTR_NO_ASAN int GHOST_ContextWGL::choose_pixel_format(bool stereoVisual, bool needAlpha)
 {
   PIXELFORMATDESCRIPTOR preferredPFD = {
       sizeof(PIXELFORMATDESCRIPTOR), /* size */
@@ -532,7 +534,7 @@ static void reportContextString(const char *name, const char *dummy, const char
 }
 #endif
 
-GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
+ATTR_NO_ASAN GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext()
 {
   SetLastError(NO_ERROR);
 
diff --git a/intern/ghost/intern/GHOST_WindowWin32.cpp b/intern/ghost/intern/GHOST_WindowWin32.cpp
index b5d0fd8e6db..ee66f827347 100644
--- a/intern/ghost/intern/GHOST_WindowWin32.cpp
+++ b/intern/ghost/intern/GHOST_WindowWin32.cpp
@@ -54,19 +54,19 @@ extern "C" {
 __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
 }
 
-GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
-                                     const char *title,
-                                     int32_t left,
-                                     int32_t top,
-                                     uint32_t width,
-                                     uint32_t height,
-                                     GHOST_TWindowState state,
-                                     GHOST_TDrawingContextType type,
-                                     bool wantStereoVisual,
-                                     bool alphaBackground,
-                                     GHOST_WindowWin32 *parentwindow,
-                                     bool is_debug,
-                                     bool dialog)
+ATTR_NO_ASAN GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
+                                                  const char *title,
+                                                  int32_t left,
+                                                  int32_t top,
+                                                  uint32_t width,
+                                                  uint32_t height,
+                                                  GHOST_TWindowState state,
+                                                  GHOST_TDrawingContextType type,
+                                                  bool wantStereoVisual,
+                                                  bool alphaBackground,
+                                                  GHOST_WindowWin32 *parentwindow,
+                                                  bool is_debug,
+                                                  bool dialog)
     : GHOST_Window(width, height, state, wantStereoVisual, false),
       m_mousePresent(false),
       m_inLiveResize(false),
@@ -526,7 +526,7 @@ GHOST_TSuccess GHOST_WindowWin32::invalidate()
   return success;
 }
 
-GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType type)
+ATTR_NO_ASAN GHOST_Context *GHOST_WindowWin32::newDrawingContext(GHOST_TDrawingContextType type)
 {
   if (type == GHOST_kDrawingContextTypeOpenGL) {
     GHOST_Context *context;
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 3835645a562..c0b9aa8b274 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -328,20 +328,8 @@ class UnifiedPaintPanel:
             sd.channels.ensure(ch)
             ch = sd.channels[prop_name]
 
-        if ch.type == "FLOAT":
-            return ch.float_value
-        elif ch.type == "INT":
-            return ch.int_value
-        elif ch.type == "ENUM":
-            return ch.enum_value
-        elif ch.type == "BITMASK":
-            return ch.flags_value
-        elif ch.type == "VEC3":
-            return ch.color3_value
-        elif ch.type == "VEC4":
-            return ch.color4_value
-        elif ch.type == "CURVE":
-            return ch.curve
+        return ch.value
+
 
     @staticmethod
     def channel_unified(layout, context, brush, prop_name, icon='NONE', pressure=None, text=None,
@@ -389,20 +377,7 @@ class UnifiedPaintPanel:
 
         row = layout.row(align=True)
 
-        if ch.type == "FLOAT":
-            typeprop = "float_value" if "spacing" in ch.idname else "factor_value"
-        if ch.type == "INT":
-            typeprop = "int_value"
-        elif ch.type == "BOOL":
-            typeprop = "bool_value"
-        elif ch.type == "ENUM":
-            typeprop = "enum_value"
-        elif ch.type == "BITMASK":
-            typeprop = "flags_value"
-        elif ch.type == "VEC3":
-            typeprop = "color3_value"
-        elif ch.type == "VEC4":
-            typeprop = "color4_value"
+        typeprop = "value"
 
         if pressure is None:
             pressure = ch.type not in ["VEC3", "VEC4", "BITMASK", "ENUM", "BOOL"]
@@ -482,7 +457,7 @@ class UnifiedPaintPanel:
                 for j, item in enumerate(finalch.enum_items):
                     row3 = row1 if j % 2 == 0 else row2
 
-                    if item.identifier in finalch.flags_value:
+                    if item.identifier in finalch.value:
                         itemicon = "CHECKBOX_HLT"
                     else:
                         itemicon = "CHECKBOX_DEHLT"
@@ -637,7 +612,7 @@ class UnifiedPaintPanel:
             if ch is not None:
                 print("FOUND CH", ch.idname)
                 prop_owner = ch
-                prop_name = "color3_value"
+                prop_name = "value"
 
         parent.template_color_picker(prop_owner, prop_name, value_slider=value_slider)
 
@@ -1141,7 +1116,7 @@ def brush_settings(layout, context, brush, popover=False):
                 UnifiedPaintPanel.prop_unified(box, context, brush, "use_weighted_smooth")
                 UnifiedPaintPanel.prop_unified(box, context, brush, "preserve_faceset_boundary")
 
-                if brush.channels["preserve_faceset_boundary"].bool_value:
+                if brush.channels["preserve_faceset_boundary"].value:
                     UnifiedPaintPanel.prop_unified(box, context, brush, "autosmooth_fset_slide", slider=True)
 
             if advanced:
@@ -1154,7 +1129,7 @@ def brush_settings(layout, context, brush, popover=False):
                     text="Custom Spacing"
                 )
 
-                if brush.channels["autosmooth_use_spacing"].bool_value:
+                if brush.channels["autosmooth_use_spacing"].value:
                     UnifiedPaintPanel.channel_unified(
                         box,
                         context,
@@ -1217,7 +1192,7 @@

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list