41#define WIDGET_RADIUS ((U.gizmo_size_navigate_v3d / 2.0f) * UI_SCALE_FAC)
44#define AXIS_HANDLE_SIZE 0.20f
46#define AXIS_LINE_WIDTH ((U.gizmo_size_navigate_v3d / 40.0f) * U.pixelsize)
47#define AXIS_RING_WIDTH ((U.gizmo_size_navigate_v3d / 60.0f) * U.pixelsize)
48#define AXIS_TEXT_SIZE (WIDGET_RADIUS * AXIS_HANDLE_SIZE * 1.25f)
51#define AXIS_DEPTH_BIAS 0.01f
71 for (
int axis = 0; axis < 3; axis++) {
88 float matrix_screen[4][4];
89 float matrix_unit[4][4];
93 params.matrix_offset = matrix_unit;
101 float viewport_size[4];
104 static float axis_color[3][4];
108 float matrix_m3[3][3];
109 float matrix_m3_invert[3][3];
123 float m3_offset[3][3];
133 if (use_project_matrix) {
158 for (
int axis_index = 0; axis_index <
ARRAY_SIZE(axis_order); axis_index++) {
159 const int index = axis_order[axis_index].index;
160 const int axis = axis_order[axis_index].axis;
161 const bool is_pos = axis_order[axis_index].is_pos;
162 const float depth = axis_order[axis_index].depth;
163 const bool is_behind = (depth <= (
AXIS_DEPTH_BIAS * (is_pos ? -1 : 1)));
164 bool is_aligned_front = (axis_align != -1 && axis_align == axis && !is_behind);
165 bool is_aligned_back = (axis_align != -1 && axis_align == axis && is_behind);
168 const float v_final[3] = {
v[(axis + 2) % 3],
v[(axis + 1) % 3],
v[axis]};
172 if (is_aligned_front && (axis_order[axis_index].axis_opposite + 1 == gz->
highlight_part)) {
177 axis_color[axis][3] = 1.0f;
180 float fading_color[4];
181 interp_v4_v4v4(fading_color, view_color, axis_color[axis], ((depth + 1) * 0.25) + 0.5);
184 float middle_color[4];
185 interp_v4_v4v4(middle_color, view_color, axis_color[axis], 0.75f);
190 if (is_pos || axis_align != -1) {
193 float v_start[3] = {0.0f, 0.0f, 0.0f};
197 float v_end[3] = {0.0f, 0.0f, 0.0f};
213 if (!is_aligned_back) {
214 float *inner_color = fading_color;
215 float *outline_color = fading_color;
216 float negative_color[4];
218 if (is_aligned_front) {
220 negative_color,
blender::float4{1.0f, 1.0f, 1.0f, 1.0f}, axis_color[axis], 0.5f);
221 negative_color[3] = std::min(depth + 1, 1.0f);
222 outline_color = negative_color;
225 interp_v4_v4v4(negative_color, view_color, axis_color[axis], 0.25f);
226 negative_color[3] = std::min(depth + 1, 1.0f);
227 inner_color = negative_color;
235 float scale = ((depth + 1) * 0.08f) + 0.92f;
243 &rect, inner_color,
nullptr, 0.0f, outline_color,
AXIS_RING_WIDTH, rad);
248 if ((is_pos || is_highlight || (axis == axis_align)) && !is_aligned_back) {
249 float axis_str_width, axis_string_height;
250 char axis_str[3] = {char(
'X' + axis), 0, 0};
253 axis_str[1] =
'X' + axis;
259 mul_v3_m3v3(v_final_px, font.matrix_m3_invert, v_final);
263 v_final_px[0] = roundf(v_final_px[0] - (axis_str_width * (is_pos ? 0.5f : 0.55f)));
264 v_final_px[1] = roundf(v_final_px[1] - (axis_string_height / 2.0f));
269 float text_color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
272 text_color[3] = is_active ? 1.0f : 0.9f;
280 if (use_project_matrix) {
291 float point_local[2] = {float(mval[0]), float(mval[1])};
304 for (
int i = 0;
i < 3;
i++) {
305 for (
int is_pos = 0; is_pos < 2; is_pos++) {
306 const float co[2] = {
321 if (len_axis_sq < i_best_len_sq) {
322 part_best = part_index;
323 i_best_len_sq = len_axis_sq;
330 if (part_best != -1) {
353 r_bounding_box->
xmax = r_bounding_box->
xmin + rad;
354 r_bounding_box->
ymax = r_bounding_box->
ymin + rad;
361 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 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])
void unit_m4(float m[4][4])
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])
static constexpr int 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)
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
VecBase< float, 4 > float4
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])