Sculpt: Clay brush speedups
* Made clay brush use a spacing of 7 for autosmooth instead of the brush default (which is 3). * Also fixed a few small UI issues
This commit is contained in:
parent
06e8cc0256
commit
c0b0e4cd16
|
@ -358,6 +358,8 @@ class UnifiedPaintPanel:
|
|||
row2.label(text=name)
|
||||
row2.prop(mp0, "inherit", text="", icon="BRUSHES_ALL")
|
||||
row2.prop(mp, "enabled", text="", icon="STYLUS_PRESSURE")
|
||||
row2.prop(mp, "invert", text="", icon="ARROW_LEFTRIGHT")
|
||||
|
||||
row2.prop(mp0, "ui_expanded", text="", icon="TRIA_DOWN" if mp.ui_expanded else "TRIA_RIGHT")
|
||||
|
||||
if mp0.ui_expanded:
|
||||
|
@ -878,9 +880,18 @@ def brush_settings(layout, context, brush, popover=False):
|
|||
|
||||
row = layout.row(align=True)
|
||||
|
||||
row.prop(brush, "hardness", slider=True)
|
||||
row.prop(brush, "invert_hardness_pressure", text="")
|
||||
row.prop(brush, "use_hardness_pressure", text="")
|
||||
UnifiedPaintPanel.prop_unified(
|
||||
layout,
|
||||
context,
|
||||
brush,
|
||||
"hardness",
|
||||
slider=True,
|
||||
pressure_name = "use_hardness_pressure"
|
||||
)
|
||||
|
||||
#row.prop(brush, "hardness", slider=True)
|
||||
#row.prop(brush, "invert_hardness_pressure", text="")
|
||||
#row.prop(brush, "use_hardness_pressure", text="")
|
||||
|
||||
# auto_smooth_factor and use_inverse_smooth_pressure
|
||||
if capabilities.has_auto_smooth:
|
||||
|
@ -913,12 +924,12 @@ def brush_settings(layout, context, brush, popover=False):
|
|||
text="Custom Spacing"
|
||||
)
|
||||
|
||||
if brush.use_custom_auto_smooth_spacing:
|
||||
UnifiedPaintPanel.prop_unified(
|
||||
if brush.channels["autosmooth_use_spacing"].bool_value:
|
||||
UnifiedPaintPanel.channel_unified(
|
||||
box,
|
||||
context,
|
||||
brush,
|
||||
"auto_smooth_spacing",
|
||||
"autosmooth_spacing",
|
||||
slider=True,
|
||||
text="Spacing"
|
||||
)
|
||||
|
|
|
@ -39,7 +39,7 @@ extern "C" {
|
|||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 24
|
||||
#define BLENDER_FILE_SUBVERSION 25
|
||||
|
||||
/* 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
|
||||
|
|
|
@ -133,8 +133,8 @@ places in rna_engine_codebase are relevent:
|
|||
MAKE_FLOAT(boundary_smooth, "Boundary Smooth", "Smooth hard boundaries", 0.0f, 0.0f, 1.0f)
|
||||
MAKE_BOOL(topology_rake_use_spacing, "Use Rake Spacing", "Use custom spacing for topology rake", false)
|
||||
MAKE_BOOL(autosmooth_use_spacing, "Use Auto-Smooth Spacing", "Use custom spacing for autosmooth", false)
|
||||
MAKE_FLOAT_EX(topology_rake_spacing, "Rake Spacing", "Topology rake stroke spacing", 13.0f, 0.05f, 1000.0f, 0.1f, 300.0f, false)
|
||||
MAKE_FLOAT_EX(autosmooth_spacing, "Auto-Smooth Spacing", "Autosmooth stroke spacing", 13.0f, 0.05f, 1000.0f, 0.1f, 300.0f, false)
|
||||
MAKE_FLOAT_EX(topology_rake_spacing, "Rake Spacing", "Topology rake stroke spacing", 13.0f, 0.05f, 1000.0f, 0.5f, 150.0f, false)
|
||||
MAKE_FLOAT_EX(autosmooth_spacing, "Auto-Smooth Spacing", "Autosmooth stroke spacing", 13.0f, 0.05f, 1000.0f, 0.5f, 150.0f, false)
|
||||
MAKE_ENUM(topology_rake_mode, "Topology Rake Mode", "", 1, {
|
||||
{0, "BRUSH_DIRECTION", ICON_NONE, "Stroke", "Stroke Direction"},
|
||||
{1, "CURVATURE", ICON_NONE, "Curvature", "Follow mesh curvature"},
|
||||
|
|
|
@ -154,7 +154,7 @@ static bool check_corrupted_curve(BrushMapping *dst)
|
|||
BKE_curvemap_reset(curve->cm + i,
|
||||
&(struct rctf){.xmin = 0, .ymin = 0.0, .xmax = 1.0, .ymax = 1.0},
|
||||
CURVE_PRESET_LINE,
|
||||
dst->flag & BRUSH_MAPPING_INVERT);
|
||||
1);
|
||||
BKE_curvemapping_init(dst->curve);
|
||||
}
|
||||
|
||||
|
@ -817,27 +817,27 @@ void BKE_brush_resolve_channels(Brush *brush, Sculpt *sd)
|
|||
BKE_brush_channelset_merge(brush->channels_final, brush->channels, sd->channels);
|
||||
}
|
||||
|
||||
int BKE_brush_channelset_get_int(BrushChannelSet *chset,
|
||||
const char *idname,
|
||||
BrushMappingData *mapdata)
|
||||
static bool channel_has_mappings(BrushChannel *ch)
|
||||
{
|
||||
BrushChannel *ch = BKE_brush_channelset_lookup(chset, idname);
|
||||
|
||||
if (!ch) {
|
||||
printf("%s, unknown channel %s", __func__, idname);
|
||||
return 0;
|
||||
for (int i = 0; i < BRUSH_MAPPING_MAX; i++) {
|
||||
if (ch->mappings[i].flag & BRUSH_MAPPING_ENABLED) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return BKE_brush_channel_get_int(ch, mapdata);
|
||||
return false;
|
||||
}
|
||||
|
||||
float BKE_brush_channel_get_int(BrushChannel *ch, BrushMappingData *mapdata)
|
||||
// idx is used by vector channels
|
||||
static double eval_channel_mappings(BrushChannel *ch, BrushMappingData *mapdata, double f, int idx)
|
||||
{
|
||||
|
||||
float f = (float)ch->ivalue;
|
||||
if (idx == 3 && !(ch->flag & BRUSH_CHANNEL_APPLY_MAPPING_TO_ALPHA)) {
|
||||
return f;
|
||||
}
|
||||
|
||||
if (mapdata) {
|
||||
float factor = 1.0f;
|
||||
double factor = 1.0f;
|
||||
|
||||
for (int i = 0; i < BRUSH_MAPPING_MAX; i++) {
|
||||
BrushMapping *mp = ch->mappings + i;
|
||||
|
@ -846,7 +846,12 @@ float BKE_brush_channel_get_int(BrushChannel *ch, BrushMappingData *mapdata)
|
|||
continue;
|
||||
}
|
||||
|
||||
float f2 = BKE_curvemapping_evaluateF(mp->curve, 0, f);
|
||||
float inputf = ((float *)mapdata)[i];
|
||||
if (mp->flag & BRUSH_MAPPING_INVERT) {
|
||||
inputf = 1.0 - inputf;
|
||||
}
|
||||
|
||||
double f2 = (float)BKE_curvemapping_evaluateF(mp->curve, 0, inputf);
|
||||
|
||||
switch (mp->blendmode) {
|
||||
case MA_RAMP_BLEND:
|
||||
|
@ -879,7 +884,32 @@ float BKE_brush_channel_get_int(BrushChannel *ch, BrushMappingData *mapdata)
|
|||
f *= factor;
|
||||
}
|
||||
|
||||
return (int)f;
|
||||
return f;
|
||||
}
|
||||
|
||||
int BKE_brush_channelset_get_int(BrushChannelSet *chset,
|
||||
const char *idname,
|
||||
BrushMappingData *mapdata)
|
||||
{
|
||||
BrushChannel *ch = BKE_brush_channelset_lookup(chset, idname);
|
||||
|
||||
if (!ch) {
|
||||
printf("%s, unknown channel %s", __func__, idname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return BKE_brush_channel_get_int(ch, mapdata);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
else {
|
||||
return ch->ivalue;
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_brush_channel_set_int(BrushChannel *ch, int val)
|
||||
|
@ -1007,56 +1037,9 @@ float BKE_brush_channelset_get_float(BrushChannelSet *chset,
|
|||
|
||||
float BKE_brush_channel_get_float(BrushChannel *ch, BrushMappingData *mapdata)
|
||||
{
|
||||
|
||||
float f = ch->fvalue;
|
||||
|
||||
if (mapdata) {
|
||||
float factor = 1.0f;
|
||||
|
||||
for (int i = 0; i < BRUSH_MAPPING_MAX; i++) {
|
||||
BrushMapping *mp = ch->mappings + i;
|
||||
|
||||
if (!(mp->flag & BRUSH_MAPPING_ENABLED)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
float inputf = ((float *)mapdata)[i];
|
||||
|
||||
float f2 = BKE_curvemapping_evaluateF(mp->curve, 0, inputf);
|
||||
|
||||
switch (mp->blendmode) {
|
||||
case MA_RAMP_BLEND:
|
||||
break;
|
||||
case MA_RAMP_MULT:
|
||||
f2 *= factor;
|
||||
break;
|
||||
case MA_RAMP_DIV:
|
||||
f2 = factor / (0.00001f + f2);
|
||||
break;
|
||||
case MA_RAMP_ADD:
|
||||
f2 += factor;
|
||||
break;
|
||||
case MA_RAMP_SUB:
|
||||
f2 = factor - f2;
|
||||
break;
|
||||
case MA_RAMP_DIFF:
|
||||
f2 = fabsf(factor - f2);
|
||||
break;
|
||||
default:
|
||||
printf("Unsupported brush mapping blend mode for %s (%s); will mix instead\n",
|
||||
ch->name,
|
||||
ch->idname);
|
||||
break;
|
||||
}
|
||||
|
||||
factor += (f2 - factor) * mp->factor;
|
||||
}
|
||||
|
||||
f *= factor;
|
||||
}
|
||||
|
||||
return f;
|
||||
return (float)eval_channel_mappings(ch, mapdata, (double)ch->fvalue, 0);
|
||||
}
|
||||
|
||||
void BKE_brush_channel_set_vector(BrushChannel *ch, float vec[4])
|
||||
{
|
||||
if (ch->type == BRUSH_CHANNEL_VEC4) {
|
||||
|
@ -1086,65 +1069,8 @@ int BKE_brush_channel_get_vector(BrushChannel *ch, float out[4], BrushMappingDat
|
|||
size = 4;
|
||||
}
|
||||
|
||||
if (mapdata) {
|
||||
float factor = 1.0f;
|
||||
|
||||
for (int i = 0; i < BRUSH_MAPPING_MAX; i++) {
|
||||
BrushMapping *mp = ch->mappings + i;
|
||||
|
||||
if (!(mp->flag & BRUSH_MAPPING_ENABLED)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
float inputf = ((float *)mapdata)[i];
|
||||
|
||||
float f2 = BKE_curvemapping_evaluateF(mp->curve, 0, inputf);
|
||||
|
||||
switch (mp->blendmode) {
|
||||
case MA_RAMP_BLEND:
|
||||
break;
|
||||
case MA_RAMP_MULT:
|
||||
f2 *= inputf * f2;
|
||||
break;
|
||||
case MA_RAMP_DIV:
|
||||
f2 = inputf / (0.00001f + inputf);
|
||||
break;
|
||||
case MA_RAMP_ADD:
|
||||
f2 += inputf;
|
||||
break;
|
||||
case MA_RAMP_SUB:
|
||||
f2 = inputf - f2;
|
||||
break;
|
||||
case MA_RAMP_DIFF:
|
||||
f2 = fabsf(inputf - f2);
|
||||
break;
|
||||
default:
|
||||
printf("Unsupported brush mapping blend mode for %s (%s); will mix instead\n",
|
||||
ch->name,
|
||||
ch->idname);
|
||||
break;
|
||||
}
|
||||
|
||||
factor += (f2 - factor) * mp->factor;
|
||||
}
|
||||
|
||||
if (size == 3) {
|
||||
copy_v3_v3(out, ch->vector);
|
||||
mul_v3_fl(out, factor);
|
||||
}
|
||||
else {
|
||||
copy_v4_v4(out, ch->vector);
|
||||
|
||||
if (ch->flag & BRUSH_CHANNEL_APPLY_MAPPING_TO_ALPHA) {
|
||||
mul_v4_fl(out, factor);
|
||||
}
|
||||
else {
|
||||
mul_v3_fl(out, factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
copy_v4_v4(out, ch->vector);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
out[i] = eval_channel_mappings(ch, mapdata, (float)ch->vector[i], i);
|
||||
}
|
||||
|
||||
return size;
|
||||
|
|
|
@ -1234,6 +1234,10 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
|
|||
GETCH(autosmooth)->fvalue = 0.25f;
|
||||
GETCH(normal_radius_factor)->fvalue = 0.75f;
|
||||
GETCH(hardness)->fvalue = 0.65;
|
||||
|
||||
BRUSHSET_SET_BOOL(chset, autosmooth_use_spacing, true);
|
||||
BRUSHSET_SET_FLOAT(chset, autosmooth_spacing, 7);
|
||||
|
||||
reset_clay_mappings(chset, false);
|
||||
break;
|
||||
case SCULPT_TOOL_TWIST:
|
||||
|
|
|
@ -1316,6 +1316,16 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
BKE_brush_channelset_compat_load(brush->channels, brush, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 300, 25)) {
|
||||
LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
|
||||
if (brush->sculpt_tool == SCULPT_TOOL_CLAY && brush->channels) {
|
||||
BRUSHSET_SET_BOOL(brush->channels, autosmooth_use_spacing, true);
|
||||
BRUSHSET_SET_FLOAT(brush->channels, autosmooth_spacing, 7.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
|
|
|
@ -484,6 +484,13 @@ void RNA_def_brush_mapping(BlenderRNA *brna)
|
|||
|
||||
prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, "BrushMapping", "flag", BRUSH_MAPPING_ENABLED);
|
||||
RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0);
|
||||
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
||||
RNA_def_property_ui_text(prop, "Enabled", "Input Mapping Is Enabled");
|
||||
|
||||
prop = RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, "BrushMapping", "flag", BRUSH_MAPPING_INVERT);
|
||||
RNA_def_property_ui_icon(prop, ICON_ARROW_LEFTRIGHT, 0);
|
||||
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
|
||||
RNA_def_property_ui_text(prop, "Enabled", "Input Mapping Is Enabled");
|
||||
|
||||
|
|
Loading…
Reference in New Issue