Sculpt: More clay brush fixes
This commit is contained in:
parent
daaf6d6660
commit
150ad9cf9c
|
@ -127,23 +127,25 @@ class DynamicPaintPanelGen:
|
|||
global classes
|
||||
|
||||
name = group.prefix + group.idname.lower()
|
||||
name1 = name
|
||||
name2 = ""
|
||||
|
||||
for c in name:
|
||||
n = ord(c)
|
||||
|
||||
ok = n >= ord("a") and n <= ord("a")
|
||||
ok = ok or n >= ord("A") and n <= ord("Z")
|
||||
ok = ok or n >= ord("0") and n <= ord("9")
|
||||
ok = n >= ord("a") and n <= ord("z")
|
||||
ok = ok or (n >= ord("A") and n <= ord("Z"))
|
||||
ok = ok or (n >= ord("0") and n <= ord("9"))
|
||||
ok = ok or c == "_"
|
||||
|
||||
if not ok:
|
||||
c = "_"
|
||||
|
||||
name2 += c
|
||||
name = name2
|
||||
|
||||
for cls in classes[:]:
|
||||
print("_", cls.bl_rna.identifier, cls.bl_rna.identifier == name) # r, dir(cls.bl_rna)) #.name)
|
||||
#print("_", cls.bl_rna.identifier, cls.bl_rna.identifier == name) # r, dir(cls.bl_rna)) #.name)
|
||||
|
||||
if cls.bl_rna.identifier == name:
|
||||
try:
|
||||
|
@ -180,7 +182,6 @@ classes.append(CLASSNAME)
|
|||
""".strip().replace("CLASSNAME", name).replace("PARENT", parent).replace("LABEL", group.name).replace("OPT", opt)
|
||||
code = code.replace("IDNAME", group.idname)
|
||||
|
||||
print("\n", code)
|
||||
exec(code)
|
||||
|
||||
|
||||
|
@ -522,7 +523,7 @@ class UnifiedPaintPanel:
|
|||
if not toolsettings_only:
|
||||
row.prop(ch, "inherit", text="", icon='BRUSHES_ALL')
|
||||
|
||||
if ch.type in ["BITMASK", "BOOL", "CURVE"]:
|
||||
if ch.type in ["BITMASK", "BOOL", "CURVE", "ENUM"]:
|
||||
return
|
||||
|
||||
if not ui_editing and not show_reorder:
|
||||
|
@ -1038,6 +1039,7 @@ def brush_settings(layout, context, brush, popover=False):
|
|||
layout.prop(context.tool_settings.unified_paint_settings, "brush_editor_advanced")
|
||||
|
||||
advanced = context.tool_settings.unified_paint_settings.brush_editor_advanced
|
||||
editor = context.tool_settings.unified_paint_settings.brush_editor_mode
|
||||
|
||||
### Draw simple settings unique to each paint mode. ###
|
||||
brush_shared_settings(layout, context, brush, popover)
|
||||
|
@ -1267,11 +1269,33 @@ def brush_settings(layout, context, brush, popover=False):
|
|||
slider=True,
|
||||
)
|
||||
|
||||
row = layout.row(heading="Plane Trim")
|
||||
row.prop(brush, "use_plane_trim", text="")
|
||||
sub = row.row()
|
||||
sub.active = brush.use_plane_trim
|
||||
sub.prop(brush, "plane_trim", slider=True, text="")
|
||||
if editor:
|
||||
col = layout.column()
|
||||
|
||||
#row.prop(brush, "use_plane_trim", text="")
|
||||
#"""
|
||||
UnifiedPaintPanel.channel_unified(
|
||||
col,
|
||||
context,
|
||||
brush,
|
||||
"use_plane_trim",
|
||||
text="Plane Trim"
|
||||
)
|
||||
UnifiedPaintPanel.channel_unified(
|
||||
col,
|
||||
context,
|
||||
brush,
|
||||
"plane_trim",
|
||||
slider=True
|
||||
)
|
||||
#"""
|
||||
else:
|
||||
row = layout.row(heading="Plane Trim")
|
||||
row.prop(brush.channels["use_plane_trim"], "bool_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="")
|
||||
|
||||
layout.separator()
|
||||
|
||||
|
@ -1802,9 +1826,26 @@ def brush_settings_advanced(layout, context, brush, popover=False):
|
|||
# sculpt plane settings
|
||||
if capabilities.has_sculpt_plane:
|
||||
layout.prop(brush, "sculpt_plane")
|
||||
col = layout.column(heading="Use Original", align=True)
|
||||
col.prop(brush, "use_original_normal", text="Normal")
|
||||
col.prop(brush, "use_original_plane", text="Plane")
|
||||
|
||||
col = layout.column(heading="Use Original", align=False)
|
||||
col = col.column()
|
||||
|
||||
UnifiedPaintPanel.channel_unified(
|
||||
col,
|
||||
context,
|
||||
brush,
|
||||
"original_normal",
|
||||
text="Normal",
|
||||
expand=False
|
||||
)
|
||||
UnifiedPaintPanel.channel_unified(
|
||||
col,
|
||||
context,
|
||||
brush,
|
||||
"original_plane",
|
||||
text="Plane",
|
||||
expand=False
|
||||
)
|
||||
layout.separator()
|
||||
|
||||
# 3D and 2D Texture Paint.
|
||||
|
|
|
@ -39,7 +39,7 @@ extern "C" {
|
|||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 26
|
||||
#define BLENDER_FILE_SUBVERSION 27
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and show a warning if the file
|
||||
|
|
|
@ -62,6 +62,8 @@ struct LibraryForeachIDData;
|
|||
|
||||
/* these macros check channel names at compile time */
|
||||
|
||||
#define BRUSHSET_LOOKUP_FINAL(childset, parentset, idname) \
|
||||
BKE_brush_channelset_lookup_final(childset, parentset, MAKE_BUILTIN_CH_NAME(idname))
|
||||
#define BRUSHSET_LOOKUP(chset, channel) \
|
||||
BKE_brush_channelset_lookup(chset, MAKE_BUILTIN_CH_NAME(channel))
|
||||
#define BRUSHSET_HAS(chset, channel, mapdata) \
|
||||
|
@ -214,6 +216,9 @@ bool BKE_brush_channelset_remove_named(BrushChannelSet *chset, const char *idnam
|
|||
void BKE_brush_channelset_ensure_existing(BrushChannelSet *chset, BrushChannel *existing);
|
||||
|
||||
BrushChannel *BKE_brush_channelset_lookup(BrushChannelSet *chset, const char *idname);
|
||||
BrushChannel *BKE_brush_channelset_lookup_final(BrushChannelSet *child,
|
||||
BrushChannelSet *parent,
|
||||
const char *idname);
|
||||
|
||||
bool BKE_brush_channelset_has(BrushChannelSet *chset, const char *idname);
|
||||
|
||||
|
@ -270,6 +275,11 @@ void BKE_brush_channel_set_vector(BrushChannel *ch, float vec[4]);
|
|||
int BKE_brush_channel_get_vector_size(BrushChannel *ch);
|
||||
|
||||
float BKE_brush_channel_curve_evaluate(BrushChannel *ch, float val, const float maxval);
|
||||
double BKE_brush_channel_eval_mappings(BrushChannel *ch,
|
||||
BrushMappingData *mapdata,
|
||||
double f,
|
||||
int idx);
|
||||
|
||||
CurveMapping *BKE_brush_channel_curvemapping_get(BrushCurve *curve, bool force_create);
|
||||
bool BKE_brush_channel_curve_ensure_write(BrushCurve *curve);
|
||||
void BKE_brush_channel_curve_assign(BrushChannel *ch, BrushCurve *curve);
|
||||
|
|
|
@ -273,6 +273,7 @@ MAKE_FLOAT(tip_scale_x, "Tip Scale X", "Scale of the brush tip in the X axis", 1
|
|||
MAKE_FLOAT(dash_ratio, "Dash Ratio", "Ratio of samples in a cycle that the brush is enabled", 1.0f, 0.0f, 1.0f)
|
||||
MAKE_FLOAT_EX(plane_offset, "Plane Offset", "Adjust plane on which the brush acts towards or away from the object surface", 0.0f, -2.0f, 2.0f, -0.5f, 0.5f, false)
|
||||
MAKE_FLOAT(plane_trim, "Plane Trim", "If a vertex is further away from offset plane than this, then it is not affected", 0.5f, 0.0f, 1.0f)
|
||||
MAKE_BOOL(use_plane_trim, "Use Plane Trim", "Enable Plane Trim", false)
|
||||
MAKE_BOOL(original_normal, "Original Normal", "When locked keep using normal of surface where stroke was initiated", false)
|
||||
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)
|
||||
|
|
|
@ -593,6 +593,28 @@ BrushChannel *BKE_brush_channelset_lookup(BrushChannelSet *chset, const char *id
|
|||
return BLI_ghash_lookup(chset->namemap, idname);
|
||||
}
|
||||
|
||||
BrushChannel *BKE_brush_channelset_lookup_final(BrushChannelSet *child,
|
||||
BrushChannelSet *parent,
|
||||
const char *idname)
|
||||
{
|
||||
BrushChannel *ch = child ? BKE_brush_channelset_lookup(child, idname) : NULL;
|
||||
BrushChannel *pch = parent ? BKE_brush_channelset_lookup(parent, idname) : NULL;
|
||||
|
||||
if (ch && pch) {
|
||||
if (ch->flag & BRUSH_CHANNEL_INHERIT) {
|
||||
return pch;
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
else if (pch) {
|
||||
return pch;
|
||||
}
|
||||
else {
|
||||
return ch;
|
||||
}
|
||||
}
|
||||
|
||||
bool BKE_brush_channelset_has(BrushChannelSet *chset, const char *idname)
|
||||
{
|
||||
return BKE_brush_channelset_lookup(chset, idname) != NULL;
|
||||
|
@ -843,7 +865,10 @@ static bool channel_has_mappings(BrushChannel *ch)
|
|||
}
|
||||
|
||||
// idx is used by vector channels
|
||||
static double eval_channel_mappings(BrushChannel *ch, BrushMappingData *mapdata, double f, int idx)
|
||||
double BKE_brush_channel_eval_mappings(BrushChannel *ch,
|
||||
BrushMappingData *mapdata,
|
||||
double f,
|
||||
int idx)
|
||||
{
|
||||
|
||||
if (idx == 3 && !(ch->flag & BRUSH_CHANNEL_APPLY_MAPPING_TO_ALPHA)) {
|
||||
|
@ -919,7 +944,7 @@ float BKE_brush_channel_get_int(BrushChannel *ch, BrushMappingData *mapdata)
|
|||
{
|
||||
|
||||
if (channel_has_mappings(ch)) {
|
||||
return (int)eval_channel_mappings(ch, mapdata, (double)ch->ivalue, 0);
|
||||
return (int)BKE_brush_channel_eval_mappings(ch, mapdata, (double)ch->ivalue, 0);
|
||||
}
|
||||
else {
|
||||
return ch->ivalue;
|
||||
|
@ -1051,7 +1076,7 @@ float BKE_brush_channelset_get_float(BrushChannelSet *chset,
|
|||
|
||||
float BKE_brush_channel_get_float(BrushChannel *ch, BrushMappingData *mapdata)
|
||||
{
|
||||
return (float)eval_channel_mappings(ch, mapdata, (double)ch->fvalue, 0);
|
||||
return (float)BKE_brush_channel_eval_mappings(ch, mapdata, (double)ch->fvalue, 0);
|
||||
}
|
||||
|
||||
void BKE_brush_channel_set_vector(BrushChannel *ch, float vec[4])
|
||||
|
@ -1084,7 +1109,7 @@ int BKE_brush_channel_get_vector(BrushChannel *ch, float out[4], BrushMappingDat
|
|||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
out[i] = eval_channel_mappings(ch, mapdata, (float)ch->vector[i], i);
|
||||
out[i] = BKE_brush_channel_eval_mappings(ch, mapdata, (float)ch->vector[i], i);
|
||||
}
|
||||
|
||||
return size;
|
||||
|
|
|
@ -477,6 +477,7 @@ BrushFlagMap brush_flags_map[] = {
|
|||
DEF(flag2, use_connected_only, BRUSH_USE_CONNECTED_ONLY)
|
||||
DEF(flag2, use_pose_lock_rotation, BRUSH_POSE_USE_LOCK_ROTATION)
|
||||
DEF(flag, use_space_attenuation, BRUSH_SPACE_ATTEN)
|
||||
DEF(flag, use_plane_trim, BRUSH_PLANE_TRIM)
|
||||
};
|
||||
|
||||
int brush_flags_map_len = ARRAY_SIZE(brush_flags_map);
|
||||
|
@ -875,7 +876,14 @@ void reset_clay_mappings(BrushChannelSet *chset, bool strips)
|
|||
|
||||
cuma = curve->cm;
|
||||
if (strips) {
|
||||
//[[0,0.000], [0.062,0.016], [0.250,0.074], [0.562,0.274], [1,1.000]
|
||||
#if 0
|
||||
BKE_curvemap_insert(cuma, 0.062f, 0.016f);
|
||||
BKE_curvemap_insert(cuma, 0.25f, 0.074f);
|
||||
BKE_curvemap_insert(cuma, 0.562f, 0.274f);
|
||||
#else
|
||||
BKE_curvemap_insert(cuma, 0.6f, 0.25f);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
@ -908,6 +916,7 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
|
|||
|
||||
ADDCH(plane_offset);
|
||||
ADDCH(plane_trim);
|
||||
ADDCH(use_plane_trim);
|
||||
|
||||
ADDCH(use_ctrl_invert);
|
||||
ADDCH(tilt_strength_factor);
|
||||
|
@ -1184,6 +1193,7 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
|
|||
SHOWCTX(autosmooth);
|
||||
SHOWCTX(plane_offset);
|
||||
SHOWCTX(plane_trim);
|
||||
SHOWCTX(use_plane_trim);
|
||||
break;
|
||||
case SCULPT_TOOL_GRAB:
|
||||
SHOWCTX(normal_weight);
|
||||
|
@ -1195,10 +1205,12 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
|
|||
SHOWWRK(plane_offset);
|
||||
SHOWWRK(plane_trim);
|
||||
SHOWWRK(tip_roundness);
|
||||
SHOWWRK(use_plane_trim);
|
||||
|
||||
SHOWCTX(autosmooth);
|
||||
SHOWCTX(plane_offset);
|
||||
SHOWCTX(plane_trim);
|
||||
SHOWCTX(use_plane_trim);
|
||||
case SCULPT_TOOL_CLAY:
|
||||
case SCULPT_TOOL_CLAY_THUMB:
|
||||
case SCULPT_TOOL_FLATTEN:
|
||||
|
@ -1206,16 +1218,20 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
|
|||
SHOWWRK(plane_offset);
|
||||
SHOWWRK(plane_trim, plane_trim);
|
||||
SHOWWRK(tip_roundness);
|
||||
SHOWWRK(use_plane_trim);
|
||||
|
||||
SHOWCTX(autosmooth);
|
||||
SHOWCTX(plane_offset);
|
||||
SHOWCTX(plane_trim);
|
||||
SHOWCTX(use_plane_trim);
|
||||
break;
|
||||
case SCULPT_TOOL_MULTIPLANE_SCRAPE:
|
||||
SHOWCTX(autosmooth);
|
||||
SHOWCTX(plane_offset);
|
||||
SHOWCTX(autosmooth);
|
||||
SHOWCTX(multiplane_scrape_angle);
|
||||
SHOWWRK(use_plane_trim);
|
||||
SHOWCTX(use_plane_trim);
|
||||
|
||||
SHOWWRK(plane_offset);
|
||||
SHOWWRK(plane_trim);
|
||||
|
|
|
@ -1317,7 +1317,7 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 300, 26)) {
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 300, 27)) {
|
||||
LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
|
||||
if (ELEM(brush->sculpt_tool, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS) && brush->channels) {
|
||||
BRUSHSET_SET_BOOL(brush->channels, autosmooth_use_spacing, true);
|
||||
|
|
|
@ -3781,10 +3781,10 @@ static void calc_area_normal_and_center(
|
|||
* values pull vertices, negative values push. Uses tablet pressure and a
|
||||
* special multiplier found experimentally to scale the strength factor.
|
||||
*/
|
||||
static float brush_strength(const Sculpt *sd,
|
||||
const StrokeCache *cache,
|
||||
const float feather,
|
||||
const UnifiedPaintSettings *ups)
|
||||
ATTR_NO_OPT static float brush_strength(const Sculpt *sd,
|
||||
const StrokeCache *cache,
|
||||
const float feather,
|
||||
const UnifiedPaintSettings *ups)
|
||||
{
|
||||
const Scene *scene = cache->vc->scene;
|
||||
const Brush *brush = cache->brush; // BKE_paint_brush((Paint *)&sd->paint);
|
||||
|
@ -7193,7 +7193,7 @@ static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
|
|||
|
||||
int SCULPT_plane_trim(const StrokeCache *cache, const Brush *brush, const float val[3])
|
||||
{
|
||||
return (!(brush->flag & BRUSH_PLANE_TRIM) ||
|
||||
return (!(cache->use_plane_trim) ||
|
||||
((dot_v3v3(val, val) <= cache->radius_squared * cache->plane_trim_squared)));
|
||||
}
|
||||
|
||||
|
@ -9356,6 +9356,11 @@ static void SCULPT_run_command_list(
|
|||
// Make sure to remove all pen pressure/tilt old code
|
||||
BKE_brush_channelset_compat_load(cmd->params_mapped, brush2, false);
|
||||
|
||||
ss->cache->use_plane_trim = BRUSHSET_GET_INT(cmd->params_mapped, use_plane_trim, NULL);
|
||||
|
||||
float plane_trim = BRUSHSET_GET_FLOAT(cmd->params_mapped, plane_trim, NULL);
|
||||
ss->cache->plane_trim_squared = plane_trim * plane_trim;
|
||||
|
||||
brush2->flag &= ~(BRUSH_ALPHA_PRESSURE | BRUSH_SIZE_PRESSURE | BRUSH_SPACING_PRESSURE |
|
||||
BRUSH_JITTER_PRESSURE | BRUSH_OFFSET_PRESSURE |
|
||||
BRUSH_INVERSE_SMOOTH_PRESSURE);
|
||||
|
@ -11653,6 +11658,9 @@ void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerR
|
|||
ss->cache->channels_final = BKE_brush_channelset_copy(brush->channels);
|
||||
}
|
||||
|
||||
ss->cache->use_plane_trim = BRUSHSET_GET_INT(
|
||||
ss->cache->channels_final, use_plane_trim, &ss->cache->input_mapping);
|
||||
|
||||
if (ss->cache->alt_smooth) {
|
||||
Brush *brush = (Brush *)BKE_libblock_find_name(
|
||||
CTX_data_main(C), ID_BR, ss->cache->saved_active_brush_name);
|
||||
|
@ -11676,6 +11684,11 @@ void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerR
|
|||
|
||||
ss->cache->bstrength = brush_strength(sd, ss->cache, calc_symmetry_feather(sd, ss->cache), ups);
|
||||
|
||||
// we have to evaluate channel mappings here manually
|
||||
BrushChannel *ch = BRUSHSET_LOOKUP_FINAL(brush->channels, sd->channels, strength);
|
||||
ss->cache->bstrength = BKE_brush_channel_eval_mappings(
|
||||
ch, &ss->cache->input_mapping, (double)ss->cache->bstrength, 0);
|
||||
|
||||
if (ss->cache->invert) {
|
||||
brush->alpha = fabs(brush->alpha);
|
||||
ss->cache->bstrength = -fabs(ss->cache->bstrength);
|
||||
|
|
|
@ -1342,6 +1342,7 @@ typedef struct StrokeCache {
|
|||
struct bContext *C;
|
||||
|
||||
struct BrushCommandList *commandlist;
|
||||
bool use_plane_trim;
|
||||
} StrokeCache;
|
||||
|
||||
/* Sculpt Filters */
|
||||
|
|
Loading…
Reference in New Issue