Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gizmo_library/gizmo_library_presets.c
| Show All 30 Lines | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "GPU_draw.h" | #include "GPU_draw.h" | ||||
| #include "GPU_immediate.h" | #include "GPU_immediate.h" | ||||
| #include "GPU_immediate_util.h" | #include "GPU_immediate_util.h" | ||||
| #include "GPU_matrix.h" | #include "GPU_matrix.h" | ||||
| #include "GPU_select.h" | #include "GPU_select.h" | ||||
| #include "GPU_state.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "ED_view3d.h" | #include "ED_view3d.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "UI_interface_icons.h" | |||||
| #include "UI_resources.h" | |||||
| /* own includes */ | /* own includes */ | ||||
| #include "ED_gizmo_library.h" /* own include */ | #include "ED_gizmo_library.h" /* own include */ | ||||
| #include "gizmo_library_intern.h" /* own include */ | #include "gizmo_library_intern.h" /* own include */ | ||||
| /* TODO, this is to be used by RNA. might move to ED_gizmo_library */ | /* TODO, this is to be used by RNA. might move to ED_gizmo_library */ | ||||
| /** | /** | ||||
| * Given a single axis, orient the matrix to a different direction. | * Given a single axis, orient the matrix to a different direction. | ||||
| ▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | void ED_gizmo_draw_preset_facemap( | ||||
| GPU_matrix_mul(ob->obmat); | GPU_matrix_mul(ob->obmat); | ||||
| ED_draw_object_facemap(depsgraph, ob, color, facemap); | ED_draw_object_facemap(depsgraph, ob, color, facemap); | ||||
| GPU_matrix_pop(); | GPU_matrix_pop(); | ||||
| if (is_select) { | if (is_select) { | ||||
| GPU_select_load_id(-1); | GPU_select_load_id(-1); | ||||
| } | } | ||||
| } | } | ||||
| void ED_gizmo_draw_preset_snap_elem(const struct wmGizmo *UNUSED(gz), | |||||
| const float screen_co[2], | |||||
| const unsigned char color[4], | |||||
| const short snap_elem_type) | |||||
| { | |||||
| float size = 2.5f * UI_GetThemeValuef(TH_VERTEX_SIZE); | |||||
| GPUVertFormat *format = immVertexFormat(); | |||||
| uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | |||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | |||||
| immUniformColor4ubv(color); | |||||
| imm_draw_circle_wire_2d(pos, screen_co[0], screen_co[1], size, 24); | |||||
| immUnbindProgram(); | |||||
| float scr_co[2]; | |||||
| copy_v2_v2(scr_co, screen_co); | |||||
| scr_co[0] += size; | |||||
| scr_co[1] -= (ICON_DEFAULT_HEIGHT * 0.5f) * U.dpi_fac; | |||||
| if (snap_elem_type) { | |||||
| int icon_id; | |||||
| switch (snap_elem_type) { | |||||
| case SCE_SNAP_MODE_VERTEX: | |||||
| icon_id = ICON_SNAP_VERTEX; | |||||
| break; | |||||
| case SCE_SNAP_MODE_EDGE: | |||||
| icon_id = ICON_SNAP_EDGE; | |||||
| break; | |||||
| case SCE_SNAP_MODE_FACE: | |||||
| icon_id = ICON_SNAP_FACE; | |||||
| break; | |||||
| case SCE_SNAP_MODE_VOLUME: | |||||
| icon_id = ICON_SNAP_VOLUME; | |||||
| break; | |||||
| case SCE_SNAP_MODE_EDGE_MIDPOINT: | |||||
| icon_id = ICON_SNAP_MIDPOINT; | |||||
| break; | |||||
| case SCE_SNAP_MODE_EDGE_PERPENDICULAR: | |||||
| icon_id = ICON_SNAP_PERPENDICULAR; | |||||
| break; | |||||
| default: | |||||
| BLI_assert(0); | |||||
| icon_id = ICON_NONE; | |||||
| } | |||||
| GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ZERO, GPU_SRC_ALPHA); | |||||
| GPU_blend(true); | |||||
| UI_icon_draw_ex(scr_co[0], scr_co[1], icon_id, U.inv_dpi_fac, 1.0f, 0.0f, color, false); | |||||
| GPU_blend(false); | |||||
| } | |||||
| } | |||||