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];
103 format,
"color", gpu::VertAttrType::SFLOAT_32_32_32_32);
104 float viewport_size[4];
107 static float axis_color[3][4];
111 float matrix_m3[3][3];
112 float matrix_m3_invert[3][3];
126 float m3_offset[3][3];
135 bool use_project_matrix = (gz->
scale_final >= -GPU_MATRIX_ORTHO_CLIP_NEAR_DEFAULT);
136 if (use_project_matrix) {
161 for (
int axis_index = 0; axis_index <
ARRAY_SIZE(axis_order); axis_index++) {
162 const int index = axis_order[axis_index].index;
163 const int axis = axis_order[axis_index].axis;
164 const bool is_pos = axis_order[axis_index].is_pos;
165 const float depth = axis_order[axis_index].depth;
166 const bool is_behind = (depth <= (
AXIS_DEPTH_BIAS * (is_pos ? -1 : 1)));
167 bool is_aligned_front = (axis_align != -1 && axis_align == axis && !is_behind);
168 bool is_aligned_back = (axis_align != -1 && axis_align == axis && is_behind);
171 const float v_final[3] = {
v[(axis + 2) % 3],
v[(axis + 1) % 3],
v[axis]};
175 if (is_aligned_front && (axis_order[axis_index].axis_opposite + 1 == gz->
highlight_part)) {
180 axis_color[axis][3] = 1.0f;
183 float fading_color[4];
184 interp_v4_v4v4(fading_color, view_color, axis_color[axis], ((depth + 1) * 0.25) + 0.5);
187 float middle_color[4];
188 interp_v4_v4v4(middle_color, view_color, axis_color[axis], 0.75f);
193 if (is_pos || axis_align != -1) {
196 float v_start[3] = {0.0f, 0.0f, 0.0f};
200 float v_end[3] = {0.0f, 0.0f, 0.0f};
216 if (!is_aligned_back) {
217 float *inner_color = fading_color;
218 float *outline_color = fading_color;
219 float negative_color[4];
221 if (is_aligned_front) {
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) {
368 gzt->
idname =
"VIEW3D_GT_navigate_rotate";
float3x3 scale(float3x3 mat, float2 scale)
void get_color_3fv(int colorid, float col[3])
void 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 draw_roundbox_4fv(const rctf *rect, bool filled, float rad, const float col[4])
void mul_m3_v3(const float M[3][3], float r[3])
ScrArea * CTX_wm_area(const bContext *C)
static bool gizmo_axis_screen_bounds_get(const bContext *C, wmGizmo *gz, rcti *r_bounding_box)
void BLF_position(int fontid, float x, float y, float z)
void GPU_matrix_scale_1f(float factor)
void ED_view3d_background_color_get(const Scene *scene, const View3D *v3d, float r_color[3])
void GPU_polygon_smooth(bool enable)
static void gizmo_axis_draw(const bContext *C, wmGizmo *gz)
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void VIEW3D_GT_navigate_rotate(wmGizmoType *gzt)
void copy_m3_m3(float m1[3][3], const float m2[3][3])
MINLINE void mul_v2_fl(float r[2], float f)
void copy_m4_m3(float m1[4][4], const float m2[3][3])
void interp_v4_v4v4(float r[4], const float a[4], const float b[4], float t)
GPUVertFormat * immVertexFormat()
void GPU_matrix_ortho_set_z(float near, float far)
void WM_gizmo_calc_matrix_final_params(const wmGizmo *gz, const wmGizmoMatrixParams *params, float r_mat[4][4])
void immBegin(GPUPrimType, uint vertex_len)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void BLF_disable(int fontid, FontFlags flag)
static int gizmo_axis_test_select(bContext *, wmGizmo *gz, const int mval[2])
void GPU_matrix_mul(const float m[4][4])
VecBase< float, 4 > float4
MINLINE void zero_v4(float r[4])
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void GPU_matrix_translate_3fv(const float vec[3])
int BLI_sortutil_cmp_float(const void *a_, const void *b_)
void BLF_size(int fontid, float size)
void WM_gizmo_set_flag(wmGizmo *gz, const int flag, const bool enable)
void immUniform1f(const char *name, float x)
void GPU_viewport_size_get_f(float coords[4])
void immAttr4fv(uint attr_id, const float data[4])
@ GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
void unit_m4(float m[4][4])
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
static int gizmo_axis_cursor_get(wmGizmo *)
static void gizmo_axis_setup(wmGizmo *gz)
bool invert_m3(float mat[3][3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
void immVertex3fv(uint attr_id, const float data[3])
@ WM_GIZMO_STATE_HIGHLIGHT
void GPU_matrix_pop_projection()
Scene * CTX_data_scene(const bContext *C)
void immUniform2fv(const char *name, const float data[2])
MINLINE void sub_v2_v2(float r[2], const float a[2])
void GPU_blend(GPUBlend blend)
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
void BLF_width_and_height(int fontid, const char *str, size_t str_len, float *r_width, float *r_height) ATTR_NONNULL()
void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3])
void GPU_matrix_push_projection()
void BLF_enable(int fontid, FontFlags flag)
View3D * CTX_wm_view3d(const bContext *C)
void BLF_color4fv(int fontid, const float rgba[4])
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
const float(* matrix_offset)[4]
wmGizmoFnCursorGet cursor_get
wmGizmoFnScreenBoundsGet screen_bounds_get
wmGizmoFnTestSelect test_select
float matrix_offset[4][4]