47using bke::CurvesGeometry;
147 for (
const int curve_i : segment) {
148 const IndexRange points = points_by_curve[curve_i];
150 self_->curve_lengths_[curve_i] = std::accumulate(
151 lengths.
begin(), lengths.
end(), 0.0f);
192 for (
const float4x4 &brush_transform : symmetry_brush_transforms) {
209 const float brush_radius_sq_re =
pow2f(brush_radius_re);
219 for (
const int curve_i : segment) {
220 bool curve_changed =
false;
221 const IndexRange points = points_by_curve[curve_i];
223 const float total_length =
self_->curve_lengths_[curve_i];
225 float current_length = 0.0f;
226 for (
const int point_i : points.
drop_front(1)) {
227 current_length += segment_lengths[point_i - 1];
239 if (distance_to_brush_sq_re > brush_radius_sq_re) {
244 const float distance_to_brush_re = std::sqrt(distance_to_brush_sq_re);
247 brush_, distance_to_brush_re, brush_radius_re);
248 const float curve_parameter = current_length * total_length_inv;
250 &curve_parameter_falloff_mapping, 0, curve_parameter);
252 const float weight =
brush_strength_ * curve_falloff * radius_falloff *
269 const float3 translation_eval = new_pos_cu - old_pos_cu;
271 point_i, translation_eval);
272 positions_cu_orig[point_i] += translation_orig;
274 curve_changed =
true;
277 r_changed_curves[curve_i] =
true;
289 float3 brush_start_wo, brush_end_wo;
310 for (
const float4x4 &brush_transform : symmetry_brush_transforms) {
319 const float3 &brush_start_cu,
320 const float3 &brush_end_cu,
321 const float brush_radius_cu)
324 const float brush_radius_sq_cu =
pow2f(brush_radius_cu);
325 const float3 brush_diff_cu = brush_end_cu - brush_start_cu;
338 for (
const int curve_i : segment) {
339 bool curve_changed =
false;
340 const IndexRange points = points_by_curve[curve_i];
342 const float total_length =
self_->curve_lengths_[curve_i];
344 float current_length = 0.0f;
345 for (
const int point_i : points.
drop_front(1)) {
346 current_length += segment_lengths[point_i - 1];
352 pos_old_cu, brush_start_cu, brush_end_cu);
353 if (distance_to_brush_sq_cu > brush_radius_sq_cu) {
358 const float distance_to_brush_cu = std::sqrt(distance_to_brush_sq_cu);
362 brush_, distance_to_brush_cu, brush_radius_cu);
363 const float curve_parameter = current_length * total_length_inv;
365 &curve_parameter_falloff_mapping, 0, curve_parameter);
367 const float weight =
brush_strength_ * curve_falloff * radius_falloff *
370 const float3 translation_eval_cu = weight * brush_diff_cu;
372 point_i, translation_eval_cu);
375 positions_cu[point_i] += translation_orig_cu;
376 curve_changed =
true;
379 r_changed_curves[curve_i] =
true;
398 if (brush_3d.has_value()) {
399 self_->brush_3d_ = *brush_3d;
411 executor.
execute(*
this, stroke_extension);
416 return std::make_unique<CombOperation>();
Low-level operations for curves.
#define BLI_SCOPED_DEFER(function_to_defer)
Object is a sort of wrapper for general info.
#define BLI_assert_unreachable()
void reinitialize(const int64_t new_size)
static IndexMask from_bools(Span< bool > bools, LinearAllocator<> &memory)
constexpr IndexRange drop_back(int64_t n) const
constexpr IndexRange drop_front(int64_t n) const
constexpr Span slice(int64_t start, int64_t size) const
constexpr const T * end() const
constexpr const T * begin() const
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
friend struct CombOperationExecutor
void on_stroke_extended(const PaintStroke &stroke, const StrokeExtension &stroke_extension) override
const Depsgraph * depsgraph
void foreach_segment(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)
std::unique_ptr< CurvesSculptStrokeOperation > new_comb_operation()
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)
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)
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])
void BKE_curvemapping_init(CurveMapping *cumap)
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)
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])
float BKE_curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value)
struct CurveMapping * curve_parameter_falloff
eBrushFalloffShape falloff_shape
struct BrushCurvesSculptSettings * curves_sculpt_settings
struct ToolSettings * toolsettings
VArray< float > point_factors_
void comb_spherical_with_symmetry(MutableSpan< bool > r_changed_curves)
void initialize_spherical_brush_reference_point()
void comb_projected_with_symmetry(MutableSpan< bool > r_changed_curves)
IndexMask curve_selection_
float brush_radius_factor_
void comb_projected(MutableSpan< bool > r_changed_curves, const float4x4 &brush_transform)
IndexMaskMemory selected_curve_memory_
CombOperationExecutor(const PaintStroke &stroke)
void execute(CombOperation &self, const StrokeExtension &stroke_extension)
float brush_radius_base_re_
void comb_spherical(MutableSpan< bool > r_changed_curves, const float3 &brush_start_cu, const float3 &brush_end_cu, const float brush_radius_cu)
float2 brush_pos_prev_re_
CurvesGeometry * curves_orig_
CurvesSculptCommonContext ctx_
float2 brush_pos_diff_re_
CurvesSurfaceTransforms transforms_
CurvesSculpt * curves_sculpt_
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)
Span< float > segment_lengths() const