Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c
| Context not available. | |||||
| const int index_y = (axis + 1) % 3; | const int index_y = (axis + 1) % 3; | ||||
| const int index_x = (axis + 2) % 3; | const int index_x = (axis + 2) % 3; | ||||
| float in_front = (gz->matrix_offset[axis][2] >= -0.01f) == is_pos; | |||||
| float screen_z = (is_pos) ? gz->matrix_offset[axis][2] : 0 - gz->matrix_offset[axis][2]; | |||||
| bool ok = true; | bool ok = true; | ||||
| /* skip view align axis */ | /* skip view align axis */ | ||||
| if ((axis_align == axis) && (gz->matrix_offset[axis][2] > 0.0f) == is_pos) { | if ((axis_align == axis) && (gz->matrix_offset[axis][2] > 0.0f) != is_pos) { | ||||
| ok = false; | ok = false; | ||||
| } | } | ||||
| if (ok) { | if (ok) { | ||||
| /* Check aligned, since the front axis won't display in this case, | /* Check aligned, since the front axis won't display in this case, | ||||
| * and we want to make sure all 3 axes have a character at all times. */ | * and we want to make sure all 3 axes have a character at all times. */ | ||||
| const bool show_axis_char = (is_pos || (axis == axis_align)); | const bool show_axis_char = (in_front || (axis == axis_align)); | ||||
| const float v[3] = {0, 0, AXIS_HANDLE_OFFSET * (is_pos ? 1 : -1)}; | const float v[3] = {0, 0, AXIS_HANDLE_OFFSET * (is_pos ? 1 : -1)}; | ||||
| const float v_final[3] = {v[index_x], v[index_y], v[index_z]}; | const float v_final[3] = {v[index_x], v[index_y], v[index_z]}; | ||||
| const float *color_current = is_highlight ? axis_highlight : axis_color[axis]; | const float *color_current = is_highlight ? axis_highlight : axis_color[axis]; | ||||
| Context not available. | |||||
| if (is_pos) { | if (is_pos) { | ||||
| float v_start[3]; | float v_start[3]; | ||||
| GPU_line_width(2.0f); | GPU_line_width(2.0f); | ||||
| immUniformColor4fv(color_current); | immUniformColor4fv(in_front ? color_current : color_current_fade); | ||||
| immBegin(GPU_PRIM_LINES, 2); | immBegin(GPU_PRIM_LINES, 2); | ||||
| if (axis_align == -1) { | if (axis_align == -1) { | ||||
| zero_v3(v_start); | zero_v3(v_start); | ||||
| Context not available. | |||||
| { | { | ||||
| GPU_matrix_push(); | GPU_matrix_push(); | ||||
| GPU_matrix_translate_3fv(v_final); | GPU_matrix_translate_3fv(v_final); | ||||
| GPU_matrix_scale_1f(show_axis_char ? AXIS_HANDLE_SIZE_FG : AXIS_HANDLE_SIZE_BG); | GPU_matrix_scale_1f((screen_z + 4) * .05); | ||||
| GPUBatch *sphere = GPU_batch_preset_sphere(0); | GPUBatch *sphere = GPU_batch_preset_sphere(0); | ||||
| GPU_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR); | GPU_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| GPU_batch_uniform_4fv(sphere, "color", is_pos ? color_current : color_current_fade); | GPU_batch_uniform_4fv(sphere, "color", in_front ? color_current : color_current_fade); | ||||
| GPU_batch_draw(sphere); | GPU_batch_draw(sphere); | ||||
| GPU_matrix_pop(); | GPU_matrix_pop(); | ||||
| } | } | ||||
| Context not available. | |||||
| GPU_matrix_translate_3fv(v_final); | GPU_matrix_translate_3fv(v_final); | ||||
| GPU_matrix_mul(font.matrix); | GPU_matrix_mul(font.matrix); | ||||
| const char axis_str[2] = {'X' + axis, 0}; | char axis_str[3] = { (is_pos) ? 'X' + axis : '-', (is_pos) ? 0 : 'X' + axis , 0 }; | ||||
| float offset[2] = {0}; | float offset[2] = {0}; | ||||
| BLF_width_and_height(font.id, axis_str, 2, &offset[0], &offset[1]); | BLF_width_and_height(font.id, axis_str, 2, &offset[0], &offset[1]); | ||||
| BLF_position(font.id, roundf(offset[0] * -0.5f), roundf(offset[1] * -0.5f), 0); | BLF_position(font.id, roundf(offset[0] * -0.5f), roundf(offset[1] * -0.5f), 0); | ||||
| BLF_draw_ascii(font.id, axis_str, 2); | BLF_draw_ascii(font.id, axis_str, 3); | ||||
| GPU_blend(true); /* XXX, blf disables */ | GPU_blend(true); /* XXX, blf disables */ | ||||
| GPU_matrix_pop(); | GPU_matrix_pop(); | ||||
| Context not available. | |||||