Sculpt-dev: fix brush test api bug

* Fixed two missing break statements.
  Amazing what a cascade of bugs this
  produced.
* Fixed small bug in BKE_brush_curve_strength_ex.
* The radius scale fix for original normal mode
  now applies to all sculpt brushes, not just
  the draw brush.
This commit is contained in:
Joseph Eagar 2022-05-22 02:47:11 -07:00
parent 3210924485
commit 4b41114f67
6 changed files with 16 additions and 15 deletions

View File

@ -357,7 +357,7 @@ void BKE_pbvh_update_sculpt_verts(PBVH *pbvh);
/** update original data, only data whose r_** parameters are passed in will be updated*/
bool BKE_pbvh_get_origvert(
PBVH *pbvh, SculptVertRef vertex, float **r_co, float **r_no, float **r_color);
PBVH *pbvh, SculptVertRef vertex, const float **r_co, float **r_no, float **r_color);
/**
checks if original data needs to be updated for v, and if so updates it. Stroke_id

View File

@ -2816,13 +2816,13 @@ void BKE_brush_randomize_texture_coords(UnifiedPaintSettings *ups, bool mask)
}
}
ATTR_NO_OPT float BKE_brush_curve_strength_ex(
float BKE_brush_curve_strength_ex(
int curve_preset, const CurveMapping *curve, float p, const float len, const bool invert)
{
float strength = 1.0f;
if (p >= len) {
return 0;
return invert ? 0.0f : 1.0f;
}
p = p / len;
@ -2876,12 +2876,8 @@ float BKE_brush_curve_strength(const Brush *br, float p, const float len)
return 0.0f;
}
/* Invert p to match behavior of master. */
if (br->curve_preset == BRUSH_CURVE_CUSTOM) {
p = len - p;
}
return BKE_brush_curve_strength_ex(br->curve_preset, br->curve, p, len, true);
return BKE_brush_curve_strength_ex(
br->curve_preset, br->curve, p, len, br->curve_preset != BRUSH_CURVE_CUSTOM);
}
float BKE_brush_curve_strength_clamped(const Brush *br, float p, const float len)

View File

@ -2642,6 +2642,8 @@ static void init_mdyntopo_layer_faces(SculptSession *ss, PBVH *pbvh, int totvert
SculptVertRef vertex = {.i = i};
copy_v3_v3(mv->origco, ss->mvert[i].co);
BKE_pbvh_update_vert_boundary_faces(ss->face_sets,
ss->mvert,
ss->medge,

View File

@ -5278,7 +5278,7 @@ void BKE_pbvh_ensure_node_loops(PBVH *pbvh)
}
bool BKE_pbvh_get_origvert(
PBVH *pbvh, SculptVertRef vertex, float **r_co, float **r_no, float **r_color)
PBVH *pbvh, SculptVertRef vertex, const float **r_co, float **r_no, float **r_color)
{
MSculptVert *mv;

View File

@ -1379,7 +1379,7 @@ static void version_liboverride_rnacollections_insertion_animdata(ID *id)
}
/* NOLINTNEXTLINE: readability-function-size */
ATTR_NO_OPT void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
{
/* The #SCE_SNAP_SEQ flag has been removed in favor of the #SCE_SNAP which can be used for each
* snap_flag member individually. */

View File

@ -3262,7 +3262,7 @@ SculptBrushTestFn SCULPT_brush_test_init_ex(const SculptSession *ss,
switch (falloff_mode) {
case PAINT_FALLOFF_SHAPE_SPHERE:
sculpt_brush_test_sq_fn = SCULPT_brush_test_cube_sq;
break;
case PAINT_FALLOFF_SHAPE_TUBE:
if (ss->cache) {
plane_from_point_normal_v3(test->plane_view, test->location, ss->cache->view_normal);
@ -3281,7 +3281,7 @@ SculptBrushTestFn SCULPT_brush_test_init_ex(const SculptSession *ss,
switch (falloff_mode) {
case PAINT_FALLOFF_SHAPE_SPHERE:
sculpt_brush_test_sq_fn = SCULPT_brush_test_sphere_sq;
break;
case PAINT_FALLOFF_SHAPE_TUBE:
if (ss->cache) {
plane_from_point_normal_v3(test->plane_view, test->location, ss->cache->view_normal);
@ -5332,6 +5332,7 @@ static void get_nodes_undo(Sculpt *sd,
BrushCommand *cmd = data->cmd;
SculptSession *ss = ob->sculpt;
float start_radius = ss->cache->radius;
float radius_scale = 1.0f;
const bool use_original = sculpt_tool_needs_original(cmd->tool) ? true : ss->cache->original;
@ -5350,7 +5351,7 @@ static void get_nodes_undo(Sculpt *sd,
else {
/* With these options enabled not all required nodes are inside the original brush radius,
* so the brush can produce artifacts in some situations. */
if (tool == SCULPT_TOOL_DRAW && brush->flag & BRUSH_ORIGINAL_NORMAL) {
if (brush->flag & BRUSH_ORIGINAL_NORMAL) {
radius_scale = MAX2(radius_scale, 2.0f);
}
nodes = sculpt_pbvh_gather_generic(ob, sd, brush, use_original, radius_scale, &totnode);
@ -5965,6 +5966,7 @@ static void SCULPT_run_commandlist(Sculpt *sd,
do_symmetrical_brush_actions(sd, ob, SCULPT_run_command, ups, paint_mode_settings, &data);
sculpt_combine_proxies(sd, ob);
BKE_pbvh_update_bounds(ss->pbvh, PBVH_UpdateOriginalBB | PBVH_UpdateBB);
}
/*
@ -6965,6 +6967,7 @@ static void sculpt_update_cache_invariants(
if (SCULPT_TOOL_HAS_ACCUMULATE(SCULPT_get_tool(ss, brush))) {
if (!(BRUSHSET_GET_INT(channels, accumulate, &ss->cache->input_mapping))) {
cache->original = true;
if (SCULPT_get_tool(ss, brush) == SCULPT_TOOL_DRAW_SHARP) {
cache->original = false;
}
@ -7902,7 +7905,7 @@ bool SCULPT_stroke_get_location(bContext *C, float out[3], const float mouse[2])
ss = ob->sculpt;
cache = ss->cache;
original = (cache) ? cache->original : false;
original = cache ? cache->original : false;
const Brush *brush = BKE_paint_brush(BKE_paint_get_active_from_context(C));