Fix #105089: Curves sculpt add creates invalid resolution #105094

Merged
Hans Goudey merged 2 commits from HooglyBoogly/blender:fix-curves-sculpt-add-resolution into blender-v3.5-release 2023-02-23 13:46:51 +01:00
4 changed files with 22 additions and 3 deletions

View File

@ -225,6 +225,7 @@ struct AddOperationExecutor {
BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_SHAPE;
add_inputs.interpolate_point_count = brush_settings_->flag &
BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_POINT_COUNT;
add_inputs.interpolate_resolution = curves_orig_->attributes().contains("resolution");
add_inputs.fallback_curve_length = brush_settings_->curve_length;
add_inputs.fallback_point_count = std::max(2, brush_settings_->points_per_curve);
add_inputs.transforms = &transforms_;
@ -234,7 +235,7 @@ struct AddOperationExecutor {
add_inputs.corner_normals_su = corner_normals_su;
if (add_inputs.interpolate_length || add_inputs.interpolate_shape ||
add_inputs.interpolate_point_count) {
add_inputs.interpolate_point_count || add_inputs.interpolate_resolution) {
this->ensure_curve_roots_kdtree();
add_inputs.old_roots_kdtree = self_->curve_roots_kdtree_;
}

View File

@ -275,6 +275,7 @@ struct DensityAddOperationExecutor {
BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_SHAPE;
add_inputs.interpolate_point_count = brush_settings_->flag &
BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_POINT_COUNT;
add_inputs.interpolate_resolution = curves_orig_->attributes().contains("resolution");
add_inputs.fallback_curve_length = brush_settings_->curve_length;
add_inputs.fallback_point_count = std::max(2, brush_settings_->points_per_curve);
add_inputs.transforms = &transforms_;

View File

@ -25,6 +25,7 @@ struct AddCurvesOnMeshInputs {
bool interpolate_length = false;
bool interpolate_shape = false;
bool interpolate_point_count = false;
bool interpolate_resolution = false;
float fallback_curve_length = 0.0f;
int fallback_point_count = 0;

View File

@ -243,7 +243,7 @@ AddCurvesOnMeshOutputs add_curves_on_mesh(CurvesGeometry &curves,
AddCurvesOnMeshOutputs outputs;
const bool use_interpolation = inputs.interpolate_length || inputs.interpolate_point_count ||
inputs.interpolate_shape;
inputs.interpolate_shape || inputs.interpolate_resolution;
Vector<float3> root_positions_cu;
Vector<float3> bary_coords;
@ -380,8 +380,24 @@ AddCurvesOnMeshOutputs add_curves_on_mesh(CurvesGeometry &curves,
bke::MutableAttributeAccessor attributes = curves.attributes_for_write();
if (bke::SpanAttributeWriter<int> resolution = attributes.lookup_for_write_span<int>(
"resolution")) {
HooglyBoogly marked this conversation as resolved
Review

typo

typo
if (inputs.interpolate_resolution) {
interpolate_from_neighbors(
neighbors_per_curve,
12,
[&](const int curve_i) { return resolution.span[curve_i]; },
resolution.span.take_back(added_curves_num));
resolution.finish();
}
else {
resolution.span.take_back(added_curves_num).fill(12);
}
}
/* Explicitly set all other attributes besides those processed above to default values. */
Set<std::string> attributes_to_skip{{"position", "curve_type", "surface_uv_coordinate"}};
Set<std::string> attributes_to_skip{
{"position", "curve_type", "surface_uv_coordinate", "resolution"}};
attributes.for_all(
[&](const bke::AttributeIDRef &id, const bke::AttributeMetaData /*meta_data*/) {
if (attributes_to_skip.contains(id.name())) {