Blender V4.3
gizmo_library_presets.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
12
13#include "DNA_object_types.h"
14
15#include "BLI_math_matrix.h"
16#include "BLI_math_rotation.h"
17
18#include "GPU_matrix.hh"
19#include "GPU_select.hh"
20
21#include "WM_types.hh"
22
23/* own includes */
24#include "ED_gizmo_library.hh" /* own include */
25#include "gizmo_library_intern.hh" /* own include */
26
27/* TODO: this is to be used by RNA. might move to ED_gizmo_library. */
28
32static void single_axis_convert(int src_axis,
33 const float src_mat[4][4],
34 int dst_axis,
35 float dst_mat[4][4])
36{
37 copy_m4_m4(dst_mat, src_mat);
38 if (src_axis == dst_axis) {
39 return;
40 }
41
42 float rotmat[3][3];
43 mat3_from_axis_conversion_single(src_axis, dst_axis, rotmat);
44 transpose_m3(rotmat);
45 mul_m4_m4m3(dst_mat, src_mat, rotmat);
46}
47
52 const float mat[4][4],
53 int select_id,
54 const GizmoGeomInfo *info)
55{
56 const bool is_select = (select_id != -1);
57 const bool is_highlight = is_select && (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
58
59 float color[4];
60 gizmo_color_get(gz, is_highlight, color);
61
62 if (is_select) {
63 GPU_select_load_id(select_id);
64 }
65
67 GPU_matrix_mul(mat);
68 wm_gizmo_geometryinfo_draw(info, is_select, color);
70
71 if (is_select) {
73 }
74}
75
76void ED_gizmo_draw_preset_box(const wmGizmo *gz, const float mat[4][4], int select_id)
77{
79}
80
81void ED_gizmo_draw_preset_arrow(const wmGizmo *gz, const float mat[4][4], int axis, int select_id)
82{
83 float mat_rotate[4][4];
84 single_axis_convert(OB_POSZ, mat, axis, mat_rotate);
86}
87
88void ED_gizmo_draw_preset_circle(const wmGizmo *gz, const float mat[4][4], int axis, int select_id)
89{
90 float mat_rotate[4][4];
91 single_axis_convert(OB_POSZ, mat, axis, mat_rotate);
92 ed_gizmo_draw_preset_geometry(gz, mat_rotate, select_id, &wm_gizmo_geom_data_dial);
93}
void mul_m4_m4m3(float R[4][4], const float A[4][4], const float B[3][3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void transpose_m3(float R[3][3])
bool mat3_from_axis_conversion_single(int src_axis, int dst_axis, float r_mat[3][3])
Object is a sort of wrapper for general info.
@ OB_POSZ
void GPU_matrix_push()
#define GPU_matrix_mul(x)
void GPU_matrix_pop()
bool GPU_select_load_id(unsigned int id)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
@ WM_GIZMO_STATE_HIGHLIGHT
GizmoGeomInfo wm_gizmo_geom_data_arrow
GizmoGeomInfo wm_gizmo_geom_data_cube
GizmoGeomInfo wm_gizmo_geom_data_dial
void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info, const bool, const float color[4])
void gizmo_color_get(const wmGizmo *gz, bool highlight, float r_color[4])
void ED_gizmo_draw_preset_box(const wmGizmo *gz, const float mat[4][4], int select_id)
static void ed_gizmo_draw_preset_geometry(const wmGizmo *gz, const float mat[4][4], int select_id, const GizmoGeomInfo *info)
void ED_gizmo_draw_preset_circle(const wmGizmo *gz, const float mat[4][4], int axis, int select_id)
static void single_axis_convert(int src_axis, const float src_mat[4][4], int dst_axis, float dst_mat[4][4])
void ED_gizmo_draw_preset_arrow(const wmGizmo *gz, const float mat[4][4], int axis, int select_id)
eWM_GizmoFlagState state