Blender V4.3
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 (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 (const blender::bke::CurvesGeometry &src, const Span< float2 > screen_space_positions, blender::bke::CurvesGeometry &dst, const bool keep_caps)
 
bool stroke_eraser (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)
 

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 86 of file grease_pencil_erase.cc.

Constructor & Destructor Documentation

◆ EraseOperationExecutor()

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

Definition at line 99 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 313 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().

◆ execute()

◆ hard_eraser()

◆ intersections_segment_circle_integers()

static 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 122 of file grease_pencil_erase.cc.

References b, blender::math::distance(), blender::math::distance_squared(), blender::math::dot(), 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 201 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.

◆ soft_eraser()

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

◆ stroke_eraser()

Member Data Documentation

◆ brush_

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

Definition at line 91 of file grease_pencil_erase.cc.

◆ eraser_radius

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

Definition at line 89 of file grease_pencil_erase.cc.

◆ eraser_squared_radius_pixels

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

Definition at line 94 of file grease_pencil_erase.cc.

◆ eraser_strength

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

Definition at line 90 of file grease_pencil_erase.cc.

◆ mouse_position

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

Definition at line 88 of file grease_pencil_erase.cc.

◆ mouse_position_pixels

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

Definition at line 93 of file grease_pencil_erase.cc.

◆ opacity_threshold

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

Definition at line 97 of file grease_pencil_erase.cc.


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