158 return curve_weights[curve_i] > 0.0f;
161 this->
puff(curves_mask, curve_weights);
175 for (
const float4x4 &brush_transform : symmetry_brush_transforms) {
188 const float brush_radius_sq_re =
pow2f(brush_radius_re);
196 const IndexRange points = points_by_curve[curve_i];
201 float max_weight = 0.0f;
202 for (
const int point_i : points.
drop_front(1)) {
210 if (dist_to_brush_sq_re > brush_radius_sq_re) {
214 const float dist_to_brush_re = std::sqrt(dist_to_brush_sq_re);
216 brush_, dist_to_brush_re, brush_radius_re);
238 for (
const float4x4 &brush_transform : symmetry_brush_transforms) {
245 const float brush_radius_cu,
248 const float brush_radius_sq_cu =
pow2f(brush_radius_cu);
256 const IndexRange points = points_by_curve[curve_i];
257 float max_weight = 0.0f;
258 for (
const int point_i : points.
drop_front(1)) {
262 brush_pos_cu, prev_pos_cu, pos_cu);
263 if (dist_to_brush_sq_cu > brush_radius_sq_cu) {
267 const float dist_to_brush_cu = std::sqrt(dist_to_brush_sq_cu);
269 brush_, dist_to_brush_cu, brush_radius_cu);
285 for (
const int curve_i : segment) {
286 const IndexRange points = points_by_curve[curve_i];
287 const int first_point_i = points[0];
288 const float3 first_pos_cu = positions_cu[first_point_i];
294 const std::optional<bke::bvh::ClosestPointResult> nearest =
301 const float3 closest_pos_su = nearest->position;
312 accumulated_lengths_cu.
resize(points.
size() - 1);
314 positions_cu.
slice(points),
false, accumulated_lengths_cu);
320 const int point_i = points[i];
321 const float3 old_pos_cu = positions_cu[point_i];
324 const float length_param_cu = accumulated_lengths_cu[i - 1];
325 const float3 goal_pos_cu = first_pos_cu + length_param_cu * normal_cu;
328 curve_weights[curve_i];
333 const float old_dist_to_root_cu =
math::distance(old_pos_cu, first_pos_cu);
334 const float new_dist_to_root_cu =
math::distance(new_pos_cu, first_pos_cu);
335 if (new_dist_to_root_cu < old_dist_to_root_cu) {
337 new_pos_cu += (old_dist_to_root_cu - new_dist_to_root_cu) * offset;
340 positions_cu[point_i] = new_pos_cu;
352 executor.
execute(*
this, stroke_extension);
357 return std::make_unique<PuffOperation>();
#define BLI_SCOPED_DEFER(function_to_defer)
#define BLI_assert_unreachable()
static IndexMask from_predicate(const IndexMask &universe, LinearAllocator<> &memory, Fn &&predicate, exec_mode::Mode mode=exec_mode::parallel)
constexpr int64_t size() const
constexpr IndexRange()=default
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)
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
std::optional< ClosestPointResult > closest_point(const float3 &point, float radius=std::numeric_limits< float >::max()) const
const Depsgraph * depsgraph
void on_stroke_extended(const PaintStroke &stroke, const StrokeExtension &stroke_extension) override
friend struct PuffOperationExecutor
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)
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)
constexpr ParallelGrainSize grain_size(int grain_size)
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)
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)
float dist_squared_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2])
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
void DEG_id_tag_update(ID *id, unsigned int flags)
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 BKE_brush_curve_strength(eBrushCurvePreset preset, const CurveMapping *cumap, float distance, float brush_radius)
float dist_squared_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3])
@ CV_SCULPT_COLLISION_ENABLED
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
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, const float surface_collision_distance)
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_
Span< int3 > surface_corner_tris_
void find_curves_weights_spherical_with_symmetry(MutableSpan< float > r_curve_weights)
const Object * surface_ob_
const bke::bvh::Tree * surface_bvh_
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_
PuffOperationExecutor(const PaintStroke &stroke)
void execute(PuffOperation &self, const StrokeExtension &stroke_extension)
float brush_radius_base_re_
void find_curve_weights_projected(const float4x4 &brush_transform, MutableSpan< float > r_curve_weights)