115 this->
smooth(point_smooth_factors);
126 for (
const float4x4 &brush_transform : symmetry_brush_transforms) {
137 const float brush_radius_sq_re =
pow2f(brush_radius_re);
146 [&](
const int curve_i) {
147 const IndexRange points = points_by_curve[curve_i];
148 for (
const int point_i : points) {
153 if (dist_to_brush_sq_re > brush_radius_sq_re) {
157 const float dist_to_brush_re = std::sqrt(dist_to_brush_sq_re);
159 brush_, dist_to_brush_re, brush_radius_re);
162 const float weight_factor = 0.1f;
163 const float weight = weight_factor *
brush_strength_ * radius_falloff *
185 for (
const float4x4 &brush_transform : symmetry_brush_transforms) {
188 r_point_smooth_factors);
193 const float brush_radius_cu,
196 const float brush_radius_sq_cu =
pow2f(brush_radius_cu);
202 [&](
const int curve_i) {
203 const IndexRange points = points_by_curve[curve_i];
204 for (
const int point_i : points) {
207 if (dist_to_brush_sq_cu > brush_radius_sq_cu) {
211 const float dist_to_brush_cu = std::sqrt(dist_to_brush_sq_cu);
213 brush_, dist_to_brush_cu, brush_radius_cu);
216 const float weight_factor = 0.1f;
217 const float weight = weight_factor *
brush_strength_ * radius_falloff *
233 for (
const int curve_i : segment) {
234 const IndexRange points = points_by_curve[curve_i];
235 old_positions.
clear();
237 for (
const int i :
IndexRange(points.
size()).drop_front(1).drop_back(1)) {
238 const int point_i = points[i];
239 const float smooth_factor = point_smooth_factors[point_i];
240 if (smooth_factor == 0.0f) {
244 const float3 old_pos = old_positions[i];
245 const float3 &prev_pos = old_positions[i - 1];
246 const float3 &next_pos = old_positions[i + 1];
249 positions[point_i] = new_pos;
261 executor.
execute(*
this, stroke_extension);
266 return std::make_unique<SmoothOperation>();
#define BLI_assert_unreachable()
constexpr int64_t size() const
constexpr IndexRange()=default
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
void extend(Span< T > array)
GAttributeReader lookup_or_default(StringRef name, AttrDomain domain, AttrType data_type, const void *default_value=nullptr) const
MutableSpan< float3 > positions_for_write()
AttributeAccessor attributes() const
void tag_positions_changed()
OffsetIndices< int > points_by_curve() const
const Depsgraph * depsgraph
friend struct SmoothOperationExecutor
void on_stroke_extended(const PaintStroke &stroke, const StrokeExtension &stroke_extension) override
void foreach_segment(Fn &&fn, Mode mode=exec_mode::serial) const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
GeometryDeformation get_evaluated_curves_deformation(const Object *ob_eval, const Object &ob_orig)
IndexMask retrieve_selected_curves(const bke::CurvesGeometry &curves, LinearAllocator<> &memory)
float brush_strength_get(const Paint &paint, const Brush &brush, const StrokeExtension &stroke_extension)
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)
void remember_stroke_position(CurvesSculpt &curves_sculpt, const float3 &brush_position_wo)
std::unique_ptr< CurvesSculptStrokeOperation > new_smooth_operation()
Vector< float4x4 > get_symmetry_brush_transforms(const eCurvesSymmetryType symmetry)
float brush_radius_factor(const Brush &brush, const StrokeExtension &stroke_extension)
constexpr ParallelGrainSize grain_size(int grain_size)
CartesianBasis invert(const CartesianBasis &basis)
T midpoint(const T &a, const T &b)
T interpolate(const T &a, const T &b, const FactorT &t)
T distance_squared(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
void max_inplace(T &a, const T &b)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
void WM_main_add_notifier(uint type, void *reference)
float4x4 ED_view3d_ob_project_mat_get(const RegionView3D *rv3d, const Object *ob)
float BKE_brush_radius_get(const Paint *paint, const Brush *brush)
@ PAINT_FALLOFF_SHAPE_SPHERE
@ PAINT_FALLOFF_SHAPE_TUBE
float2 ED_view3d_project_float_v2_m4(const ARegion *region, const float co[3], const float4x4 &mat)
MatBase< float, 4, 4 > float4x4
void ED_region_tag_redraw(ARegion *region)
MINLINE float pow2f(float x)
VecBase< float, 2 > float2
void DEG_id_tag_update(ID *id, unsigned int flags)
float BKE_brush_curve_strength(eBrushCurvePreset preset, const CurveMapping *cumap, float distance, float brush_radius)
const Brush * BKE_paint_brush_for_read(const Paint *paint)
VecBase< float, 3 > float3
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])
eBrushFalloffShape falloff_shape
struct ToolSettings * toolsettings
SmoothOperationExecutor(const PaintStroke &stroke)
void find_spherical_smooth_factors(const float3 &brush_pos_cu, const float brush_radius_cu, MutableSpan< float > r_point_smooth_factors)
CurvesSculpt * curves_sculpt_
void find_projected_smooth_factors(const float4x4 &brush_transform, MutableSpan< float > r_point_smooth_factors)
VArray< float > point_factors_
float brush_radius_base_re_
IndexMaskMemory selected_curve_memory_
IndexMask curve_selection_
CurvesSculptCommonContext ctx_
CurvesSurfaceTransforms transforms_
void smooth(const Span< float > point_smooth_factors)
void find_spherical_smooth_factors_with_symmetry(MutableSpan< float > r_point_smooth_factors)
void execute(SmoothOperation &self, const StrokeExtension &stroke_extension)
float brush_radius_factor_
void find_projected_smooth_factors_with_symmetry(MutableSpan< float > r_point_smooth_factors)