43#define WIDGET_RADIUS ((U.gizmo_size_navigate_v3d / 2.0f) * UI_SCALE_FAC)
46#define AXIS_HANDLE_SIZE 0.20f
48#define AXIS_LINE_WIDTH ((U.gizmo_size_navigate_v3d / 40.0f) * U.pixelsize)
49#define AXIS_RING_WIDTH ((U.gizmo_size_navigate_v3d / 60.0f) * U.pixelsize)
50#define AXIS_TEXT_SIZE (WIDGET_RADIUS * AXIS_HANDLE_SIZE * 1.25f)
53#define AXIS_DEPTH_BIAS 0.01f
73 for (
int axis = 0; axis < 3; axis++) {
90 float matrix_screen[4][4];
91 float matrix_unit[4][4];
95 params.matrix_offset = matrix_unit;
103 float viewport_size[4];
106 static float axis_color[3][4];
110 float matrix_m3[3][3];
111 float matrix_m3_invert[3][3];
125 float m3_offset[3][3];
135 if (use_project_matrix) {
160 for (
int axis_index = 0; axis_index <
ARRAY_SIZE(axis_order); axis_index++) {
161 const int index = axis_order[axis_index].index;
162 const int axis = axis_order[axis_index].axis;
163 const bool is_pos = axis_order[axis_index].is_pos;
164 const float depth = axis_order[axis_index].depth;
165 const bool is_behind = (depth <= (
AXIS_DEPTH_BIAS * (is_pos ? -1 : 1)));
166 bool is_aligned_front = (axis_align != -1 && axis_align == axis && !is_behind);
167 bool is_aligned_back = (axis_align != -1 && axis_align == axis && is_behind);
170 const float v_final[3] = {
v[(axis + 2) % 3],
v[(axis + 1) % 3],
v[axis]};
174 if (is_aligned_front && (axis_order[axis_index].axis_opposite + 1 == gz->
highlight_part)) {
179 axis_color[axis][3] = 1.0f;
182 float fading_color[4];
183 interp_v4_v4v4(fading_color, view_color, axis_color[axis], ((depth + 1) * 0.25) + 0.5);
186 float middle_color[4];
187 interp_v4_v4v4(middle_color, view_color, axis_color[axis], 0.75f);
192 if (is_pos || axis_align != -1) {
195 float v_start[3] = {0.0f, 0.0f, 0.0f};
199 float v_end[3] = {0.0f, 0.0f, 0.0f};
215 if (!is_aligned_back) {
216 float *inner_color = fading_color;
217 float *outline_color = fading_color;
218 float negative_color[4];
220 if (is_aligned_front) {
222 negative_color,
blender::float4{1.0f, 1.0f, 1.0f, 1.0f}, axis_color[axis], 0.5f);
223 negative_color[3] = std::min(depth + 1, 1.0f);
224 outline_color = negative_color;
227 interp_v4_v4v4(negative_color, view_color, axis_color[axis], 0.25f);
228 negative_color[3] = std::min(depth + 1, 1.0f);
229 inner_color = negative_color;
237 float scale = ((depth + 1) * 0.08f) + 0.92f;
245 &rect, inner_color,
nullptr, 0.0f, outline_color,
AXIS_RING_WIDTH, rad);
250 if ((is_pos || is_highlight || (axis == axis_align)) && !is_aligned_back) {
251 float axis_str_width, axis_string_height;
252 char axis_str[3] = {char(
'X' + axis), 0, 0};
255 axis_str[1] =
'X' + axis;
261 mul_v3_m3v3(v_final_px, font.matrix_m3_invert, v_final);
265 v_final_px[0] = roundf(v_final_px[0] - (axis_str_width * (is_pos ? 0.5f : 0.55f)));
266 v_final_px[1] = roundf(v_final_px[1] - (axis_string_height / 2.0f));
271 float text_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
274 text_color[3] = is_active ? 1.0f : 0.9f;
282 if (use_project_matrix) {
293 float point_local[2] = {
float(mval[0]),
float(mval[1])};
306 for (
int i = 0; i < 3; i++) {
307 for (
int is_pos = 0; is_pos < 2; is_pos++) {
308 const float co[2] = {
323 if (len_axis_sq < i_best_len_sq) {
324 part_best = part_index;
325 i_best_len_sq = len_axis_sq;
332 if (part_best != -1) {
355 r_bounding_box->
xmax = r_bounding_box->
xmin + rad;
356 r_bounding_box->
ymax = r_bounding_box->
ymin + rad;
363 gzt->
idname =
"VIEW3D_GT_navigate_rotate";
ScrArea * CTX_wm_area(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
void BLF_size(int fontid, float size)
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, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
void BLF_enable(int fontid, int option)
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])
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])
bool invert_m3(float mat[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 Scene *scene, const View3D *v3d, float r_color[3])
void GPU_matrix_ortho_set_z(float near, float far)
void GPU_matrix_push_projection()
#define GPU_matrix_mul(x)
void GPU_matrix_scale_1f(float factor)
void GPU_matrix_pop_projection()
void GPU_matrix_translate_3fv(const float vec[3])
#define GPU_MATRIX_ORTHO_CLIP_NEAR_DEFAULT
@ 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 rctf *rect, bool filled, float rad, const float col[4])
void UI_draw_roundbox_4fv_ex(const rctf *rect, const float inner1[4], const float inner2[4], float shade_dir, const float outline[4], float outline_width, float rad)
void UI_draw_roundbox_corner_set(int type)
void UI_GetThemeColor3fv(int colorid, float col[3])
@ WM_GIZMO_STATE_HIGHLIGHT
ATTR_WARN_UNUSED_RESULT const BMVert * v
draw_view in_light_buf[] float
wmGizmoFnScreenBoundsGet screen_bounds_get
wmGizmoFnTestSelect test_select
wmGizmoFnCursorGet cursor_get
float matrix_offset[4][4]
static int gizmo_axis_test_select(bContext *, wmGizmo *gz, const int mval[2])
static void gizmo_axis_draw(const bContext *C, wmGizmo *gz)
static int gizmo_axis_cursor_get(wmGizmo *)
static bool gizmo_axis_screen_bounds_get(bContext *C, wmGizmo *gz, rcti *r_bounding_box)
void VIEW3D_GT_navigate_rotate(wmGizmoType *gzt)
void WM_gizmo_calc_matrix_final_params(const wmGizmo *gz, const WM_GizmoMatrixParams *params, float r_mat[4][4])