diff options
author | Jacques Lucke <jacques@blender.org> | 2022-07-28 12:37:35 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-07-28 12:37:35 +0300 |
commit | aa7d13034701b6e4e9eada24cb96a7ec78171a0a (patch) | |
tree | 314b98801ba342d2d012a24c09c5711eaf885b2c /source | |
parent | 397731d4df44197cf9cf359d9da38156ad86904e (diff) |
Curves: improve handling of empty surface meshes
Diffstat (limited to 'source')
5 files changed, 36 insertions, 0 deletions
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc index 6c693376ad3..f6539284f74 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc @@ -126,12 +126,20 @@ struct AddOperationExecutor { Object &surface_ob_orig = *curves_id_orig_->surface; Mesh &surface_orig = *static_cast<Mesh *>(surface_ob_orig.data); + if (surface_orig.totpoly == 0) { + report_empty_original_surface(stroke_extension.reports); + return; + } surface_ob_eval_ = DEG_get_evaluated_object(ctx_.depsgraph, &surface_ob_orig); if (surface_ob_eval_ == nullptr) { return; } surface_eval_ = BKE_object_get_evaluated_mesh(surface_ob_eval_); + if (surface_eval_->totpoly == 0) { + report_empty_evaluated_surface(stroke_extension.reports); + return; + } curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt; brush_ = BKE_paint_brush_for_read(&curves_sculpt_->paint); diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc index a180a232189..95261f29914 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_brush.cc @@ -391,6 +391,16 @@ CurvesSculptCommonContext::CurvesSculptCommonContext(const bContext &C) this->rv3d = CTX_wm_region_view3d(&C); } +void report_empty_original_surface(ReportList *reports) +{ + BKE_report(reports, RPT_WARNING, TIP_("Original surface mesh is empty")); +} + +void report_empty_evaluated_surface(ReportList *reports) +{ + BKE_report(reports, RPT_WARNING, TIP_("Evaluated surface mesh is empty")); +} + void report_missing_surface(ReportList *reports) { BKE_report(reports, RPT_WARNING, TIP_("Missing surface mesh")); diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_density.cc b/source/blender/editors/sculpt_paint/curves_sculpt_density.cc index e1ac941eb2b..2e03e907e34 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_density.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_density.cc @@ -115,12 +115,20 @@ struct DensityAddOperationExecutor { surface_ob_orig_ = curves_id_orig_->surface; surface_orig_ = static_cast<Mesh *>(surface_ob_orig_->data); + if (surface_orig_->totpoly == 0) { + report_empty_original_surface(stroke_extension.reports); + return; + } surface_ob_eval_ = DEG_get_evaluated_object(ctx_.depsgraph, surface_ob_orig_); if (surface_ob_eval_ == nullptr) { return; } surface_eval_ = BKE_object_get_evaluated_mesh(surface_ob_eval_); + if (surface_eval_->totpoly == 0) { + report_empty_evaluated_surface(stroke_extension.reports); + return; + } BKE_bvhtree_from_mesh_get(&surface_bvh_eval_, surface_eval_, BVHTREE_FROM_LOOPTRI, 2); BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_eval_); }); diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_intern.hh b/source/blender/editors/sculpt_paint/curves_sculpt_intern.hh index 7d40ed80a65..5c8c0cedc6f 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_intern.hh +++ b/source/blender/editors/sculpt_paint/curves_sculpt_intern.hh @@ -128,6 +128,8 @@ float transform_brush_radius(const float4x4 &transform, const float3 &brush_position, const float old_radius); +void report_empty_original_surface(ReportList *reports); +void report_empty_evaluated_surface(ReportList *reports); 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); diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc b/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc index 443fbcb883c..ebdff8a6c4b 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_slide.cc @@ -166,6 +166,10 @@ struct SlideOperationExecutor { surface_ob_orig_ = curves_id_orig_->surface; surface_orig_ = static_cast<Mesh *>(surface_ob_orig_->data); + if (surface_orig_->totpoly == 0) { + report_empty_original_surface(stroke_extension.reports); + return; + } surface_looptris_orig_ = {BKE_mesh_runtime_looptri_ensure(surface_orig_), BKE_mesh_runtime_looptri_len(surface_orig_)}; surface_uv_map_orig_ = @@ -189,6 +193,10 @@ struct SlideOperationExecutor { if (surface_eval_ == nullptr) { return; } + if (surface_eval_->totpoly == 0) { + report_empty_evaluated_surface(stroke_extension.reports); + return; + } surface_looptris_eval_ = {BKE_mesh_runtime_looptri_ensure(surface_eval_), BKE_mesh_runtime_looptri_len(surface_eval_)}; surface_uv_map_eval_ = |