Curves: add warning when invalid uv map is used when adding curves
UV maps that are used for surface attachment must not have overlapping uv islands, because then the same uv coordinate would correspond to multiple surface positions. Ref T99936.
This commit is contained in:
parent
53113a2e57
commit
1c05f30e4d
Notes:
blender-bot
2023-02-14 01:52:41 +01:00
Referenced by issue #99936, Regression: Unable to add curve hair on the left side of the model.
|
@ -231,7 +231,12 @@ struct AddOperationExecutor {
|
|||
add_inputs.old_roots_kdtree = self_->curve_roots_kdtree_;
|
||||
}
|
||||
|
||||
geometry::add_curves_on_mesh(*curves_orig_, add_inputs);
|
||||
const geometry::AddCurvesOnMeshOutputs add_outputs = geometry::add_curves_on_mesh(
|
||||
*curves_orig_, add_inputs);
|
||||
|
||||
if (add_outputs.uv_error) {
|
||||
report_invalid_uv_map(stroke_extension.reports);
|
||||
}
|
||||
|
||||
DEG_id_tag_update(&curves_id_orig_->id, ID_RECALC_GEOMETRY);
|
||||
WM_main_add_notifier(NC_GEOM | ND_DATA, &curves_id_orig_->id);
|
||||
|
|
|
@ -408,4 +408,9 @@ void report_missing_uv_map_on_evaluated_surface(ReportList *reports)
|
|||
reports, RPT_WARNING, TIP_("Missing UV map for attaching curves on evaluated surface"));
|
||||
}
|
||||
|
||||
void report_invalid_uv_map(ReportList *reports)
|
||||
{
|
||||
BKE_report(reports, RPT_WARNING, TIP_("Invalid UV map: UV islands must not overlap"));
|
||||
}
|
||||
|
||||
} // namespace blender::ed::sculpt_paint
|
||||
|
|
|
@ -277,7 +277,12 @@ struct DensityAddOperationExecutor {
|
|||
add_inputs.reverse_uv_sampler = &reverse_uv_sampler;
|
||||
add_inputs.old_roots_kdtree = self_->original_curve_roots_kdtree_;
|
||||
|
||||
geometry::add_curves_on_mesh(*curves_orig_, add_inputs);
|
||||
const geometry::AddCurvesOnMeshOutputs add_outputs = geometry::add_curves_on_mesh(
|
||||
*curves_orig_, add_inputs);
|
||||
|
||||
if (add_outputs.uv_error) {
|
||||
report_invalid_uv_map(stroke_extension.reports);
|
||||
}
|
||||
|
||||
DEG_id_tag_update(&curves_id_orig_->id, ID_RECALC_GEOMETRY);
|
||||
WM_main_add_notifier(NC_GEOM | ND_DATA, &curves_id_orig_->id);
|
||||
|
|
|
@ -131,5 +131,6 @@ float transform_brush_radius(const float4x4 &transform,
|
|||
void report_missing_surface(ReportList *reports);
|
||||
void report_missing_uv_map_on_original_surface(ReportList *reports);
|
||||
void report_missing_uv_map_on_evaluated_surface(ReportList *reports);
|
||||
void report_invalid_uv_map(ReportList *reports);
|
||||
|
||||
} // namespace blender::ed::sculpt_paint
|
||||
|
|
|
@ -40,12 +40,19 @@ struct AddCurvesOnMeshInputs {
|
|||
* interpolation is used.
|
||||
*/
|
||||
KDTree_3d *old_roots_kdtree = nullptr;
|
||||
|
||||
bool r_uv_error = false;
|
||||
};
|
||||
|
||||
struct AddCurvesOnMeshOutputs {
|
||||
bool uv_error = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate new curves on a mesh surface with the given inputs. Existing curves stay intact.
|
||||
*/
|
||||
void add_curves_on_mesh(bke::CurvesGeometry &curves, const AddCurvesOnMeshInputs &inputs);
|
||||
AddCurvesOnMeshOutputs add_curves_on_mesh(bke::CurvesGeometry &curves,
|
||||
const AddCurvesOnMeshInputs &inputs);
|
||||
|
||||
float3 compute_surface_point_normal(const MLoopTri &looptri,
|
||||
const float3 &bary_coord,
|
||||
|
|
|
@ -229,8 +229,11 @@ static void interpolate_position_with_interpolation(CurvesGeometry &curves,
|
|||
});
|
||||
}
|
||||
|
||||
void add_curves_on_mesh(CurvesGeometry &curves, const AddCurvesOnMeshInputs &inputs)
|
||||
AddCurvesOnMeshOutputs add_curves_on_mesh(CurvesGeometry &curves,
|
||||
const AddCurvesOnMeshInputs &inputs)
|
||||
{
|
||||
AddCurvesOnMeshOutputs outputs;
|
||||
|
||||
const bool use_interpolation = inputs.interpolate_length || inputs.interpolate_point_count ||
|
||||
inputs.interpolate_shape;
|
||||
|
||||
|
@ -244,6 +247,7 @@ void add_curves_on_mesh(CurvesGeometry &curves, const AddCurvesOnMeshInputs &inp
|
|||
const float2 &uv = inputs.uvs[i];
|
||||
const ReverseUVSampler::Result result = inputs.reverse_uv_sampler->sample(uv);
|
||||
if (result.type != ReverseUVSampler::ResultType::Ok) {
|
||||
outputs.uv_error = true;
|
||||
continue;
|
||||
}
|
||||
const MLoopTri &looptri = *result.looptri;
|
||||
|
@ -365,6 +369,8 @@ void add_curves_on_mesh(CurvesGeometry &curves, const AddCurvesOnMeshInputs &inp
|
|||
MutableSpan<int8_t> types_span = curves.curve_types_for_write();
|
||||
types_span.drop_front(old_curves_num).fill(CURVE_TYPE_CATMULL_ROM);
|
||||
curves.update_curve_types();
|
||||
|
||||
return outputs;
|
||||
}
|
||||
|
||||
} // namespace blender::geometry
|
||||
|
|
Loading…
Reference in New Issue