73 const float fill_alpha,
75 const float screen_scale)
80 const float max_pixel_error = 0.25f;
81 int nsegments = int(
ceilf(
M_PI /
acosf(1.0f - max_pixel_error / screen_scale)));
82 nsegments =
max_ff(nsegments, 8);
83 nsegments =
min_ff(nsegments, 1000);
90 if (color[3] == 1.0 && fill_alpha == 1.0 &&
select ==
false) {
105 if ((fill_alpha != 0.0f) || (
select ==
true)) {
106 const float fill_color[4] = {
UNPACK3(color), fill_alpha * color[3]};
114 if ((fill_alpha != 1.0f) && (
select ==
false)) {
130 const bool highlight)
137 if (button->
is_init ==
false) {
155 if (
LIKELY(polys_len > 0)) {
160 (
const uchar *)polys, polys_len - 1,
nullptr);
162 (
const uchar *)polys, polys_len - 1,
nullptr);
169 float matrix_final[4][4];
177 float matrix_final_no_offset[4][4];
180 immVertexFormat(),
"pos", blender::gpu::VertAttrType::SFLOAT_32_32_32);
192 bool need_to_pop =
true;
196 float screen_scale = 200.0f;
199 float matrix_align[4][4];
200 float matrix_final_unit[4][4];
228 const bool do_wires = (
i == 1);
245 float color_contrast[4];
247 color_contrast[3] = color[3];
257 color[0] = 1.0f - color[0];
258 color[1] = 1.0f - color[1];
259 color[2] = 1.0f - color[2];
265 else if (button->
icon != -1) {
268 const float fac = 2.0f;
282 float alpha = (highlight) ? 1.0f : 0.8f;
312 float point_local[2];
343#define CIRCLE_RESOLUTION_3D 32
348 const float *co =
nullptr;
349 float matrix_final[4][4];
358 float matrix_final_no_offset[4][4];
373 co = matrix_final[3];
379 r_bounding_box->
xmax = r_bounding_box->
xmin + rad;
380 r_bounding_box->
ymax = r_bounding_box->
ymin + rad;
404 gzt->
idname =
"GIZMO_GT_button_2d";
421 {0,
nullptr, 0,
nullptr,
nullptr},
439 "backdrop_fill_alpha",
443 "When below 1.0, draw the interior with a reduced alpha compared to the outline",
ScrArea * CTX_wm_area(const bContext *C)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
MINLINE float srgb_to_grayscale(const float rgb[3])
float mat4_to_scale(const float mat[4][4])
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void normalize_m4_m4(float rmat[4][4], const float mat[4][4]) ATTR_NONNULL()
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
float ED_view3d_pixel_size_no_ui_scale(const RegionView3D *rv3d, const float co[3])
eV3DProjStatus ED_view3d_project_float_global(const ARegion *region, const float co[3], float r_co[2], eV3DProjTest flag)
#define GPU_batch_uniform_1f(batch, name, x)
void GPU_batch_program_set_builtin(blender::gpu::Batch *batch, GPUBuiltinShader shader_id)
#define GPU_batch_uniform_2fv(batch, name, val)
#define GPU_BATCH_DISCARD_SAFE(batch)
void GPU_batch_draw(blender::gpu::Batch *batch)
blender::gpu::Batch * GPU_batch_tris_from_poly_2d_encoded(const uchar *polys_flat, uint polys_flat_len, const rctf *rect) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
blender::gpu::Batch * GPU_batch_wire_from_poly_2d_encoded(const uchar *polys_flat, uint polys_flat_len, const rctf *rect) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void GPU_matrix_scale_2f(float x, float y)
#define GPU_matrix_mul(x)
void GPU_matrix_translate_2f(float x, float y)
bool GPU_select_load_id(unsigned int id)
void GPU_shader_uniform_4f(blender::gpu::Shader *sh, const char *name, float x, float y, float z, float w)
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
@ GPU_SHADER_3D_UNIFORM_COLOR
void GPU_line_smooth(bool enable)
void GPU_blend(GPUBlend blend)
void GPU_viewport_size_get_f(float coords[4])
void GPU_polygon_smooth(bool enable)
Read Guarded memory(de)allocation.
#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
void gizmo_color_get(const wmGizmo *gz, bool highlight, float r_color[4])
bool gizmo_window_project_2d(bContext *C, const wmGizmo *gz, const float mval[2], int axis, bool use_offset, float r_co[2])
static float WM_gizmo_select_bias(bool select)
void ui_icon_ensure_deferred(const bContext *C, const int icon_id, const bool big)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
float RNA_float_get(PointerRNA *ptr, const char *name)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
std::string RNA_property_string_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, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
const EnumPropertyItem rna_enum_icon_items[]
eWM_GizmoFlagGroupTypeFlag flag
wmGizmoFnScreenBoundsGet screen_bounds_get
wmGizmoFnTestSelect test_select
wmGizmoFnCursorGet cursor_get
wmGizmoFnDrawSelect draw_select
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)(wmGizmoType *))