Cleanup: Sculpt: Changes for consistency in draw sharp brush
This commit is contained in:
parent
fad8d451ef
commit
7c9b323b56
@ -97,7 +97,7 @@ static void calc_grids(const Sculpt &sd,
|
|||||||
const int grid_verts_num = grids.size() * key.grid_area;
|
const int grid_verts_num = grids.size() * key.grid_area;
|
||||||
|
|
||||||
tls.positions.reinitialize(grid_verts_num);
|
tls.positions.reinitialize(grid_verts_num);
|
||||||
MutableSpan<float3> positions = tls.positions;
|
const MutableSpan<float3> positions = tls.positions;
|
||||||
gather_grids_positions(subdiv_ccg, grids, positions);
|
gather_grids_positions(subdiv_ccg, grids, positions);
|
||||||
|
|
||||||
tls.factors.reinitialize(grid_verts_num);
|
tls.factors.reinitialize(grid_verts_num);
|
||||||
@ -142,7 +142,7 @@ static void calc_bmesh(const Sculpt &sd,
|
|||||||
const Set<BMVert *, 0> &verts = BKE_pbvh_bmesh_node_unique_verts(&node);
|
const Set<BMVert *, 0> &verts = BKE_pbvh_bmesh_node_unique_verts(&node);
|
||||||
|
|
||||||
tls.positions.reinitialize(verts.size());
|
tls.positions.reinitialize(verts.size());
|
||||||
MutableSpan<float3> positions = tls.positions;
|
const MutableSpan<float3> positions = tls.positions;
|
||||||
gather_bmesh_positions(verts, positions);
|
gather_bmesh_positions(verts, positions);
|
||||||
|
|
||||||
tls.factors.reinitialize(verts.size());
|
tls.factors.reinitialize(verts.size());
|
||||||
|
@ -31,20 +31,19 @@ namespace blender::ed::sculpt_paint {
|
|||||||
inline namespace draw_sharp_cc {
|
inline namespace draw_sharp_cc {
|
||||||
|
|
||||||
struct LocalData {
|
struct LocalData {
|
||||||
Vector<float3> positions;
|
|
||||||
Vector<float> factors;
|
Vector<float> factors;
|
||||||
Vector<float> distances;
|
Vector<float> distances;
|
||||||
Vector<float3> translations;
|
Vector<float3> translations;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void calc_faces_sharp(const Sculpt &sd,
|
static void calc_faces(const Sculpt &sd,
|
||||||
const Brush &brush,
|
const Brush &brush,
|
||||||
const float3 &offset,
|
const float3 &offset,
|
||||||
const Span<float3> positions_eval,
|
const Span<float3> positions_eval,
|
||||||
const PBVHNode &node,
|
const PBVHNode &node,
|
||||||
Object &object,
|
Object &object,
|
||||||
LocalData &tls,
|
LocalData &tls,
|
||||||
const MutableSpan<float3> positions_orig)
|
const MutableSpan<float3> positions_orig)
|
||||||
{
|
{
|
||||||
SculptSession &ss = *object.sculpt;
|
SculptSession &ss = *object.sculpt;
|
||||||
const StrokeCache &cache = *ss.cache;
|
const StrokeCache &cache = *ss.cache;
|
||||||
@ -82,12 +81,12 @@ static void calc_faces_sharp(const Sculpt &sd,
|
|||||||
write_translations(sd, object, orig_data.positions, verts, translations, positions_orig);
|
write_translations(sd, object, orig_data.positions, verts, translations, positions_orig);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void calc_grids_sharp(const Sculpt &sd,
|
static void calc_grids(const Sculpt &sd,
|
||||||
Object &object,
|
Object &object,
|
||||||
const Brush &brush,
|
const Brush &brush,
|
||||||
const float3 &offset,
|
const float3 &offset,
|
||||||
const PBVHNode &node,
|
const PBVHNode &node,
|
||||||
LocalData &tls)
|
LocalData &tls)
|
||||||
{
|
{
|
||||||
SculptSession &ss = *object.sculpt;
|
SculptSession &ss = *object.sculpt;
|
||||||
const StrokeCache &cache = *ss.cache;
|
const StrokeCache &cache = *ss.cache;
|
||||||
@ -128,12 +127,12 @@ static void calc_grids_sharp(const Sculpt &sd,
|
|||||||
apply_translations(translations, grids, subdiv_ccg);
|
apply_translations(translations, grids, subdiv_ccg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void calc_bmesh_sharp(const Sculpt &sd,
|
static void calc_bmesh(const Sculpt &sd,
|
||||||
Object &object,
|
Object &object,
|
||||||
const Brush &brush,
|
const Brush &brush,
|
||||||
const float3 &offset,
|
const float3 &offset,
|
||||||
PBVHNode &node,
|
PBVHNode &node,
|
||||||
LocalData &tls)
|
LocalData &tls)
|
||||||
{
|
{
|
||||||
SculptSession &ss = *object.sculpt;
|
SculptSession &ss = *object.sculpt;
|
||||||
const StrokeCache &cache = *ss.cache;
|
const StrokeCache &cache = *ss.cache;
|
||||||
@ -148,7 +147,6 @@ static void calc_bmesh_sharp(const Sculpt &sd,
|
|||||||
const MutableSpan<float> factors = tls.factors;
|
const MutableSpan<float> factors = tls.factors;
|
||||||
fill_factor_from_hide_and_mask(*ss.bm, verts, factors);
|
fill_factor_from_hide_and_mask(*ss.bm, verts, factors);
|
||||||
filter_region_clip_factors(ss, orig_positions, factors);
|
filter_region_clip_factors(ss, orig_positions, factors);
|
||||||
|
|
||||||
if (brush.flag & BRUSH_FRONTFACE) {
|
if (brush.flag & BRUSH_FRONTFACE) {
|
||||||
calc_front_face(cache.view_normal, orig_normals, factors);
|
calc_front_face(cache.view_normal, orig_normals, factors);
|
||||||
}
|
}
|
||||||
@ -194,8 +192,7 @@ static void offset_positions(const Sculpt &sd,
|
|||||||
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
|
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
|
||||||
LocalData &tls = all_tls.local();
|
LocalData &tls = all_tls.local();
|
||||||
for (const int i : range) {
|
for (const int i : range) {
|
||||||
calc_faces_sharp(
|
calc_faces(sd, brush, offset, positions_eval, *nodes[i], object, tls, positions_orig);
|
||||||
sd, brush, offset, positions_eval, *nodes[i], object, tls, positions_orig);
|
|
||||||
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
BKE_pbvh_node_mark_positions_update(nodes[i]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -205,7 +202,7 @@ static void offset_positions(const Sculpt &sd,
|
|||||||
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
|
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
|
||||||
LocalData &tls = all_tls.local();
|
LocalData &tls = all_tls.local();
|
||||||
for (const int i : range) {
|
for (const int i : range) {
|
||||||
calc_grids_sharp(sd, object, brush, offset, *nodes[i], tls);
|
calc_grids(sd, object, brush, offset, *nodes[i], tls);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@ -213,7 +210,7 @@ static void offset_positions(const Sculpt &sd,
|
|||||||
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
|
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
|
||||||
LocalData &tls = all_tls.local();
|
LocalData &tls = all_tls.local();
|
||||||
for (const int i : range) {
|
for (const int i : range) {
|
||||||
calc_bmesh_sharp(sd, object, brush, offset, *nodes[i], tls);
|
calc_bmesh(sd, object, brush, offset, *nodes[i], tls);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user