43#define GIZMO_MARGIN_OFFSET_SCALE 1.5f
46 float orig_matrix_final_no_offset[4][4],
49 float mat_identity[4][4];
52 if (use_space ==
false) {
53 params.matrix_basis = mat_identity;
55 params.matrix_offset = mat_identity;
64 float matrix_final_no_offset[4][4];
66 float x_axis[3], y_axis[3], z_axis[3];
72 scale[0] = 1.0f /
len_v3(x_axis);
73 scale[1] = 1.0f /
len_v3(y_axis);
74 scale[2] = 1.0f /
len_v3(z_axis);
79 const float handle_size = 9.0f;
85 margin[0] = (handle_size * scale_xyz[0]);
86 margin[1] = (handle_size * scale_xyz[1]);
87 margin[2] = (handle_size * scale_xyz[2]);
94 bool r_constrain_axis[3],
102 range[2] = index % 3;
104 range[1] = index % 3;
106 range[0] = index % 3;
108 const float sign[3] = {0.5f, 0.0f, -0.5f};
109 for (
int i = 0; i < 3; i++) {
110 r_pt[i] = has_translation ? sign[range[i]] : 0.0f;
111 r_constrain_axis[i] = (range[i] == 1);
123 const float margin[3],
124 const float color[3],
125 const float line_width)
144 const float matrix_final[4][4],
145 const float color[4],
146 const int highlighted,
148 const float margin[3])
155 range[2] = index % 3;
157 range[1] = index % 3;
159 range[0] = index % 3;
161 const float sign[3] = {-1.0f, 0.0f, 1.0f};
164 for (
int i = 0; i < 3; i++) {
165 co[i] = size[i] * sign[range[i]];
167 const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3};
203 const float margin[3],
204 const float color[3],
205 const int transform_flag,
206 const int draw_options,
207 const float line_width)
224 const float rad[2] = {margin[0] / 2, margin[1] / 2};
225 const float center[2] = {0.0f, 0.0f};
243 const float matrix_final[4][4],
245 const float margin[3],
246 const float color[3],
248 const float handle_scale)
251 const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3};
256 const float sign[3] = {-1.0f, 0.0f, 1.0f};
257 for (
int x = 0; x < 3; x++) {
258 for (
int y = 0; y < 3; y++) {
259 for (
int z = 0;
z < 3;
z++) {
260 if (x == 1 && y == 1 &&
z == 1) {
263 const float co[3] = {r[0] * sign[
x], r[1] * sign[
y], r[2] * sign[
z]};
284 float matrix_final[4][4];
290 const float size_real[3] = {dims[0] / 2.0f, dims[1] / 2.0f, dims[2] / 2.0f};
315 const float size[3] = {
316 size_real[0] + margin[0] / 2,
317 size_real[1] + margin[1] / 2,
318 size_real[2] + margin[2] / 2,
322 const float size[3] = {
UNPACK3(size_real)};
346 _r.
xmin = -size_real[0];
347 _r.ymin = -size_real[1];
348 _r.xmax = size_real[0];
349 _r.ymax = size_real[1];
352 float color[4], black[3] = {0, 0, 0};
379 float color[4], black[3] = {0, 0, 0};
385 size_real, margin, black, transform_flag, draw_options, gz->
line_width + 3.0f);
387 size_real, margin, color, transform_flag, draw_options, gz->
line_width);
480 float point_local[3];
486 float matrix_back[4][4];
502 if (gz_prop->
type !=
nullptr) {
510 (point_local[0] - data->orig_mouse[0]);
512 (point_local[1] - data->orig_mouse[1]);
514 (point_local[2] - data->orig_mouse[2]);
524 bool constrain_axis[3] = {
false};
528 float scale[3] = {1.0f, 1.0f, 1.0f};
529 for (
int i = 0; i < 3; i++) {
530 if (constrain_axis[i] ==
false) {
532 const float delta_orig = (data->orig_mouse[i] - data->orig_matrix_offset[3][i]) /
533 (dims[i] *
len_v3(data->orig_matrix_offset[i])) -
535 const float delta_curr = (point_local[i] - data->orig_matrix_offset[3][i]) /
536 (dims[i] *
len_v3(data->orig_matrix_offset[i])) -
547 const float delta_boundary =
signf(delta_orig) * 0.5f - pivot[i];
548 scale[i] = delta_curr / delta_boundary;
553 if (constrain_axis[0] ==
false && constrain_axis[1] ==
false) {
554 scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f;
556 else if (constrain_axis[0] ==
false) {
559 else if (constrain_axis[1] ==
false) {
568 float matrix_scale[4][4];
576 matrix_scale,
blender::float3(pivot[0] * dims[0], pivot[1] * dims[1], pivot[2] * dims[2]));
580 if (gz_prop->
type !=
nullptr) {
618 if (gz_prop->
type !=
nullptr) {
632 gzt->
idname =
"GIZMO_GT_cage_3d";
650 {0,
nullptr, 0,
nullptr,
nullptr},
656 {0,
nullptr, 0,
nullptr,
nullptr},
660 {0,
nullptr, 0,
nullptr,
nullptr},
662 static const float unit_v3[3] = {1.0f, 1.0f, 1.0f};
674 rna_enum_draw_options,
wmWindow * CTX_wm_window(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
MINLINE float signf(float f)
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])
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_m4v3(float r[3], const float mat[4][4], const float vec[3])
void mul_v3_mat3_m4v3(float r[3], const float mat[4][4], const float vec[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
@ ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z
@ ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z
@ ED_GIZMO_CAGE3D_PART_ROTATE
@ ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z
@ ED_GIZMO_CAGE3D_PART_TRANSLATE
@ ED_GIZMO_CAGE_DRAW_FLAG_XFORM_CENTER_HANDLE
@ ED_GIZMO_CAGE3D_STYLE_BOX
@ ED_GIZMO_CAGE3D_STYLE_CIRCLE
@ ED_GIZMO_CAGE_XFORM_FLAG_SCALE
@ ED_GIZMO_CAGE_XFORM_FLAG_TRANSLATE
@ ED_GIZMO_CAGE_XFORM_FLAG_SCALE_UNIFORM
@ ED_GIZMO_CAGE_XFORM_FLAG_SCALE_SIGNED
void ED_region_tag_redraw_editor_overlays(ARegion *region)
float ED_view3d_pixel_size(const RegionView3D *rv3d, const float co[3])
#define GPU_matrix_mul(x)
bool GPU_select_load_id(unsigned int id)
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
@ GPU_SHADER_3D_UNIFORM_COLOR
void GPU_blend(eGPUBlend blend)
void GPU_viewport_size_get_f(float coords[4])
void GPU_polygon_smooth(bool enable)
Read Guarded memory(de)allocation.
eWM_GizmoFlagTweak
Gizmo tweak flag. Bit-flag passed to gizmo while tweaking.
@ WM_GIZMO_STATE_HIGHLIGHT
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
static void gizmo_cage3d_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop)
static void cage3d_draw_circle_handles(const RegionView3D *rv3d, const float matrix_final[4][4], const float r[3], const float margin[3], const float color[3], bool solid, const float handle_scale)
static void cage3d_draw_box_corners(const float r[3], const float margin[3], const float color[3], const float line_width)
static void gizmo_cage3d_draw_select(const bContext *C, wmGizmo *gz, int select_id)
static void gizmo_cage3d_draw_intern(RegionView3D *rv3d, wmGizmo *gz, const bool select, const bool highlight, const int select_id)
static void gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[3], float scale[3])
static int gizmo_cage3d_get_cursor(wmGizmo *gz)
static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[3], bool r_constrain_axis[3], bool has_translation)
static void gizmo_cage3d_setup(wmGizmo *gz)
static int gizmo_cage3d_invoke(bContext *C, wmGizmo *gz, const wmEvent *event)
static void cage3d_draw_circle_wire(const float r[3], const float margin[3], const float color[3], const int transform_flag, const int draw_options, const float line_width)
static void GIZMO_GT_cage_3d(wmGizmoType *gzt)
static void gizmo_cage3d_draw(const bContext *C, wmGizmo *gz)
static int gizmo_cage3d_modal(bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak)
static void gizmo_calc_rect_view_margin(const wmGizmo *gz, const float dims[3], float margin[3])
void ED_gizmotypes_cage_3d()
static void imm_draw_point_aspect_3d(uint pos, const float co[3], const float rad[3], bool solid)
static void gizmo_cage3d_exit(bContext *C, wmGizmo *gz, const bool cancel)
static void cage3d_draw_box_interaction(const RegionView3D *rv3d, const float matrix_final[4][4], const float color[4], const int highlighted, const float size[3], const float margin[3])
static void gizmo_calc_matrix_final_no_offset(const wmGizmo *gz, float orig_matrix_final_no_offset[4][4], bool use_space)
void gizmo_color_get(const wmGizmo *gz, bool highlight, float r_color[4])
bool gizmo_window_project_3d(bContext *C, const wmGizmo *gz, const float mval[2], bool use_offset, float r_co[3])
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
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_params(const wmGizmo *gz, const WM_GizmoMatrixParams *params, float r_mat[4][4])
void WM_gizmo_calc_matrix_final(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 *))