148 if (stroke && brush) {
185 float viewport_size[4];
187 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
192 "colors", (
float *)(
float[][4]){{0.0f, 0.0f, 0.0f,
alpha}, {1.0f, 1.0f, 1.0f,
alpha}}, 2);
296 const float mouse_init[2],
300 bool *r_location_is_set)
304 bool location_sampled =
false;
305 bool location_success =
false;
308 bool is_dry_run =
false;
309 bool do_random =
false;
310 bool do_random_mask =
false;
311 *r_location_is_set =
false;
383 do_random_mask =
true;
413 location_sampled =
true;
414 location_success =
true;
415 *r_location_is_set =
true;
462 if ((do_random || do_random_mask) && stroke->
rng ==
NULL) {
476 if (do_random_mask) {
483 if (!location_sampled) {
486 location_success =
true;
487 *r_location_is_set =
true;
490 location_success =
true;
495 location_success =
true;
500 return location_success && (is_dry_run ==
false);
526 const float mouse_in[2],
545 if (tablet && (pressure >= 0.99f) &&
558 if (tablet && (pressure < 0.0002f) &&
578 float factor = stroke->
zoom_2d;
589 if (factor != 1.0f) {
599 bool is_location_is_set;
601 C, brush, mode, stroke, mouse_in, mouse_out, pressure, location, &is_location_is_set);
602 if (is_location_is_set) {
610 bool add_step =
true;
664 r_mouse[0] =
sample->mouse[0];
665 r_mouse[1] =
sample->mouse[1];
666 *r_pressure =
sample->pressure;
676 float spacing_pressure)
681 float size_clamp = 0.0f;
685 float last_object_space_position[3];
704 spacing = spacing * (1.5f - spacing_pressure);
720 return max_ff(0.001f, size_clamp * spacing / 50.0f);
722 return max_ff(stroke->
zoom_2d, size_clamp * spacing / 50.0f);
727 const int n = 100 / spacing;
728 const float h = spacing / 50.0f;
729 const float x0 =
x - 1;
732 for (
int i = 0; i < n; i++) {
735 xx =
fabsf(x0 + i * h);
747 float spacing = br->
spacing * factor;
756 for (
int i = 0; i < m; i++) {
782 float q = s * dpressure / (2.0f *
length);
783 float pressure_fac = (1.0f + q) / (1.0f - q);
786 float new_size_pressure = stroke->
last_pressure * pressure_fac;
790 C,
scene, stroke, last_size_pressure, pressure);
793 return 0.5f * (last_spacing + new_spacing);
804 const float final_mouse[2],
805 float final_pressure)
817 float d_world_space_position[3] = {0.0f};
827 if (use_scene_spacing) {
828 float world_space_position[3];
838 zero_v3(d_world_space_position);
852 if (use_scene_spacing) {
853 float final_world_space_position[3];
855 mul_v3_v3fl(final_world_space_position, d_world_space_position, spacing);
858 final_world_space_position);
868 spacing / no_pressure_spacing);
958 if (stroke ==
NULL) {
999 stroke->
redraw(
C, stroke,
true);
1003 stroke->
done(
C, stroke);
1116 #define PAINT_STROKE_MODAL_CANCEL 1
1126 static const char *
name =
"Paint Stroke Modal";
1146 sample->pressure = pressure;
1182 float *length_residue,
1183 const float old_pos[2],
1184 const float new_pos[2])
1194 float mouse[3], dmouse[2];
1196 float d_world_space_position[3] = {0.0f};
1197 float world_space_position_old[3], world_space_position_new[3];
1201 if (use_scene_spacing) {
1207 sub_v3_v3v3(d_world_space_position, world_space_position_new, world_space_position_old);
1213 zero_v3(d_world_space_position);
1232 float spacing_final = spacing - *length_residue;
1233 length += *length_residue;
1234 *length_residue = 0.0;
1237 if (use_scene_spacing) {
1238 float final_world_space_position[3];
1240 mul_v3_v3fl(final_world_space_position, d_world_space_position, spacing_final);
1242 final_world_space_position, world_space_position_old, final_world_space_position);
1256 spacing_final = spacing;
1263 *length_residue =
length;
1269 const float mouse[2])
1290 float length_residue = 0.0f;
1304 for (i = 0; i < pc->
tot_points - 1; i++, pcp++) {
1309 bool do_rake =
false;
1311 for (j = 0; j < 2; j++) {
1314 pcp_next->bez.vec[0][j],
1315 pcp_next->bez.vec[1][j],
1324 for (j = 0; j < 2; j++) {
1327 pcp_next->bez.vec[0][j],
1328 pcp_next->bez.vec[1][j],
1337 float rotation =
atan2f(tangents[2 * j], tangents[2 * j + 1]);
1356 C, op, stroke, spacing, &length_residue,
data + 2 * j,
data + 2 * (j + 1));
1361 C, op, stroke, spacing, &length_residue,
data + 2 * j,
data + 2 * (j + 1));
1415 bool first_dab =
false;
1416 bool first_modal =
false;
1417 bool redraw =
false;
1443 stroke->
x_tilt =
event->tablet.x_tilt;
1444 stroke->
y_tilt =
event->tablet.y_tilt;
1447 #ifdef WITH_INPUT_NDOF
1544 else if (first_modal ||
1587 if (redraw && stroke->
redraw) {
1588 stroke->
redraw(
C, stroke,
false);
typedef float(TangentPoint)[2]
bool BKE_brush_use_size_pressure(const struct Brush *brush)
float BKE_brush_curve_strength(const struct Brush *br, float p, const float len)
void BKE_brush_randomize_texture_coords(struct UnifiedPaintSettings *ups, bool mask)
int BKE_brush_size_get(const struct Scene *scene, const struct Brush *brush)
float BKE_brush_unprojected_radius_get(const struct Scene *scene, const struct Brush *brush)
bool BKE_brush_use_locked_size(const struct Scene *scene, const struct Brush *brush)
void BKE_brush_jitter_pos(const struct Scene *scene, struct Brush *brush, const float pos[2], float jitterpos[2])
bool BKE_brush_use_alpha_pressure(const struct Brush *brush)
struct ScrArea * CTX_wm_area(const bContext *C)
struct Scene * CTX_data_scene(const bContext *C)
struct wmWindowManager * CTX_wm_manager(const bContext *C)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct Object * CTX_data_active_object(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct ToolSettings * CTX_data_tool_settings(const bContext *C)
struct RegionView3D * CTX_wm_region_view3d(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
void BKE_curve_forward_diff_tangent_bezier(float q0, float q1, float q2, float q3, float *p, int it, int stride)
void BKE_image_pool_release_ibuf(struct Image *ima, struct ImBuf *ibuf, struct ImagePool *pool)
struct ImBuf * BKE_image_pool_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, struct ImagePool *pool)
bool paint_calculate_rake_rotation(struct UnifiedPaintSettings *ups, struct Brush *brush, const float mouse_pos[2])
ePaintMode BKE_paintmode_get_active_from_context(const struct bContext *C)
struct Brush * BKE_paint_brush(struct Paint *paint)
void BKE_paint_set_overlay_override(enum eOverlayFlags flag)
struct Paint * BKE_paint_get_active_from_context(const struct bContext *C)
void paint_update_brush_rake_rotation(struct UnifiedPaintSettings *ups, struct Brush *brush, float rotation)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
MINLINE float max_ff(float a, float b)
MINLINE float square_f(float a)
MINLINE float interpf(float a, float b, float t)
void mul_m4_v3(const float M[4][4], float r[3])
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
void interp_v2_v2v2(float r[2], const float a[2], const float b[2], const float t)
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v2_fl2(float v[2], float x, float y)
MINLINE float normalize_v3(float r[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void add_v2_v2(float r[2], const float a[2])
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE float len_v2(const float a[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float normalize_v2(float r[2])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
struct RNG * BLI_rng_new(unsigned int seed)
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define POINTER_AS_INT(i)
struct Depsgraph Depsgraph
@ BRUSH_CLOTH_DEFORM_GRAB
@ SCULPT_TOOL_ELASTIC_DEFORM
Object is a sort of wrapper for general info.
#define PAINT_MAX_INPUT_SAMPLES
#define MTEX_MAP_MODE_VIEW
#define MTEX_MAP_MODE_AREA
#define MTEX_ANGLE_RANDOM
#define MTEX_MAP_MODE_RANDOM
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc, struct Depsgraph *depsgraph)
void ED_view3d_project(const struct ARegion *region, const float world[3], float r_region_co[3])
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
@ GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR
@ GPU_SHADER_2D_UNIFORM_COLOR
void GPU_blend(eGPUBlend blend)
void GPU_line_smooth(bool enable)
void GPU_viewport_size_get_f(float coords[4])
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume TEX_IMAGE
Platform independent time functions.
Utility defines for timing/benchmarks.
#define TIMEIT_START_AVERAGED(var)
#define TIMEIT_END_AVERAGED(var)
#define RNA_BEGIN(sptr, itemptr, propname)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE btScalar length(const btQuaternion &q)
Return the length of a quaternion.
static T sum(const btAlignedObjectArray< T > &items)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
const Depsgraph * depsgraph
static CCL_NAMESPACE_BEGIN const double alpha
void *(* MEM_callocN)(size_t len, const char *str)
static void area(int d1, int d2, int e1, int e2, float weights[2])
static void sample(SocketReader *reader, int x, int y, float color[4])
bool get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
void(* StrokeRedraw)(const struct bContext *C, struct PaintStroke *stroke, bool final)
bool(* StrokeGetLocation)(struct bContext *C, float location[3], const float mouse[2])
void(* StrokeDone)(const struct bContext *C, struct PaintStroke *stroke)
float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius)
#define PAINT_CURVE_NUM_SEGMENTS
void(* StrokeUpdateStep)(struct bContext *C, struct PaintStroke *stroke, struct PointerRNA *itemptr)
bool(* StrokeTestStart)(struct bContext *C, struct wmOperator *op, const float mouse[2])
bool paint_supports_smooth_stroke(Brush *br, ePaintMode mode)
static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, const float mouse_in[2], float pressure)
bool paint_supports_dynamic_size(Brush *br, ePaintMode mode)
ViewContext * paint_stroke_view_context(PaintStroke *stroke)
bool paint_poll(bContext *C)
bool paint_supports_dynamic_tex_coords(Brush *br, ePaintMode mode)
static bool paint_tool_require_inbetween_mouse_events(Brush *brush, ePaintMode mode)
static void paint_stroke_sample_average(const PaintStroke *stroke, PaintSample *average)
static void paint_stroke_line_end(bContext *C, wmOperator *op, PaintStroke *stroke, const float mouse[2])
static float paint_space_stroke_spacing(bContext *C, const Scene *scene, PaintStroke *stroke, float size_pressure, float spacing_pressure)
static void stroke_done(bContext *C, wmOperator *op)
bool paint_stroke_flipped(struct PaintStroke *stroke)
#define PAINT_STROKE_MODAL_CANCEL
struct PaintSample PaintSample
static float paint_space_stroke_spacing_variable(bContext *C, const Scene *scene, PaintStroke *stroke, float pressure, float dpressure, float length)
static int paint_space_stroke(bContext *C, wmOperator *op, const float final_mouse[2], float final_pressure)
static bool paint_tool_require_location(Brush *brush, ePaintMode mode)
PaintStroke * paint_stroke_new(bContext *C, wmOperator *op, StrokeGetLocation get_location, StrokeTestStart test_start, StrokeUpdateStep update_step, StrokeRedraw redraw, StrokeDone done, int event_type)
static void paint_line_strokes_spacing(bContext *C, wmOperator *op, PaintStroke *stroke, float spacing, float *length_residue, const float old_pos[2], const float new_pos[2])
void paint_stroke_free(bContext *C, wmOperator *op)
static bool sculpt_is_grab_tool(Brush *br)
void paint_stroke_set_mode_data(PaintStroke *stroke, void *mode_data)
bool paint_space_stroke_enabled(Brush *br, ePaintMode mode)
static bool paint_stroke_use_jitter(ePaintMode mode, Brush *brush, bool invert)
static void paint_stroke_line_constrain(PaintStroke *stroke, float mouse[2])
static void paint_stroke_add_sample(const Paint *paint, PaintStroke *stroke, float x, float y, float pressure)
static float paint_stroke_integrate_overlap(Brush *br, float factor)
void * paint_stroke_mode_data(struct PaintStroke *stroke)
struct wmKeyMap * paint_stroke_modal_keymap(struct wmKeyConfig *keyconf)
bool paint_stroke_inverted(struct PaintStroke *stroke)
static bool paint_stroke_curve_end(bContext *C, wmOperator *op, PaintStroke *stroke)
bool paint_supports_texture(ePaintMode mode)
static void paint_draw_line_cursor(bContext *C, int x, int y, void *customdata)
static bool paint_stroke_use_dash(Brush *brush)
static bool paint_smooth_stroke(PaintStroke *stroke, const PaintSample *sample, ePaintMode mode, float r_mouse[2], float *r_pressure)
void paint_stroke_cancel(bContext *C, wmOperator *op)
int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event)
static bool paint_stroke_use_scene_spacing(Brush *brush, ePaintMode mode)
static void paint_draw_smooth_cursor(bContext *C, int x, int y, void *customdata)
static float paint_stroke_overlapped_curve(Brush *br, float x, float spacing)
struct PaintStroke PaintStroke
int paint_stroke_exec(bContext *C, wmOperator *op)
static bool paint_brush_update(bContext *C, Brush *brush, ePaintMode mode, struct PaintStroke *stroke, const float mouse_init[2], float mouse[2], float pressure, float r_location[3], bool *r_location_is_set)
float paint_stroke_distance_get(struct PaintStroke *stroke)
void RNA_collection_clear(PointerRNA *ptr, const char *name)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
int RNA_property_collection_lookup_int(PointerRNA *ptr, PropertyRNA *prop, int key, PointerRNA *r_ptr)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
void RNA_collection_add(PointerRNA *ptr, const char *name, PointerRNA *r_value)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
int RNA_enum_get(PointerRNA *ptr, const char *name)
bool SCULPT_stroke_get_location(bContext *C, float out[3], const float mouse[2])
BLI_INLINE bool SCULPT_is_cloth_deform_brush(const Brush *brush)
float smooth_stroke_factor
struct CurveMapping * curve
struct PaintCurve * paint_curve
struct ColorSpace * rect_colorspace
StrokeGetLocation get_location
float last_world_space_position[3]
UnifiedPaintSettings * ups
StrokeTestStart test_start
float last_tablet_event_pressure
float cached_size_pressure
StrokeUpdateStep update_step
float last_mouse_position[2]
PaintSample samples[PAINT_MAX_INPUT_SAMPLES]
unsigned char paint_cursor_col[4]
struct CurveMapping * cavity_curve
float average_stroke_accum[3]
char do_linear_conversion
float anchored_initial_mouse[2]
float initial_pixel_radius
int average_stroke_counter
float size_pressure_value
struct ColorSpace * colorspace
void(* cancel)(struct bContext *, struct wmOperator *)
struct wmOperatorType * type
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
long int PIL_check_seconds_timer_i(void)
ccl_device_inline float average(const float2 &a)
ccl_device_inline float2 fabs(const float2 &a)
void WM_paint_cursor_tag_redraw(wmWindow *win, ARegion *UNUSED(region))
bool WM_event_is_tablet(const struct wmEvent *event)
float WM_event_tablet_data(const wmEvent *event, int *pen_flip, float tilt[2])
wmKeyMap * WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
bool WM_paint_cursor_end(wmPaintCursor *handle)
wmPaintCursor * WM_paint_cursor_activate(short space_type, short region_type, bool(*poll)(bContext *C), wmPaintCursorDraw draw, void *customdata)
void WM_event_remove_timer(wmWindowManager *wm, wmWindow *UNUSED(win), wmTimer *timer)
wmTimer * WM_event_add_timer(wmWindowManager *wm, wmWindow *win, int event_type, double timestep)