45#define GIZMO_MARGIN_OFFSET_SCALE 1.5f
47#define CIRCLE_RESOL 32
53 float matrix_final_no_offset[4][4];
54 float asp[2] = {1.0f, 1.0f};
55 if (dims[0] > dims[1]) {
56 asp[0] = dims[1] / dims[0];
59 asp[1] = dims[0] / dims[1];
61 float x_axis[3], y_axis[3];
69 float len_x_axis =
len_v3(x_axis);
70 float len_y_axis =
len_v3(y_axis);
85 margin[0] = (handle_size * scale_xy[0]);
86 margin[1] = (handle_size * scale_xy[1]);
96 const float margin[2],
98 const float line_width)
140 const int highlighted,
142 const float margin[2],
143 const float line_width,
145 const int draw_options)
152 switch (highlighted) {
156 r.
xmax = -size[0] + margin[0];
157 r.
ymin = -size[1] + margin[1];
158 r.
ymax = size[1] - margin[1];
176 r.
xmin = size[0] - margin[0];
178 r.
ymin = -size[1] + margin[1];
179 r.
ymax = size[1] - margin[1];
197 r.
xmin = -size[0] + margin[0];
198 r.
xmax = size[0] - margin[0];
200 r.
ymax = -size[1] + margin[1];
218 r.
xmin = -size[0] + margin[0];
219 r.
xmax = size[0] - margin[0];
220 r.
ymin = size[1] - margin[1];
240 r.
xmax = -size[0] + margin[0];
242 r.
ymax = -size[1] + margin[1];
261 r.
xmax = -size[0] + margin[0];
262 r.
ymin = size[1] - margin[1];
281 r.
xmin = size[0] - margin[0];
284 r.
ymax = -size[1] + margin[1];
302 r.
xmin = size[0] - margin[0];
304 r.
ymin = size[1] - margin[1];
322 const float rotate_pt[2] = {0.0f, size[1] + margin[1]};
324 r_rotate.
xmin = rotate_pt[0] - margin[0] / 2.0f;
325 r_rotate.xmax = rotate_pt[0] + margin[0] / 2.0f;
326 r_rotate.ymin = rotate_pt[1] - margin[1] / 2.0f;
327 r_rotate.ymax = rotate_pt[1] + margin[1] / 2.0f;
392 if (margin[0] == 0.0f && margin[1] == 0.0) {
395 else if (margin[0] == 0.0f || margin[1] == 0.0) {
404 for (
uint i = 0; i < verts_len; i++) {
416 immUniform1f(
"lineWidth", (line_width * 3.0f) *
U.pixelsize);
420 for (
uint i = 0; i < verts_len; i++) {
429 for (
uint i = 0; i < verts_len; i++) {
448 uint pos,
float x,
float y,
float rad_x,
float rad_y,
bool solid)
450 if (rad_x == 0 && rad_y == 0) {
457 if (rad_x == 0 || rad_y == 0) {
494 const float margin[2],
495 const float color[3],
496 const int transform_flag,
497 const int draw_options,
498 const float line_width)
539 const float rad[2] = {margin[0] / 2, margin[1] / 2};
556 const float margin[2],
557 const float line_width)
585 const int highlighted,
586 const float margin[2],
587 const float color[3],
588 const int transform_flag,
602 const int resolu = 12;
603 const float rad[2] = {margin[0] / 3, margin[1] / 3};
617 const float handle[2] = {
621 circle_fn(
pos, handle[0], handle[1], rad[0], rad[1], resolu);
628 const int highlighted,
630 const float margin[2],
631 const float color[3],
639 switch (highlighted) {
642 const float rad[2] = {0.2f * margin[0], 0.4f * size[1]};
649 const float rad[2] = {0.4f * size[0], 0.2f * margin[1]};
663 const bool highlight,
669 float matrix_final[4][4];
675 const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f};
699 const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2};
708 int scale_parts[] = {
719 for (
int i = 0; i <
ARRAY_SIZE(scale_parts); i++) {
722 gz->
color, scale_parts[i], size, margin, gz->
line_width,
true, draw_options);
729 gz->
color, transform_part, size, margin, gz->
line_width,
true, draw_options);
744 r.
xmin = -size_real[0];
745 r.
ymin = -size_real[1];
746 r.
xmax = size_real[0];
747 r.
ymax = size_real[1];
750 float color[4], black[3] = {0, 0, 0};
787 float color[4], black[3] = {0, 0, 0};
792 float outline_line_width = gz->
line_width + 3.0f;
844 switch (highlight_part) {
870 float point_local[2];
873 const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f};
885 const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2};
893 r.
xmin = -margin[0] / 2;
894 r.
ymin = -margin[1] / 2;
895 r.
xmax = margin[0] / 2;
896 r.
ymax = margin[1] / 2;
899 r.
xmin = -size[0] + margin[0];
900 r.
ymin = -size[1] + margin[1];
901 r.
xmax = size[0] - margin[0];
902 r.
ymax = size[1] - margin[1];
913 r_xmin.
xmin = -size[0];
914 r_xmin.ymin = -size[1];
915 r_xmin.xmax = -size[0] + margin[0];
916 r_xmin.ymax = size[1];
919 r_xmax.
xmin = size[0] - margin[0];
920 r_xmax.ymin = -size[1];
921 r_xmax.xmax = size[0];
922 r_xmax.ymax = size[1];
925 r_ymin.
xmin = -size[0];
926 r_ymin.ymin = -size[1];
927 r_ymin.xmax = size[0];
928 r_ymin.ymax = -size[1] + margin[1];
931 r_ymax.
xmin = -size[0];
932 r_ymax.ymin = size[1] - margin[1];
933 r_ymax.xmax = size[0];
934 r_ymax.ymax = size[1];
970 r_rotate.
xmin = r_rotate_pt[0] - margin[0] / 2.0f;
971 r_rotate.xmax = r_rotate_pt[0] + margin[0] / 2.0f;
972 r_rotate.ymin = r_rotate_pt[1] - margin[1] / 2.0f;
973 r_rotate.ymax = r_rotate_pt[1] + margin[1] / 2.0f;
996 if (data->use_temp_uniform) {
1000 return transform_flag;
1093 const bool use_temp_uniform = (
event->modifier &
KM_SHIFT) != 0;
1094 const bool changed = data->use_temp_uniform != use_temp_uniform;
1095 data->use_temp_uniform = use_temp_uniform;
1096 if (use_temp_uniform) {
1108 float point_local[2];
1114 float matrix_back[4][4];
1131 if (gz_prop->
type !=
nullptr) {
1139 (point_local[0] - data->orig_mouse[0]);
1141 (point_local[1] - data->orig_mouse[1]);
1145#define MUL_V2_V3_M4_FINAL(test_co, mouse_co) \
1146 mul_v3_m4v3(test_co, data->orig_matrix_final_no_offset, blender::float3{UNPACK2(mouse_co), 0.0})
1150 if (data->dial ==
nullptr) {
1163 float matrix_space_inv[4][4];
1164 float matrix_rotate[4][4];
1167 copy_v3_v3(pivot, data->orig_matrix_offset[3]);
1172 mul_m4_m4m4(matrix_rotate, matrix_rotate, matrix_space_inv);
1181#undef MUL_V2_V3_M4_FINAL
1197 bool constrain_axis[2] = {
false};
1200 float size_new[2], size_orig[2];
1201 for (
int i = 0; i < 2; i++) {
1202 size_orig[i] =
len_v3(data->orig_matrix_offset[i]);
1203 size_new[i] = size_orig[i];
1204 if (constrain_axis[i] ==
false) {
1206 const float delta_orig = data->orig_mouse[i] - data->orig_matrix_offset[3][i] -
1207 pivot[i] * size_orig[i];
1208 const float delta_curr = point_local[i] - data->orig_matrix_offset[3][i] -
1209 pivot[i] * size_orig[i];
1219 size_new[i] = delta_curr / (
signf(delta_orig) * 0.5f * dims[i] - pivot[i]);
1223 float scale[2] = {1.0f, 1.0f};
1224 for (
int i = 0; i < 2; i++) {
1225 if (size_orig[i] == 0) {
1226 size_orig[i] = 1.0f;
1229 scale[i] = size_new[i] / size_orig[i];
1233 if (constrain_axis[0] ==
false && constrain_axis[1] ==
false) {
1236 scale[1] = scale[0] =
len_v2(scale);
1239 scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f;
1242 else if (constrain_axis[0] ==
false) {
1243 scale[1] = scale[0];
1245 else if (constrain_axis[1] ==
false) {
1246 scale[0] = scale[1];
1254 float matrix_scale[4][4];
1264 if (gz_prop->
type !=
nullptr) {
1304 if (gz_prop->
type !=
nullptr) {
1318 gzt->
idname =
"GIZMO_GT_cage_2d";
1338 {0,
nullptr, 0,
nullptr,
nullptr},
1345 {0,
nullptr, 0,
nullptr,
nullptr},
1349 {0,
nullptr, 0,
nullptr,
nullptr},
1351 static const float unit_v2[2] = {1.0f, 1.0f};
1357 rna_enum_draw_style,
1363 rna_enum_draw_options,
wmWindow * CTX_wm_window(const bContext *C)
ARegion * CTX_wm_region(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 float signf(float f)
MINLINE int signum_i(float a)
MINLINE float safe_divide(float a, float b)
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])
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])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void rotate_m4(float mat[4][4], char axis, float angle)
void mul_m4_m4_post(float R[4][4], const float B[4][4])
void mul_v3_mat3_m4v3(float r[3], const float mat[4][4], const float vec[3])
MINLINE float len_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE bool is_zero_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
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_CAGE_DRAW_FLAG_XFORM_CENTER_HANDLE
@ ED_GIZMO_CAGE2D_STYLE_BOX_TRANSFORM
@ ED_GIZMO_CAGE2D_STYLE_BOX
@ ED_GIZMO_CAGE2D_STYLE_CIRCLE
@ ED_GIZMO_CAGE2D_PART_SCALE_MIN_X_MAX_Y
@ ED_GIZMO_CAGE2D_PART_TRANSLATE
@ ED_GIZMO_CAGE2D_PART_ROTATE
@ ED_GIZMO_CAGE2D_PART_SCALE
@ 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_CAGE_XFORM_FLAG_SCALE
@ ED_GIZMO_CAGE_XFORM_FLAG_TRANSLATE
@ ED_GIZMO_CAGE_XFORM_FLAG_ROTATE
@ ED_GIZMO_CAGE_XFORM_FLAG_SCALE_UNIFORM
@ ED_GIZMO_CAGE_XFORM_FLAG_SCALE_SIGNED
void ED_region_tag_redraw_editor_overlays(ARegion *region)
#define GPU_matrix_mul(x)
bool GPU_select_load_id(unsigned int id)
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
@ GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA
@ GPU_SHADER_3D_UNIFORM_COLOR
@ GPU_SHADER_3D_FLAT_COLOR
@ GPU_SHADER_3D_POLYLINE_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. Bit-flag passed to gizmo while tweaking.
@ WM_GIZMO_STATE_HIGHLIGHT
void ED_gizmotypes_cage_2d()
static void gizmo_constrain_from_scale_part(int part, bool r_constrain_axis[2])
static void GIZMO_GT_cage_2d(wmGizmoType *gzt)
#define GIZMO_MARGIN_OFFSET_SCALE
static void cage2d_draw_rect_edge_handles(const rctf *r, const int highlighted, const float size[2], const float margin[2], const float color[3], bool solid)
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_rect_corner_handles(const rctf *r, const int highlighted, const float margin[2], const float color[3], const int transform_flag, bool solid)
static void cage2d_draw_box_corners(const rctf *r, const float margin[2], const float color[3], const float line_width)
static void gizmo_calc_rect_view_margin(const wmGizmo *gz, const float dims[2], float margin[2])
static int gizmo_cage2d_modal(bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak)
static void cage2d_draw_rect_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 void gizmo_pivot_from_scale_part(int part, float r_pt[2])
static void gizmo_cage2d_draw(const bContext *, wmGizmo *gz)
static int gizmo_cage2d_test_select(bContext *C, wmGizmo *gz, const int mval[2])
static void cage2d_draw_circle_wire(const float color[3], const float size[2], const float margin[2], const float line_width)
static void gizmo_cage2d_draw_select(const bContext *, wmGizmo *gz, int select_id)
static void gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[2], float scale[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_intern(wmGizmo *gz, const bool select, const bool highlight, const int select_id)
static int gizmo_cage2d_transform_flag_get(const wmGizmo *gz)
static void gizmo_cage2d_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop)
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void gizmo_color_get(const wmGizmo *gz, bool highlight, float r_color[4])
bool gizmo_window_project_2d(bContext *C, const wmGizmo *gz, const float mval[2], int axis, bool use_offset, float r_co[2])
struct @620::@623 attr_id
void *(* MEM_callocN)(size_t len, const char *str)
ccl_device_inline float4 select(const int4 mask, const float4 a, const float4 b)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
eWM_GizmoFlagGroupTypeFlag flag
const wmGizmoPropertyType * type
wmGizmoFnTestSelect test_select
wmGizmoFnCursorGet cursor_get
wmGizmoFnDrawSelect draw_select
wmGizmoFnPropertyUpdate property_update
wmGizmoGroup * parent_gzgroup
float matrix_offset[4][4]
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])
void WM_gizmo_target_property_float_get_array(const wmGizmo *gz, wmGizmoProperty *gz_prop, float *value)
int WM_gizmo_target_property_array_length(const wmGizmo *, wmGizmoProperty *gz_prop)
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)
wmGizmoProperty * WM_gizmo_target_property_find(wmGizmo *gz, const char *idname)
void WM_gizmotype_append(void(*gtfunc)(wmGizmoType *))