47 gesture->event_type =
event->type;
48 gesture->event_modifier =
event->modifier;
49 gesture->event_keymodifier =
event->keymodifier;
51 gesture->user_data.use_free =
true;
81 size_t(2) *
gesture->points_alloc,
"lasso points");
82 lasso[0] = xy[0] -
gesture->winrct.xmin;
83 lasso[1] = xy[1] -
gesture->winrct.ymin;
91 border[0] = xy[0] -
gesture->winrct.xmin;
92 border[1] = xy[1] -
gesture->winrct.ymin;
106 MEM_delete(
gesture->edge_pan_data);
129 return (
gesture->is_active_prev ==
false);
145 float gradient_dir[2];
146 float gradient_point[2][2];
150 const float color_line_gradient_start[4] = {0.2f, 0.2f, 0.2f, 0.4f};
151 const float color_line_gradient_end[4] = {0.0f, 0.0f, 0.0f, 0.0f};
159 mul_v2_fl(gradient_dir, gradient_length);
160 add_v2_v2v2(gradient_point[0], line_start, gradient_dir);
161 add_v2_v2v2(gradient_point[1], line_end, gradient_dir);
165 immVertex2f(shdr_pos, line_start[0], line_start[1]);
169 immVertex2f(shdr_pos, gradient_point[1][0], gradient_point[1][1]);
172 immVertex2f(shdr_pos, line_start[0], line_start[1]);
174 immVertex2f(shdr_pos, gradient_point[1][0], gradient_point[1][1]);
176 immVertex2f(shdr_pos, gradient_point[0][0], gradient_point[0][1]);
196 float viewport_size[4];
198 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
239 float viewport_size[4];
241 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
250 shdr_pos,
float(rect->
xmin),
float(rect->
ymin),
float(rect->
xmax),
float(rect->
ymax));
278 float viewport_size[4];
280 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
302 memset(col, 0x10, x_end -
x);
307 const int mcoords_len = gt->
points + (lasso_pt_extra ? 1 : 0);
311 const float red[4] = {1.0f, 0.0f, 0.0f, 0.0f};
314 const short *lasso =
static_cast<const short *
>(gt->
customdata);
315 for (i = 0; i < mcoords_len; i++, lasso += 2) {
316 mcoords[i][0] = lasso[0];
317 mcoords[i][1] = lasso[1];
321 const float *lasso =
static_cast<const float *
>(gt->
customdata);
322 for (i = 0; i < mcoords_len; i++, lasso += 2) {
323 mcoords[i][0] = lasso[0];
324 mcoords[i][1] = lasso[1];
328 if (lasso_pt_extra) {
329 mcoords[mcoords_len - 1][0] = lasso_pt_extra->x;
330 mcoords[mcoords_len - 1][1] = lasso_pt_extra->y;
363 gpu::TextureFormat::UNORM_8,
370 MEM_delete(pixel_buf);
381 float last_x = lasso[gt->
points - 1][0];
382 float last_y = lasso[gt->
points - 1][1];
389 const float color[3] = {1.0f, 0.39f, 0.39f};
391 const float radius = 4.0f;
417 const float *lasso =
static_cast<float *
>(gt->
customdata);
424 const int numverts = gt->
points;
436 float viewport_size[4];
438 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
448 for (i = 0; i < gt->
points; i++, lasso += 2) {
462 const int numverts = gt.
points;
465 const short (*border)[2] =
static_cast<short int (*)[2]
>(gt.
customdata);
467 const float start_pos[2] = {
float(border[0][0]),
float(border[0][1])};
470 const float dist =
len_v2v2(start_pos, current_pos);
473 if (dist < limit && numverts > 2) {
474 const float u =
smoothstep(0.0f, limit, dist);
496 const int numverts = gt->
points + 1;
506 float viewport_size[4];
508 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
518 const short *border =
static_cast<short *
>(gt->
customdata);
519 for (
int i = 0; i < gt->
points; i++, border += 2) {
520 immVertex2f(shdr_pos,
float(border[0]),
float(border[1]));
536 float x1, x2, y1, y2;
543 float viewport_size[4];
545 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
581 for (; gt; gt = gt->
next) {
Read Blender memory allocation and freeing.
#define WM_GESTURE_STRAIGHTLINE
#define WM_GESTURE_CIRCLE
#define WM_GESTURE_CROSS_RECT
#define WM_GESTURE_POLYLINE
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
gpu::Shader * shader_get()
void draw(float x, float y, int img_w, int img_h, gpu::TextureFormat gpu_format, bool use_filter, const void *rect, float scale_x, float scale_y, const float color[4])
constexpr float POLYLINE_CLICK_RADIUS
static void wm_gesture_draw_rect(wmGesture *gt)
void WM_gestures_free_all(wmWindow *win)
void wmViewport(const rcti *winrct)
void immAttr4f(uint attr_id, float x, float y, float z, float w)
static void wm_gesture_draw_lasso(wmGesture *gt, bool filled)
static void wm_gesture_draw_cross(const wmWindow *win, const wmGesture *gt)
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest)
MINLINE void mul_v2_fl(float r[2], float f)
void immUniform2f(const char *name, float x, float y)
GPUVertFormat * immVertexFormat()
wmGesture * WM_gesture_new(wmWindow *window, const ARegion *region, const wmEvent *event, int type)
void WM_event_drag_start_xy(const wmEvent *event, int r_xy[2])
void immBegin(GPUPrimType, uint vertex_len)
void ortho_v2_v2(float out[2], const float v[2])
void GPU_line_smooth(bool enable)
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE float normalize_v2(float n[2])
static void draw_start_vertex_circle(const wmGesture >, const uint shdr_pos)
void MEM_delete_void(void *vmemh)
MINLINE float pow2f(float x)
void GPU_line_width(float width)
@ GPU_BLEND_ADDITIVE_PREMULT
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float radius, int nsegments)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
VecBase< int32_t, 2 > int2
void immUniform1f(const char *name, float x)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void immVertex2f(uint attr_id, float x, float y)
static void wm_gesture_draw_line_active_side(const rcti *rect, const bool flip)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void GPU_viewport_size_get_f(float coords[4])
BMesh const char void * data
void BLI_bitmap_draw_2d_poly_v2i_n(int xmin, int ymin, int xmax, int ymax, Span< int2 > verts, void(*callback)(int x, int x_end, int y, void *), void *user_data)
@ GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR
@ GPU_SHADER_3D_SMOOTH_COLOR
@ GPU_SHADER_3D_UNIFORM_COLOR
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
static void draw_filled_lasso(wmGesture *gt, const int2 *lasso_pt_extra)
void GPU_shader_uniform_float_ex(gpu::Shader *shader, int location, int length, int array_size, const float *value)
void BLI_rcti_translate(struct rcti *rect, int x, int y)
void immUniformColor4f(float r, float g, float b, float a)
static void draw_filled_lasso_px_cb(int x, int x_end, int y, void *user_data)
static void draw_lasso_smooth_stroke_indicator(wmGesture *gt, const uint shdr_pos)
void wm_gesture_tag_redraw(wmWindow *win)
bool BLI_rcti_is_empty(const struct rcti *rect)
void WM_gesture_end(wmWindow *win, wmGesture *gesture)
MINLINE float smoothstep(float edge0, float edge1, float x)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
static void wm_gesture_draw_polyline(wmGesture *gt)
int GPU_shader_get_uniform(gpu::Shader *shader, const char *name)
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
void immUniform4f(const char *name, float x, float y, float z, float w)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void imm_draw_box_wire_2d(uint pos, float x1, float y1, float x2, float y2)
int2 WM_window_native_pixel_size(const wmWindow *win)
MINLINE float len_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
void WM_gestures_remove(wmWindow *win)
MINLINE float interpf(float target, float origin, float t)
void GPU_blend(GPUBlend blend)
void immUniform1i(const char *name, int x)
VecBase< float, 3 > float3
bool WM_gesture_is_modal_first(const wmGesture *gesture)
static void wm_gesture_draw_circle(wmGesture *gt)
void imm_draw_circle_fill_2d(uint shdr_pos, float x, float y, float radius, int nsegments)
bScreen * WM_window_get_active_screen(const wmWindow *win)
void WM_generic_user_data_free(wmGenericUserData *wm_userdata)
void wm_gesture_draw(wmWindow *win)
void immRectf(uint pos, float x1, float y1, float x2, float y2)
void BLI_lasso_boundbox(rcti *rect, Span< int2 > mcoords)
static void wm_gesture_draw_line(wmGesture *gt)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
ListBaseT< wmGesture > gesture
bke::WindowRuntime * runtime