45 #define WIDGET_RADIUS ((U.gizmo_size_navigate_v3d / 2.0f) * UI_DPI_FAC)
48 #define AXIS_HANDLE_SIZE 0.20f
50 #define AXIS_LINE_WIDTH ((U.gizmo_size_navigate_v3d / 40.0f) * U.pixelsize)
51 #define AXIS_RING_WIDTH ((U.gizmo_size_navigate_v3d / 60.0f) * U.pixelsize)
52 #define AXIS_TEXT_SIZE (WIDGET_RADIUS * AXIS_HANDLE_SIZE * 1.25f)
55 #define AXIS_DEPTH_BIAS 0.01f
75 for (
int axis = 0; axis < 3; axis++) {
92 float matrix_screen[4][4];
93 float matrix_unit[4][4];
97 .matrix_offset = matrix_unit,
106 float viewport_size[4];
109 static float axis_color[3][4];
113 float matrix_m3[3][3];
114 float matrix_m3_invert[3][3];
128 float m3_offset[3][3];
138 if (use_project_matrix) {
166 for (
int axis_index = 0; axis_index <
ARRAY_SIZE(axis_order); axis_index++) {
167 const int index = axis_order[axis_index].index;
168 const int axis = axis_order[axis_index].axis;
169 const bool is_pos = axis_order[axis_index].is_pos;
170 const float depth = axis_order[axis_index].depth;
171 const bool is_behind = (depth <= (
AXIS_DEPTH_BIAS * (is_pos ? -1 : 1)));
172 bool is_aligned_front = (axis_align != -1 && axis_align == axis && !is_behind);
173 bool is_aligned_back = (axis_align != -1 && axis_align == axis && is_behind);
176 const float v_final[3] = {
v[(axis + 2) % 3],
v[(axis + 1) % 3],
v[axis]};
180 if (is_aligned_front && (axis_order[axis_index].axis_opposite + 1 == gz->
highlight_part)) {
185 axis_color[axis][3] = 1.0f;
188 float fading_color[4];
189 interp_v4_v4v4(fading_color, view_color, axis_color[axis], ((depth + 1) * 0.25) + 0.5);
192 float middle_color[4];
193 interp_v4_v4v4(middle_color, view_color, axis_color[axis], 0.75f);
198 if (is_pos || axis_align != -1) {
201 float v_start[3] = {0.0f, 0.0f, 0.0f};
205 float v_end[3] = {0.0f, 0.0f, 0.0f};
221 if (!is_aligned_back) {
222 float *inner_color = fading_color;
223 float *outline_color = fading_color;
224 float negative_color[4];
226 if (is_aligned_front) {
228 negative_color, (
float[4]){1.0f, 1.0f, 1.0f, 1.0f}, axis_color[axis], 0.5f);
229 negative_color[3] =
MIN2(depth + 1, 1.0f);
230 outline_color = negative_color;
233 interp_v4_v4v4(negative_color, view_color, axis_color[axis], 0.25f);
234 negative_color[3] =
MIN2(depth + 1, 1.0f);
235 inner_color = negative_color;
243 float scale = ((depth + 1) * 0.08f) + 0.92f;
262 if ((is_pos || is_highlight || (axis == axis_align)) && !is_aligned_back) {
263 float axis_str_width, axis_string_height;
264 char axis_str[3] = {
'X' + axis, 0, 0};
267 axis_str[1] =
'X' + axis;
273 mul_v3_m3v3(v_final_px, font.matrix_m3_invert, v_final);
277 v_final_px[0] = roundf(v_final_px[0] - (axis_str_width * (is_pos ? 0.5f : 0.55f)));
278 v_final_px[1] = roundf(v_final_px[1] - (axis_string_height / 2.0f));
283 float text_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
286 text_color[3] = is_active ? 1.0f : 0.9f;
294 if (use_project_matrix) {
305 float point_local[2] = {
UNPACK2(mval)};
317 float i_best_len_sq = FLT_MAX;
318 for (
int i = 0; i < 3; i++) {
319 for (
int is_pos = 0; is_pos < 2; is_pos++) {
320 const float co[2] = {
335 if (len_axis_sq < i_best_len_sq) {
336 part_best = part_index;
337 i_best_len_sq = len_axis_sq;
344 if (part_best != -1) {
367 r_bounding_box->
xmax = r_bounding_box->
xmin + rad;
368 r_bounding_box->
ymax = r_bounding_box->
ymin + rad;
375 gzt->
idname =
"VIEW3D_GT_navigate_rotate";
struct ScrArea * CTX_wm_area(const bContext *C)
struct Scene * CTX_data_scene(const bContext *C)
struct View3D * CTX_wm_view3d(const bContext *C)
void BLF_width_and_height(int fontid, const char *str, size_t str_len, float *r_width, float *r_height) ATTR_NONNULL()
void BLF_color4fv(int fontid, const float rgba[4])
void BLF_disable(int fontid, int option)
void BLF_draw(int fontid, const char *str, size_t str_len) ATTR_NONNULL(2)
void BLF_enable(int fontid, int option)
void BLF_size(int fontid, float size, int dpi)
void BLF_position(int fontid, float x, float y, float z)
void mul_m3_v3(const float M[3][3], float r[3])
void copy_m3_m3(float m1[3][3], const float m2[3][3])
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void unit_m4(float m[4][4])
void copy_m4_m3(float m1[4][4], const float m2[3][3])
bool invert_m3(float R[3][3])
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2(float r[2], const float a[2])
MINLINE void mul_v2_fl(float r[2], float f)
void interp_v4_v4v4(float r[4], const float a[4], const float b[4], float t)
MINLINE void zero_v4(float r[4])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
int BLI_sortutil_cmp_float(const void *a_, const void *b_)
void ED_view3d_background_color_get(const struct Scene *scene, const struct View3D *v3d, float r_color[3])
void GPU_matrix_pop(void)
void GPU_matrix_pop_projection(void)
void GPU_matrix_ortho_set_z(float near, float far)
#define GPU_matrix_mul(x)
void GPU_matrix_push(void)
void GPU_matrix_scale_1f(float factor)
void GPU_matrix_translate_3fv(const float vec[3])
#define GPU_MATRIX_ORTHO_CLIP_NEAR_DEFAULT
void GPU_matrix_push_projection(void)
@ GPU_SHADER_3D_POLYLINE_SMOOTH_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.
void UI_draw_roundbox_4fv(const struct rctf *rect, bool filled, float rad, const float col[4])
void UI_draw_roundbox_corner_set(int type)
void UI_draw_roundbox_4fv_ex(const struct rctf *rect, const float inner1[4], const float inner2[4], float shade_dir, const float outline[4], float outline_width, float rad)
void UI_GetThemeColor3fv(int colorid, float col[3])
@ WM_GIZMO_STATE_HIGHLIGHT
ATTR_WARN_UNUSED_RESULT const BMVert * v
static void area(int d1, int d2, int e1, int e2, float weights[2])
wmGizmoFnScreenBoundsGet screen_bounds_get
wmGizmoFnTestSelect test_select
wmGizmoFnCursorGet cursor_get
float matrix_offset[4][4]
static void gizmo_axis_draw(const bContext *C, wmGizmo *gz)
static int gizmo_axis_test_select(bContext *UNUSED(C), wmGizmo *gz, const int mval[2])
static bool gizmo_axis_screen_bounds_get(bContext *C, wmGizmo *gz, rcti *r_bounding_box)
static int gizmo_axis_cursor_get(wmGizmo *UNUSED(gz))
void VIEW3D_GT_navigate_rotate(wmGizmoType *gzt)
void WM_gizmo_calc_matrix_final_params(const wmGizmo *gz, const struct WM_GizmoMatrixParams *params, float r_mat[4][4])