46#define GIZMO_MARGIN_OFFSET_SCALE 1.5f
48#define CIRCLE_RESOL 32
54 float matrix_final_no_offset[4][4];
55 float x_axis[3], y_axis[3];
60 float len_x_axis =
len_v3(x_axis);
61 float len_y_axis =
len_v3(y_axis);
76 margin[0] = (handle_size * scale_xy[0]);
77 margin[1] = (handle_size * scale_xy[1]);
87 const float margin[2],
89 const float line_width)
132 const int highlighted,
134 const float margin[2],
135 const float line_width,
137 const int draw_options)
144 switch (highlighted) {
314 const float rotate_pt[2] = {0.0f,
size[1] + margin[1]};
316 r_rotate.
xmin = rotate_pt[0] - margin[0] / 2.0f;
317 r_rotate.
xmax = rotate_pt[0] + margin[0] / 2.0f;
318 r_rotate.
ymin = rotate_pt[1] - margin[1] / 2.0f;
319 r_rotate.
ymax = rotate_pt[1] + margin[1] / 2.0f;
379 format,
"color", blender::gpu::VertAttrType::SFLOAT_32_32_32);
385 if (margin[0] == 0.0f && margin[1] == 0.0) {
388 else if (margin[0] == 0.0f || margin[1] == 0.0) {
397 for (
uint i = 0;
i < verts_len;
i++) {
409 immUniform1f(
"lineWidth", (line_width * 3.0f) *
U.pixelsize);
413 for (
uint i = 0;
i < verts_len;
i++) {
422 for (
uint i = 0;
i < verts_len;
i++) {
441 uint pos,
float x,
float y,
float rad_x,
float rad_y,
bool solid)
443 if (rad_x == 0 && rad_y == 0) {
450 if (rad_x == 0 || rad_y == 0) {
487 const float margin[2],
488 const float color[3],
489 const int transform_flag,
490 const int draw_options,
491 const float line_width)
496 immVertexFormat(),
"pos", blender::gpu::VertAttrType::SFLOAT_32_32_32);
533 const float rad[2] = {margin[0] / 2, margin[1] / 2};
550 const float margin[2],
551 const int transform_flag,
552 const int draw_options,
553 const float line_width)
556 immVertexFormat(),
"pos", blender::gpu::VertAttrType::SFLOAT_32_32_32);
590 const float rad[2] = {margin[0] / 2, margin[1] / 2};
591 const float center[2] = {0.0f, 0.0f};
607 return ELEM(highlighted,
615 const float margin[2],
616 const float color[3],
624 const int resolu = 12;
625 const float rad[2] = {margin[0] / 3, margin[1] / 3};
630 const float handle[2] = {
634 circle_fn(
pos, handle[0], handle[1], rad[0], rad[1], resolu);
640 const float margin[2],
641 const float color[3],
646 const float rad[2] = {margin[0] / 3, margin[1] / 3};
663 const int highlighted,
665 const float margin[2],
666 const float color[3],
675 switch (highlighted) {
678 const float rad[2] = {0.2f * margin[0], 0.4f *
size[1]};
685 const float rad[2] = {0.4f *
size[0], 0.2f * margin[1]};
699 const bool highlight,
705 float matrix_final[4][4];
711 const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f};
736 const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2};
745 int scale_parts[] = {
781 r.
xmin = -size_real[0];
782 r.
ymin = -size_real[1];
783 r.
xmax = size_real[0];
784 r.
ymax = size_real[1];
787 float color[4], black[3] = {0, 0, 0};
824 float color[4], black[3] = {0, 0, 0};
829 float outline_line_width = gz->
line_width + 3.0f;
853 black, size_real, margin, transform_flag, draw_options, outline_line_width);
855 color, size_real, margin, transform_flag, draw_options, gz->
line_width);
905 switch (highlight_part) {
931 float point_local[2];
934 const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f};
946 const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2};
954 r.
xmin = -margin[0] / 2;
955 r.
ymin = -margin[1] / 2;
956 r.
xmax = margin[0] / 2;
957 r.
ymax = margin[1] / 2;
1041 r_rotate.
xmin = r_rotate_pt[0] - margin[0] / 2.0f;
1042 r_rotate.
xmax = r_rotate_pt[0] + margin[0] / 2.0f;
1043 r_rotate.
ymin = r_rotate_pt[1] - margin[1] / 2.0f;
1044 r_rotate.
ymax = r_rotate_pt[1] + margin[1] / 2.0f;
1056struct RectTransformInteraction {
1057 float orig_mouse[2];
1058 float orig_matrix_offset[4][4];
1059 float orig_matrix_final_no_offset[4][4];
1061 bool use_temp_uniform;
1068 RectTransformInteraction *
data =
static_cast<RectTransformInteraction *
>(gz->
interaction_data);
1071 if (
data->use_temp_uniform) {
1075 return transform_flag;
1162 RectTransformInteraction *
data =
static_cast<RectTransformInteraction *
>(gz->
interaction_data);
1167 const bool use_temp_uniform = (
event->modifier &
KM_SHIFT) != 0;
1168 const bool changed =
data->use_temp_uniform != use_temp_uniform;
1169 data->use_temp_uniform = use_temp_uniform;
1170 if (use_temp_uniform) {
1182 float point_local[2];
1188 float matrix_back[4][4];
1205 if (gz_prop->
type !=
nullptr) {
1213 (point_local[0] -
data->orig_mouse[0]);
1215 (point_local[1] -
data->orig_mouse[1]);
1219#define MUL_V2_V3_M4_FINAL(test_co, mouse_co) \
1220 mul_v3_m4v3(test_co, data->orig_matrix_final_no_offset, blender::float3{UNPACK2(mouse_co), 0.0})
1224 if (
data->dial ==
nullptr) {
1237 float matrix_space_inv[4][4];
1238 float matrix_rotate[4][4];
1246 mul_m4_m4m4(matrix_rotate, matrix_rotate, matrix_space_inv);
1255#undef MUL_V2_V3_M4_FINAL
1271 float curr_mouse[2];
1291 bool constrain_axis[2] = {
false};
1294 float size_new[2], size_orig[2];
1295 for (
int i = 0;
i < 2;
i++) {
1297 size_new[
i] = size_orig[
i];
1298 if (constrain_axis[
i] ==
false) {
1300 const float delta_orig = curr_mouse[
i] -
data->orig_matrix_offset[3][
i] -
1301 pivot[
i] * size_orig[
i];
1302 const float delta_curr = point_local[
i] -
data->orig_matrix_offset[3][
i] -
1303 pivot[
i] * size_orig[
i];
1312 size_new[
i] = delta_curr / (
signf(delta_orig) * 0.5f * dims[
i] - pivot[
i]);
1316 float scale[2] = {1.0f, 1.0f};
1317 for (
int i = 0;
i < 2;
i++) {
1318 if (size_orig[
i] == 0) {
1319 size_orig[
i] = 1.0f;
1322 scale[
i] = size_new[
i] / size_orig[
i];
1326 if (constrain_axis[0] ==
false && constrain_axis[1] ==
false) {
1329 scale[1] = scale[0] =
len_v2(scale);
1332 scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f;
1335 else if (constrain_axis[0] ==
false) {
1336 scale[1] = scale[0];
1338 else if (constrain_axis[1] ==
false) {
1339 scale[0] = scale[1];
1347 float matrix_scale[4][4];
1357 if (gz_prop->
type !=
nullptr) {
1384 RectTransformInteraction *
data =
static_cast<RectTransformInteraction *
>(gz->
interaction_data);
1388 data->dial =
nullptr;
1401 if (gz_prop->
type !=
nullptr) {
1415 gzt->
idname =
"GIZMO_GT_cage_2d";
1435 {0,
nullptr, 0,
nullptr,
nullptr},
1442 {0,
nullptr, 0,
nullptr,
nullptr},
1447 {0,
nullptr, 0,
nullptr,
nullptr},
1449 static const float unit_v2[2] = {1.0f, 1.0f};
1455 rna_enum_draw_style,
1461 rna_enum_draw_options,
ARegion * CTX_wm_region(const bContext *C)
void BLI_dial_free(Dial *dial)
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 mul_m3_v2(const float m[3][3], float r[2])
void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], const float wmat[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])
bool invert_m3(float mat[3][3])
void unit_m4(float m[4][4])
MINLINE float len_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2(float r[2], const float a[2])
MINLINE void mul_v2_v2(float r[2], const float a[2])
MINLINE void copy_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 add_v2_v2(float r[2], const float a[2])
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_is_valid(const struct rctf *rect)
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)
void BLI_rctf_sanitize(struct rctf *rect)
#define ARRAY_SET_ITEMS(...)
@ ED_GIZMO_CAGE_DRAW_FLAG_CORNER_HANDLES
@ ED_GIZMO_CAGE_DRAW_FLAG_XFORM_CENTER_HANDLE
@ 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_CAGE2D_STYLE_BOX_TRANSFORM
@ ED_GIZMO_CAGE2D_STYLE_BOX
@ ED_GIZMO_CAGE2D_STYLE_CIRCLE
@ 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(GPUBlend blend)
void GPU_viewport_size_get_f(float coords[4])
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
Read Guarded memory(de)allocation.
eWM_GizmoFlagTweak
Gizmo tweak flag. Bit-flag passed to gizmo while tweaking.
@ WM_GIZMO_STATE_HIGHLIGHT
BMesh const char void * data
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static void gizmo_calc_rect_view_margin(const wmGizmo *gz, float margin[2])
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_box_corners(const rctf *r, const float margin[2], const float color[3], const float line_width)
static wmOperatorStatus gizmo_cage2d_invoke(bContext *C, wmGizmo *gz, const wmEvent *event)
static void cage2d_draw_rect_rotate_handle(const rctf *r, const float margin[2], const float color[3], bool solid)
static bool is_corner_highlighted(const int highlighted)
static void cage2d_draw_circle_wire(const float color[3], const float size[2], const float margin[2], const int transform_flag, const int draw_options, const float line_width)
static wmOperatorStatus 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 gizmo_calc_rect_view_scale(const wmGizmo *gz, float scale[2])
static void gizmo_cage2d_draw_select(const bContext *, wmGizmo *gz, int select_id)
static void imm_draw_point_aspect_2d(uint pos, float x, float y, float rad_x, float rad_y, bool solid)
#define MUL_V2_V3_M4_FINAL(test_co, mouse_co)
static void gizmo_cage2d_setup(wmGizmo *gz)
static void cage2d_draw_rect_corner_handles(const rctf *r, const float margin[2], const float color[3], bool solid)
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)
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 @021025263243242147216143265077100330027142264337::@240232116316110053135047106323056371161236243121 attr_id
void * MEM_callocN(size_t len, const char *str)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< float, 3 > float3
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_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_anim_autokey(bContext *C, const wmGizmo *, wmGizmoProperty *gz_prop)
bool WM_gizmo_target_property_is_valid(const wmGizmoProperty *gz_prop)
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 *))