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.
This commit is contained in:
Joseph Eagar 2021-09-30 19:11:14 -07:00
parent d02b557f10
commit 23da07bf45
13 changed files with 348 additions and 147 deletions

View File

@ -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:
/**

View File

@ -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);

View File

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

View File

@ -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 @@ def brush_settings(layout, context, brush, popover=False):
if advanced:
box.prop(brush, "use_custom_topology_rake_spacing", text="Custom Spacing")
if brush.channels["topology_rake_use_spacing"].bool_value:
if brush.channels["topology_rake_use_spacing"].value:
UnifiedPaintPanel.prop_unified(
box,
context,
@ -1322,11 +1297,11 @@ def brush_settings(layout, context, brush, popover=False):
#"""
else:
row = layout.row(heading="Plane Trim")
row.prop(brush.channels["use_plane_trim"], "bool_value", text="")
row.prop(brush.channels["use_plane_trim"], "value", text="")
sub = row.row()
sub.active = brush.channels["use_plane_trim"].bool_value
sub.prop(brush.channels["plane_trim"], "factor_value", slider=True, text="")
sub.active = brush.channels["use_plane_trim"].value
sub.prop(brush.channels["plane_trim"], "value", slider=True, text="")
layout.separator()
@ -1529,7 +1504,7 @@ def brush_settings(layout, context, brush, popover=False):
#col.prop(brush, "use_weighted_smooth")
#col.prop(brush, "preserve_faceset_boundary")
if brush.channels["preserve_faceset_boundary"].bool_value:
if brush.channels["preserve_faceset_boundary"].value:
UnifiedPaintPanel.channel_unified(
layout,
context,

View File

@ -50,6 +50,7 @@ This should completely replace UnifiedPaintSettings.
struct BrushChannel;
struct BlendWriter;
struct StructRNA;
struct BlendDataReader;
struct BlendLibReader;
struct ID;
@ -131,6 +132,7 @@ typedef struct BrushChannelType {
BrushMappingPreset mappings;
int type, flag;
int subtype;
int ivalue;
float fvalue;
float vector[4];
@ -140,6 +142,7 @@ typedef struct BrushChannelType {
EnumPropertyItem *rna_enumdef;
bool user_defined;
struct StructRNA *rna_ext;
} BrushChannelType;
/* since MTex is going away lets'

View File

@ -278,7 +278,7 @@ MAKE_BOOL(original_normal, "Original Normal", "When locked keep using normal of
MAKE_BOOL(original_plane, "Original Plane", "When locked keep using the plane origin of surface where stroke was initiated", false)
MAKE_BOOL(use_weighted_smooth, "Weight By Area", "Weight by face area to get a smoother result", true)
MAKE_BOOL_EX(preserve_faceset_boundary, "Preserve Faceset Boundary", "Preserve face set boundaries", true, BRUSH_CHANNEL_INHERIT)
MAKE_BOOL_EX(hard_edge_mode, "Hard Edge Mode", "Forces all brushes into hard edge face set mode (sets face set slide to 0)", false, BRUSH_CHANNEL_INHERIT)
MAKE_BOOL_EX(hard_edge_mode, "Hard Edge Mode", "Treat face set boundaries as hard edges", false, BRUSH_CHANNEL_INHERIT)
MAKE_BOOL(grab_silhouette, "Grab Silhouette", "Grabs trying to automask the silhouette of the object", false)
MAKE_FLOAT_EX_FLAG(dyntopo_detail_percent, "Detail Percent", "Detail Percent", 25.0f, 0.0f, 1000.0f, 0.0f, 1000.0f, false, BRUSH_CHANNEL_INHERIT)
MAKE_FLOAT_EX_FLAG(dyntopo_detail_range, "Detail Range", "Detail Range", 0.45f, 0.01f, 0.99f, 0.01f, 0.99f, false, BRUSH_CHANNEL_INHERIT)

View File

@ -264,7 +264,7 @@ static void copy_channel_data_keep_mappings(BrushChannel *dst, BrushChannel *src
dst->ui_order = src->ui_order;
switch (src->type) {
case BRUSH_CHANNEL_CURVE:
case BRUSH_CHANNEL_TYPE_CURVE:
dst->curve.preset = src->curve.preset;
if (dst->curve.curve && IS_CACHE_CURVE(dst->curve.curve)) {
@ -285,17 +285,17 @@ static void copy_channel_data_keep_mappings(BrushChannel *dst, BrushChannel *src
}
}
break;
case BRUSH_CHANNEL_FLOAT:
case BRUSH_CHANNEL_TYPE_FLOAT:
dst->fvalue = src->fvalue;
break;
case BRUSH_CHANNEL_BOOL:
case BRUSH_CHANNEL_ENUM:
case BRUSH_CHANNEL_BITMASK:
case BRUSH_CHANNEL_INT:
case BRUSH_CHANNEL_TYPE_BOOL:
case BRUSH_CHANNEL_TYPE_ENUM:
case BRUSH_CHANNEL_TYPE_BITMASK:
case BRUSH_CHANNEL_TYPE_INT:
dst->ivalue = src->ivalue;
break;
case BRUSH_CHANNEL_VEC3:
case BRUSH_CHANNEL_VEC4:
case BRUSH_CHANNEL_TYPE_VEC3:
case BRUSH_CHANNEL_TYPE_VEC4:
copy_v4_v4(dst->vector, src->vector);
break;
}
@ -308,7 +308,7 @@ void BKE_brush_channel_copy_data(BrushChannel *dst, BrushChannel *src, bool keep
return;
}
if (src->type == BRUSH_CHANNEL_CURVE) {
if (src->type == BRUSH_CHANNEL_TYPE_CURVE) {
if (dst->curve.curve && IS_CACHE_CURVE(dst->curve.curve)) {
RELEASE_CACHE_CURVE(dst->curve.curve);
}
@ -638,7 +638,7 @@ BrushChannelType brush_default_channel_type = {
.max = 1.0f,
.soft_min = 0.0f,
.soft_max = 1.0f,
.type = BRUSH_CHANNEL_FLOAT,
.type = BRUSH_CHANNEL_TYPE_FLOAT,
.flag = 0,
.ivalue = 0,
.fvalue = 0.0f,
@ -783,7 +783,7 @@ void BKE_brush_channelset_merge(BrushChannelSet *dst,
continue;
}
if (ch->type == BRUSH_CHANNEL_BITMASK && (ch->flag & BRUSH_CHANNEL_INHERIT_IF_UNSET)) {
if (ch->type == BRUSH_CHANNEL_TYPE_BITMASK && (ch->flag & BRUSH_CHANNEL_INHERIT_IF_UNSET)) {
mch->ivalue = ch->ivalue | pch->ivalue;
}
}
@ -822,18 +822,18 @@ void BKE_brush_channelset_apply_mapping(BrushChannelSet *chset, BrushMappingData
for (ch = chset->channels.first; ch; ch = ch->next) {
switch (ch->type) {
case BRUSH_CHANNEL_FLOAT:
case BRUSH_CHANNEL_TYPE_FLOAT:
ch->fvalue = BKE_brush_channel_get_float(ch, mapdata);
break;
case BRUSH_CHANNEL_INT:
case BRUSH_CHANNEL_ENUM:
case BRUSH_CHANNEL_BITMASK:
case BRUSH_CHANNEL_BOOL:
case BRUSH_CHANNEL_TYPE_INT:
case BRUSH_CHANNEL_TYPE_ENUM:
case BRUSH_CHANNEL_TYPE_BITMASK:
case BRUSH_CHANNEL_TYPE_BOOL:
ch->ivalue = BKE_brush_channel_get_int(ch, mapdata);
break;
case BRUSH_CHANNEL_VEC4:
case BRUSH_CHANNEL_TYPE_VEC4:
n = 4;
case BRUSH_CHANNEL_VEC3:
case BRUSH_CHANNEL_TYPE_VEC3:
n = 3;
for (int i = 0; i < n; i++) {
@ -1113,7 +1113,7 @@ float BKE_brush_channel_get_float(BrushChannel *ch, BrushMappingData *mapdata)
void BKE_brush_channel_set_vector(BrushChannel *ch, float vec[4])
{
if (ch->type == BRUSH_CHANNEL_VEC4) {
if (ch->type == BRUSH_CHANNEL_TYPE_VEC4) {
copy_v4_v4(ch->vector, vec);
}
else {
@ -1124,9 +1124,9 @@ void BKE_brush_channel_set_vector(BrushChannel *ch, float vec[4])
int BKE_brush_channel_get_vector_size(BrushChannel *ch)
{
switch (ch->type) {
case BRUSH_CHANNEL_VEC3:
case BRUSH_CHANNEL_TYPE_VEC3:
return 3;
case BRUSH_CHANNEL_VEC4:
case BRUSH_CHANNEL_TYPE_VEC4:
return 4;
default:
return 1;
@ -1136,7 +1136,7 @@ int BKE_brush_channel_get_vector_size(BrushChannel *ch)
int BKE_brush_channel_get_vector(BrushChannel *ch, float out[4], BrushMappingData *mapdata)
{
int size = 3;
if (ch->type == BRUSH_CHANNEL_VEC4) {
if (ch->type == BRUSH_CHANNEL_TYPE_VEC4) {
size = 4;
}

View File

@ -87,7 +87,8 @@ To enable converting to/from old data:
.soft_min = smin1,\
.flag = flag1,\
.soft_max = smax1,\
.type = BRUSH_CHANNEL_FLOAT,\
.type = BRUSH_CHANNEL_TYPE_FLOAT,\
.subtype = BRUSH_CHANNEL_FACTOR,\
.mappings = {\
.pressure = {.curve = CURVE_PRESET_LINE, .factor = 1.0f, .min = 0.0f, .max = 1.0f, .enabled = pressure_enabled, .inv = pressure_inv},\
}\
@ -106,18 +107,18 @@ MAKE_FLOAT_EX_EX(idname1, name1, tooltip1, value1, min1, max1, smin1, smax1, pre
.idname = #idname1, \
.name = name1, \
.tooltip = tooltip1, \
.type = BRUSH_CHANNEL_VEC3,\
.type = BRUSH_CHANNEL_TYPE_VEC3,\
.vector = {r, g, b, 1.0f},\
.min = 0.0f, .max = 5.0f,\
.soft_min = 0.0f, .soft_max = 1.0f,\
.flag = BRUSH_CHANNEL_COLOR,\
.subtype = BRUSH_CHANNEL_COLOR,\
},
#define MAKE_FLOAT3_EX(idname1, name1, tooltip1, x1, y1, z1, min1, max1, smin, smax, flag1){\
.idname = #idname1, \
.name = name1, \
.tooltip = tooltip1, \
.type = BRUSH_CHANNEL_VEC3,\
.type = BRUSH_CHANNEL_TYPE_VEC3,\
.vector = {x1, y1, z1, 1.0f},\
.min = min1, .max = max1,\
.soft_min = smin, .soft_max = smax,\
@ -131,11 +132,11 @@ MAKE_FLOAT_EX_EX(idname1, name1, tooltip1, value1, min1, max1, smin1, smax1, pre
.idname = #idname1, \
.name = name1, \
.tooltip = tooltip1, \
.type = BRUSH_CHANNEL_VEC4,\
.type = BRUSH_CHANNEL_TYPE_VEC4,\
.vector = {r, g, b, a},\
.min = 0.0f, .max = 5.0f,\
.soft_min = 0.0f, .soft_max = 1.0f,\
.flag = BRUSH_CHANNEL_COLOR,\
.subtype = BRUSH_CHANNEL_COLOR,\
},
#define MAKE_INT_EX_OPEN(idname1, name1, tooltip1, value1, min1, max1, smin1, smax1) \
@ -147,7 +148,7 @@ MAKE_FLOAT_EX_EX(idname1, name1, tooltip1, value1, min1, max1, smin1, smax1, pre
.ivalue = value1,\
.soft_min = smin1,\
.soft_max = smax1,\
.type = BRUSH_CHANNEL_INT
.type = BRUSH_CHANNEL_TYPE_INT
#define MAKE_INT_EX(idname, name, tooltip, value, min, max, smin, smax) \
MAKE_INT_EX_OPEN(idname, name, tooltip, value, min, max, smin, smax) },
@ -160,7 +161,7 @@ MAKE_FLOAT_EX_EX(idname1, name1, tooltip1, value1, min1, max1, smin1, smax1, pre
.tooltip = tooltip1, \
.ivalue = value1,\
.flag = flag1,\
.type = BRUSH_CHANNEL_BOOL\
.type = BRUSH_CHANNEL_TYPE_BOOL\
},
#define MAKE_BOOL(idname, name, tooltip, value)\
@ -172,7 +173,7 @@ MAKE_FLOAT_EX_EX(idname1, name1, tooltip1, value1, min1, max1, smin1, smax1, pre
.tooltip = tooltip1,\
.ivalue = value1,\
.flag = flag1,\
.type = BRUSH_CHANNEL_ENUM,\
.type = BRUSH_CHANNEL_TYPE_ENUM,\
.rna_enumdef = NULL,\
.enumdef = enumdef1\
, __VA_ARGS__\
@ -183,7 +184,7 @@ MAKE_FLOAT_EX_EX(idname1, name1, tooltip1, value1, min1, max1, smin1, smax1, pre
.tooltip = tooltip1,\
.ivalue = value1,\
.flag = flag1,\
.type = BRUSH_CHANNEL_BITMASK,\
.type = BRUSH_CHANNEL_TYPE_BITMASK,\
.rna_enumdef = NULL,\
.enumdef = enumdef1 , __VA_ARGS__\
},
@ -195,7 +196,7 @@ MAKE_FLOAT_EX_EX(idname1, name1, tooltip1, value1, min1, max1, smin1, smax1, pre
.idname = #idname1,\
.name = name1,\
.tooltip = tooltip1,\
.type = BRUSH_CHANNEL_CURVE,\
.type = BRUSH_CHANNEL_TYPE_CURVE,\
.curve_preset = preset1,\
},
@ -227,6 +228,7 @@ static BrushChannelType *_get_def(const char *idname)
#define GETDEF(idname) _get_def(MAKE_BUILTIN_CH_NAME(idname))
#define SETCAT(idname, cat) \
BLI_strncpy(GETDEF(idname)->category, cat, sizeof(GETDEF(idname)->category))
#define SUBTYPE_SET(idname, type1) GETDEF(idname)->subtype = type1
static bool do_builtin_init = true;
static bool check_builtin_init()
@ -242,6 +244,13 @@ static bool check_builtin_init()
// BKE_brush_channeltype_rna_check(brush_builtin_channels + i);
//}
SUBTYPE_SET(radius, BRUSH_CHANNEL_PIXEL);
SUBTYPE_SET(spacing, BRUSH_CHANNEL_PERCENT);
SUBTYPE_SET(autosmooth_spacing, BRUSH_CHANNEL_PERCENT);
SUBTYPE_SET(topology_rake_spacing, BRUSH_CHANNEL_PERCENT);
SUBTYPE_SET(autosmooth_radius_scale, BRUSH_CHANNEL_PERCENT);
SUBTYPE_SET(topology_rake_radius_scale, BRUSH_CHANNEL_PERCENT);
// don't group strength/radius/direction in subpanels
// SETCAT(strength, "Basic");
// SETCAT(radius, "Basic");
@ -325,11 +334,11 @@ static bool check_builtin_init()
# undef BOOL
#endif
#define FLOAT BRUSH_CHANNEL_FLOAT
#define INT BRUSH_CHANNEL_INT
#define BOOL BRUSH_CHANNEL_BOOL
#define FLOAT3 BRUSH_CHANNEL_VEC3
#define FLOAT4 BRUSH_CHANNEL_VEC4
#define FLOAT BRUSH_CHANNEL_TYPE_FLOAT
#define INT BRUSH_CHANNEL_TYPE_INT
#define BOOL BRUSH_CHANNEL_TYPE_BOOL
#define FLOAT3 BRUSH_CHANNEL_TYPE_VEC3
#define FLOAT4 BRUSH_CHANNEL_TYPE_VEC4
#ifdef ADDCH
# undef ADDCH
@ -509,13 +518,13 @@ static void do_coerce(int type1, void *ptr1, int size1, int type2, void *ptr2, i
float vec[4];
switch (type1) {
case BRUSH_CHANNEL_FLOAT:
case BRUSH_CHANNEL_TYPE_FLOAT:
val = *(float *)ptr1;
break;
case BRUSH_CHANNEL_INT:
case BRUSH_CHANNEL_ENUM:
case BRUSH_CHANNEL_BITMASK:
case BRUSH_CHANNEL_BOOL:
case BRUSH_CHANNEL_TYPE_INT:
case BRUSH_CHANNEL_TYPE_ENUM:
case BRUSH_CHANNEL_TYPE_BITMASK:
case BRUSH_CHANNEL_TYPE_BOOL:
switch (size1) {
case 1:
val = (double)*(char *)ptr1;
@ -531,22 +540,22 @@ static void do_coerce(int type1, void *ptr1, int size1, int type2, void *ptr2, i
break;
}
break;
case BRUSH_CHANNEL_VEC3:
case BRUSH_CHANNEL_TYPE_VEC3:
copy_v3_v3(vec, (float *)ptr1);
break;
case BRUSH_CHANNEL_VEC4:
case BRUSH_CHANNEL_TYPE_VEC4:
copy_v4_v4(vec, (float *)ptr1);
break;
}
switch (type2) {
case BRUSH_CHANNEL_FLOAT:
case BRUSH_CHANNEL_TYPE_FLOAT:
*(float *)ptr2 = (float)val;
break;
case BRUSH_CHANNEL_INT:
case BRUSH_CHANNEL_ENUM:
case BRUSH_CHANNEL_BITMASK:
case BRUSH_CHANNEL_BOOL: {
case BRUSH_CHANNEL_TYPE_INT:
case BRUSH_CHANNEL_TYPE_ENUM:
case BRUSH_CHANNEL_TYPE_BITMASK:
case BRUSH_CHANNEL_TYPE_BOOL: {
switch (size2) {
case 1:
*(char *)ptr2 = (char)val;
@ -563,10 +572,10 @@ static void do_coerce(int type1, void *ptr1, int size1, int type2, void *ptr2, i
}
break;
}
case BRUSH_CHANNEL_VEC3:
case BRUSH_CHANNEL_TYPE_VEC3:
copy_v3_v3((float *)ptr2, vec);
break;
case BRUSH_CHANNEL_VEC4:
case BRUSH_CHANNEL_TYPE_VEC4:
copy_v4_v4((float *)ptr2, vec);
break;
}
@ -577,17 +586,17 @@ void *get_channel_value_pointer(BrushChannel *ch, int *r_data_size)
*r_data_size = 4;
switch (ch->type) {
case BRUSH_CHANNEL_FLOAT:
case BRUSH_CHANNEL_TYPE_FLOAT:
return &ch->fvalue;
case BRUSH_CHANNEL_INT:
case BRUSH_CHANNEL_ENUM:
case BRUSH_CHANNEL_BITMASK:
case BRUSH_CHANNEL_BOOL:
case BRUSH_CHANNEL_TYPE_INT:
case BRUSH_CHANNEL_TYPE_ENUM:
case BRUSH_CHANNEL_TYPE_BITMASK:
case BRUSH_CHANNEL_TYPE_BOOL:
return &ch->ivalue;
case BRUSH_CHANNEL_VEC3:
case BRUSH_CHANNEL_TYPE_VEC3:
*r_data_size = sizeof(float) * 3;
return ch->vector;
case BRUSH_CHANNEL_VEC4:
case BRUSH_CHANNEL_TYPE_VEC4:
*r_data_size = sizeof(float) * 4;
return ch->vector;
}

View File

@ -2672,6 +2672,10 @@ static void long_edge_queue_create(EdgeQueueContext *eq_ctx,
BMVert *v = td->val34_verts[j];
MDynTopoVert *mv = BKE_PBVH_DYNVERT(cd_dyn_vert, v);
if (bm_elem_is_free((BMElem *)v, BM_VERT)) {
continue;
}
if (mv->flag & DYNVERT_NEED_VALENCE) {
BKE_pbvh_bmesh_update_valence(pbvh->cd_dyn_vert, (SculptVertRef){.i = (intptr_t)v});
}

View File

@ -36,6 +36,14 @@
#include "gl_shader.hh"
#include "gl_shader_interface.hh"
#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
using namespace blender;
using namespace blender::gpu;
@ -207,7 +215,7 @@ void GLShader::compute_shader_from_glsl(MutableSpan<const char *> sources)
compute_shader_ = this->create_shader_stage(GL_COMPUTE_SHADER, sources);
}
bool GLShader::finalize()
ATTR_NO_ASAN bool GLShader::finalize()
{
if (compilation_failed_) {
return false;

View File

@ -104,7 +104,6 @@ enum {
BRUSH_CHANNEL_NO_MAPPINGS = 1 << 2,
BRUSH_CHANNEL_UI_EXPANDED = 1 << 3,
BRUSH_CHANNEL_APPLY_MAPPING_TO_ALPHA = 1 << 4,
BRUSH_CHANNEL_COLOR = 1 << 5,
BRUSH_CHANNEL_SHOW_IN_WORKSPACE = 1 << 6,
BRUSH_CHANNEL_SHOW_IN_HEADER = 1 << 7,
BRUSH_CHANNEL_SHOW_IN_CONTEXT_MENU = 1 << 8,
@ -112,12 +111,22 @@ enum {
// BrushChannelType->type
enum {
BRUSH_CHANNEL_FLOAT = 1 << 0,
BRUSH_CHANNEL_INT = 1 << 1,
BRUSH_CHANNEL_ENUM = 1 << 2,
BRUSH_CHANNEL_BITMASK = 1 << 3,
BRUSH_CHANNEL_BOOL = 1 << 4,
BRUSH_CHANNEL_VEC3 = 1 << 5,
BRUSH_CHANNEL_VEC4 = 1 << 6,
BRUSH_CHANNEL_CURVE = 1 << 7
BRUSH_CHANNEL_TYPE_FLOAT = 1 << 0,
BRUSH_CHANNEL_TYPE_INT = 1 << 1,
BRUSH_CHANNEL_TYPE_ENUM = 1 << 2,
BRUSH_CHANNEL_TYPE_BITMASK = 1 << 3,
BRUSH_CHANNEL_TYPE_BOOL = 1 << 4,
BRUSH_CHANNEL_TYPE_VEC3 = 1 << 5,
BRUSH_CHANNEL_TYPE_VEC4 = 1 << 6,
BRUSH_CHANNEL_TYPE_CURVE = 1 << 7
};
/* clang-format off */
enum {
BRUSH_CHANNEL_NONE,
BRUSH_CHANNEL_COLOR,
BRUSH_CHANNEL_FACTOR,
BRUSH_CHANNEL_PERCENT,
BRUSH_CHANNEL_PIXEL
};
/* clang-format on */

