136 if (stroke && brush) {
173 float viewport_size[4];
175 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
289 const float mouse_init[2],
293 bool *r_location_is_set)
297 bool location_sampled =
false;
298 bool location_success =
false;
301 bool is_dry_run =
false;
302 bool do_random =
false;
303 bool do_random_mask =
false;
304 *r_location_is_set =
false;
361 do_random_mask =
true;
391 location_sampled =
true;
392 location_success =
true;
393 *r_location_is_set =
true;
440 if ((do_random || do_random_mask) && stroke->
rng ==
NULL) {
454 if (do_random_mask) {
461 if (!location_sampled) {
464 location_success =
true;
465 *r_location_is_set =
true;
468 location_success =
true;
473 location_success =
true;
478 return location_success && (is_dry_run ==
false);
520 if (tablet && (pressure >= 0.99f) &&
533 if (tablet && (pressure < 0.0002f) &&
547 float world_space_position[3];
561 float factor = stroke->
zoom_2d;
572 if (factor != 1.0f) {
582 bool is_location_is_set;
584 C, brush, mode, stroke, mval, mouse_out, pressure, location, &is_location_is_set);
585 if (is_location_is_set) {
593 bool add_step =
true;
647 r_mouse[0] =
sample->mouse[0];
648 r_mouse[1] =
sample->mouse[1];
649 *r_pressure =
sample->pressure;
659 float spacing_pressure)
664 float size_clamp = 0.0f;
668 float last_object_space_position[3];
687 spacing = spacing * (1.5f - spacing_pressure);
703 return size_clamp * spacing / 50.0f;
705 return max_ff(stroke->
zoom_2d, size_clamp * spacing / 50.0f);
710 const int n = 100 / spacing;
711 const float h = spacing / 50.0f;
712 const float x0 =
x - 1;
715 for (
int i = 0; i < n; i++) {
718 xx =
fabsf(x0 + i * h);
730 float spacing = br->
spacing * factor;
739 for (
int i = 0; i < m; i++) {
765 float q = s * dpressure / (2.0f *
length);
766 float pressure_fac = (1.0f + q) / (1.0f - q);
769 float new_size_pressure = stroke->
last_pressure * pressure_fac;
773 C,
scene, stroke, last_size_pressure, pressure);
776 return 0.5f * (last_spacing + new_spacing);
788 const float final_mouse[2],
789 float final_pressure)
800 float d_world_space_position[3] = {0.0f};
810 if (use_scene_spacing) {
811 float world_space_position[3];
821 zero_v3(d_world_space_position);
835 if (use_scene_spacing) {
836 float final_world_space_position[3];
838 mul_v3_v3fl(final_world_space_position, d_world_space_position, spacing);
841 final_world_space_position);
853 spacing / no_pressure_spacing);
965 if (stroke ==
NULL) {
1005 stroke->
redraw(
C, stroke,
true);
1009 stroke->
done(
C, stroke);
1129 #define PAINT_STROKE_MODAL_CANCEL 1
1138 static const char *
name =
"Paint Stroke Modal";
1158 sample->pressure = pressure;
1194 float *length_residue,
1195 const float old_pos[2],
1196 const float new_pos[2])
1206 float mouse[2], dmouse[2];
1208 float d_world_space_position[3] = {0.0f};
1209 float world_space_position_old[3], world_space_position_new[3];
1213 if (use_scene_spacing) {
1215 C, world_space_position_old, old_pos, stroke->
original);
1217 C, world_space_position_new, new_pos, stroke->
original);
1221 sub_v3_v3v3(d_world_space_position, world_space_position_new, world_space_position_old);
1227 zero_v3(d_world_space_position);
1246 float spacing_final = spacing - *length_residue;
1247 length += *length_residue;
1248 *length_residue = 0.0;
1251 if (use_scene_spacing) {
1252 float final_world_space_position[3];
1254 mul_v3_v3fl(final_world_space_position, d_world_space_position, spacing_final);
1256 final_world_space_position, world_space_position_old, final_world_space_position);
1270 spacing_final = spacing;
1277 *length_residue =
length;
1283 const float mouse[2])
1304 float length_residue = 0.0f;
1318 for (i = 0; i < pc->
tot_points - 1; i++, pcp++) {
1323 bool do_rake =
false;
1325 for (j = 0; j < 2; j++) {
1328 pcp_next->bez.vec[0][j],
1329 pcp_next->bez.vec[1][j],
1338 for (j = 0; j < 2; j++) {
1341 pcp_next->bez.vec[0][j],
1342 pcp_next->bez.vec[1][j],
1370 C, op, stroke, spacing, &length_residue,
data + 2 * j,
data + 2 * (j + 1));
1375 C, op, stroke, spacing, &length_residue,
data + 2 * j,
data + 2 * (j + 1));
1429 bool first_dab =
false;
1430 bool first_modal =
false;
1431 bool redraw =
false;
1457 stroke->
x_tilt =
event->tablet.x_tilt;
1458 stroke->
y_tilt =
event->tablet.y_tilt;
1461 #ifdef WITH_INPUT_NDOF
1560 else if (first_modal ||
1603 if (redraw && stroke->
redraw) {
1604 stroke->
redraw(
C, stroke,
false);
typedef float(TangentPoint)[2]
float BKE_brush_curve_strength(const struct Brush *br, float p, float len)
bool BKE_brush_use_size_pressure(const struct Brush *brush)
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)
@ PAINT_MODE_SCULPT_CURVES
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])
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)
void interp_v2_v2v2(float r[2], const float a[2], const float b[2], float t)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
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 void add_v3_v3(float r[3], const float a[3])
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
@ CURVES_SCULPT_TOOL_DENSITY
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_v2(const struct ARegion *region, const float world[3], float r_region_co[2])
_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.
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 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)
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
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
void *(* MEM_callocN)(size_t len, const char *str)
ccl_device_inline float average(const float2 &a)
ccl_device_inline float2 fabs(const float2 &a)
static void area(int d1, int d2, int e1, int e2, float weights[2])
T length(const vec_base< T, Size > &a)
static const pxr::TfToken g("g", pxr::TfToken::Immortal)
MutableSpan< float3 > tangents
bool get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy)
void(* StrokeRedraw)(const struct bContext *C, struct PaintStroke *stroke, bool final)
void(* StrokeUpdateStep)(struct bContext *C, struct wmOperator *op, struct PaintStroke *stroke, struct PointerRNA *itemptr)
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)
bool(* StrokeGetLocation)(struct bContext *C, float location[3], const float mouse[2], bool force_original)
#define PAINT_CURVE_NUM_SEGMENTS
bool(* StrokeTestStart)(struct bContext *C, struct wmOperator *op, const float mouse[2])
bool paint_supports_smooth_stroke(Brush *br, ePaintMode mode)
bool paint_supports_dynamic_size(Brush *br, ePaintMode mode)
ViewContext * paint_stroke_view_context(PaintStroke *stroke)
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)
void paint_stroke_cancel(bContext *C, wmOperator *op, PaintStroke *stroke)
int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event, PaintStroke **stroke_p)
bool paint_stroke_flipped(struct PaintStroke *stroke)
static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, PaintStroke *stroke, const float mval[2], float pressure)
#define PAINT_STROKE_MODAL_CANCEL
struct PaintSample PaintSample
static void stroke_done(bContext *C, wmOperator *op, PaintStroke *stroke)
static float paint_space_stroke_spacing_variable(bContext *C, const Scene *scene, PaintStroke *stroke, float pressure, float dpressure, float length)
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)
bool PAINT_brush_tool_poll(bContext *C)
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])
static bool sculpt_is_grab_tool(Brush *br)
static bool paint_tool_raycast_original(Brush *brush, ePaintMode UNUSED(mode))
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)
static bool curves_sculpt_brush_uses_spacing(const eBrushCurvesSculptTool tool)
int paint_stroke_exec(bContext *C, wmOperator *op, PaintStroke *stroke)
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 int paint_space_stroke(bContext *C, wmOperator *op, PaintStroke *stroke, const float final_mouse[2], float final_pressure)
static bool paint_smooth_stroke(PaintStroke *stroke, const PaintSample *sample, ePaintMode mode, float r_mouse[2], float *r_pressure)
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)
void paint_stroke_free(bContext *C, wmOperator *UNUSED(op), PaintStroke *stroke)
struct PaintStroke PaintStroke
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 mval[2], bool force_original)
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 last_scene_spacing_delta[3]
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
long int PIL_check_seconds_timer_i(void)
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])
#define ISMOUSE_MOTION(event_type)
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)