Cleanup: Sculpt: Use simpler argument for brush utility function
Also make use of local "cache" variable consistent.
This commit is contained in:
@@ -46,7 +46,7 @@ static void calc_faces(const Sculpt &sd,
|
||||
const MutableSpan<float3> positions_orig)
|
||||
{
|
||||
SculptSession &ss = *object.sculpt;
|
||||
StrokeCache &cache = *ss.cache;
|
||||
const StrokeCache &cache = *ss.cache;
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
|
||||
const Span<int> verts = bke::pbvh::node_unique_verts(node);
|
||||
@@ -63,10 +63,10 @@ static void calc_faces(const Sculpt &sd,
|
||||
const MutableSpan<float> distances = tls.distances;
|
||||
calc_distance_falloff(
|
||||
ss, positions_eval, verts, eBrushFalloffShape(brush.falloff_shape), distances, factors);
|
||||
calc_brush_strength_factors(ss, brush, distances, factors);
|
||||
calc_brush_strength_factors(cache, brush, distances, factors);
|
||||
|
||||
if (ss.cache->automasking) {
|
||||
auto_mask::calc_vert_factors(object, *ss.cache->automasking, node, verts, factors);
|
||||
if (cache.automasking) {
|
||||
auto_mask::calc_vert_factors(object, *cache.automasking, node, verts, factors);
|
||||
}
|
||||
|
||||
calc_brush_texture_factors(ss, brush, positions_eval, verts, factors);
|
||||
|
||||
@@ -67,7 +67,7 @@ static void calc_faces(const Sculpt &sd,
|
||||
MutableSpan<float3> positions_orig)
|
||||
{
|
||||
SculptSession &ss = *object.sculpt;
|
||||
StrokeCache &cache = *ss.cache;
|
||||
const StrokeCache &cache = *ss.cache;
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
|
||||
const Span<int> verts = bke::pbvh::node_unique_verts(node);
|
||||
@@ -84,10 +84,10 @@ static void calc_faces(const Sculpt &sd,
|
||||
const MutableSpan<float> distances = tls.distances;
|
||||
calc_distance_falloff(
|
||||
ss, positions_eval, verts, eBrushFalloffShape(brush.falloff_shape), distances, factors);
|
||||
calc_brush_strength_factors(ss, brush, distances, factors);
|
||||
calc_brush_strength_factors(cache, brush, distances, factors);
|
||||
|
||||
if (ss.cache->automasking) {
|
||||
auto_mask::calc_vert_factors(object, *ss.cache->automasking, node, verts, factors);
|
||||
if (cache.automasking) {
|
||||
auto_mask::calc_vert_factors(object, *cache.automasking, node, verts, factors);
|
||||
}
|
||||
|
||||
tls.colors.reinitialize(verts.size());
|
||||
|
||||
@@ -48,7 +48,7 @@ static void calc_faces(const Sculpt &sd,
|
||||
const MutableSpan<float3> positions_orig)
|
||||
{
|
||||
SculptSession &ss = *object.sculpt;
|
||||
StrokeCache &cache = *ss.cache;
|
||||
const StrokeCache &cache = *ss.cache;
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
|
||||
const Span<int> verts = bke::pbvh::node_unique_verts(node);
|
||||
@@ -65,10 +65,10 @@ static void calc_faces(const Sculpt &sd,
|
||||
const MutableSpan<float> distances = tls.distances;
|
||||
calc_distance_falloff(
|
||||
ss, positions_eval, verts, eBrushFalloffShape(brush.falloff_shape), distances, factors);
|
||||
calc_brush_strength_factors(ss, brush, distances, factors);
|
||||
calc_brush_strength_factors(cache, brush, distances, factors);
|
||||
|
||||
if (ss.cache->automasking) {
|
||||
auto_mask::calc_vert_factors(object, *ss.cache->automasking, node, verts, factors);
|
||||
if (cache.automasking) {
|
||||
auto_mask::calc_vert_factors(object, *cache.automasking, node, verts, factors);
|
||||
}
|
||||
|
||||
calc_brush_texture_factors(ss, brush, positions_eval, verts, factors);
|
||||
@@ -80,7 +80,7 @@ static void calc_faces(const Sculpt &sd,
|
||||
tls.translations.reinitialize(verts.size());
|
||||
const MutableSpan<float3> translations = tls.translations;
|
||||
calc_translations_to_plane(positions_eval, verts, plane, translations);
|
||||
filter_plane_trim_limit_factors(brush, *ss.cache, translations, factors);
|
||||
filter_plane_trim_limit_factors(brush, cache, translations, factors);
|
||||
scale_translations(translations, factors);
|
||||
|
||||
clip_and_lock_translations(sd, ss, positions_eval, verts, translations);
|
||||
|
||||
@@ -47,7 +47,7 @@ static void calc_faces(const Sculpt &sd,
|
||||
const MutableSpan<float3> positions_orig)
|
||||
{
|
||||
SculptSession &ss = *object.sculpt;
|
||||
StrokeCache &cache = *ss.cache;
|
||||
const StrokeCache &cache = *ss.cache;
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
|
||||
const Span<int> verts = bke::pbvh::node_unique_verts(node);
|
||||
@@ -64,10 +64,10 @@ static void calc_faces(const Sculpt &sd,
|
||||
const MutableSpan<float> distances = tls.distances;
|
||||
calc_distance_falloff(
|
||||
ss, positions_eval, verts, eBrushFalloffShape(brush.falloff_shape), distances, factors);
|
||||
calc_brush_strength_factors(ss, brush, distances, factors);
|
||||
calc_brush_strength_factors(cache, brush, distances, factors);
|
||||
|
||||
if (ss.cache->automasking) {
|
||||
auto_mask::calc_vert_factors(object, *ss.cache->automasking, node, verts, factors);
|
||||
if (cache.automasking) {
|
||||
auto_mask::calc_vert_factors(object, *cache.automasking, node, verts, factors);
|
||||
}
|
||||
|
||||
calc_brush_texture_factors(ss, brush, positions_eval, verts, factors);
|
||||
@@ -77,7 +77,7 @@ static void calc_faces(const Sculpt &sd,
|
||||
tls.translations.reinitialize(verts.size());
|
||||
const MutableSpan<float3> translations = tls.translations;
|
||||
calc_translations_to_plane(positions_eval, verts, plane, translations);
|
||||
filter_plane_trim_limit_factors(brush, *ss.cache, translations, factors);
|
||||
filter_plane_trim_limit_factors(brush, cache, translations, factors);
|
||||
scale_translations(translations, factors);
|
||||
|
||||
clip_and_lock_translations(sd, ss, positions_eval, verts, translations);
|
||||
|
||||
@@ -54,7 +54,7 @@ static void calc_faces(const Sculpt &sd,
|
||||
const MutableSpan<float3> positions_orig)
|
||||
{
|
||||
SculptSession &ss = *object.sculpt;
|
||||
StrokeCache &cache = *ss.cache;
|
||||
const StrokeCache &cache = *ss.cache;
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
|
||||
const Span<int> verts = bke::pbvh::node_unique_verts(node);
|
||||
@@ -71,10 +71,10 @@ static void calc_faces(const Sculpt &sd,
|
||||
const MutableSpan<float> distances = tls.distances;
|
||||
calc_distance_falloff(
|
||||
ss, positions_eval, verts, eBrushFalloffShape(brush.falloff_shape), distances, factors);
|
||||
calc_brush_strength_factors(ss, brush, distances, factors);
|
||||
calc_brush_strength_factors(cache, brush, distances, factors);
|
||||
|
||||
if (ss.cache->automasking) {
|
||||
auto_mask::calc_vert_factors(object, *ss.cache->automasking, node, verts, factors);
|
||||
if (cache.automasking) {
|
||||
auto_mask::calc_vert_factors(object, *cache.automasking, node, verts, factors);
|
||||
}
|
||||
|
||||
calc_brush_texture_factors(ss, brush, positions_eval, verts, factors);
|
||||
|
||||
@@ -69,7 +69,7 @@ static void calc_faces(const Brush &brush,
|
||||
const MutableSpan<float> mask)
|
||||
{
|
||||
SculptSession &ss = *object.sculpt;
|
||||
StrokeCache &cache = *ss.cache;
|
||||
const StrokeCache &cache = *ss.cache;
|
||||
|
||||
const Span<int> verts = bke::pbvh::node_unique_verts(node);
|
||||
|
||||
@@ -85,10 +85,10 @@ static void calc_faces(const Brush &brush,
|
||||
const MutableSpan<float> distances = tls.distances;
|
||||
calc_distance_falloff(
|
||||
ss, positions, verts, eBrushFalloffShape(brush.falloff_shape), distances, factors);
|
||||
calc_brush_strength_factors(ss, brush, distances, factors);
|
||||
calc_brush_strength_factors(cache, brush, distances, factors);
|
||||
|
||||
if (ss.cache->automasking) {
|
||||
auto_mask::calc_vert_factors(object, *ss.cache->automasking, node, verts, factors);
|
||||
if (cache.automasking) {
|
||||
auto_mask::calc_vert_factors(object, *cache.automasking, node, verts, factors);
|
||||
}
|
||||
|
||||
calc_brush_texture_factors(ss, brush, positions, verts, factors);
|
||||
|
||||
@@ -48,7 +48,7 @@ static void calc_faces(const Sculpt &sd,
|
||||
const MutableSpan<float3> positions_orig)
|
||||
{
|
||||
SculptSession &ss = *object.sculpt;
|
||||
StrokeCache &cache = *ss.cache;
|
||||
const StrokeCache &cache = *ss.cache;
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
|
||||
const Span<int> verts = bke::pbvh::node_unique_verts(node);
|
||||
@@ -65,10 +65,10 @@ static void calc_faces(const Sculpt &sd,
|
||||
const MutableSpan<float> distances = tls.distances;
|
||||
calc_distance_falloff(
|
||||
ss, positions_eval, verts, eBrushFalloffShape(brush.falloff_shape), distances, factors);
|
||||
calc_brush_strength_factors(ss, brush, distances, factors);
|
||||
calc_brush_strength_factors(cache, brush, distances, factors);
|
||||
|
||||
if (ss.cache->automasking) {
|
||||
auto_mask::calc_vert_factors(object, *ss.cache->automasking, node, verts, factors);
|
||||
if (cache.automasking) {
|
||||
auto_mask::calc_vert_factors(object, *cache.automasking, node, verts, factors);
|
||||
}
|
||||
|
||||
calc_brush_texture_factors(ss, brush, positions_eval, verts, factors);
|
||||
@@ -80,7 +80,7 @@ static void calc_faces(const Sculpt &sd,
|
||||
tls.translations.reinitialize(verts.size());
|
||||
const MutableSpan<float3> translations = tls.translations;
|
||||
calc_translations_to_plane(positions_eval, verts, plane, translations);
|
||||
filter_plane_trim_limit_factors(brush, *ss.cache, translations, factors);
|
||||
filter_plane_trim_limit_factors(brush, cache, translations, factors);
|
||||
scale_translations(translations, factors);
|
||||
|
||||
clip_and_lock_translations(sd, ss, positions_eval, verts, translations);
|
||||
|
||||
@@ -130,10 +130,10 @@ BLI_NOINLINE static void apply_positions_faces(const Sculpt &sd,
|
||||
const MutableSpan<float> distances = tls.distances;
|
||||
calc_distance_falloff(
|
||||
ss, positions_eval, verts, eBrushFalloffShape(brush.falloff_shape), distances, factors);
|
||||
calc_brush_strength_factors(ss, brush, distances, factors);
|
||||
calc_brush_strength_factors(cache, brush, distances, factors);
|
||||
|
||||
if (ss.cache->automasking) {
|
||||
auto_mask::calc_vert_factors(object, *ss.cache->automasking, node, verts, factors);
|
||||
if (cache.automasking) {
|
||||
auto_mask::calc_vert_factors(object, *cache.automasking, node, verts, factors);
|
||||
}
|
||||
|
||||
scale_factors(factors, strength);
|
||||
|
||||
@@ -86,7 +86,7 @@ void calc_distance_falloff(SculptSession &ss,
|
||||
/**
|
||||
* Modify the factors based on distances to the brush cursor, using various brush settings.
|
||||
*/
|
||||
void calc_brush_strength_factors(const SculptSession &ss,
|
||||
void calc_brush_strength_factors(const StrokeCache &cache,
|
||||
const Brush &brush,
|
||||
Span<float> distances,
|
||||
MutableSpan<float> factors);
|
||||
|
||||
@@ -2602,9 +2602,9 @@ static float brush_strength(const Sculpt &sd,
|
||||
}
|
||||
}
|
||||
|
||||
static float sculpt_apply_hardness(const SculptSession &ss, const float input_len)
|
||||
static float sculpt_apply_hardness(const blender::ed::sculpt_paint::StrokeCache &cache,
|
||||
const float input_len)
|
||||
{
|
||||
const blender::ed::sculpt_paint::StrokeCache &cache = *ss.cache;
|
||||
float final_len = input_len;
|
||||
const float hardness = cache.paint_brush.hardness;
|
||||
float p = input_len / cache.radius;
|
||||
@@ -2709,7 +2709,7 @@ float SCULPT_brush_strength_factor(
|
||||
sculpt_apply_texture(ss, brush, brush_point, thread_id, &avg, rgba);
|
||||
|
||||
/* Hardness. */
|
||||
const float final_len = sculpt_apply_hardness(ss, len);
|
||||
const float final_len = sculpt_apply_hardness(*cache, len);
|
||||
|
||||
/* Falloff curve. */
|
||||
avg *= BKE_brush_curve_strength(&brush, final_len, cache->radius);
|
||||
@@ -2744,7 +2744,7 @@ void SCULPT_brush_strength_color(
|
||||
sculpt_apply_texture(ss, brush, brush_point, thread_id, &avg, r_rgba);
|
||||
|
||||
/* Hardness. */
|
||||
const float final_len = sculpt_apply_hardness(ss, len);
|
||||
const float final_len = sculpt_apply_hardness(*cache, len);
|
||||
|
||||
/* Falloff curve. */
|
||||
const float falloff = BKE_brush_curve_strength(&brush, final_len, cache->radius) *
|
||||
@@ -6592,15 +6592,13 @@ void calc_distance_falloff(SculptSession &ss,
|
||||
}
|
||||
}
|
||||
|
||||
void calc_brush_strength_factors(const SculptSession &ss,
|
||||
void calc_brush_strength_factors(const StrokeCache &cache,
|
||||
const Brush &brush,
|
||||
const Span<float> distances,
|
||||
const MutableSpan<float> factors)
|
||||
{
|
||||
BLI_assert(factors.size() == distances.size());
|
||||
|
||||
const StrokeCache &cache = *ss.cache;
|
||||
|
||||
for (const int i : factors.index_range()) {
|
||||
if (factors[i] == 0.0f) {
|
||||
/* Skip already masked-out points, as they might be outside of the brush radius and be
|
||||
@@ -6609,7 +6607,7 @@ void calc_brush_strength_factors(const SculptSession &ss,
|
||||
continue;
|
||||
}
|
||||
|
||||
const float hardness = sculpt_apply_hardness(ss, distances[i]);
|
||||
const float hardness = sculpt_apply_hardness(cache, distances[i]);
|
||||
const float strength = BKE_brush_curve_strength(&brush, hardness, cache.radius);
|
||||
|
||||
factors[i] *= strength;
|
||||
|
||||
Reference in New Issue
Block a user