Blender V5.0
blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor Struct Reference

Classes

struct  EraserRing

Public Member Functions

 EraseOperationExecutor (const bContext &)
int8_t segment_intersections_and_points_sides (const int2 &point, const int2 &point_after, const int64_t squared_radius, float &r_mu0, float &r_mu1, PointCircleSide &r_point_side, PointCircleSide &r_point_after_side) const
int curves_intersections_and_points_sides (const bke::CurvesGeometry &src, const Span< float2 > screen_space_positions, const Span< EraserRing > rings, MutableSpan< std::pair< int, PointCircleSide > > r_point_ring, MutableSpan< SegmentCircleIntersection > r_intersections) const
bool hard_eraser (Object &ob, const bke::CurvesGeometry &src, const Span< float2 > screen_space_positions, bke::CurvesGeometry &dst, const bool keep_caps) const
Vector< EraserRingcompute_piecewise_linear_falloff () const
bool soft_eraser (Object &ob, const blender::bke::CurvesGeometry &src, const Span< float2 > screen_space_positions, blender::bke::CurvesGeometry &dst, const bool keep_caps)
bool stroke_eraser (Object &ob, const bke::CurvesGeometry &src, const Span< float2 > screen_space_positions, bke::CurvesGeometry &dst) const
void execute (EraseOperation &self, const bContext &C, const InputSample &extension_sample)

Static Public Member Functions

static int8_t intersections_segment_circle_integers (const int2 &s0, const int2 &s1, const int2 &center, const int64_t radius_2, int64_t &r_mu0, int64_t &r_mu1)
static bool skip_strokes_with_locked_material (Object &ob, const int src_curve, const IndexRange &src_points, const VArray< int > stroke_material, const VArray< float > &point_opacity, Array< Vector< ed::greasepencil::PointTransferData > > &src_to_dst_points)

Public Attributes

float2 mouse_position
float eraser_radius
float eraser_strength
Brushbrush_
int2 mouse_position_pixels
int64_t eraser_squared_radius_pixels

Static Public Attributes

static constexpr float opacity_threshold = 0.05f

Detailed Description

Utility class that actually executes the update when the stroke is updated. That's useful because it avoids passing a very large number of parameters between functions.

Definition at line 90 of file grease_pencil_erase.cc.

Constructor & Destructor Documentation

◆ EraseOperationExecutor()

blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::EraseOperationExecutor ( const bContext & )
inline

Definition at line 103 of file grease_pencil_erase.cc.

Member Function Documentation

◆ compute_piecewise_linear_falloff()

◆ curves_intersections_and_points_sides()

int blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::curves_intersections_and_points_sides ( const bke::CurvesGeometry & src,
const Span< float2 > screen_space_positions,
const Span< EraserRing > rings,
MutableSpan< std::pair< int, PointCircleSide > > r_point_ring,
MutableSpan< SegmentCircleIntersection > r_intersections ) const
inline

Compute intersections between the eraser and the input src Curves Geometry. Also computes if the points of the geometry lie inside/outside, or in the boundary of the eraser.

Parameters
screen_space_positions2D positions of the geometry in screen space.
intersections_max_per_segmentmaximum number of intersections per-segment.
r_point_side(output) for each point in the source, enum describing where the point lies relatively to the eraser: inside, outside or at the boundary of the eraser.
r_intersections(output) array containing all the intersections found in the curves geometry. The size of the array should be src.points_num*intersections_max_per_segment. Initially all intersections are set as invalid, and the function fills valid intersections at an offset of src_point*intersections_max_per_segment.
Returns
total number of intersections found.

Definition at line 317 of file grease_pencil_erase.cc.

References blender::bke::CurvesGeometry::cyclic(), blender::threading::parallel_for(), blender::bke::CurvesGeometry::points_by_curve(), blender::bke::CurvesGeometry::points_num(), blender::bke::CurvesGeometry::points_range(), and blender::Span< T >::size().

Referenced by hard_eraser(), and soft_eraser().

◆ execute()

◆ hard_eraser()

◆ intersections_segment_circle_integers()

int8_t blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::intersections_segment_circle_integers ( const int2 & s0,
const int2 & s1,
const int2 & center,
const int64_t radius_2,
int64_t & r_mu0,
int64_t & r_mu1 )
inlinestatic

Computes the intersections between a 2D line segment and a circle with integer values.

Parameters
s0,s1endpoints of the segment.
centercenter of the circle,
radius_2squared radius of the circle.
r_mu0(output) signed distance from s0 to the first intersection, if it exists.
r_mu1(output) signed distance from s0 to the second intersection, if it exists.

All intersections with the infinite line of the segment are considered.

Returns
the number of intersection found.

Definition at line 126 of file grease_pencil_erase.cc.

References b, blender::math::distance(), blender::math::distance_squared(), blender::math::dot(), i, blender::math::round(), and blender::math::sqrt().

Referenced by segment_intersections_and_points_sides().

◆ segment_intersections_and_points_sides()

