59 #include "../gizmo_geometry.h"
60 #include "../gizmo_library_intern.h"
89 #define DIAL_WIDTH 1.0f
90 #define DIAL_RESOLUTION 48
93 #define DIAL_CLIP_BIAS 0.02
98 const float line_width,
100 const float axis_modal_mat[4][4],
101 const float clip_plane[4],
102 const float arc_partial_angle,
103 const float arc_inner_factor,
104 const int draw_options)
106 #ifdef USE_GIZMO_CUSTOM_DIAL
131 if (arc_partial_angle == 0.0f) {
132 if (arc_inner_factor == 0.0f) {
141 float arc_partial_deg =
RAD2DEGF((
M_PI * 2) - arc_partial_angle);
148 -arc_partial_deg / 2,
158 if (arc_partial_angle == 0.0f) {
160 if (arc_inner_factor != 0.0f) {
165 float arc_partial_deg =
RAD2DEGF((
M_PI * 2) - arc_partial_angle);
169 if (arc_inner_factor != 0.0f) {
186 const float co_outer[3],
187 const float color[4],
188 const float line_width)
219 const int tot_incr = (2 *
M_PI) / incremental_angle;
234 for (
int i = 0; i < tot_incr; i++) {
235 v[0] =
sinf(offset + incremental_angle * i);
236 v[1] =
cosf(offset + incremental_angle * i);
251 const float arc_inner_factor,
252 const float color[4])
261 int rotation_count = (int)
floorf(
fabsf(angle_delta) / pi2);
262 angle_delta = fmod(angle_delta, pi2);
265 const float angle_background = angle_delta >= 0 ? (pi2 - angle_delta) : -(pi2 + angle_delta);
267 float color_background[4] = {0};
268 if (arc_inner_factor != 0.0) {
269 color_background[3] = color[3] / 2.0f;
272 if (rotation_count != 0) {
275 color_background[3] = color[3] * rotation_count;
303 const float mat[4][4],
304 const float co_outer[3],
313 float view_vec[3], axis_vec[3];
317 float proj_outer_rel[3];
321 float proj_mval_new_rel[3];
322 float proj_mval_init_rel[3];
328 region, dial_plane, inter->
init.
mval,
false, proj_mval_init_rel)) {
377 const float angle_delta,
378 const float arc_inner_factor,
379 const float color_helpline[4],
380 const int draw_options)
383 const float co_outer[4] = {0.0f,
DIAL_WIDTH, 0.0f};
384 const float color_arc_inner[4] = {0.8f, 0.8f, 0.8f, 0.2f};
395 float matrix_final[4][4];
405 const float arc_partial_angle =
RNA_float_get(gz->
ptr,
"arc_partial_angle");
408 float angle_ofs = 0.0f;
409 float angle_delta = 0.0f;
410 float angle_increment = 0.0f;
437 .draw_options = draw_options,
438 .angle_ofs = angle_ofs,
439 .angle_delta = angle_delta,
440 .angle_increment = angle_increment,
441 .arc_partial_angle = arc_partial_angle,
442 .arc_inner_factor = arc_inner_factor,
443 .clip_plane = clip_plane,
449 float clip_plane_buf[4];
470 float clip_plane_buf[4];
500 const float co_outer[4] = {0.0f,
DIAL_WIDTH, 0.0f};
501 float angle_ofs, angle_delta, angle_increment = 0.0f;
508 angle_delta = (
float)roundf((
double)angle_delta / angle_increment) * angle_increment;
511 angle_increment *= 0.2f;
514 if (angle_delta != 0.0f) {
536 bool use_reset_value =
false;
537 float reset_value = 0.0f;
542 use_reset_value =
true;
550 use_reset_value =
true;
556 if (use_reset_value) {
573 const float dir_default[3] = {0.0f, 0.0f, 1.0f};
583 inter->
init.
mval[0] =
event->mval[0];
584 inter->
init.
mval[1] =
event->mval[1];
601 const float matrix_final[4][4],
602 const float line_width,
603 const float color[4],
629 if (
params->angle_increment) {
639 params->arc_partial_angle,
649 gzt->
idname =
"GIZMO_GT_dial_3d";
674 gzt->
srna,
"arc_inner_factor", 0.0f, 0.0f, 1.0f,
"Arc Inner Factor",
"", 0.0f, 1.0f);
690 "Angle to snap in steps",
699 "Value to use for a single click action",
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
void mul_v3_project_m4_v3(float r[3], const float mat[4][4], const float vec[3])
float angle_wrap_rad(float angle)
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
float angle_signed_on_axis_v3v3_v3(const float v1[3], const float v2[3], const float axis[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v3_v3(float r[3], const float a[3])
typedef double(DMatrix)[4][4]
@ ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR
@ ED_GIZMO_DIAL_DRAW_FLAG_FILL_SELECT
@ ED_GIZMO_DIAL_DRAW_FLAG_FILL
@ ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y
@ ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE
@ ED_GIZMO_DIAL_DRAW_FLAG_CLIP
bool ED_view3d_win_to_3d_on_plane(const struct ARegion *region, const float plane[4], const float mval[2], const bool do_clip, float r_out[3])
void ED_view3d_global_to_vector(const struct RegionView3D *rv3d, const float coord[3], float vec[3])
void GPU_matrix_pop(void)
#define GPU_matrix_mul(x)
void GPU_matrix_push(void)
void GPU_matrix_rotate_3f(float deg, float x, float y, float z)
bool GPU_select_load_id(unsigned int id)
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
@ GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR
@ GPU_SHADER_3D_UNIFORM_COLOR
@ GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR
void GPU_blend(eGPUBlend blend)
void GPU_viewport_size_get_f(float coords[4])
void GPU_polygon_smooth(bool enable)
Read Guarded memory(de)allocation.
eWM_GizmoFlagTweak
Gizmo tweak flag. Bitflag passed to gizmo while tweaking.
@ WM_GIZMO_STATE_HIGHLIGHT
ATTR_WARN_UNUSED_RESULT const BMVert * v
ccl_device_inline float wrap_angle(float a)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
static void dial_ghostarc_draw_incremental_angle(const float incremental_angle, const float offset)
static void gizmo_dial_exit(bContext *C, wmGizmo *gz, const bool cancel)
static void dial_ghostarc_get_angles(const wmGizmo *gz, const wmEvent *event, const ARegion *region, const float mat[4][4], const float co_outer[3], float *r_start, float *r_delta)
static int gizmo_dial_modal(bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak tweak_flag)
static void gizmo_dial_setup(wmGizmo *gz)
static void dial_ghostarc_draw_with_helplines(const float angle_ofs, const float angle_delta, const float arc_inner_factor, const float color_helpline[4], const int draw_options)
static void gizmo_dial_draw(const bContext *C, wmGizmo *gz)
static void gizmo_dial_draw_select(const bContext *C, wmGizmo *gz, int select_id)
void ED_gizmotypes_dial_3d_draw_util(const float matrix_basis[4][4], const float matrix_final[4][4], const float line_width, const float color[4], const bool select, struct Dial3dParams *params)
static void dial_draw_intern(const bContext *C, wmGizmo *gz, const bool select, const bool highlight, float clip_plane[4])
void ED_gizmotypes_dial_3d(void)
static void dial_ghostarc_draw(const float angle_ofs, float angle_delta, const float arc_inner_factor, const float color[4])
struct DialInteraction DialInteraction
static void GIZMO_GT_dial_3d(wmGizmoType *gzt)
static void dial_geom_draw(const float color[4], const float line_width, const bool select, const float axis_modal_mat[4][4], const float clip_plane[4], const float arc_partial_angle, const float arc_inner_factor, const int draw_options)
static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[3], const float color[4], const float line_width)
static int gizmo_dial_invoke(bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
GizmoGeomInfo wm_gizmo_geom_data_dial
void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info, const bool UNUSED(select), const float color[4])
void gizmo_color_get(const struct wmGizmo *gz, const bool highlight, float r_color[4])
void *(* MEM_callocN)(size_t len, const char *str)
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
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)
PropertyRNA * RNA_def_float_factor(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
struct DialInteraction::@320 init
struct DialInteraction::@322 output
struct DialInteraction::@321 prev
eWM_GizmoFlagTweak tweak_flag
wmGizmoFnDrawSelect draw_select
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
void WM_gizmo_target_property_float_set(bContext *C, const wmGizmo *gz, wmGizmoProperty *gz_prop, const float value)
wmGizmoProperty * WM_gizmo_target_property_find(wmGizmo *gz, const char *idname)
bool WM_gizmo_target_property_is_valid(const wmGizmoProperty *gz_prop)
void WM_gizmotype_target_property_def(wmGizmoType *gzt, const char *idname, int data_type, int array_length)
float WM_gizmo_target_property_float_get(const wmGizmo *gz, wmGizmoProperty *gz_prop)
void WM_gizmo_target_property_anim_autokey(bContext *C, const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop)
void WM_gizmotype_append(void(*gtfunc)(struct wmGizmoType *))