45 if (active_layer_only) {
47 if (!grease_pencil.has_active_layer()) {
50 const Layer &active_layer = *grease_pencil.get_active_layer();
52 scene, grease_pencil, active_layer);
90 const float multi_frame_falloff)
104 return influence_base * brush_falloff;
109 int j =
verts.size() - 1;
112 for (
int i = 0; i <
verts.size(); i++) {
114 if (((
verts[i].y > pt.y) != (
verts[j].y > pt.y)) &&
130 const float multi_frame_falloff)
143 return influence_base * brush_falloff;
148 const float2 &mouse_position,
149 const float pressure,
150 const float multi_frame_falloff,
156 if (selection.is_empty()) {
160 const float radius =
brush_radius(scene, brush, pressure);
161 const float radius_squared = radius * radius;
167 Array<float> all_influences(selection.min_array_size());
169 selection,
GrainSize(4096), memory, [&](
const int point) {
172 if (distance_squared > radius_squared) {
173 all_influences[
point] = 0.0f;
178 &brush,
math::sqrt(distance_squared), radius);
179 all_influences[
point] = influence_base * brush_falloff;
180 return all_influences[
point] > 0.0f;
185 return influence_mask;
200 const float4x4 layer_to_world = layer.to_world_space(
object);
203 auto screen_to_world = [=](
const float3 &world_pos,
const float2 &screen_delta) {
210 switch (
params.toolsettings.gp_sculpt.lock_axis) {
213 return [=](
const float3 &position,
const float2 &screen_delta) {
215 const float3 world_delta = screen_to_world(world_pos, screen_delta);
217 world_to_layer, world_delta - world_normal *
math::dot(world_delta, world_normal));
218 return position + layer_delta;
222 return [=](
const float3 &position,
const float2 &screen_delta) {
224 const float3 world_delta = screen_to_world(world_pos, screen_delta);
226 world_to_layer,
float3(0.0f, world_delta.y, world_delta.z));
227 return position + layer_delta;
231 return [=](
const float3 &position,
const float2 &screen_delta) {
233 const float3 world_delta = screen_to_world(world_pos, screen_delta);
235 world_to_layer,
float3(world_delta.x, 0.0f, world_delta.z));
236 return position + layer_delta;
240 return [=](
const float3 &position,
const float2 &screen_delta) {
242 const float3 world_delta = screen_to_world(world_pos, screen_delta);
244 world_to_layer,
float3(world_delta.x, world_delta.y, 0.0f));
245 return position + layer_delta;
250 return [=](
const float3 &position,
const float2 &screen_delta) {
252 const float3 world_delta = screen_to_world(world_pos, screen_delta);
254 world_to_layer, world_delta - world_normal *
math::dot(world_delta, world_normal));
255 return position + layer_delta;
270 const int layer_index,
271 const int frame_number,
272 const float multi_frame_falloff,
279 return {*scene.toolsettings,
293 const bool use_masking,
299 params.drawing.strokes().points_range());
303 const bool use_masking,
309 params.drawing.strokes().curves_range());
313 const bool use_masking,
318 params.drawing.strokes().curves_range());
341 view_positions[point_i],
344 view_positions[point_i] =
float2(0);
348 return view_positions;
364 view_radii[point_i] = radii[point_i] / pixel_size;
404 std::atomic<bool> changed =
false;
443 std::atomic<bool> changed =
false;
446 for (const int64_t i : range) {
447 const MutableDrawingInfo &info = drawings[i];
448 GreasePencilStrokeParams params = GreasePencilStrokeParams::from_context(
456 info.multi_frame_falloff,
470void GreasePencilStrokeOperationCommon::foreach_editable_drawing(
485 std::atomic<bool> changed =
false;
501 if (fn(
params, projection_fn)) {
512void GreasePencilStrokeOperationCommon::init_stroke(
const bContext &C,
524void GreasePencilStrokeOperationCommon::stroke_extended(
const InputSample &extension_sample)
bool BKE_brush_use_alpha_pressure(const Brush *brush)
int BKE_brush_size_get(const Scene *scene, const Brush *brush)
float BKE_brush_curve_strength(eBrushCurvePreset preset, const CurveMapping *cumap, float distance, float brush_radius)
bool BKE_brush_use_size_pressure(const Brush *brush)
void BKE_brush_init_gpencil_settings(Brush *brush)
float BKE_brush_alpha_get(const Scene *scene, const Brush *brush)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Object * CTX_data_active_object(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
Low-level operations for curves.
Low-level operations for grease pencil.
Paint * BKE_paint_get_active_from_context(const bContext *C)
Brush * BKE_paint_brush(Paint *paint)
#define BLI_assert_unreachable()
void DEG_id_tag_update(ID *id, unsigned int flags)
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
@ GP_BRUSH_ACTIVE_LAYER_ONLY
float ED_view3d_pixel_size(const RegionView3D *rv3d, const float co[3])
void ED_view3d_win_to_delta(const ARegion *region, const float xy_delta[2], float zfac, float r_out[3])
float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3])
eV3DProjStatus ED_view3d_project_float_global(const ARegion *region, const float co[3], float r_co[2], eV3DProjTest flag)
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a point
Span< T > as_span() const
IndexRange index_range() const
void resize(const int64_t new_size)
MutableSpan< T > as_mutable_span()
float2 prev_mouse_position
bool is_inverted(const Brush &brush) const
float2 mouse_delta(const InputSample &input_sample) const
BrushStrokeMode stroke_mode
void foreach_editable_drawing(const bContext &C, FunctionRef< bool(const GreasePencilStrokeParams ¶ms)> fn) const
static IndexMask from_predicate(const IndexMask &universe, GrainSize grain_size, IndexMaskMemory &memory, Fn &&predicate)
const Depsgraph * depsgraph
void gather(const GVArray &src, const IndexMask &indices, GMutableSpan dst, int64_t grain_size=4096)
GeometryDeformation get_evaluated_grease_pencil_drawing_deformation(const Object *ob_eval, const Object &ob_orig, int layer_index, int frame)
IndexMask retrieve_editable_and_selected_strokes(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
IndexMask retrieve_editable_and_selected_fill_strokes(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
IndexMask retrieve_editable_and_selected_points(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
Vector< MutableDrawingInfo > retrieve_editable_drawings_from_layer_with_falloff(const Scene &scene, GreasePencil &grease_pencil, const blender::bke::greasepencil::Layer &layer)
Vector< MutableDrawingInfo > retrieve_editable_drawings_with_falloff(const Scene &scene, GreasePencil &grease_pencil)
bool is_brush_inverted(const Brush &brush, BrushStrokeMode stroke_mode)
float closest_distance_to_surface_2d(const float2 pt, const Span< float2 > verts)
Array< float > calculate_view_radii(const GreasePencilStrokeParams ¶ms, const IndexMask &selection)
bool do_vertex_color_fill(const Brush &brush)
Vector< ed::greasepencil::MutableDrawingInfo > get_drawings_for_painting(const bContext &C)
void init_brush(Brush &brush)
IndexMask point_selection_mask(const GreasePencilStrokeParams ¶ms, const bool use_masking, IndexMaskMemory &memory)
Array< float2 > calculate_view_positions(const GreasePencilStrokeParams ¶ms, const IndexMask &selection)
IndexMask fill_selection_mask(const GreasePencilStrokeParams ¶ms, const bool use_masking, IndexMaskMemory &memory)
IndexMask brush_point_influence_mask(const Scene &scene, const Brush &brush, const float2 &mouse_position, float pressure, float multi_frame_falloff, const IndexMask &selection, Span< float2 > view_positions, Vector< float > &influences, IndexMaskMemory &memory)
float brush_point_influence(const Scene &scene, const Brush &brush, const float2 &co, const InputSample &sample, float multi_frame_falloff)
IndexMask stroke_selection_mask(const GreasePencilStrokeParams ¶ms, const bool use_masking, IndexMaskMemory &memory)
float brush_fill_influence(const Scene &scene, const Brush &brush, Span< float2 > fill_positions, const InputSample &sample, float multi_frame_falloff)
bke::crazyspace::GeometryDeformation get_drawing_deformation(const GreasePencilStrokeParams ¶ms)
DeltaProjectionFunc get_screen_projection_fn(const GreasePencilStrokeParams ¶ms, const Object &object, const bke::greasepencil::Layer &layer)
bool do_vertex_color_points(const Brush &brush)
float brush_radius(const Scene &scene, const Brush &brush, float pressure)
std::function< float3(const float3 position, const float2 &screen_delta)> DeltaProjectionFunc
T distance(const T &a, const T &b)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
T min(const T &a, const T &b)
CartesianBasis invert(const CartesianBasis &basis)
T distance_squared(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
VecBase< T, 3 > transform_direction(const MatBase< T, 3, 3 > &mat, const VecBase< T, 3 > &direction)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
void parallel_for_each(Range &&range, const Function &function)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
MatBase< float, 4, 4 > float4x4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< float, 3 > float3
float distance(float a, float b)
struct CurveMapping * curve_sensitivity
struct CurveMapping * curve_strength
struct CurveMapping * curve_jitter
struct CurveMapping * curve_rand_pressure
struct CurveMapping * curve_rand_strength
struct CurveMapping * curve_rand_saturation
struct CurveMapping * curve_rand_hue
struct CurveMapping * curve_rand_uv
struct CurveMapping * curve_rand_value
struct CurveMapping * curve
struct BrushGpencilSettings * gpencil_settings
const float multi_frame_falloff
bke::greasepencil::Drawing & drawing
float multi_frame_falloff
const RegionView3D & rv3d
const bke::greasepencil::Layer & layer
static GreasePencilStrokeParams from_context(const Scene &scene, Depsgraph &depsgraph, ARegion ®ion, RegionView3D &rv3d, Object &object, int layer_index, int frame_number, float multi_frame_falloff, bke::greasepencil::Drawing &drawing)
bke::greasepencil::Drawing & drawing
void WM_event_add_notifier(const bContext *C, uint type, void *reference)