57 #include "../gizmo_library_intern.h"
59 #define GIZMO_MARGIN_OFFSET_SCALE 1.5f
63 float matrix_final_no_offset[4][4];
64 float asp[2] = {1.0f, 1.0f};
65 if (dims[0] > dims[1]) {
66 asp[0] = dims[1] / dims[0];
69 asp[1] = dims[0] / dims[1];
71 float x_axis[3], y_axis[3];
79 float len_x_axis =
len_v3(x_axis);
80 float len_y_axis =
len_v3(y_axis);
82 if (len_x_axis == 0.0f || len_y_axis == 0.0f) {
86 scale[0] = 1.0f / len_x_axis;
87 scale[1] = 1.0f / len_y_axis;
101 margin[0] = ((handle_size * scale_xy[0]));
102 margin[1] = ((handle_size * scale_xy[1]));
110 bool x =
true,
y =
true;
155 r_constrain_axis[0] =
x;
156 r_constrain_axis[1] =
y;
166 const float margin[2],
167 const float color[3],
168 const float line_width)
209 const int highlighted,
211 const float margin[2],
212 const float line_width,
214 const int draw_options)
221 switch (highlighted) {
225 .xmax = -
size[0] + margin[0],
226 .ymin = -
size[1] + margin[1],
227 .ymax =
size[1] - margin[1],
245 .xmin =
size[0] - margin[0],
247 .ymin = -
size[1] + margin[1],
248 .ymax =
size[1] - margin[1],
266 .xmin = -
size[0] + margin[0],
267 .xmax =
size[0] - margin[0],
269 .ymax = -
size[1] + margin[1],
287 .xmin = -
size[0] + margin[0],
288 .xmax =
size[0] - margin[0],
289 .ymin =
size[1] - margin[1],
309 .xmax = -
size[0] + margin[0],
311 .ymax = -
size[1] + margin[1],
330 .xmax = -
size[0] + margin[0],
331 .ymin =
size[1] - margin[1],
350 .xmin =
size[0] - margin[0],
353 .ymax = -
size[1] + margin[1],
371 .xmin =
size[0] - margin[0],
373 .ymin =
size[1] - margin[1],
391 const float rotate_pt[2] = {0.0f,
size[1] + margin[1]};
392 const rctf r_rotate = {
393 .
xmin = rotate_pt[0] - margin[0] / 2.0f,
394 .xmax = rotate_pt[0] + margin[0] / 2.0f,
395 .ymin = rotate_pt[1] - margin[1] / 2.0f,
396 .ymax = rotate_pt[1] + margin[1] / 2.0f,
464 for (
uint i = 0; i < verts_len; i++) {
476 immUniform1f(
"lineWidth", (line_width * 3.0f) *
U.pixelsize);
480 for (
uint i = 0; i < verts_len; i++) {
489 for (
uint i = 0; i < verts_len; i++) {
508 uint pos,
float x,
float y,
float rad_x,
float rad_y,
bool solid)
519 const float margin[2],
520 const float color[3],
521 const int transform_flag,
522 const int draw_options,
523 const float line_width)
551 const float rad[2] = {margin[0] / 2, margin[1] / 2};
567 const float margin[2],
568 const float color[3],
569 const int transform_flag,
576 const int resolu = 12;
577 const float rad[2] = {margin[0] / 3, margin[1] / 3};
591 const float handle[2] = {
595 circle_fn(
pos, handle[0], handle[1], rad[0], rad[1], resolu);
605 const bool highlight,
611 float matrix_final[4][4];
617 const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f};
641 const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2};
644 int scale_parts[] = {
655 for (
int i = 0; i <
ARRAY_SIZE(scale_parts); i++) {
679 .xmin = -size_real[0],
680 .ymin = -size_real[1],
681 .xmax = size_real[0],
682 .ymax = size_real[1],
685 float color[4], black[3] = {0, 0, 0};
722 float color[4], black[3] = {0, 0, 0};
727 float outline_line_width = gz->
line_width + 3.0f;
767 switch (highlight_part) {
793 float point_local[2];
796 const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f};
809 const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2};
817 r.xmin = -margin[0] / 2;
818 r.ymin = -margin[1] / 2;
819 r.xmax = margin[0] / 2;
820 r.ymax = margin[1] / 2;
823 r.xmin = -
size[0] + margin[0];
824 r.ymin = -
size[1] + margin[1];
825 r.xmax =
size[0] - margin[0];
826 r.ymax =
size[1] - margin[1];
837 const rctf r_xmin = {
840 .xmax = -
size[0] + margin[0],
843 const rctf r_xmax = {
849 const rctf r_ymin = {
853 .ymax = -
size[1] + margin[1],
855 const rctf r_ymax = {
857 .ymin =
size[1] - margin[1],
895 const rctf r_rotate = {
896 .
xmin = r_rotate_pt[0] - margin[0] / 2.0f,
897 .xmax = r_rotate_pt[0] + margin[0] / 2.0f,
898 .ymin = r_rotate_pt[1] - margin[1] / 2.0f,
899 .ymax = r_rotate_pt[1] + margin[1] / 2.0f,
931 C, gz, (
const float[2]){
UNPACK2(event->
mval)}, 2,
false,
data->orig_mouse) == 0) {
957 float point_local[2];
963 float matrix_back[4][4];
968 C, gz, (
const float[2]){
UNPACK2(event->
mval)}, 2,
false, point_local);
987 (point_local[0] -
data->orig_mouse[0]);
989 (point_local[1] -
data->orig_mouse[1]);
993 #define MUL_V2_V3_M4_FINAL(test_co, mouse_co) \
995 test_co, data->orig_matrix_final_no_offset, ((const float[3]){UNPACK2(mouse_co), 0.0}))
1012 float matrix_space_inv[4][4];
1013 float matrix_rotate[4][4];
1021 mul_m4_m4m4(matrix_rotate, matrix_rotate, matrix_space_inv);
1030 #undef MUL_V2_V3_M4_FINAL
1036 bool constrain_axis[2] = {
false};
1046 float delta_orig[2], delta_curr[2];
1047 for (
int i = 0; i < 2; i++) {
1048 delta_orig[i] = ((
data->orig_mouse[i] -
data->orig_matrix_offset[3][i]) / dims[i]) -
1050 delta_curr[i] = ((point_local[i] -
data->orig_matrix_offset[3][i]) / dims[i]) - pivot[i];
1053 float scale[2] = {1.0f, 1.0f};
1054 for (
int i = 0; i < 2; i++) {
1055 if (constrain_axis[i] ==
false) {
1056 if (delta_orig[i] < 0.0f) {
1057 delta_orig[i] *= -1.0f;
1058 delta_curr[i] *= -1.0f;
1062 scale[i] = 1.0f + ((delta_curr[i] - delta_orig[i]) /
len_v3(
data->orig_matrix_offset[i]));
1073 if (constrain_axis[0] ==
false && constrain_axis[1] ==
false) {
1074 scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f;
1076 else if (constrain_axis[0] ==
false) {
1077 scale[1] = scale[0];
1079 else if (constrain_axis[1] ==
false) {
1080 scale[0] = scale[1];
1088 float matrix_scale[4][4];
1095 (
const float[3]){pivot[0] * dims[0], pivot[1] * dims[1], 0.0f});
1153 gzt->
idname =
"GIZMO_GT_cage_2d";
1183 "XFORM_CENTER_HANDLE",
1189 static float unit_v2[2] = {1.0f, 1.0f};
1191 gzt->
srna,
"dimensions", 2, unit_v2, 0, FLT_MAX,
"Dimensions",
"", 0.0f, FLT_MAX);
1195 rna_enum_draw_style,
1201 rna_enum_draw_options,
typedef float(TangentPoint)[2]
struct ARegion * CTX_wm_region(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
Dial * BLI_dial_init(const float start_position[2], float threshold)
float BLI_dial_angle(Dial *dial, const float current_position[2])
MINLINE int signum_i(float a)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void unit_m4(float m[4][4])
bool invert_m4_m4(float R[4][4], const float A[4][4])
void transform_pivot_set_m4(float mat[4][4], const float pivot[3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void mul_v3_mat3_m4v3(float r[3], const float M[4][4], const float v[3])
void rotate_m4(float mat[4][4], const char axis, const float angle)
MINLINE void mul_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 zero_v2(float r[2])
MINLINE void zero_v3(float r[3])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
bool BLI_rctf_isect_pt_v(const struct rctf *rect, const float xy[2])
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
#define ARRAY_SET_ITEMS(...)
@ ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y
@ ED_GIZMO_CAGE2D_PART_TRANSLATE
@ ED_GIZMO_CAGE2D_PART_ROTATE
@ ED_GIZMO_CAGE2D_PART_SCALE_MAX_Y
@ ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MAX_Y
@ ED_GIZMO_CAGE2D_PART_SCALE_MIN_X
@ ED_GIZMO_CAGE2D_PART_SCALE_MAX_X_MIN_Y
@ ED_GIZMO_CAGE2D_PART_SCALE_MAX_X
@ ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MIN_Y
@ ED_GIZMO_CAGE2D_PART_SCALE_MIN_Y
@ ED_GIZMO_CAGE2D_STYLE_BOX
@ ED_GIZMO_CAGE2D_STYLE_CIRCLE
@ ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE
@ ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE
@ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_SIGNED
@ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE
@ ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE
@ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM
void ED_region_tag_redraw_editor_overlays(struct ARegion *region)
NSNotificationCenter * center
_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 GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_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
void GPU_matrix_pop(void)
#define GPU_matrix_mul(x)
void GPU_matrix_push(void)
bool GPU_select_load_id(unsigned int id)
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
@ GPU_SHADER_2D_UNIFORM_COLOR
@ GPU_SHADER_3D_POLYLINE_FLAT_COLOR
@ GPU_SHADER_2D_FLAT_COLOR
void GPU_blend(eGPUBlend blend)
void GPU_viewport_size_get_f(float coords[4])
Read Guarded memory(de)allocation.
eWM_GizmoFlagTweak
Gizmo tweak flag. Bitflag passed to gizmo while tweaking.
@ WM_GIZMO_STATE_HIGHLIGHT
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
static void GIZMO_GT_cage_2d(wmGizmoType *gzt)
#define GIZMO_MARGIN_OFFSET_SCALE
static bool gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[2], float scale[2])
static int gizmo_cage2d_get_cursor(wmGizmo *gz)
static void cage2d_draw_box_interaction(const float color[4], const int highlighted, const float size[2], const float margin[2], const float line_width, const bool is_solid, const int draw_options)
static void cage2d_draw_box_corners(const rctf *r, const float margin[2], const float color[3], const float line_width)
static void cage2d_draw_circle_wire(const rctf *r, const float margin[2], const float color[3], const int transform_flag, const int draw_options, const float line_width)
static int gizmo_cage2d_modal(bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak UNUSED(tweak_flag))
static void gizmo_cage2d_draw(const bContext *UNUSED(C), wmGizmo *gz)
struct RectTransformInteraction RectTransformInteraction
static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[2], bool r_constrain_axis[2])
static int gizmo_cage2d_test_select(bContext *C, wmGizmo *gz, const int mval[2])
static void imm_draw_point_aspect_2d(uint pos, float x, float y, float rad_x, float rad_y, bool solid)
static int gizmo_cage2d_invoke(bContext *C, wmGizmo *gz, const wmEvent *event)
#define MUL_V2_V3_M4_FINAL(test_co, mouse_co)
static void gizmo_cage2d_setup(wmGizmo *gz)
static void gizmo_cage2d_exit(bContext *C, wmGizmo *gz, const bool cancel)
static void gizmo_cage2d_draw_select(const bContext *UNUSED(C), wmGizmo *gz, int select_id)
void ED_gizmotypes_cage_2d(void)
static void gizmo_cage2d_draw_intern(wmGizmo *gz, const bool select, const bool highlight, const int select_id)
static bool gizmo_calc_rect_view_margin(const wmGizmo *gz, const float dims[2], float margin[2])
static void cage2d_draw_circle_handles(const rctf *r, const float margin[2], const float color[3], const int transform_flag, bool solid)
static void gizmo_cage2d_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop)
bool gizmo_window_project_2d(bContext *C, const struct wmGizmo *gz, const float mval[2], int axis, bool use_offset, float r_co[2])
void gizmo_color_get(const struct wmGizmo *gz, const bool highlight, float r_color[4])
struct @612::@615 attr_id
void *(* MEM_callocN)(size_t len, const char *str)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
eWM_GizmoFlagGroupTypeFlag flag
struct wmGizmoGroupType * type
const struct wmGizmoPropertyType * type
wmGizmoFnTestSelect test_select
wmGizmoFnCursorGet cursor_get
wmGizmoFnDrawSelect draw_select
wmGizmoFnPropertyUpdate property_update
struct wmGizmoGroup * parent_gzgroup
float matrix_offset[4][4]
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
void WM_event_add_mousemove(wmWindow *win)
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
void WM_gizmo_calc_matrix_final_no_offset(const wmGizmo *gz, float r_mat[4][4])
wmGizmoProperty * WM_gizmo_target_property_find(wmGizmo *gz, const char *idname)
void WM_gizmo_target_property_float_get_array(const wmGizmo *gz, wmGizmoProperty *gz_prop, float *value)
void WM_gizmotype_target_property_def(wmGizmoType *gzt, const char *idname, int data_type, int array_length)
void WM_gizmo_target_property_float_set_array(bContext *C, const wmGizmo *gz, wmGizmoProperty *gz_prop, const float *value)
int WM_gizmo_target_property_array_length(const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop)
void WM_gizmotype_append(void(*gtfunc)(struct wmGizmoType *))