45 #include "../gizmo_geometry.h"
46 #include "../gizmo_library_intern.h"
68 const float fill_alpha,
70 const float screen_scale)
75 const float max_pixel_error = 0.25f;
76 int nsegments = (int)(
ceilf(
M_PI /
acosf(1.0f - max_pixel_error / screen_scale)));
77 nsegments =
max_ff(nsegments, 8);
78 nsegments =
min_ff(nsegments, 1000);
85 if (
color[3] == 1.0 && fill_alpha == 1.0 &&
select ==
false) {
100 if ((fill_alpha != 0.0f) || (
select ==
true)) {
109 if ((fill_alpha != 1.0f) && (
select ==
false)) {
125 const bool highlight)
132 if (button->
is_init ==
false) {
143 char *polys =
MEM_mallocN(polys_len + 1, __func__);
154 float matrix_final[4][4];
162 float matrix_final_no_offset[4][4];
176 bool need_to_pop =
true;
180 float screen_scale = 200.0f;
183 float matrix_align[4][4];
184 float matrix_final_unit[4][4];
212 const bool do_wires = (i == 1);
229 float color_contrast[4];
231 color_contrast[3] =
color[3];
249 else if (button->
icon != -1) {
252 const float fac = 2.0f;
266 float alpha = (highlight) ? 1.0f : 0.8f;
296 float point_local[2];
326 #define CIRCLE_RESOLUTION_3D 32
331 const float *co =
NULL;
332 float matrix_final[4][4];
340 float matrix_final_no_offset[4][4];
355 co = matrix_final[3];
359 r_bounding_box->
xmin = co[0] +
area->totrct.xmin - rad;
360 r_bounding_box->
ymin = co[1] +
area->totrct.ymin - rad;
361 r_bounding_box->
xmax = r_bounding_box->
xmin + rad;
362 r_bounding_box->
ymax = r_bounding_box->
ymin + rad;
386 gzt->
idname =
"GIZMO_GT_button_2d";
419 "backdrop_fill_alpha",
423 "When below 1.0, draw the interior with a reduced alpha compared to the outline",
struct ScrArea * CTX_wm_area(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct RegionView3D * CTX_wm_region_view3d(const bContext *C)
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
MINLINE float rgb_to_grayscale(const float rgb[3])
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void normalize_m4_m4(float R[4][4], const float M[4][4]) ATTR_NONNULL()
float mat4_to_scale(const float M[4][4])
void transpose_m4(float R[4][4])
MINLINE float len_squared_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2(float r[2], const float a[2])
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_fl(float r[3], float f)
MINLINE void zero_v3(float r[3])
@ ED_GIZMO_BUTTON_SHOW_BACKDROP
@ ED_GIZMO_BUTTON_SHOW_OUTLINE
@ ED_GIZMO_BUTTON_SHOW_HELPLINE
eV3DProjStatus ED_view3d_project_float_global(const struct ARegion *region, const float co[3], float r_co[2], eV3DProjTest flag)
float ED_view3d_pixel_size_no_ui_scale(const struct RegionView3D *rv3d, const float co[3])
#define GPU_batch_uniform_1f(batch, name, x)
void GPU_batch_program_set_builtin(GPUBatch *batch, eGPUBuiltinShader shader_id)
#define GPU_batch_uniform_2fv(batch, name, val)
#define GPU_BATCH_DISCARD_SAFE(batch)
void GPU_batch_draw(GPUBatch *batch)
struct GPUBatch * GPU_batch_tris_from_poly_2d_encoded(const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
struct GPUBatch * GPU_batch_wire_from_poly_2d_encoded(const uchar *polys_flat, uint polys_flat_len, const struct rctf *rect) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void GPU_matrix_pop(void)
void GPU_matrix_scale_2f(float x, float y)
#define GPU_matrix_mul(x)
void GPU_matrix_push(void)
void GPU_matrix_translate_2f(float x, float y)
bool GPU_select_load_id(unsigned int id)
void GPU_shader_uniform_4f(GPUShader *sh, const char *name, float x, float y, float z, float w)
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
@ GPU_SHADER_2D_UNIFORM_COLOR
@ GPU_SHADER_3D_UNIFORM_COLOR
void GPU_blend(eGPUBlend blend)
void GPU_line_smooth(bool enable)
void GPU_viewport_size_get_f(float coords[4])
void GPU_polygon_smooth(bool enable)
Read Guarded memory(de)allocation.
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 Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input 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 a color
#define ICON_DEFAULT_HEIGHT
void UI_icon_draw_alpha(float x, float y, int icon_id, float alpha)
#define ICON_DEFAULT_WIDTH
@ WM_GIZMO_STATE_HIGHLIGHT
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
bool gizmo_window_project_2d(bContext *C, const struct wmGizmo *gz, const float mval[2], int axis, bool use_offset, float r_co[2])
void gizmo_color_get(const struct wmGizmo *gz, bool highlight, float r_color[4])
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
static void area(int d1, int d2, int e1, int e2, float weights[2])
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop, char *value)
float RNA_float_get(PointerRNA *ptr, const char *name)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
int RNA_property_string_length(PointerRNA *ptr, PropertyRNA *prop)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
const EnumPropertyItem rna_enum_icon_items[]
eWM_GizmoFlagGroupTypeFlag flag
struct wmGizmoGroupType * type
wmGizmoFnScreenBoundsGet screen_bounds_get
wmGizmoFnTestSelect test_select
wmGizmoFnCursorGet cursor_get
wmGizmoFnDrawSelect draw_select
struct wmGizmoGroup * parent_gzgroup
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
void WM_gizmo_calc_matrix_final_no_offset(const wmGizmo *gz, float r_mat[4][4])
void WM_gizmotype_append(void(*gtfunc)(struct wmGizmoType *))