Curves: show warning when using Add brush without surface
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_mesh_runtime.h"
|
||||
#include "BKE_paint.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_spline.hh"
|
||||
|
||||
#include "DNA_brush_enums.h"
|
||||
@@ -836,8 +837,16 @@ void AddOperation::on_stroke_extended(bContext *C, const StrokeExtension &stroke
|
||||
executor.execute(*this, C, stroke_extension);
|
||||
}
|
||||
|
||||
std::unique_ptr<CurvesSculptStrokeOperation> new_add_operation()
|
||||
std::unique_ptr<CurvesSculptStrokeOperation> new_add_operation(bContext &C, ReportList *reports)
|
||||
{
|
||||
Object &ob_active = *CTX_data_active_object(&C);
|
||||
BLI_assert(ob_active.type == OB_CURVES);
|
||||
Curves &curves_id = *static_cast<Curves *>(ob_active.data);
|
||||
if (curves_id.surface == nullptr || curves_id.surface->type != OB_MESH) {
|
||||
BKE_report(reports, RPT_WARNING, "Can not use Add brush when there is no surface mesh");
|
||||
return {};
|
||||
}
|
||||
|
||||
return std::make_unique<AddOperation>();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class CurvesSculptStrokeOperation {
|
||||
virtual void on_stroke_extended(bContext *C, const StrokeExtension &stroke_extension) = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr<CurvesSculptStrokeOperation> new_add_operation();
|
||||
std::unique_ptr<CurvesSculptStrokeOperation> new_add_operation(bContext &C, ReportList *reports);
|
||||
std::unique_ptr<CurvesSculptStrokeOperation> new_comb_operation();
|
||||
std::unique_ptr<CurvesSculptStrokeOperation> new_delete_operation();
|
||||
std::unique_ptr<CurvesSculptStrokeOperation> new_snake_hook_operation();
|
||||
|
||||
@@ -74,12 +74,12 @@ using blender::bke::CurvesGeometry;
|
||||
/** \name * SCULPT_CURVES_OT_brush_stroke
|
||||
* \{ */
|
||||
|
||||
static std::unique_ptr<CurvesSculptStrokeOperation> start_brush_operation(bContext *C,
|
||||
wmOperator *op)
|
||||
static std::unique_ptr<CurvesSculptStrokeOperation> start_brush_operation(bContext &C,
|
||||
wmOperator &op)
|
||||
{
|
||||
const BrushStrokeMode mode = static_cast<BrushStrokeMode>(RNA_enum_get(op->ptr, "mode"));
|
||||
const BrushStrokeMode mode = static_cast<BrushStrokeMode>(RNA_enum_get(op.ptr, "mode"));
|
||||
|
||||
Scene &scene = *CTX_data_scene(C);
|
||||
Scene &scene = *CTX_data_scene(&C);
|
||||
CurvesSculpt &curves_sculpt = *scene.toolsettings->curves_sculpt;
|
||||
Brush &brush = *BKE_paint_brush(&curves_sculpt.paint);
|
||||
switch (brush.curves_sculpt_tool) {
|
||||
@@ -90,9 +90,9 @@ static std::unique_ptr<CurvesSculptStrokeOperation> start_brush_operation(bConte
|
||||
case CURVES_SCULPT_TOOL_SNAKE_HOOK:
|
||||
return new_snake_hook_operation();
|
||||
case CURVES_SCULPT_TOOL_ADD:
|
||||
return new_add_operation();
|
||||
return new_add_operation(C, op.reports);
|
||||
case CURVES_SCULPT_TOOL_GROW_SHRINK:
|
||||
return new_grow_shrink_operation(mode, C);
|
||||
return new_grow_shrink_operation(mode, &C);
|
||||
}
|
||||
BLI_assert_unreachable();
|
||||
return {};
|
||||
@@ -131,7 +131,7 @@ static void stroke_update_step(bContext *C,
|
||||
|
||||
if (!op_data->operation) {
|
||||
stroke_extension.is_first = true;
|
||||
op_data->operation = start_brush_operation(C, op);
|
||||
op_data->operation = start_brush_operation(*C, *op);
|
||||
}
|
||||
else {
|
||||
stroke_extension.is_first = false;
|
||||
|
||||
Reference in New Issue
Block a user