int8_t blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::segment_intersections_and_points_sides ( const int2 & point,
const int2 & point_after,
const int64_t squared_radius,
float & r_mu0,
float & r_mu1,
PointCircleSide & r_point_side,
PointCircleSide & r_point_after_side ) const
inline

Computes the intersection between the eraser brush and a 2D segment, using integer values. Also computes if the endpoints of the segment lie inside/outside, or in the boundary of the eraser.

Parameters
point,point_aftercoordinates of the first (resp. second) endpoint in the segment.
squared_radiussquared radius of the brush in pixels.
r_mu0,r_mu0(output) factor of the two intersections if they exists, otherwise (-1).
point_side,point_after_side(output) enum describing where the first (resp. second) endpoint lies relatively to the eraser: inside, outside or at the boundary of the eraser.
Returns
total number of intersections lying inside the segment (ie whose factor is in ]0,1[).

Note that the eraser is represented as a circle, and thus there can be only 0, 1 or 2 intersections with a segment.

Definition at line 205 of file grease_pencil_erase.cc.

References blender::math::distance(), float, blender::ed::sculpt_paint::greasepencil::Inside, blender::ed::sculpt_paint::greasepencil::InsideOutsideBoundary, intersections_segment_circle_integers(), blender::ed::sculpt_paint::greasepencil::Outside, and blender::ed::sculpt_paint::greasepencil::OutsideInsideBoundary.

◆ skip_strokes_with_locked_material()

bool blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::skip_strokes_with_locked_material ( Object & ob,
const int src_curve,
const IndexRange & src_points,
const VArray< int > stroke_material,
const VArray< float > & point_opacity,
Array< Vector< ed::greasepencil::PointTransferData > > & src_to_dst_points )
inlinestatic

◆ soft_eraser()

bool blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::soft_eraser ( Object & ob,
const blender::bke::CurvesGeometry & src,
const Span< float2 > screen_space_positions,
blender::bke::CurvesGeometry & dst,
const bool keep_caps )
inline

The soft eraser decreases the opacity of the points it hits. The new opacity is computed as a minimum between the current opacity and a falloff function of the distance of the point to the center of the eraser. If the opacity of a point falls below a threshold, then the point is removed from the curves.

Definition at line 700 of file grease_pencil_erase.cc.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::Array< T, InlineBufferCapacity, Allocator >::as_span(), blender::bke::CurvesGeometry::attributes(), blender::bke::CurvesGeometry::attributes_for_write(), b, blender::Array< T, InlineBufferCapacity, Allocator >::begin(), BKE_brush_curve_strength(), brush_strength(), blender::math::clamp(), compute_piecewise_linear_falloff(), blender::bke::Curve, curves_intersections_and_points_sides(), blender::bke::CurvesGeometry::curves_range(), blender::math::distance(), distance(), blender::IndexRange::first(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::EraserRing::hard_erase, blender::ed::sculpt_paint::greasepencil::Inside, blender::ed::sculpt_paint::greasepencil::InsideOutsideBoundary, blender::math::interpolate(), blender::Vector< T, InlineBufferCapacity, Allocator >::is_empty(), blender::IndexRange::last(), blender::Vector< T, InlineBufferCapacity, Allocator >::last(), blender::bke::MutableAttributeAccessor::lookup_or_add_for_write_span(), blender::bke::AttributeAccessor::lookup_or_default(), blender::math::max(), blender::math::min(), blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::EraserRing::opacity, blender::ed::sculpt_paint::greasepencil::Outside, blender::threading::parallel_for(), blender::bke::Point, blender::bke::CurvesGeometry::points_by_curve(), blender::bke::CurvesGeometry::points_num(), blender::bke::CurvesGeometry::points_range(), blender::Vector< T, InlineBufferCapacity, Allocator >::remove_last(), blender::Vector< T, InlineBufferCapacity, Allocator >::size(), and skip_strokes_with_locked_material().

Referenced by execute().

◆ stroke_eraser()

Member Data Documentation

◆ brush_

Brush* blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::brush_

Definition at line 95 of file grease_pencil_erase.cc.

◆ eraser_radius

float blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::eraser_radius

Definition at line 93 of file grease_pencil_erase.cc.

Referenced by stroke_eraser().

◆ eraser_squared_radius_pixels

int64_t blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::eraser_squared_radius_pixels

Definition at line 98 of file grease_pencil_erase.cc.

◆ eraser_strength

float blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::eraser_strength

Definition at line 94 of file grease_pencil_erase.cc.

◆ mouse_position

float2 blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::mouse_position

Definition at line 92 of file grease_pencil_erase.cc.

◆ mouse_position_pixels

int2 blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::mouse_position_pixels

Definition at line 97 of file grease_pencil_erase.cc.

◆ opacity_threshold

float blender::ed::sculpt_paint::greasepencil::EraseOperationExecutor::opacity_threshold = 0.05f
staticconstexpr

Definition at line 101 of file grease_pencil_erase.cc.

Referenced by compute_piecewise_linear_falloff().


The documentation for this struct was generated from the following file: