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,
160 const float radius =
brush_radius(scene, brush, pressure);
161 const float radius_squared = radius * radius;
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;
192 if (brush_use_pinned_mode) {
213 auto screen_to_world = [=](
const float3 &world_pos,
const float2 &screen_delta) {
220 switch (
params.toolsettings.gp_sculpt.lock_axis) {
223 return [=](
const float3 &position,
const float2 &screen_delta) {
225 const float3 world_delta = screen_to_world(world_pos, screen_delta);
227 world_to_layer, world_delta - world_normal *
math::dot(world_delta, world_normal));
228 return position + layer_delta;
232 return [=](
const float3 &position,
const float2 &screen_delta) {
234 const float3 world_delta = screen_to_world(world_pos, screen_delta);
236 world_to_layer,
float3(0.0f, world_delta.y, world_delta.z));
237 return position + layer_delta;
241 return [=](
const float3 &position,
const float2 &screen_delta) {
243 const float3 world_delta = screen_to_world(world_pos, screen_delta);
245 world_to_layer,
float3(world_delta.x, 0.0f, world_delta.z));
246 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,
float3(world_delta.x, world_delta.y, 0.0f));
255 return position + layer_delta;
260 return [=](
const float3 &position,
const float2 &screen_delta) {
262 const float3 world_delta = screen_to_world(world_pos, screen_delta);
264 world_to_layer, world_delta - world_normal *
math::dot(world_delta, world_normal));
265 return position + layer_delta;
289 return {*
scene.toolsettings,
303 const bool use_masking,
314 const bool use_masking,
325 const bool use_masking,
330 params.drawing.strokes().curves_range());
353 view_positions[point_i],
356 view_positions[point_i] =
float2(0);
360 return view_positions;
376 view_radii[point_i] = radii[point_i] / pixel_size;
416 std::atomic<bool> changed =
false;
455 std::atomic<bool> changed =
false;
458 for (const int64_t i : range) {
459 const MutableDrawingInfo &info = drawings[i];
460 GreasePencilStrokeParams params = GreasePencilStrokeParams::from_context(
468 info.multi_frame_falloff,
497 std::atomic<bool> changed =
false;
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_MODE_VERTEXCOLOR
@ GP_BRUSH_ACTIVE_LAYER_ONLY
@ GPPAINT_FLAG_USE_VERTEXCOLOR
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
BPy_StructRNA * depsgraph
Span< T > as_span() const
static IndexMask from_predicate(const IndexMask &universe, GrainSize grain_size, IndexMaskMemory &memory, Fn &&predicate)
IndexRange index_range() const
void resize(const int64_t new_size)
MutableSpan< T > as_mutable_span()
float4x4 to_world_space(const Object &object) const
float2 prev_mouse_position
bool is_inverted(const Brush &brush) const
float2 mouse_delta(const InputSample &input_sample) const
blender::ed::greasepencil::MutableDrawingInfo MutableDrawingInfo
void stroke_extended(const InputSample &extension_sample)
void init_stroke(const bContext &C, const InputSample &start_sample)
float2 start_mouse_position
BrushStrokeMode stroke_mode
void foreach_editable_drawing(const bContext &C, FunctionRef< bool(const GreasePencilStrokeParams ¶ms)> fn) const
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_points(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)
IndexMask retrieve_editable_strokes(Object &object, const bke::greasepencil::Drawing &drawing, int layer_index, IndexMaskMemory &memory)
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)
bool brush_using_vertex_color(const GpPaint *gp_paint, const Brush *brush)
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
MatBase< float, 3, 3 > float3x3
VecBase< float, 3 > float3
float distance(float a, float b)
GPU_SHADER_INTERFACE_INFO(overlay_edit_curve_handle_iface, "vert").flat(Type pos vertex_in(1, Type::UINT, "data") .vertex_out(overlay_edit_curve_handle_iface) .geometry_layout(PrimitiveIn Frequency::GEOMETRY storage_buf(1, Qualifier::READ, "uint", "data[]", Frequency::GEOMETRY) .push_constant(Type Frequency::GEOMETRY selection[]
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)