Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
| Show First 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | |||||
| static bool stroke_test_start(bContext *C, struct wmOperator *op, const float mouse[2]) | static bool stroke_test_start(bContext *C, struct wmOperator *op, const float mouse[2]) | ||||
| { | { | ||||
| UNUSED_VARS(C, op, mouse); | UNUSED_VARS(C, op, mouse); | ||||
| return true; | return true; | ||||
| } | } | ||||
| static void stroke_update_step(bContext *C, | static void stroke_update_step(bContext *C, | ||||
| wmOperator *op, | wmOperator *op, | ||||
| PaintStroke * /*stroke*/, | PaintStroke *stroke, | ||||
| PointerRNA *stroke_element) | PointerRNA *stroke_element) | ||||
| { | { | ||||
| SculptCurvesBrushStrokeData *op_data = static_cast<SculptCurvesBrushStrokeData *>( | SculptCurvesBrushStrokeData *op_data = static_cast<SculptCurvesBrushStrokeData *>( | ||||
| op->customdata); | op->customdata); | ||||
| StrokeExtension stroke_extension; | StrokeExtension stroke_extension; | ||||
| RNA_float_get_array(stroke_element, "mouse", stroke_extension.mouse_position); | RNA_float_get_array(stroke_element, "mouse", stroke_extension.mouse_position); | ||||
| stroke_extension.pressure = RNA_float_get(stroke_element, "pressure"); | stroke_extension.pressure = RNA_float_get(stroke_element, "pressure"); | ||||
| stroke_extension.reports = op->reports; | stroke_extension.reports = op->reports; | ||||
| if (!op_data->operation) { | if (!op_data->operation) { | ||||
| stroke_extension.is_first = true; | stroke_extension.is_first = true; | ||||
| op_data->operation = start_brush_operation(*C, *op, stroke_extension); | op_data->operation = start_brush_operation(*C, *op, stroke_extension); | ||||
| } | } | ||||
| else { | else { | ||||
| stroke_extension.is_first = false; | stroke_extension.is_first = false; | ||||
| } | } | ||||
| if (op_data->operation) { | if (op_data->operation) { | ||||
| op_data->operation->on_stroke_extended(*C, stroke_extension); | op_data->operation->on_stroke_extended(*C, stroke_extension); | ||||
| } | } | ||||
| /* Calculate pivot for rotation around selection if needed. | |||||
| * also needed for "Frame Selected" on last stroke. */ | |||||
| UnifiedPaintSettings *ups = paint_stroke_paintsettings_get(stroke); | |||||
| Object *ob = CTX_data_active_object(C); | |||||
| float4x4 object_to_world = ob->object_to_world; | |||||
| CurvesBrush3D brush_3d = *sample_curves_3d_brush( | |||||
| *CTX_data_depsgraph_pointer(C), | |||||
| *CTX_wm_region(C), | |||||
| *CTX_wm_view3d(C), | |||||
| *CTX_wm_region_view3d(C), | |||||
| *ob, | |||||
| stroke_extension.mouse_position, | |||||
| BKE_brush_size_get(CTX_data_scene(C), paint_stroke_brush_get(stroke))); | |||||
| ups->average_stroke_counter++; | |||||
| add_v3_v3(ups->average_stroke_accum, object_to_world * brush_3d.position_cu); | |||||
| ups->last_stroke_valid = true; | |||||
HooglyBoogly: Since `sample_curves_3d_brush` is already called in some sculpt brushes, it would probably be… | |||||
lichtwerkAuthorUnsubmitted Not Done Inline ActionsThx for the feedback, that could work, will check on this (I was having the same worry -- see the initial note in the patch description) lichtwerk: Thx for the feedback, that could work, will check on this (I was having the same worry -- see… | |||||
| } | } | ||||
| static void stroke_done(const bContext *C, PaintStroke *stroke) | static void stroke_done(const bContext *C, PaintStroke *stroke) | ||||
| { | { | ||||
| UNUSED_VARS(C, stroke); | UNUSED_VARS(C, stroke); | ||||
| } | } | ||||
| static int sculpt_curves_stroke_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int sculpt_curves_stroke_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| ▲ Show 20 Lines • Show All 1,078 Lines • Show Last 20 Lines | |||||
Since sample_curves_3d_brush is already called in some sculpt brushes, it would probably be best not to duplicate it here. The operation is multi-threaded but not trivial for performance. Maybe on_stroke_extended should be able to return a position?