52 gesture->
move =
false;
91 gesture->
mval.x = border[0];
92 gesture->
mval.y = border[1];
123 if (gesture ==
nullptr) {
142 float gradient_dir[2];
143 float gradient_point[2][2];
145 const float line_start[2] = {float(rect->
xmin), float(rect->
ymin)};
146 const float line_end[2] = {float(rect->
xmax), float(rect->
ymax)};
147 const float color_line_gradient_start[4] = {0.2f, 0.2f, 0.2f, 0.4f};
148 const float color_line_gradient_end[4] = {0.0f, 0.0f, 0.0f, 0.0f};
156 mul_v2_fl(gradient_dir, gradient_length);
157 add_v2_v2v2(gradient_point[0], line_start, gradient_dir);
158 add_v2_v2v2(gradient_point[1], line_end, gradient_dir);
162 immVertex2f(shdr_pos, line_start[0], line_start[1]);
166 immVertex2f(shdr_pos, gradient_point[1][0], gradient_point[1][1]);
169 immVertex2f(shdr_pos, line_start[0], line_start[1]);
171 immVertex2f(shdr_pos, gradient_point[1][0], gradient_point[1][1]);
173 immVertex2f(shdr_pos, gradient_point[0][0], gradient_point[0][1]);
193 float viewport_size[4];
195 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
203 float xmin = float(rect->
xmin);
204 float ymin = float(rect->
ymin);
236 float viewport_size[4];
238 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
247 shdr_pos,
float(rect->
xmin),
float(rect->
ymin),
float(rect->
xmax),
float(rect->
ymax));
275 float viewport_size[4];
277 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
299 memset(
col, 0x10, x_end -
x);
304 const int mcoords_len = gt->
points + (lasso_pt_extra ? 1 : 0);
308 const float red[4] = {1.0f, 0.0f, 0.0f, 0.0f};
311 const short *lasso =
static_cast<const short *
>(gt->
customdata);
312 for (
i = 0;
i < mcoords_len;
i++, lasso += 2) {
313 mcoords[
i][0] = lasso[0];
314 mcoords[
i][1] = lasso[1];
318 const float *lasso =
static_cast<const float *
>(gt->
customdata);
319 for (
i = 0;
i < mcoords_len;
i++, lasso += 2) {
320 mcoords[
i][0] = lasso[0];
321 mcoords[
i][1] = lasso[1];
325 if (lasso_pt_extra) {
326 mcoords[mcoords_len - 1][0] = lasso_pt_extra->x;
327 mcoords[mcoords_len - 1][1] = lasso_pt_extra->y;
359 &
state, rect.
xmin, rect.
ymin,
w, h,
GPU_R8,
false, pixel_buf, 1.0f, 1.0f,
nullptr);
373 float(*lasso)[2] =
static_cast<float(*)[2]
>(gt->
customdata);
374 float last_x = lasso[gt->
points - 1][0];
375 float last_y = lasso[gt->
points - 1][1];
382 const float color[3] = {1.0f, 0.39f, 0.39f};
384 const float radius = 4.0f;
417 const int numverts = gt->
points;
429 float viewport_size[4];
431 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
441 for (
i = 0;
i < gt->
points;
i++, lasso += 2) {
455 const int numverts = gt.
points;
458 const short(*border)[2] =
static_cast<short int(*)[2]
>(gt.
customdata);
460 const float start_pos[2] = {float(border[0][0]), float(border[0][1])};
461 const float current_pos[2] = {float(gt.
mval.x), float(gt.
mval.y)};
463 const float dist =
len_v2v2(start_pos, current_pos);
466 if (dist < limit && numverts > 2) {
467 const float u =
smoothstep(0.0f, limit, dist);
489 const int numverts = gt->
points + 1;
499 float viewport_size[4];
501 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
511 const short *border = (
short *)gt->
customdata;
512 for (
int i = 0;
i < gt->
points;
i++, border += 2) {
513 immVertex2f(shdr_pos,
float(border[0]),
float(border[1]));
529 float x1, x2, y1, y2;
536 float viewport_size[4];
538 immUniform2f(
"viewport_size", viewport_size[2], viewport_size[3]);
548 x1 = float(rect->
xmin - win_size[0]);
549 y1 = float(rect->
ymin);
550 x2 = float(rect->
xmin + win_size[0]);
556 x1 = float(rect->
xmin);
557 y1 = float(rect->
ymin - win_size[1]);
559 y2 = float(rect->
ymin + win_size[1]);
574 for (; gt; gt = gt->
next) {
void immDrawPixelsTexTiled(IMMDrawPixelsTexState *state, float x, float y, int img_w, int img_h, eGPUTextureFormat gpu_format, bool use_filter, const void *rect, float xzoom, float yzoom, const float color[4])
IMMDrawPixelsTexState immDrawPixelsTexSetup(int builtin)
void BLI_bitmap_draw_2d_poly_v2i_n(int xmin, int ymin, int xmax, int ymax, blender::Span< blender::int2 > verts, void(*callback)(int x, int x_end, int y, void *), void *user_data)
void BLI_lasso_boundbox(rcti *rect, blender::Span< blender::int2 > mcoords)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE float pow2f(float x)
MINLINE float interpf(float target, float origin, float t)
MINLINE float len_v2v2(const float v1[2], const float v2[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void add_v2_v2v2(float r[2], const float a[2], const float b[2])
void ortho_v2_v2(float out[2], const float v[2])
MINLINE void sub_v2_v2v2(float r[2], const float a[2], const float b[2])
MINLINE float normalize_v2(float n[2])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
void BLI_rcti_translate(struct rcti *rect, int x, int y)
bool BLI_rcti_isect(const struct rcti *src1, const struct rcti *src2, struct rcti *dest)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
bool BLI_rcti_is_empty(const struct rcti *rect)
int GPU_shader_get_uniform(GPUShader *shader, const char *name)
void GPU_shader_bind(GPUShader *shader, const blender::gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_shader_uniform_float_ex(GPUShader *shader, int location, int length, int array_size, const float *value)
@ GPU_SHADER_3D_SMOOTH_COLOR
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
@ GPU_SHADER_3D_UNIFORM_COLOR
@ GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR
@ GPU_BLEND_ADDITIVE_PREMULT
void GPU_blend(eGPUBlend blend)
void GPU_line_width(float width)
void GPU_line_smooth(bool enable)
void GPU_viewport_size_get_f(float coords[4])
Read Guarded memory(de)allocation.
#define WM_GESTURE_STRAIGHTLINE
#define WM_GESTURE_CIRCLE
#define WM_GESTURE_CROSS_RECT
#define WM_GESTURE_POLYLINE
BMesh const char void * data
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
MINLINE float smoothstep(float edge0, float edge1, float x)
constexpr float POLYLINE_CLICK_RADIUS
VecBase< int32_t, 2 > int2
VecBase< float, 3 > float3
wmGenericUserData user_data
void WM_event_drag_start_xy(const wmEvent *event, int r_xy[2])
static void wm_gesture_draw_circle(wmGesture *gt)
static void draw_start_vertex_circle(const wmGesture >, const uint shdr_pos)
static void wm_gesture_draw_polyline(wmGesture *gt)
static void draw_filled_lasso_px_cb(int x, int x_end, int y, void *user_data)
static void wm_gesture_draw_cross(const wmWindow *win, const wmGesture *gt)
wmGesture * WM_gesture_new(wmWindow *window, const ARegion *region, const wmEvent *event, int type)
void wm_gesture_draw(wmWindow *win)
static void wm_gesture_draw_rect(wmGesture *gt)
void wm_gesture_tag_redraw(wmWindow *win)
static void wm_gesture_draw_lasso(wmGesture *gt, bool filled)
static void draw_lasso_smooth_stroke_indicator(wmGesture *gt, const uint shdr_pos)
static void wm_gesture_draw_line(wmGesture *gt)
static void draw_filled_lasso(wmGesture *gt, const blender::int2 *lasso_pt_extra)
bool WM_gesture_is_modal_first(const wmGesture *gesture)
void WM_gestures_free_all(wmWindow *win)
void WM_gesture_end(wmWindow *win, wmGesture *gesture)
void WM_gestures_remove(wmWindow *win)
static void wm_gesture_draw_line_active_side(const rcti *rect, const bool flip)
void wmViewport(const rcti *winrct)
void WM_generic_user_data_free(wmGenericUserData *wm_userdata)
blender::int2 WM_window_native_pixel_size(const wmWindow *win)
bScreen * WM_window_get_active_screen(const wmWindow *win)