Curves: initial surface collision for curves sculpt mode #104469

Merged
Jacques Lucke merged 29 commits from JacquesLucke/blender:temp-curves-surface-collision into main 2023-02-11 13:46:39 +01:00
3 changed files with 23 additions and 19 deletions
Showing only changes of commit c58b362a6b - Show all commits

View File

@ -71,7 +71,7 @@ struct ConstraintSolver {
use_surface_collision_ = use_surface_collision;
segment_lengths_.reinitialize(curves.points_num());
geometry::curve_constraint_solver::compute_segment_lengths(
curves, curve_selection, segment_lengths_);
curves.points_by_curve(), curves.positions(), curve_selection, segment_lengths_);
if (use_surface_collision_) {
start_positions_ = curves.positions();
}
@ -84,7 +84,7 @@ struct ConstraintSolver {
{
if (use_surface_collision_) {
geometry::curve_constraint_solver::solve_length_and_collision_constraints(
curves,
curves.points_by_curve(),
curve_selection,
segment_lengths_,
start_positions_,
@ -94,8 +94,10 @@ struct ConstraintSolver {
start_positions_ = curves.positions();
}
else {
geometry::curve_constraint_solver::solve_length_constraints(
curves, curve_selection, segment_lengths_, curves.positions_for_write());
geometry::curve_constraint_solver::solve_length_constraints(curves.points_by_curve(),
curve_selection,
segment_lengths_,
curves.positions_for_write());
}
curves.tag_positions_changed();
}

View File

@ -6,16 +6,17 @@
namespace blender::geometry::curve_constraint_solver {
JacquesLucke marked this conversation as resolved
Review

Suggestion: curve_constraint_solver -> curve_constraint(s)

I'm guessing the current name is left over from when it was more object oriented

Suggestion: `curve_constraint_solver` -> `curve_constraint(s)` I'm guessing the current name is left over from when it was more object oriented
void compute_segment_lengths(const bke::CurvesGeometry &curves,
void compute_segment_lengths(OffsetIndices<int> points_by_curve,
Span<float3> positions,
IndexMask curve_selection,
MutableSpan<float> r_segment_lengths);
void solve_length_constraints(const bke::CurvesGeometry &curves,
void solve_length_constraints(OffsetIndices<int> points_by_curve,
IndexMask curve_selection,
Span<float> segment_lenghts,
MutableSpan<float3> positions);
void solve_length_and_collision_constraints(const bke::CurvesGeometry &curves,
void solve_length_and_collision_constraints(OffsetIndices<int> points_by_curve,
IndexMask curve_selection,
Span<float> segment_lengths,
Span<float3> start_positions,
@ -23,6 +24,4 @@ void solve_length_and_collision_constraints(const bke::CurvesGeometry &curves,
const bke::CurvesSurfaceTransforms &transforms,
MutableSpan<float3> positions);
} // namespace blender::geometry::curve_constraint_solver

View File

@ -4,14 +4,13 @@
namespace blender::geometry::curve_constraint_solver {
void compute_segment_lengths(const bke::CurvesGeometry &curves,
void compute_segment_lengths(const OffsetIndices<int> points_by_curve,
const Span<float3> positions,
const IndexMask curve_selection,
JacquesLucke marked this conversation as resolved
Review

Should probably have the note about the coordinate spaces in this file too

Should probably have the note about the coordinate spaces in this file too
MutableSpan<float> r_segment_lengths)
{
BLI_assert(r_segment_lengths.size() == curves.points_num());
BLI_assert(r_segment_lengths.size() == points_by_curve.total_size());
const Span<float3> positions = curves.positions();
const OffsetIndices points_by_curve = curves.points_by_curve();
threading::parallel_for(curve_selection.index_range(), 256, [&](const IndexRange range) {
for (const int curve_i : curve_selection.slice(range)) {
const IndexRange points = points_by_curve[curve_i].drop_back(1);
@ -25,14 +24,13 @@ void compute_segment_lengths(const bke::CurvesGeometry &curves,
});
}
void solve_length_constraints(const bke::CurvesGeometry &curves,
void solve_length_constraints(const OffsetIndices<int> points_by_curve,
const IndexMask curve_selection,
const Span<float> segment_lenghts,
MutableSpan<float3> positions)
{
BLI_assert(segment_lenghts.size() == curves.points_num());
BLI_assert(segment_lenghts.size() == points_by_curve.total_size());
const OffsetIndices points_by_curve = curves.points_by_curve();
threading::parallel_for(curve_selection.index_range(), 256, [&](const IndexRange range) {
for (const int curve_i : curve_selection.slice(range)) {
const IndexRange points = points_by_curve[curve_i].drop_back(1);
@ -47,7 +45,7 @@ void solve_length_constraints(const bke::CurvesGeometry &curves,
});
}
void solve_length_and_collision_constraints(const bke::CurvesGeometry &curves,
void solve_length_and_collision_constraints(const OffsetIndices<int> points_by_curve,
const IndexMask curve_selection,
const Span<float> segment_lengths,
const Span<float3> start_positions,
@ -55,8 +53,13 @@ void solve_length_and_collision_constraints(const bke::CurvesGeometry &curves,
const bke::CurvesSurfaceTransforms &transforms,
MutableSpan<float3> positions)
{
UNUSED_VARS(
curves, curve_selection, segment_lengths, start_positions, surface, transforms, positions);
UNUSED_VARS(points_by_curve,
curve_selection,
segment_lengths,
start_positions,
surface,
transforms,
positions);
}
} // namespace blender::geometry::curve_constraint_solver