View File

@ -18,6 +18,7 @@
* \ingroup RNA
*/
#include <ctype.h>
#include <stdlib.h>
#include "DNA_ID_enums.h"
@ -54,6 +55,156 @@ static EnumPropertyItem null_enum[2] = {{0, "null", ICON_NONE, "null"}, {0, NULL
# include "RNA_access.h"
void rna_BrushChannel_update_tooltip(PointerRNA *ptr, const char *propname)
{
BrushChannel *ch = (BrushChannel *)ptr->data;
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
if (prop) {
if (prop->description) {
// MEM_SAFE_FREE(prop->description);
}
prop->description = ch->def->tooltip;
}
}
struct StructRNA *rna_BrushChannel_refine(PointerRNA *ptr)
{
BrushChannel *ch = (BrushChannel *)ptr->data;
if (!ch) {
return &RNA_BrushChannel;
}
if (!ch->def->rna_ext) {
char buf[512] = "BrushChannel";
const char *c = (const char *)ch->def->idname;
int i = strlen(buf);
bool first = true;
do {
if (*c == '_') {
first = true;
continue;
}
if (first) {
buf[i++] = toupper(*c);
first = false;
}
else {
buf[i++] = *c;
}
} while (*++c);
buf[i] = 0;
StructRNA *srna = ch->def->rna_ext = RNA_def_struct_ptr(&BLENDER_RNA, strdup(buf), ptr->type);
srna->refine = NULL;
PropertyRNA *prop;
const char *propname = NULL;
int proptype;
int subtype = PROP_NONE;
switch (ch->def->subtype) {
case BRUSH_CHANNEL_FACTOR:
subtype = PROP_FACTOR;
break;
case BRUSH_CHANNEL_PERCENT:
subtype = PROP_PERCENTAGE;
break;
case BRUSH_CHANNEL_COLOR:
subtype = PROP_COLOR;
break;
case BRUSH_CHANNEL_PIXEL:
subtype = PROP_PIXEL;
break;
default:
subtype = PROP_NONE;
break;
}
switch (ch->def->type) {
case BRUSH_CHANNEL_TYPE_FLOAT:
propname = "float_value";
proptype = PROP_FLOAT;
break;
case BRUSH_CHANNEL_TYPE_INT:
propname = "int_value";
proptype = PROP_INT;
break;
case BRUSH_CHANNEL_TYPE_BOOL:
propname = "bool_value";
proptype = PROP_BOOLEAN;
break;
case BRUSH_CHANNEL_TYPE_ENUM:
propname = "enum_value";
proptype = PROP_ENUM;
break;
case BRUSH_CHANNEL_TYPE_BITMASK:
propname = "flags_value";
proptype = PROP_ENUM;
break;
case BRUSH_CHANNEL_TYPE_VEC3:
propname = ch->def->subtype == BRUSH_CHANNEL_COLOR ? "color3_value" : "vector3_value";
proptype = PROP_FLOAT;
break;
case BRUSH_CHANNEL_TYPE_VEC4:
propname = ch->def->subtype == BRUSH_CHANNEL_COLOR ? "color4_value" : "vector4_value";
proptype = PROP_FLOAT;
break;
case BRUSH_CHANNEL_TYPE_CURVE:
propname = "curve";
proptype = PROP_POINTER;
break;
}
PointerRNA ptr2 = *ptr;
ptr2.type = &RNA_BrushChannel;
// create a .value alias
PropertyRNA *prop2;
if (propname && (prop2 = RNA_struct_find_property(&ptr2, propname))) {
prop = RNA_def_property(srna, "value", proptype, subtype);
PropertyRNA old = *prop;
size_t size = MEM_allocN_len(prop);
memcpy(prop, prop2, size);
prop->subtype = old.subtype;
prop->next = old.next;
prop->prev = old.prev;
prop->srna = old.srna;
prop->magic = old.magic;
prop->name = ch->def->name;
prop->identifier = "value";
prop->description = ch->def->tooltip;
}
ptr2.type = srna;
/*
rna_BrushChannel_update_tooltip(&ptr2, "bool_value");
rna_BrushChannel_update_tooltip(&ptr2, "int_value");
rna_BrushChannel_update_tooltip(&ptr2, "value");
rna_BrushChannel_update_tooltip(&ptr2, "factor_value");
rna_BrushChannel_update_tooltip(&ptr2, "float_value");
rna_BrushChannel_update_tooltip(&ptr2, "color3_value");
rna_BrushChannel_update_tooltip(&ptr2, "color4_value");
rna_BrushChannel_update_tooltip(&ptr2, "vector3_value");
rna_BrushChannel_update_tooltip(&ptr2, "vector4_value");
rna_BrushChannel_update_tooltip(&ptr2, "enum_value");
rna_BrushChannel_update_tooltip(&ptr2, "flags_value");
*/
}
return ch->def->rna_ext;
}
BrushChannelSet *rna_BrushChannelSet_get_set(struct PointerRNA *ptr)
{
BrushChannelSet *chset = NULL;
@ -107,9 +258,9 @@ int rna_BrushChannelSet_channels_assignint(struct PointerRNA *ptr,
return 1;
}
float rna_BrushChannel_get_value(PointerRNA *rna)
float rna_BrushChannel_get_value(PointerRNA *ptr)
{
BrushChannel *ch = (BrushChannel *)rna->data;
BrushChannel *ch = (BrushChannel *)ptr->data;
return ch->fvalue;
}
@ -211,9 +362,9 @@ void rna_BrushChannel_value_range(
}
}
int rna_BrushChannel_get_ivalue(PointerRNA *rna)
int rna_BrushChannel_get_ivalue(PointerRNA *ptr)
{
BrushChannel *ch = rna->data;
BrushChannel *ch = ptr->data;
return ch->ivalue;
}
@ -348,7 +499,7 @@ const EnumPropertyItem *rna_BrushChannel_enum_value_get_items(struct bContext *C
{
BrushChannel *ch = (BrushChannel *)ptr->data;
if (!ch->def || !ELEM(ch->type, BRUSH_CHANNEL_ENUM, BRUSH_CHANNEL_BITMASK)) {
if (!ch->def || !ELEM(ch->type, BRUSH_CHANNEL_TYPE_ENUM, BRUSH_CHANNEL_TYPE_BITMASK)) {
return null_enum;
}
@ -372,7 +523,7 @@ static void rna_BrushChannel_enum_items_begin(CollectionPropertyIterator *iter,
BrushChannel *ch = (BrushChannel *)ptr->data;
if (!ch->def || !ELEM(ch->type, BRUSH_CHANNEL_ENUM, BRUSH_CHANNEL_BITMASK)) {
if (!ch->def || !ELEM(ch->type, BRUSH_CHANNEL_TYPE_ENUM, BRUSH_CHANNEL_TYPE_BITMASK)) {
if (!ch->def) {
printf("%s: channel '%s' had no definition\n", __func__, ch->idname);
}
@ -452,11 +603,37 @@ int rna_BrushChannel_category_length(PointerRNA *ptr)
return strlen(BKE_brush_channel_category_get((BrushChannel *)ptr->data));
}
int rna_BrushChannel_factor_value_editable(PointerRNA *ptr)
{
return 1;
}
bool rna_BrushChannel_get_is_color(PointerRNA *ptr)
{
BrushChannel *ch = (BrushChannel *)ptr->data;
return ch && ch->def ? ch->def->subtype == BRUSH_CHANNEL_COLOR : false;
}
void rna_BrushChannel_category_set(PointerRNA *ptr, const char *value)
{
BKE_brush_channel_category_set((BrushChannel *)ptr->data, value);
}
bool rna_BrushChannel_bool_get(PointerRNA *ptr)
{
BrushChannel *ch = (BrushChannel *)ptr->data;
return ch->ivalue;
}
void rna_BrushChannel_bool_set(PointerRNA *prop, bool value)
{
BrushChannel *ch = (BrushChannel *)prop->data;
return ch->ivalue = value ? 1 : 0;
}
#endif
static EnumPropertyItem mapping_type_items[] = {
@ -518,14 +695,14 @@ void RNA_def_brush_mapping(BlenderRNA *brna)
extern BrushChannelType *brush_builtin_channels;
extern const int builtin_channel_len;
EnumPropertyItem channel_types[] = {{BRUSH_CHANNEL_FLOAT, "FLOAT", ICON_NONE, "Float"},
{BRUSH_CHANNEL_INT, "INT", ICON_NONE, "Int"},
{BRUSH_CHANNEL_ENUM, "ENUM", ICON_NONE, "Enum"},
{BRUSH_CHANNEL_BITMASK, "BITMASK", ICON_NONE, "Bitmask"},
{BRUSH_CHANNEL_BOOL, "BOOL", ICON_NONE, "Boolean"},
{BRUSH_CHANNEL_VEC3, "VEC3", ICON_NONE, "Color3"},
{BRUSH_CHANNEL_VEC4, "VEC4", ICON_NONE, "Color4"},
{BRUSH_CHANNEL_CURVE, "CURVE", ICON_NONE, "Curve"},
EnumPropertyItem channel_types[] = {{BRUSH_CHANNEL_TYPE_FLOAT, "FLOAT", ICON_NONE, "Float"},
{BRUSH_CHANNEL_TYPE_INT, "INT", ICON_NONE, "Int"},
{BRUSH_CHANNEL_TYPE_ENUM, "ENUM", ICON_NONE, "Enum"},
{BRUSH_CHANNEL_TYPE_BITMASK, "BITMASK", ICON_NONE, "Bitmask"},
{BRUSH_CHANNEL_TYPE_BOOL, "BOOL", ICON_NONE, "Boolean"},
{BRUSH_CHANNEL_TYPE_VEC3, "VEC3", ICON_NONE, "Color3"},
{BRUSH_CHANNEL_TYPE_VEC4, "VEC4", ICON_NONE, "Color4"},
{BRUSH_CHANNEL_TYPE_CURVE, "CURVE", ICON_NONE, "Curve"},
{0, NULL, 0, NULL, NULL}};
// getting weird link errors here
@ -575,6 +752,7 @@ void RNA_def_brush_channel(BlenderRNA *brna)
RNA_def_struct_sdna(srna, "BrushChannel");
RNA_def_struct_ui_text(srna, "Brush Channel", "Brush Channel");
RNA_def_struct_path_func(srna, "rna_BrushChannel_rnapath");
RNA_def_struct_refine_func(srna, "rna_BrushChannel_refine");
prop = RNA_def_property(srna, "idname", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, "BrushChannel", "idname");
@ -604,6 +782,7 @@ void RNA_def_brush_channel(BlenderRNA *brna)
prop = RNA_def_property(srna, "bool_value", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, "BrushChannel", "ivalue", 1);
RNA_def_property_ui_text(prop, "Value", "Current value");
RNA_def_property_boolean_funcs(prop, "rna_BrushChannel_bool_get", "rna_BrushChannel_bool_set");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
prop = RNA_def_property(srna, "ui_order", PROP_INT, PROP_NONE);
@ -638,6 +817,7 @@ void RNA_def_brush_channel(BlenderRNA *brna)
"rna_BrushChannel_get_value",
"rna_BrushChannel_set_value",
"rna_BrushChannel_value_range");
RNA_def_property_editable_func(prop, "rna_BrushChannel_factor_value_editable");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
prop = RNA_def_property(srna, "percent_value", PROP_FLOAT, PROP_PERCENTAGE);
@ -672,9 +852,9 @@ void RNA_def_brush_channel(BlenderRNA *brna)
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
prop = RNA_def_property(srna, "is_color", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, "BrushChannel", "flag", BRUSH_CHANNEL_COLOR);
RNA_def_property_ui_text(prop, "Is Color", "Is this channel a color");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_boolean_funcs(prop, "rna_BrushChannel_get_is_color", NULL);
prop = RNA_def_property(srna, "ui_expanded", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, "BrushChannel", "flag", BRUSH_CHANNEL_UI_EXPANDED);
@ -703,6 +883,7 @@ void RNA_def_brush_channel(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, "BrushChannel", "vector");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Color", "");
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
prop = RNA_def_property(srna, "color4_value", PROP_FLOAT, PROP_COLOR);

View File

@ -255,6 +255,8 @@ void gmp_blender_init_allocator()
* - run #WM_main() event loop,
* or exit immediately when running in background-mode.
*/
#include "direct.h"
int main(int argc,
#ifdef WIN32
const char **UNUSED(argv_c)
@ -308,7 +310,7 @@ int main(int argc,
LocalFree(argv_16);
/* free on early-exit */
app_init_data.argv = (const char**) argv;
app_init_data.argv = (const char **)argv;
app_init_data.argv_num = argv_num;
}
#endif /* WIN32 */