Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-05-17 14:06:14 +0300
committerHans Goudey <h.goudey@me.com>2022-05-17 14:06:14 +0300
commited62b65474f007025bc19d1f8758257b12cbc8b3 (patch)
treeaf034e94cc54b9acfd0ecbc632eed19bee4956c3 /source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc
parent3ad5510427002a299e6d6b1856da2f910a116a82 (diff)
Cleanup: Use const in curves sculpt code
This makes it much clearer what data is supposed to be modified and what data is just used to influence the operation. The new `BKE_paint_brush_for_read` function isn't great design, but it can be removed or renamed if similar changes are applied to more places. Also pass pointers explicitly to `sample_curves_3d_brush` rather than reusing the `bContext`. This makes it clearer what data the function actually needs. Differential Revision: https://developer.blender.org/D14967
Diffstat (limited to 'source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc')
-rw-r--r--source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc40
1 files changed, 22 insertions, 18 deletions
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc b/source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc
index 973751e9045..e009b443839 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc
@@ -63,7 +63,7 @@ class SnakeHookOperation : public CurvesSculptStrokeOperation {
friend struct SnakeHookOperatorExecutor;
public:
- void on_stroke_extended(bContext *C, const StrokeExtension &stroke_extension) override;
+ void on_stroke_extended(const bContext &C, const StrokeExtension &stroke_extension) override;
};
/**
@@ -72,19 +72,19 @@ class SnakeHookOperation : public CurvesSculptStrokeOperation {
*/
struct SnakeHookOperatorExecutor {
SnakeHookOperation *self_ = nullptr;
- bContext *C_ = nullptr;
- Scene *scene_ = nullptr;
- Object *object_ = nullptr;
+ const Depsgraph *depsgraph_ = nullptr;
+ const Scene *scene_ = nullptr;
ARegion *region_ = nullptr;
- View3D *v3d_ = nullptr;
- RegionView3D *rv3d_ = nullptr;
+ const View3D *v3d_ = nullptr;
+ const RegionView3D *rv3d_ = nullptr;
- CurvesSculpt *curves_sculpt_ = nullptr;
- Brush *brush_ = nullptr;
+ const CurvesSculpt *curves_sculpt_ = nullptr;
+ const Brush *brush_ = nullptr;
float brush_radius_re_;
float brush_strength_;
eBrushFalloffShape falloff_shape_;
+ Object *object_ = nullptr;
Curves *curves_id_ = nullptr;
CurvesGeometry *curves_ = nullptr;
@@ -95,20 +95,23 @@ struct SnakeHookOperatorExecutor {
float2 brush_pos_re_;
float2 brush_pos_diff_re_;
- void execute(SnakeHookOperation &self, bContext *C, const StrokeExtension &stroke_extension)
+ void execute(SnakeHookOperation &self,
+ const bContext &C,
+ const StrokeExtension &stroke_extension)
{
BLI_SCOPED_DEFER([&]() { self.last_mouse_position_re_ = stroke_extension.mouse_position; });
self_ = &self;
- C_ = C;
- scene_ = CTX_data_scene(C);
- object_ = CTX_data_active_object(C);
- region_ = CTX_wm_region(C);
- v3d_ = CTX_wm_view3d(C);
- rv3d_ = CTX_wm_region_view3d(C);
+ depsgraph_ = CTX_data_depsgraph_pointer(&C);
+ scene_ = CTX_data_scene(&C);
+ scene_ = CTX_data_scene(&C);
+ object_ = CTX_data_active_object(&C);
+ region_ = CTX_wm_region(&C);
+ v3d_ = CTX_wm_view3d(&C);
+ rv3d_ = CTX_wm_region_view3d(&C);
curves_sculpt_ = scene_->toolsettings->curves_sculpt;
- brush_ = BKE_paint_brush(&curves_sculpt_->paint);
+ brush_ = BKE_paint_brush_for_read(&curves_sculpt_->paint);
brush_radius_re_ = BKE_brush_size_get(scene_, brush_);
brush_strength_ = BKE_brush_alpha_get(scene_, brush_);
falloff_shape_ = static_cast<eBrushFalloffShape>(brush_->falloff_shape);
@@ -129,7 +132,7 @@ struct SnakeHookOperatorExecutor {
if (stroke_extension.is_first) {
if (falloff_shape_ == PAINT_FALLOFF_SHAPE_SPHERE) {
std::optional<CurvesBrush3D> brush_3d = sample_curves_3d_brush(
- *C_, *object_, brush_pos_re_, brush_radius_re_);
+ *depsgraph_, *region_, *v3d_, *rv3d_, *object_, brush_pos_re_, brush_radius_re_);
if (brush_3d.has_value()) {
self_->brush_3d_ = *brush_3d;
}
@@ -295,7 +298,8 @@ struct SnakeHookOperatorExecutor {
}
};
-void SnakeHookOperation::on_stroke_extended(bContext *C, const StrokeExtension &stroke_extension)
+void SnakeHookOperation::on_stroke_extended(const bContext &C,
+ const StrokeExtension &stroke_extension)
{
SnakeHookOperatorExecutor executor;
executor.execute(*this, C, stroke_extension);