Sculpt: More brush channels stuff
This commit is contained in:
parent
430e7efd09
commit
1b6beea2df
|
@ -170,7 +170,6 @@ places in rna_engine_codebase are relevent:
|
|||
}))
|
||||
|
||||
MAKE_FLOAT(normal_weight, "Normal Weight", "", 0.0f, 0.0f, 1.0f)
|
||||
MAKE_FLOAT(rake_factor, "Rake Factor", "How much grab will follow cursor rotation", 0.0f, 0.0f, 10.0f)
|
||||
MAKE_FLOAT(weight, "Weight", "", 0.5f, 0.0f, 1.0f)
|
||||
MAKE_FLOAT(jitter, "Jitter", "Jitter the position of the brush while painting", 0.0f, 0.0f, 1.0f)
|
||||
MAKE_INT(jitter_absolute, "Absolute Jitter", "", 0, 0.0f, 1000.0f)
|
||||
|
@ -343,6 +342,67 @@ MAKE_ENUM_EX(radius_unit, "Radius Unit", "Measure brush size relative to the vi
|
|||
}), BRUSH_CHANNEL_SHOW_IN_WORKSPACE)
|
||||
MAKE_FLOAT(tilt_strength_factor, "Tilt Strength", "How much the tilt of the pen will affect the brush", 0.0f, 0.0f, 1.0f)
|
||||
|
||||
MAKE_FLOAT_EX(rake_factor, "Rake", "How much grab will follow cursor rotation", 0.5f, 0.0f, 10.0f, 0.0f, 1.0f, false)
|
||||
MAKE_FLOAT(pose_offset, "Pose Origin Offset", "Offset of the pose origin in relation to the brush radius", 0.0f, 0.0f, 2.0f)
|
||||
MAKE_FLOAT(disconnected_distance_max, "Max Element Distance",
|
||||
"Maximum distance to search for disconnected loose parts in the mesh", 0.1f, 0.0f, 10.0f)
|
||||
MAKE_INT(pose_smooth_iterations, "Smooth Iterations",
|
||||
"Smooth iterations applied after calculating the pose factor of each vertex", 4.0f, 0.0f, 100.0f)
|
||||
MAKE_INT(pose_ik_segments, "Pose IK Segments",
|
||||
"Number of segments of the inverse kinematics chain that will deform the mesh", 1, 1, 20)
|
||||
MAKE_FLOAT(surface_smooth_shape_preservation, "Shape Preservation", "How much of the original shape is preserved when smoothing", 0.5f, 0.0f, 1.0f)
|
||||
MAKE_FLOAT(surface_smooth_current_vertex, "Per Vertex Displacement",
|
||||
"How much the position of each individual vertex influences the final result", 0.5f, 0.0f, 1.0f)
|
||||
MAKE_INT(surface_smooth_iterations, "Iterations", "Number of smoothing iterations per brush step", 4, 1, 10)
|
||||
MAKE_BOOL(use_connected_only, "Connected Only", "Affect only topologically connected elements", true)
|
||||
MAKE_BOOL(use_pose_ik_anchored, "Keep Anchor Point", "Keep the position of the last segment in the IK chain fixed", true)
|
||||
MAKE_BOOL(use_pose_lock_rotation, "Lock Rotation When Scaling",
|
||||
"Do not rotate the segment when using the scale deform mode", false)
|
||||
MAKE_ENUM(pose_deform_type, "Deformation", "Deformation type that is used in the brush", 0, _({
|
||||
{BRUSH_POSE_DEFORM_ROTATE_TWIST, "ROTATE_TWIST", "NONE", "Rotate/Twist", ""},
|
||||
{BRUSH_POSE_DEFORM_SCALE_TRASLATE, "SCALE_TRANSLATE", "NONE", "Scale/Translate", ""},
|
||||
{BRUSH_POSE_DEFORM_SQUASH_STRETCH, "SQUASH_STRETCH", "NONE", "Squash & Stretch", ""},
|
||||
{BRUSH_POSE_DEFORM_BEND, "BEND", "NONE", "Bend", ""},
|
||||
{-1}
|
||||
}))
|
||||
MAKE_ENUM(pose_origin_type, "Rotation Origins",
|
||||
"Method to set the rotation origins for the segments of the brush", 0, _({
|
||||
|
||||
{BRUSH_POSE_ORIGIN_TOPOLOGY,
|
||||
"TOPOLOGY",
|
||||
"NONE",
|
||||
"Topology",
|
||||
"Sets the rotation origin automatically using the topology and shape of the mesh as a "
|
||||
"guide"},
|
||||
{BRUSH_POSE_ORIGIN_FACE_SETS,
|
||||
"FACE_SETS",
|
||||
"NONE",
|
||||
"Face Sets",
|
||||
"Creates a pose segment per face sets, starting from the active face set"},
|
||||
{BRUSH_POSE_ORIGIN_FACE_SETS_FK,
|
||||
"FACE_SETS_FK",
|
||||
"NONE",
|
||||
"Face Sets FK",
|
||||
"Simulates an FK deformation using the Face Set under the cursor as control"},
|
||||
{-1}
|
||||
}))
|
||||
|
||||
MAKE_FLOAT(crease_pinch_factor, "Crease Brush Pinch Factor", "How much the crease brush pinches", 0.0f, 0.0f, 1.0f)
|
||||
|
||||
MAKE_ENUM(snake_hook_deform_type, "Deformation", "Deformation type that is used in the brush", BRUSH_SNAKE_HOOK_DEFORM_FALLOFF, _({
|
||||
{BRUSH_SNAKE_HOOK_DEFORM_FALLOFF,
|
||||
"FALLOFF",
|
||||
"NONE",
|
||||
"Radius Falloff",
|
||||
"Applies the brush falloff in the tip of the brush"},
|
||||
{BRUSH_SNAKE_HOOK_DEFORM_ELASTIC,
|
||||
"ELASTIC",
|
||||
"NONE",
|
||||
"Elastic",
|
||||
"Modifies the entire mesh using elastic deform"},
|
||||
{-1}
|
||||
}))
|
||||
|
||||
/* clang-format on */
|
||||
#if defined(BRUSH_CHANNEL_DEFINE_TYPES) || defined(BRUSH_CHANNEL_DEFINE_EXTERNAL)
|
||||
# ifdef MAKE_FLOAT
|
||||
|
|
|
@ -292,6 +292,18 @@ static BrushSettingsMap brush_settings_map[] = {
|
|||
DEF(boundary_falloff_type, boundary_falloff_type, INT, INT)
|
||||
DEF(deform_target, deform_target, INT, INT)
|
||||
DEF(tilt_strength_factor, tilt_strength_factor, FLOAT, FLOAT)
|
||||
DEF(crease_pinch_factor, crease_pinch_factor, FLOAT, FLOAT)
|
||||
DEF(pose_offset, pose_offset, FLOAT, FLOAT)
|
||||
DEF(disconnected_distance_max, disconnected_distance_max, FLOAT, FLOAT)
|
||||
DEF(surface_smooth_shape_preservation, surface_smooth_shape_preservation, FLOAT, FLOAT)
|
||||
DEF(pose_smooth_iterations, pose_smooth_iterations, INT, INT)
|
||||
DEF(pose_ik_segments, pose_ik_segments, INT, INT)
|
||||
DEF(surface_smooth_shape_preservation, surface_smooth_shape_preservation, FLOAT, FLOAT)
|
||||
DEF(surface_smooth_current_vertex, surface_smooth_current_vertex, FLOAT, FLOAT)
|
||||
DEF(surface_smooth_iterations, surface_smooth_iterations, INT, INT)
|
||||
DEF(pose_deform_type, pose_deform_type, INT, INT)
|
||||
DEF(pose_origin_type, pose_origin_type, INT, INT)
|
||||
DEF(snake_hook_deform_type, snake_hook_deform_type, INT, INT)
|
||||
};
|
||||
|
||||
static const int brush_settings_map_len = ARRAY_SIZE(brush_settings_map);
|
||||
|
@ -352,6 +364,9 @@ BrushFlagMap brush_flags_map[] = {
|
|||
DEF(flag2, cloth_use_collision, BRUSH_CLOTH_USE_COLLISION)
|
||||
DEF(flag2, cloth_pin_simulation_boundary, BRUSH_CLOTH_PIN_SIMULATION_BOUNDARY)
|
||||
DEF(flag, radius_unit, BRUSH_LOCK_SIZE)
|
||||
DEF(flag2, use_pose_ik_anchored, BRUSH_POSE_IK_ANCHORED)
|
||||
DEF(flag2, use_connected_only, BRUSH_USE_CONNECTED_ONLY)
|
||||
DEF(flag2, use_pose_lock_rotation, BRUSH_POSE_USE_LOCK_ROTATION)
|
||||
};
|
||||
|
||||
int brush_flags_map_len = ARRAY_SIZE(brush_flags_map);
|
||||
|
@ -733,6 +748,10 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
|
|||
ADDCH(autosmooth_projection);
|
||||
ADDCH(autosmooth_falloff_curve);
|
||||
|
||||
ADDCH(surface_smooth_shape_preservation);
|
||||
ADDCH(surface_smooth_current_vertex);
|
||||
ADDCH(surface_smooth_iterations);
|
||||
|
||||
ADDCH(vcol_boundary_exponent);
|
||||
ADDCH(vcol_boundary_factor);
|
||||
ADDCH(vcol_boundary_radius_scale);
|
||||
|
@ -813,6 +832,11 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
|
|||
ADDCH(cloth_use_collision);
|
||||
ADDCH(cloth_pin_simulation_boundary);
|
||||
|
||||
break;
|
||||
case SCULPT_TOOL_SNAKE_HOOK:
|
||||
ADDCH(crease_pinch_factor);
|
||||
ADDCH(rake_factor);
|
||||
ADDCH(snake_hook_deform_type);
|
||||
break;
|
||||
case SCULPT_TOOL_BOUNDARY:
|
||||
ADDCH(boundary_offset);
|
||||
|
@ -820,8 +844,21 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
|
|||
ADDCH(boundary_falloff_type);
|
||||
ADDCH(deform_target);
|
||||
break;
|
||||
case SCULPT_TOOL_CREASE:
|
||||
ADDCH(crease_pinch_factor);
|
||||
break;
|
||||
case SCULPT_TOOL_POSE:
|
||||
ADDCH(deform_target);
|
||||
ADDCH(disconnected_distance_max);
|
||||
ADDCH(surface_smooth_shape_preservation);
|
||||
ADDCH(pose_smooth_iterations);
|
||||
ADDCH(pose_ik_segments);
|
||||
ADDCH(use_pose_ik_anchored);
|
||||
ADDCH(use_connected_only);
|
||||
ADDCH(use_pose_lock_rotation);
|
||||
ADDCH(pose_deform_type);
|
||||
ADDCH(pose_origin_type);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -866,7 +903,25 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
|
|||
SHOWALL(strength);
|
||||
SHOWALL(color);
|
||||
SHOWALL(secondary_color);
|
||||
SHOWALL(accumulate);
|
||||
|
||||
if (!ELEM(tool,
|
||||
SCULPT_TOOL_SNAKE_HOOK,
|
||||
SCULPT_TOOL_ARRAY,
|
||||
SCULPT_TOOL_BOUNDARY,
|
||||
SCULPT_TOOL_POSE,
|
||||
SCULPT_TOOL_ROTATE,
|
||||
SCULPT_TOOL_SCENE_PROJECT,
|
||||
SCULPT_TOOL_SLIDE_RELAX,
|
||||
SCULPT_TOOL_CLOTH,
|
||||
SCULPT_TOOL_ELASTIC_DEFORM,
|
||||
SCULPT_TOOL_FAIRING,
|
||||
SCULPT_TOOL_DRAW_FACE_SETS,
|
||||
SCULPT_TOOL_SMOOTH,
|
||||
SCULPT_TOOL_SIMPLIFY)) {
|
||||
|
||||
SHOWALL(accumulate);
|
||||
}
|
||||
SHOWWRK(direction);
|
||||
|
||||
SHOWWRK(radius_unit);
|
||||
SHOWWRK(use_frontface);
|
||||
|
@ -877,6 +932,11 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
|
|||
SHOWWRK(hardness);
|
||||
|
||||
switch (tool) {
|
||||
case SCULPT_TOOL_SMOOTH:
|
||||
SHOWWRK(surface_smooth_shape_preservation);
|
||||
SHOWWRK(surface_smooth_current_vertex);
|
||||
SHOWWRK(surface_smooth_iterations);
|
||||
break;
|
||||
case SCULPT_TOOL_SCRAPE:
|
||||
case SCULPT_TOOL_FILL:
|
||||
SHOWWRK(plane_offset);
|
||||
|
@ -917,6 +977,26 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
|
|||
SHOWWRK(boundary_deform_type);
|
||||
SHOWWRK(boundary_falloff_type);
|
||||
|
||||
break;
|
||||
case SCULPT_TOOL_CREASE:
|
||||
SHOWWRK(crease_pinch_factor);
|
||||
break;
|
||||
case SCULPT_TOOL_SNAKE_HOOK:
|
||||
SHOWWRK(crease_pinch_factor);
|
||||
SHOWWRK(rake_factor);
|
||||
SHOWWRK(snake_hook_deform_type);
|
||||
break;
|
||||
case SCULPT_TOOL_POSE:
|
||||
SHOWWRK(pose_ik_segments);
|
||||
SHOWWRK(pose_smooth_iterations);
|
||||
SHOWWRK(disconnected_distance_max);
|
||||
SHOWWRK(pose_offset);
|
||||
SHOWWRK(use_connected_only);
|
||||
SHOWWRK(use_pose_ik_anchored);
|
||||
SHOWWRK(use_pose_lock_rotation);
|
||||
SHOWWRK(pose_deform_type);
|
||||
SHOWWRK(pose_origin_type);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -963,9 +1043,12 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
|
|||
break;
|
||||
}
|
||||
case SCULPT_TOOL_DRAW_SHARP:
|
||||
GETCH(spacing)->ivalue = 5;
|
||||
GETCH(radius)->mappings[BRUSH_MAPPING_PRESSURE].flag |= BRUSH_MAPPING_ENABLED;
|
||||
GETCH(strength)->mappings[BRUSH_MAPPING_PRESSURE].flag &= ~BRUSH_MAPPING_ENABLED;
|
||||
BRUSHSET_LOOKUP(chset, spacing)->ivalue = 5;
|
||||
BRUSHSET_SET_INT(chset, direction, 1);
|
||||
BRUSHSET_LOOKUP(chset, radius)->mappings[BRUSH_MAPPING_PRESSURE].flag |=
|
||||
BRUSH_MAPPING_ENABLED;
|
||||
BRUSHSET_LOOKUP(chset, strength)->mappings[BRUSH_MAPPING_PRESSURE].flag &=
|
||||
~BRUSH_MAPPING_ENABLED;
|
||||
break;
|
||||
case SCULPT_TOOL_DISPLACEMENT_ERASER:
|
||||
case SCULPT_TOOL_FAIRING:
|
||||
|
@ -1049,6 +1132,12 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
|
|||
case SCULPT_TOOL_CLOTH:
|
||||
GETCH(radius)->mappings[BRUSH_MAPPING_PRESSURE].flag &= ~BRUSH_MAPPING_ENABLED;
|
||||
GETCH(strength)->mappings[BRUSH_MAPPING_PRESSURE].flag &= ~BRUSH_MAPPING_ENABLED;
|
||||
break;
|
||||
case SCULPT_TOOL_SNAKE_HOOK:
|
||||
GETCH(dyntopo_mode)->ivalue = DYNTOPO_LOCAL_COLLAPSE | DYNTOPO_SUBDIVIDE;
|
||||
GETCH(dyntopo_mode)->flag = BRUSH_CHANNEL_INHERIT_IF_UNSET;
|
||||
GETCH(strength)->fvalue = 1.0f;
|
||||
|
||||
break;
|
||||
default: {
|
||||
// implement me!
|
||||
|
@ -1089,7 +1178,7 @@ void BKE_brush_channelset_check_radius(BrushChannelSet *chset)
|
|||
}
|
||||
|
||||
int mask = BRUSH_CHANNEL_INHERIT | BRUSH_CHANNEL_INHERIT_IF_UNSET |
|
||||
BRUSH_CHANNEL_SHOW_IN_HEADER | BRUSH_CHANNEL_SHOW_IN_WORKSPACE |
|
||||
/*BRUSH_CHANNEL_SHOW_IN_HEADER | BRUSH_CHANNEL_SHOW_IN_WORKSPACE |*/
|
||||
BRUSH_CHANNEL_UI_EXPANDED;
|
||||
|
||||
if (ch2) {
|
||||
|
|
|
@ -5717,8 +5717,10 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
|
|||
|
||||
/* We divide out the squared alpha and multiply by the squared crease
|
||||
* to give us the pinch strength. */
|
||||
crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor * 2.0;
|
||||
brush_alpha = BKE_brush_alpha_get(scene, brush);
|
||||
crease_correction = SCULPT_get_float(ss, crease_pinch_factor, sd, brush);
|
||||
crease_correction = crease_correction * crease_correction * 2.0f;
|
||||
|
||||
brush_alpha = SCULPT_get_float(ss, strength, sd, brush); // BKE_brush_alpha_get(scene, brush);
|
||||
if (brush_alpha > 0.0f) {
|
||||
crease_correction /= brush_alpha * brush_alpha;
|
||||
}
|
||||
|
@ -5743,6 +5745,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
|
|||
.nodes = nodes,
|
||||
.spvc = &spvc,
|
||||
.offset = offset,
|
||||
.crease_pinch_factor = SCULPT_get_float(ss, crease_pinch_factor, sd, brush),
|
||||
.flippedbstrength = flippedbstrength,
|
||||
};
|
||||
|
||||
|
@ -6338,8 +6341,8 @@ static void do_snake_hook_brush_task_cb_ex(void *__restrict userdata,
|
|||
float(*proxy)[3];
|
||||
const float bstrength = ss->cache->bstrength;
|
||||
const bool do_rake_rotation = ss->cache->is_rake_rotation_valid;
|
||||
const bool do_pinch = (brush->crease_pinch_factor != 0.5f);
|
||||
const float pinch = do_pinch ? (2.0f * (0.5f - brush->crease_pinch_factor) *
|
||||
const bool do_pinch = (data->crease_pinch_factor != 0.5f);
|
||||
const float pinch = do_pinch ? (2.0f * (0.5f - data->crease_pinch_factor) *
|
||||
(len_v3(grab_delta) / ss->cache->radius)) :
|
||||
0.0f;
|
||||
|
||||
|
@ -6450,19 +6453,20 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
|
|||
sculpt_project_v3_normal_align(ss, ss->cache->normal_weight, grab_delta);
|
||||
}
|
||||
|
||||
float crease_pinch_factor = SCULPT_get_float(ss, crease_pinch_factor, sd, brush);
|
||||
|
||||
/* Optionally pinch while painting. */
|
||||
if (brush->crease_pinch_factor != 0.5f) {
|
||||
if (crease_pinch_factor != 0.5f) {
|
||||
sculpt_project_v3_cache_init(&spvc, grab_delta);
|
||||
}
|
||||
|
||||
SculptThreadedTaskData data = {
|
||||
.sd = sd,
|
||||
.ob = ob,
|
||||
.brush = brush,
|
||||
.nodes = nodes,
|
||||
.spvc = &spvc,
|
||||
.grab_delta = grab_delta,
|
||||
};
|
||||
SculptThreadedTaskData data = {.sd = sd,
|
||||
.ob = ob,
|
||||
.brush = brush,
|
||||
.nodes = nodes,
|
||||
.spvc = &spvc,
|
||||
.grab_delta = grab_delta,
|
||||
.crease_pinch_factor = crease_pinch_factor};
|
||||
|
||||
TaskParallelSettings settings;
|
||||
BKE_pbvh_parallel_range_settings(&settings, true, totnode);
|
||||
|
|
|
@ -998,6 +998,7 @@ typedef struct SculptThreadedTaskData {
|
|||
float *brush_color;
|
||||
|
||||
float fset_slide, bound_smooth;
|
||||
float crease_pinch_factor;
|
||||
} SculptThreadedTaskData;
|
||||
|
||||
/*************** Brush testing declarations ****************/
|
||||
|
|
|
@ -712,10 +712,6 @@ ATTR_NO_OPT bool RNA_struct_override_matches(Main *bmain,
|
|||
rna_property_rna_or_id_get(rawprop, ptr_local, &prop_local);
|
||||
rna_property_rna_or_id_get(rawprop, ptr_reference, &prop_reference);
|
||||
|
||||
if (STREQ(prop_local.identifier, "channels")) {
|
||||
printf("break\n");
|
||||
}
|
||||
|
||||
BLI_assert(prop_local.rnaprop != NULL);
|
||||
BLI_assert(prop_local.rnaprop == prop_reference.rnaprop);
|
||||
BLI_assert(prop_local.is_idprop == prop_reference.is_idprop);
|
||||
|
@ -793,10 +789,6 @@ ATTR_NO_OPT bool RNA_struct_override_matches(Main *bmain,
|
|||
continue;
|
||||
}
|
||||
|
||||
if (STRPREFIX(rna_path, "channels[\"autosmooth\"].factor_value")) {
|
||||
printf("break\n");
|
||||
}
|
||||
|
||||
CLOG_INFO(&LOG, 5, "Override Checking %s", rna_path);
|
||||
|
||||
IDOverrideLibraryProperty *op = BKE_lib_override_library_property_find(override, rna_path);
|
||||
|
|
|
@ -3184,8 +3184,9 @@ static struct IDFilterEnumPropertyItem rna_enum_space_file_id_filter_categories[
|
|||
ICON_WORLD_DATA,
|
||||
"Environment",
|
||||
"Show worlds, lights, cameras and speakers"},
|
||||
{FILTER_ID_BR | FILTER_ID_GD | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_TXT |
|
||||
FILTER_ID_VF | FILTER_ID_CF | FILTER_ID_WS,
|
||||
{FILTER_ID_BR, "category_brush", ICON_GREASEPENCIL, "Brushes", "Show brushes"},
|
||||
{FILTER_ID_GD | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_TXT | FILTER_ID_VF |
|
||||
FILTER_ID_CF | FILTER_ID_WS,
|
||||
"category_misc",
|
||||
ICON_GREASEPENCIL,
|
||||
"Miscellaneous",
|
||||
|
@ -6510,8 +6511,9 @@ static void rna_def_fileselect_asset_params(BlenderRNA *brna)
|
|||
ICON_WORLD_DATA,
|
||||
"Environment",
|
||||
"Show worlds, lights, cameras and speakers"},
|
||||
{FILTER_ID_BR | FILTER_ID_GD | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_TXT |
|
||||
FILTER_ID_VF | FILTER_ID_CF | FILTER_ID_WS,
|
||||
{FILTER_ID_BR, "BRUSHES", ICON_GREASEPENCIL, "Brushes", "Show brushes"},
|
||||
{FILTER_ID_GD | FILTER_ID_PA | FILTER_ID_PAL | FILTER_ID_PC | FILTER_ID_TXT | FILTER_ID_VF |
|
||||
FILTER_ID_CF | FILTER_ID_WS,
|
||||
"MISC",
|
||||
ICON_GREASEPENCIL,
|
||||
"Miscellaneous",
|
||||
|
|
Loading…
Reference in New Issue