157 return curve_weights[curve_i] > 0.0f;
160 this->
puff(curves_mask, curve_weights);
164 curves_->tag_positions_changed();
174 for (
const float4x4 &brush_transform : symmetry_brush_transforms) {
187 const float brush_radius_sq_re =
pow2f(brush_radius_re);
194 const IndexRange points = points_by_curve[curve_i];
198 float max_weight = 0.0f;
199 for (
const int point_i : points.
drop_front(1)) {
207 if (dist_to_brush_sq_re > brush_radius_sq_re) {
211 const float dist_to_brush_re = std::sqrt(dist_to_brush_sq_re);
213 brush_, dist_to_brush_re, brush_radius_re);
234 for (
const float4x4 &brush_transform : symmetry_brush_transforms) {
241 const float brush_radius_cu,
244 const float brush_radius_sq_cu =
pow2f(brush_radius_cu);
251 const IndexRange points = points_by_curve[curve_i];
252 float max_weight = 0.0f;
253 for (
const int point_i : points.
drop_front(1)) {
257 brush_pos_cu, prev_pos_cu, pos_cu);
258 if (dist_to_brush_sq_cu > brush_radius_sq_cu) {
262 const float dist_to_brush_cu = std::sqrt(dist_to_brush_sq_cu);
264 brush_, dist_to_brush_cu, brush_radius_cu);
278 for (
const int curve_i : segment) {
279 const IndexRange points = points_by_curve[curve_i];
280 const int first_point_i = points[0];
281 const float3 first_pos_cu = positions_cu[first_point_i];
296 const float3 closest_pos_su = nearest.
co;
307 accumulated_lengths_cu.
resize(points.
size() - 1);
309 positions_cu.
slice(points),
false, accumulated_lengths_cu);
314 const int point_i = points[
i];
315 const float3 old_pos_cu = positions_cu[point_i];
318 const float length_param_cu = accumulated_lengths_cu[
i - 1];
319 const float3 goal_pos_cu = first_pos_cu + length_param_cu * normal_cu;
322 curve_weights[curve_i];
327 const float old_dist_to_root_cu =
math::distance(old_pos_cu, first_pos_cu);
328 const float new_dist_to_root_cu =
math::distance(new_pos_cu, first_pos_cu);
329 if (new_dist_to_root_cu < old_dist_to_root_cu) {
331 new_pos_cu += (old_dist_to_root_cu - new_dist_to_root_cu) * offset;
334 positions_cu[point_i] = new_pos_cu;
344 executor.
execute(*
this,
C, stroke_extension);
349 return std::make_unique<PuffOperation>();
float BKE_brush_curve_strength(eBrushCurvePreset preset, const CurveMapping *cumap, float distance, float brush_radius)
float BKE_brush_radius_get(const Paint *paint, const Brush *brush)
Object * CTX_data_active_object(const bContext *C)
const Brush * BKE_paint_brush_for_read(const Paint *paint)
#define BLI_assert_unreachable()
int BLI_bvhtree_find_nearest(const BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata)
MINLINE float pow2f(float x)
float dist_squared_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3])
void interp_weights_tri_v3(float w[3], const float v1[3], const float v2[3], const float v3[3], const float co[3])
float dist_squared_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2])
#define BLI_SCOPED_DEFER(function_to_defer)
void DEG_id_tag_update(ID *id, unsigned int flags)
@ PAINT_FALLOFF_SHAPE_SPHERE
@ PAINT_FALLOFF_SHAPE_TUBE
@ CV_SCULPT_COLLISION_ENABLED
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)
static IndexMask from_predicate(const IndexMask &universe, GrainSize grain_size, IndexMaskMemory &memory, Fn &&predicate)
constexpr int64_t size() const
constexpr IndexRange drop_front(int64_t n) const
constexpr MutableSpan slice(const int64_t start, const int64_t size) const
void resize(const int64_t new_size)
friend struct PuffOperationExecutor
void on_stroke_extended(const bContext &C, const StrokeExtension &stroke_extension) override
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)
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)
void report_missing_surface(ReportList *reports)
Vector< float4x4 > get_symmetry_brush_transforms(const eCurvesSymmetryType symmetry)
std::unique_ptr< CurvesSculptStrokeOperation > new_puff_operation()
float brush_radius_factor(const Brush &brush, const StrokeExtension &stroke_extension)
float3 compute_surface_point_normal(const int3 &tri, const float3 &bary_coord, Span< float3 > corner_normals)
void accumulate_lengths(const Span< T > values, const bool cyclic, MutableSpan< float > lengths)
T distance(const T &a, const T &b)
CartesianBasis invert(const CartesianBasis &basis)
T interpolate(const T &a, const T &b, const FactorT &t)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
VecBase< T, 3 > transform_direction(const MatBase< T, 3, 3 > &mat, const VecBase< T, 3 > &direction)
void max_inplace(T &a, const T &b)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
MatBase< float, 4, 4 > float4x4
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
VecBase< float, 3 > float3
void execute(PuffOperation &self, const bContext &C, const StrokeExtension &stroke_extension)
PuffOperationExecutor(const bContext &C)
void find_curve_weights_projected_with_symmetry(MutableSpan< float > r_curve_weights)
float brush_radius_factor_
CurvesSculptCommonContext ctx_
Span< int > surface_corner_verts_
Span< float3 > surface_positions_
bke::BVHTreeFromMesh surface_bvh_
Span< int3 > surface_corner_tris_
void find_curves_weights_spherical_with_symmetry(MutableSpan< float > r_curve_weights)
const Object * surface_ob_
void puff(const IndexMask &selection, const Span< float > curve_weights)
Span< float3 > corner_normals_su_
IndexMask curve_selection_
IndexMaskMemory selected_curve_memory_
void find_curves_weights_spherical(const float3 &brush_pos_cu, const float brush_radius_cu, MutableSpan< float > r_curve_weights)
CurvesSculpt * curves_sculpt_
VArray< float > point_factors_
CurvesSurfaceTransforms transforms_
float brush_radius_base_re_
void find_curve_weights_projected(const float4x4 &brush_transform, MutableSpan< float > r_curve_weights)
void WM_main_add_notifier(uint type, void *reference)