157 for (
const float4x4 &brush_transform : symmetry_brush_transforms) {
173 const float brush_radius_sq_re =
pow2f(brush_radius_re);
176 for (
const int curve_i : segment) {
177 const IndexRange points = points_by_curve[curve_i];
178 for (
const int point_i : points.drop_front(1)) {
179 const float3 old_pos_cu = deformation.positions[point_i];
185 if (dist_to_brush_sq_re > brush_radius_sq_re) {
189 const float dist_to_brush_re = std::sqrt(dist_to_brush_sq_re);
206 const float3 translation_eval = new_pos_cu - old_pos_cu;
207 const float3 translation_orig = deformation.translation_from_deformed_to_original(
208 point_i, translation_eval);
209 positions_cu[point_i] += translation_orig;
210 r_changed_curves[curve_i] =
true;
230 for (
const float4x4 &brush_transform : symmetry_brush_transforms) {
237 const float brush_radius_cu,
241 const float brush_radius_sq_cu =
pow2f(brush_radius_cu);
248 for (
const int curve_i : segment) {
249 const IndexRange points = points_by_curve[curve_i];
250 for (
const int point_i : points.drop_front(1)) {
251 const float3 old_pos_cu = deformation.positions[point_i];
254 if (dist_to_brush_sq_cu > brush_radius_sq_cu) {
258 const float dist_to_brush_cu = std::sqrt(dist_to_brush_sq_cu);
265 const float3 translation_eval = new_pos_cu - old_pos_cu;
266 const float3 translation_orig = deformation.translation_from_deformed_to_original(
267 point_i, translation_eval);
268 positions_cu[point_i] += translation_orig;
270 r_changed_curves[curve_i] =
true;
280 executor.
execute(*
this, C, stroke_extension);
291 return std::make_unique<PinchOperation>(invert_pinch);
int BKE_brush_size_get(const Scene *scene, const Brush *brush)
float BKE_brush_curve_strength(eBrushCurvePreset preset, const CurveMapping *cumap, float distance, float brush_radius)
float BKE_brush_alpha_get(const Scene *scene, const Brush *brush)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Low-level operations for curves.
const Brush * BKE_paint_brush_for_read(const Paint *paint)
#define BLI_assert_unreachable()
MINLINE float pow2f(float x)
void DEG_id_tag_update(ID *id, unsigned int flags)
@ PAINT_FALLOFF_SHAPE_SPHERE
@ PAINT_FALLOFF_SHAPE_TUBE
@ CV_SCULPT_COLLISION_ENABLED
Object is a sort of wrapper for general info.
void ED_region_tag_redraw(ARegion *region)
blender::float2 ED_view3d_project_float_v2_m4(const ARegion *region, const float co[3], const blender::float4x4 &mat)
void ED_view3d_win_to_3d(const View3D *v3d, const ARegion *region, const float depth_pt[3], const float mval[2], float r_out[3])
blender::float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const Object *ob)
GAttributeReader lookup_or_default(StringRef attribute_id, AttrDomain domain, eCustomDataType data_type, const void *default_value=nullptr) const
MutableSpan< float3 > positions_for_write()
OffsetIndices< int > points_by_curve() const
void tag_positions_changed()
AttributeAccessor attributes() const
const Depsgraph * depsgraph
void on_stroke_extended(const bContext &C, const StrokeExtension &stroke_extension) override
PinchOperation(const bool invert_pinch)
static IndexMask from_bools(Span< bool > bools, IndexMaskMemory &memory)
void foreach_segment(Fn &&fn) const
GeometryDeformation get_evaluated_curves_deformation(const Object *ob_eval, const Object &ob_orig)
IndexMask retrieve_selected_curves(const bke::CurvesGeometry &curves, IndexMaskMemory &memory)
std::unique_ptr< CurvesSculptStrokeOperation > new_pinch_operation(const BrushStrokeMode brush_mode, const bContext &C)
std::optional< CurvesBrush3D > sample_curves_3d_brush(const Depsgraph &depsgraph, const ARegion ®ion, const View3D &v3d, const RegionView3D &rv3d, const Object &curves_object, const float2 &brush_pos_re, const float brush_radius_re)
Vector< float4x4 > get_symmetry_brush_transforms(const eCurvesSymmetryType symmetry)
float brush_radius_factor(const Brush &brush, const StrokeExtension &stroke_extension)
T safe_divide(const T &a, const T &b)
CartesianBasis invert(const CartesianBasis &basis)
T interpolate(const T &a, const T &b, const FactorT &t)
T distance_squared(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
struct ToolSettings * toolsettings
void solve_step(bke::CurvesGeometry &curves, const IndexMask &curve_selection, const Mesh *surface, const CurvesSurfaceTransforms &transforms)
void initialize(const bke::CurvesGeometry &curves, const IndexMask &curve_selection, const bool use_surface_collision)
PinchOperationExecutor(const bContext &C)
const CurvesSculpt * curves_sculpt_
void execute(PinchOperation &self, const bContext &C, const StrokeExtension &stroke_extension)
void pinch_spherical_with_symmetry(MutableSpan< bool > r_changed_curves)
void pinch_projected(const float4x4 &brush_transform, MutableSpan< bool > r_changed_curves)
float brush_radius_base_re_
VArray< float > point_factors_
CurvesSculptCommonContext ctx_
CurvesSurfaceTransforms transforms_
void pinch_projected_with_symmetry(MutableSpan< bool > r_changed_curves)
void pinch_spherical(const float3 &brush_pos_cu, const float brush_radius_cu, MutableSpan< bool > r_changed_curves)
float brush_radius_factor_
IndexMask curve_selection_
IndexMaskMemory selected_curve_memory_
void WM_main_add_notifier(uint type, void *reference)