Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c125
1 files changed, 64 insertions, 61 deletions
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c
index 041fe343526..5a4f910955e 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.c
@@ -84,7 +84,7 @@ static void draw_xyz_wire(
switch (axis) {
case 0: /* x axis */
- line_type = GWN_PRIM_LINES;
+ line_type = GPU_PRIM_LINES;
/* bottom left to top right */
negate_v3_v3(v1, dx);
@@ -105,7 +105,7 @@ static void draw_xyz_wire(
break;
case 1: /* y axis */
- line_type = GWN_PRIM_LINES;
+ line_type = GPU_PRIM_LINES;
/* bottom left to top right */
mul_v3_fl(dx, 0.75f);
@@ -127,7 +127,7 @@ static void draw_xyz_wire(
break;
case 2: /* z axis */
- line_type = GWN_PRIM_LINE_STRIP;
+ line_type = GPU_PRIM_LINE_STRIP;
/* start at top left */
negate_v3_v3(v1, dx);
@@ -168,12 +168,12 @@ static void draw_xyz_wire(
immEnd();
}
-static void axis_geom_draw(const wmGizmo *mpr, const float color[4], const bool UNUSED(select))
+static void axis_geom_draw(const wmGizmo *gz, const float color[4], const bool UNUSED(select))
{
- GPU_line_width(mpr->line_width);
+ GPU_line_width(gz->line_width);
- Gwn_VertFormat *format = immVertexFormat();
- const uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT);
+ GPUVertFormat *format = immVertexFormat();
+ const uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
struct {
@@ -182,12 +182,12 @@ static void axis_geom_draw(const wmGizmo *mpr, const float color[4], const bool
char axis;
char is_pos;
} axis_order[6] = {
- {-mpr->matrix_offset[0][2], 0, 0, false},
- {+mpr->matrix_offset[0][2], 1, 0, true},
- {-mpr->matrix_offset[1][2], 2, 1, false},
- {+mpr->matrix_offset[1][2], 3, 1, true},
- {-mpr->matrix_offset[2][2], 4, 2, false},
- {+mpr->matrix_offset[2][2], 5, 2, true},
+ {-gz->matrix_offset[0][2], 0, 0, false},
+ {+gz->matrix_offset[0][2], 1, 0, true},
+ {-gz->matrix_offset[1][2], 2, 1, false},
+ {+gz->matrix_offset[1][2], 3, 1, true},
+ {-gz->matrix_offset[2][2], 4, 2, false},
+ {+gz->matrix_offset[2][2], 5, 2, true},
};
qsort(&axis_order, ARRAY_SIZE(axis_order), sizeof(axis_order[0]), BLI_sortutil_cmp_float);
@@ -195,14 +195,14 @@ static void axis_geom_draw(const wmGizmo *mpr, const float color[4], const bool
static const float axis_highlight[4] = {1, 1, 1, 1};
static const float axis_black[4] = {0, 0, 0, 1};
static float axis_color[3][4];
- gpuPushMatrix();
- gpuMultMatrix(mpr->matrix_offset);
+ GPU_matrix_push();
+ GPU_matrix_mul(gz->matrix_offset);
bool draw_center_done = false;
int axis_align = -1;
for (int axis = 0; axis < 3; axis++) {
- if (len_squared_v2(mpr->matrix_offset[axis]) < 1e-6f) {
+ if (len_squared_v2(gz->matrix_offset[axis]) < 1e-6f) {
axis_align = axis;
break;
}
@@ -212,18 +212,18 @@ static void axis_geom_draw(const wmGizmo *mpr, const float color[4], const bool
const int index = axis_order[axis_index].index;
const int axis = axis_order[axis_index].axis;
const bool is_pos = axis_order[axis_index].is_pos;
- const bool is_highlight = index + 1 == mpr->highlight_part;
+ const bool is_highlight = index + 1 == gz->highlight_part;
/* Draw slightly before, so axis aligned arrows draw ontop. */
if ((draw_center_done == false) && (axis_order[axis_index].depth > -0.01f)) {
/* Circle defining active area (revert back to 2D space). */
{
- gpuPopMatrix();
+ GPU_matrix_pop();
immUniformColor4fv(color);
imm_draw_circle_fill_3d(pos_id, 0, 0, 1.0f, DIAL_RESOLUTION);
- gpuPushMatrix();
- gpuMultMatrix(mpr->matrix_offset);
+ GPU_matrix_push();
+ GPU_matrix_mul(gz->matrix_offset);
}
draw_center_done = true;
}
@@ -237,10 +237,13 @@ static void axis_geom_draw(const wmGizmo *mpr, const float color[4], const bool
bool ok = true;
/* skip view align axis */
- if ((axis_align == axis) && (mpr->matrix_offset[axis][2] > 0.0f) == is_pos) {
+ if ((axis_align == axis) && (gz->matrix_offset[axis][2] > 0.0f) == is_pos) {
ok = false;
}
if (ok) {
+ /* 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. */
+ const bool show_axis_char = (is_pos || (axis == axis_align));
const float v[3] = {0, 0, 3 * (is_pos ? 1 : -1)};
const float v_final[3] = {
v[index_x] * scale_axis,
@@ -257,7 +260,7 @@ static void axis_geom_draw(const wmGizmo *mpr, const float color[4], const bool
float v_start[3];
GPU_line_width(2.0f);
immUniformColor4fv(color_current);
- immBegin(GWN_PRIM_LINES, 2);
+ immBegin(GPU_PRIM_LINES, 2);
if (axis_align == -1) {
zero_v3(v_start);
}
@@ -276,75 +279,75 @@ static void axis_geom_draw(const wmGizmo *mpr, const float color[4], const bool
/* Axis Ball. */
{
- gpuPushMatrix();
- gpuTranslate3fv(v_final);
- gpuScaleUniform(is_pos ? 0.22f : 0.18f);
-
- Gwn_Batch *sphere = GPU_batch_preset_sphere(0);
- GWN_batch_program_set_builtin(sphere, GPU_SHADER_3D_UNIFORM_COLOR);
- GWN_batch_uniform_4fv(sphere, "color", is_pos ? color_current : color_current_fade);
- GWN_batch_draw(sphere);
- gpuPopMatrix();
+ GPU_matrix_push();
+ GPU_matrix_translate_3fv(v_final);
+ GPU_matrix_scale_1f(show_axis_char ? 0.22f : 0.18f);
+
+ GPUBatch *sphere = GPU_batch_preset_sphere(0);
+ 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_draw(sphere);
+ GPU_matrix_pop();
}
/* Axis XYZ Character. */
- if (is_pos) {
+ if (show_axis_char) {
GPU_line_width(1.0f);
float m3[3][3];
- copy_m3_m4(m3, mpr->matrix_offset);
+ copy_m3_m4(m3, gz->matrix_offset);
immUniformColor4fv(is_highlight ? axis_black : axis_highlight);
draw_xyz_wire(pos_id, m3, v_final, 1.0, axis);
}
}
}
- gpuPopMatrix();
+ GPU_matrix_pop();
immUnbindProgram();
}
static void axis3d_draw_intern(
- const bContext *UNUSED(C), wmGizmo *mpr,
+ const bContext *UNUSED(C), wmGizmo *gz,
const bool select, const bool highlight)
{
- const float *color = highlight ? mpr->color_hi : mpr->color;
+ const float *color = highlight ? gz->color_hi : gz->color;
float matrix_final[4][4];
float matrix_unit[4][4];
unit_m4(matrix_unit);
WM_gizmo_calc_matrix_final_params(
- mpr,
+ gz,
&((struct WM_GizmoMatrixParams) {
.matrix_offset = matrix_unit,
}), matrix_final);
- gpuPushMatrix();
- gpuMultMatrix(matrix_final);
+ GPU_matrix_push();
+ GPU_matrix_mul(matrix_final);
GPU_blend(true);
- axis_geom_draw(mpr, color, select);
+ axis_geom_draw(gz, color, select);
GPU_blend(false);
- gpuPopMatrix();
+ GPU_matrix_pop();
}
-static void gizmo_axis_draw(const bContext *C, wmGizmo *mpr)
+static void gizmo_axis_draw(const bContext *C, wmGizmo *gz)
{
- const bool is_modal = mpr->state & WM_GIZMO_STATE_MODAL;
- const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
+ const bool is_modal = gz->state & WM_GIZMO_STATE_MODAL;
+ const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
(void)is_modal;
GPU_blend(true);
- axis3d_draw_intern(C, mpr, false, is_highlight);
+ axis3d_draw_intern(C, gz, false, is_highlight);
GPU_blend(false);
}
static int gizmo_axis_test_select(
- bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event)
+ bContext *UNUSED(C), wmGizmo *gz, const int mval[2])
{
- float point_local[2] = {UNPACK2(event->mval)};
- sub_v2_v2(point_local, mpr->matrix_basis[3]);
- mul_v2_fl(point_local, 1.0f / (mpr->scale_basis * UI_DPI_FAC));
+ float point_local[2] = {UNPACK2(mval)};
+ sub_v2_v2(point_local, gz->matrix_basis[3]);
+ mul_v2_fl(point_local, 1.0f / (gz->scale_basis * UI_DPI_FAC));
const float len_sq = len_squared_v2(point_local);
if (len_sq > 1.0) {
@@ -358,14 +361,14 @@ static int gizmo_axis_test_select(
for (int i = 0; i < 3; i++) {
for (int is_pos = 0; is_pos < 2; is_pos++) {
float co[2] = {
- mpr->matrix_offset[i][0] * (is_pos ? 1 : -1),
- mpr->matrix_offset[i][1] * (is_pos ? 1 : -1),
+ gz->matrix_offset[i][0] * (is_pos ? 1 : -1),
+ gz->matrix_offset[i][1] * (is_pos ? 1 : -1),
};
bool ok = true;
/* Check if we're viewing on an axis, there is no point to clicking on the current axis so show the reverse. */
- if (len_squared_v2(co) < 1e-6f && (mpr->matrix_offset[i][2] > 0.0f) == is_pos) {
+ if (len_squared_v2(co) < 1e-6f && (gz->matrix_offset[i][2] > 0.0f) == is_pos) {
ok = false;
}
@@ -384,7 +387,7 @@ static int gizmo_axis_test_select(
return part_best;
}
- /* The 'mpr->scale_final' is already applied when projecting. */
+ /* The 'gz->scale_final' is already applied when projecting. */
if (len_sq < 1.0f) {
return 0;
}
@@ -392,23 +395,23 @@ static int gizmo_axis_test_select(
return -1;
}
-static int gizmo_axis_cursor_get(wmGizmo *mpr)
+static int gizmo_axis_cursor_get(wmGizmo *gz)
{
- if (mpr->highlight_part > 0) {
+ if (gz->highlight_part > 0) {
return CURSOR_EDIT;
}
return BC_NSEW_SCROLLCURSOR;
}
-void VIEW3D_WT_navigate_rotate(wmGizmoType *wt)
+void VIEW3D_GT_navigate_rotate(wmGizmoType *gzt)
{
/* identifiers */
- wt->idname = "VIEW3D_WT_navigate_rotate";
+ gzt->idname = "VIEW3D_GT_navigate_rotate";
/* api callbacks */
- wt->draw = gizmo_axis_draw;
- wt->test_select = gizmo_axis_test_select;
- wt->cursor_get = gizmo_axis_cursor_get;
+ gzt->draw = gizmo_axis_draw;
+ gzt->test_select = gizmo_axis_test_select;
+ gzt->cursor_get = gizmo_axis_cursor_get;
- wt->struct_size = sizeof(wmGizmo);
+ gzt->struct_size = sizeof(wmGizmo);
}