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/gizmo_library/gizmo_types/primitive3d_gizmo.c')
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c165
1 files changed, 82 insertions, 83 deletions
diff --git a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c
index 2b13398dc4c..48b2e3348c9 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c
@@ -33,7 +33,6 @@
#include "BKE_context.h"
-
#include "GPU_immediate.h"
#include "GPU_matrix.h"
#include "GPU_select.h"
@@ -51,106 +50,101 @@
#include "../gizmo_library_intern.h"
static float verts_plane[4][3] = {
- {-1, -1, 0},
- { 1, -1, 0},
- { 1, 1, 0},
- {-1, 1, 0},
+ {-1, -1, 0},
+ {1, -1, 0},
+ {1, 1, 0},
+ {-1, 1, 0},
};
-
/* -------------------------------------------------------------------- */
-static void gizmo_primitive_draw_geom(
- const float col_inner[4], const float col_outer[4], const int draw_style)
+static void gizmo_primitive_draw_geom(const float col_inner[4],
+ const float col_outer[4],
+ const int draw_style)
{
- float (*verts)[3];
- uint vert_count = 0;
-
- if (draw_style == ED_GIZMO_PRIMITIVE_STYLE_PLANE) {
- verts = verts_plane;
- vert_count = ARRAY_SIZE(verts_plane);
- }
-
- if (vert_count > 0) {
- uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
- immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
- wm_gizmo_vec_draw(col_inner, verts, vert_count, pos, GPU_PRIM_TRI_FAN);
- wm_gizmo_vec_draw(col_outer, verts, vert_count, pos, GPU_PRIM_LINE_LOOP);
- immUnbindProgram();
- }
+ float(*verts)[3];
+ uint vert_count = 0;
+
+ if (draw_style == ED_GIZMO_PRIMITIVE_STYLE_PLANE) {
+ verts = verts_plane;
+ vert_count = ARRAY_SIZE(verts_plane);
+ }
+
+ if (vert_count > 0) {
+ uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
+ immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+ wm_gizmo_vec_draw(col_inner, verts, vert_count, pos, GPU_PRIM_TRI_FAN);
+ wm_gizmo_vec_draw(col_outer, verts, vert_count, pos, GPU_PRIM_LINE_LOOP);
+ immUnbindProgram();
+ }
}
-static void gizmo_primitive_draw_intern(
- wmGizmo *gz, const bool UNUSED(select),
- const bool highlight)
+static void gizmo_primitive_draw_intern(wmGizmo *gz,
+ const bool UNUSED(select),
+ const bool highlight)
{
- float color_inner[4], color_outer[4];
- float matrix_final[4][4];
- const int draw_style = RNA_enum_get(gz->ptr, "draw_style");
+ float color_inner[4], color_outer[4];
+ float matrix_final[4][4];
+ const int draw_style = RNA_enum_get(gz->ptr, "draw_style");
- gizmo_color_get(gz, highlight, color_outer);
- copy_v4_v4(color_inner, color_outer);
- color_inner[3] *= 0.5f;
+ gizmo_color_get(gz, highlight, color_outer);
+ copy_v4_v4(color_inner, color_outer);
+ color_inner[3] *= 0.5f;
- WM_gizmo_calc_matrix_final(gz, matrix_final);
+ WM_gizmo_calc_matrix_final(gz, matrix_final);
- GPU_matrix_push();
- GPU_matrix_mul(matrix_final);
+ GPU_matrix_push();
+ GPU_matrix_mul(matrix_final);
- GPU_blend(true);
- gizmo_primitive_draw_geom(color_inner, color_outer, draw_style);
- GPU_blend(false);
+ GPU_blend(true);
+ gizmo_primitive_draw_geom(color_inner, color_outer, draw_style);
+ GPU_blend(false);
- GPU_matrix_pop();
+ GPU_matrix_pop();
- if (gz->interaction_data) {
- GizmoInteraction *inter = gz->interaction_data;
+ if (gz->interaction_data) {
+ GizmoInteraction *inter = gz->interaction_data;
- copy_v4_fl(color_inner, 0.5f);
- copy_v3_fl(color_outer, 0.5f);
- color_outer[3] = 0.8f;
+ copy_v4_fl(color_inner, 0.5f);
+ copy_v3_fl(color_outer, 0.5f);
+ color_outer[3] = 0.8f;
- GPU_matrix_push();
- GPU_matrix_mul(inter->init_matrix_final);
+ GPU_matrix_push();
+ GPU_matrix_mul(inter->init_matrix_final);
- GPU_blend(true);
- gizmo_primitive_draw_geom(color_inner, color_outer, draw_style);
- GPU_blend(false);
+ GPU_blend(true);
+ gizmo_primitive_draw_geom(color_inner, color_outer, draw_style);
+ GPU_blend(false);
- GPU_matrix_pop();
- }
+ GPU_matrix_pop();
+ }
}
-static void gizmo_primitive_draw_select(
- const bContext *UNUSED(C), wmGizmo *gz,
- int select_id)
+static void gizmo_primitive_draw_select(const bContext *UNUSED(C), wmGizmo *gz, int select_id)
{
- GPU_select_load_id(select_id);
- gizmo_primitive_draw_intern(gz, true, false);
+ GPU_select_load_id(select_id);
+ gizmo_primitive_draw_intern(gz, true, false);
}
static void gizmo_primitive_draw(const bContext *UNUSED(C), wmGizmo *gz)
{
- gizmo_primitive_draw_intern(
- gz, false,
- (gz->state & WM_GIZMO_STATE_HIGHLIGHT));
+ gizmo_primitive_draw_intern(gz, false, (gz->state & WM_GIZMO_STATE_HIGHLIGHT));
}
static void gizmo_primitive_setup(wmGizmo *gz)
{
- gz->flag |= WM_GIZMO_DRAW_MODAL;
+ gz->flag |= WM_GIZMO_DRAW_MODAL;
}
-static int gizmo_primitive_invoke(
- bContext *UNUSED(C), wmGizmo *gz, const wmEvent *UNUSED(event))
+static int gizmo_primitive_invoke(bContext *UNUSED(C), wmGizmo *gz, const wmEvent *UNUSED(event))
{
- GizmoInteraction *inter = MEM_callocN(sizeof(GizmoInteraction), __func__);
+ GizmoInteraction *inter = MEM_callocN(sizeof(GizmoInteraction), __func__);
- WM_gizmo_calc_matrix_final(gz, inter->init_matrix_final);
+ WM_gizmo_calc_matrix_final(gz, inter->init_matrix_final);
- gz->interaction_data = inter;
+ gz->interaction_data = inter;
- return OPERATOR_RUNNING_MODAL;
+ return OPERATOR_RUNNING_MODAL;
}
/* -------------------------------------------------------------------- */
@@ -160,27 +154,32 @@ static int gizmo_primitive_invoke(
static void GIZMO_GT_primitive_3d(wmGizmoType *gzt)
{
- /* identifiers */
- gzt->idname = "GIZMO_GT_primitive_3d";
-
- /* api callbacks */
- gzt->draw = gizmo_primitive_draw;
- gzt->draw_select = gizmo_primitive_draw_select;
- gzt->setup = gizmo_primitive_setup;
- gzt->invoke = gizmo_primitive_invoke;
-
- gzt->struct_size = sizeof(wmGizmo);
-
- static EnumPropertyItem rna_enum_draw_style[] = {
- {ED_GIZMO_PRIMITIVE_STYLE_PLANE, "PLANE", 0, "Plane", ""},
- {0, NULL, 0, NULL, NULL},
- };
- RNA_def_enum(gzt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_PRIMITIVE_STYLE_PLANE, "Draw Style", "");
+ /* identifiers */
+ gzt->idname = "GIZMO_GT_primitive_3d";
+
+ /* api callbacks */
+ gzt->draw = gizmo_primitive_draw;
+ gzt->draw_select = gizmo_primitive_draw_select;
+ gzt->setup = gizmo_primitive_setup;
+ gzt->invoke = gizmo_primitive_invoke;
+
+ gzt->struct_size = sizeof(wmGizmo);
+
+ static EnumPropertyItem rna_enum_draw_style[] = {
+ {ED_GIZMO_PRIMITIVE_STYLE_PLANE, "PLANE", 0, "Plane", ""},
+ {0, NULL, 0, NULL, NULL},
+ };
+ RNA_def_enum(gzt->srna,
+ "draw_style",
+ rna_enum_draw_style,
+ ED_GIZMO_PRIMITIVE_STYLE_PLANE,
+ "Draw Style",
+ "");
}
void ED_gizmotypes_primitive_3d(void)
{
- WM_gizmotype_append(GIZMO_GT_primitive_3d);
+ WM_gizmotype_append(GIZMO_GT_primitive_3d);
}
/** \} */