Blender V4.5
dial3d_gizmo.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2014 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
19
20#include "MEM_guardedalloc.h"
21
22#include "BLI_math_geom.h"
23#include "BLI_math_matrix.h"
24#include "BLI_math_rotation.h"
25
26#include "BKE_context.hh"
27
28#include "GPU_immediate.hh"
29#include "GPU_immediate_util.hh"
30#include "GPU_matrix.hh"
31#include "GPU_select.hh"
32#include "GPU_state.hh"
33
34#include "RNA_access.hh"
35#include "RNA_define.hh"
36
37#include "WM_api.hh"
38#include "WM_types.hh"
39
40#include "ED_gizmo_library.hh"
41#include "ED_screen.hh"
42#include "ED_transform.hh"
43#include "ED_view3d.hh"
44
45/* own includes */
47
48// /** To use custom dials exported to `geom_dial_gizmo.cc`. */
49// #define USE_GIZMO_CUSTOM_DIAL
50
52 struct {
53 float mval[2];
54 /* Only for when using properties. */
57 struct {
58 /* Cache the last angle to detect rotations bigger than -/+ PI. */
60 float angle;
62
63 /* Number of full rotations. */
67
68 /* Final output values, used for drawing. */
69 struct {
70 float angle_ofs;
73};
74
75#define DIAL_WIDTH 1.0f
76
77/* Could make option, negative to clip more (don't show when view aligned). */
78#define DIAL_CLIP_BIAS 0.02
79
80/* -------------------------------------------------------------------- */
90static void dial_3d_draw_util(const float matrix_final[4][4],
91 const float line_width,
92 const float color[4],
93 const bool select,
95
96static void dial_geom_draw(const float color[4],
97 const float line_width,
98 const bool select,
99 const float clip_plane_mat[4][4],
100 const float clip_plane[4],
101 const float arc_partial_angle,
102 const float arc_inner_factor,
103 const int draw_options)
104{
105#ifdef USE_GIZMO_CUSTOM_DIAL
106 UNUSED_VARS(gz, axis_modal_mat, clip_plane);
108#else
109 const bool filled = (draw_options & (select ? (ED_GIZMO_DIAL_DRAW_FLAG_FILL |
112
114 /* NOTE(Metal): Prefer using 3D coordinates with 3D shader, even if rendering 2D gizmo's. */
116
117 if (clip_plane) {
120 immUniform4fv("ClipPlane", clip_plane);
121 immUniformMatrix4fv("ModelMatrix", clip_plane_mat);
122 }
123 else {
126 }
127
128 immUniformColor4fv(color);
129
130 if (filled) {
131 if (arc_partial_angle == 0.0f) {
132 if (arc_inner_factor == 0.0f) {
133 imm_draw_circle_fill_3d(pos, 0.0f, 0.0f, 1.0f, DIAL_RESOLUTION);
134 }
135 else {
137 pos, 0.0f, 0.0f, 0.0f, arc_inner_factor, 1.0f, DIAL_RESOLUTION, 0, RAD2DEGF(M_PI * 2));
138 }
139 }
140 else {
141 float arc_partial_deg = RAD2DEGF((M_PI * 2) - arc_partial_angle);
143 0.0f,
144 0.0f,
145 0.0f,
146 arc_inner_factor,
147 1.0f,
149 -arc_partial_deg / 2,
150 arc_partial_deg);
151 }
152 }
153 else {
154 float viewport[4];
155 GPU_viewport_size_get_f(viewport);
156 immUniform2fv("viewportSize", &viewport[2]);
157 immUniform1f("lineWidth", line_width);
158
159 if (arc_partial_angle == 0.0f) {
160 imm_draw_circle_wire_3d(pos, 0.0f, 0.0f, 1.0f, DIAL_RESOLUTION);
161 if (arc_inner_factor != 0.0f) {
162 imm_draw_circle_wire_3d(pos, 0.0f, 0.0f, arc_inner_factor, DIAL_RESOLUTION);
163 }
164 }
165 else {
166 float arc_partial_deg = RAD2DEGF((M_PI * 2) - arc_partial_angle);
168 pos, 0.0f, 0.0f, 0.0f, 1.0f, DIAL_RESOLUTION, -arc_partial_deg / 2, arc_partial_deg);
169# if 0
170 if (arc_inner_factor != 0.0f) {
171 BLI_assert(0);
172 }
173# endif
174 }
175 }
176
178
180#endif
181}
182
186static void dial_ghostarc_draw_helpline(const float angle,
187 const float co_outer[3],
188 const float color[4],
189 const float line_width)
190{
192 GPU_matrix_rotate_3f(RAD2DEGF(angle), 0.0f, 0.0f, -1.0f);
193
195
197
198 float viewport[4];
199 GPU_viewport_size_get_f(viewport);
200 immUniform2fv("viewportSize", &viewport[2]);
201 immUniform1f("lineWidth", line_width * U.pixelsize);
202
203 immUniformColor4fv(color);
204
206 immVertex3f(pos, 0.0f, 0.0f, 0.0f);
207 immVertex3fv(pos, co_outer);
208 immEnd();
209
211
213}
214
218static void dial_ghostarc_draw_incremental_angle(const float incremental_angle,
219 const float offset,
220 const float angle_delta)
221{
222
225
226 immUniformColor3f(1.0f, 1.0f, 1.0f);
227
228 float viewport[4];
229 GPU_viewport_size_get_f(viewport);
230 immUniform2fv("viewportSize", &viewport[2]);
231 immUniform1f("lineWidth", U.pixelsize);
232
233 const int current_increment = roundf(angle_delta / incremental_angle);
234 const int total_increment = roundf((M_PI * 2.0f) / incremental_angle);
235
236 immBegin(GPU_PRIM_LINES, total_increment * 2);
237
238 /* Chop off excess full circles, draw an arc of ticks centered at current increment;
239 * if there's no even division of circle by increment,
240 * ends of the arc will move with the rotation. */
241 const float start_offset = fmodf(
242 offset + incremental_angle * (current_increment - total_increment / 2), M_PI * 2.0f);
243
244 float v[3] = {0};
245 for (int i = 0; i < total_increment; i++) {
246 v[0] = sinf(start_offset + incremental_angle * i);
247 v[1] = cosf(start_offset + incremental_angle * i);
248
249 mul_v2_fl(v, DIAL_WIDTH * 1.1f);
251
252 mul_v2_fl(v, 1.1f);
254 }
255
256 immEnd();
258}
259
260static void dial_ghostarc_draw(const float angle_ofs,
261 float angle_delta,
262 const float arc_inner_factor,
263 const float color[4])
264{
265 const float width_inner = DIAL_WIDTH;
269
270 /* Avoid artifacts by drawing the main arc over the span of one rotation only. */
271 const float pi2 = float(M_PI * 2.0);
272 int rotation_count = int(floorf(fabsf(angle_delta) / pi2));
273 angle_delta = fmod(angle_delta, pi2);
274
275 /* Calculate the remaining angle that can be filled with the background color. */
276 const float angle_background = angle_delta >= 0 ? (pi2 - angle_delta) : -(pi2 + angle_delta);
277
278 float color_background[4] = {0};
279 if (arc_inner_factor != 0.0) {
280 color_background[3] = color[3] / 2.0f;
281 }
282
283 if (rotation_count != 0) {
284 /* Calculate the background color to visualize the rotation count. */
285 copy_v4_v4(color_background, color);
286 color_background[3] = color[3] * rotation_count;
287 }
288
289 immUniformColor4fv(color_background);
291 0,
292 0,
293 arc_inner_factor,
294 width_inner,
296 RAD2DEGF(angle_ofs + angle_delta),
297 RAD2DEGF(angle_background));
298
299 immUniformColor4f(UNPACK3(color), color[3] * (rotation_count + 1));
301 0,
302 0,
303 arc_inner_factor,
304 width_inner,
306 RAD2DEGF(angle_ofs),
307 RAD2DEGF(angle_delta));
309}
310
311static void dial_ghostarc_get_angles(const wmGizmo *gz,
312 const wmEvent *event,
313 const ARegion *region,
314 const float mat[4][4],
315 const float co_outer[3],
316 float *r_start,
317 float *r_delta)
318{
319 DialInteraction *inter = static_cast<DialInteraction *>(gz->interaction_data);
320 const RegionView3D *rv3d = static_cast<const RegionView3D *>(region->regiondata);
321 const float mval[2] = {float(event->xy[0] - region->winrct.xmin),
322 float(event->xy[1] - region->winrct.ymin)};
323
324 /* We might need to invert the direction of the angles. */
325 float view_vec[3], axis_vec[3];
326 ED_view3d_global_to_vector(rv3d, gz->matrix_basis[3], view_vec);
327 normalize_v3_v3(axis_vec, gz->matrix_basis[2]);
328
329 float proj_outer_rel[3];
330 mul_v3_project_m4_v3(proj_outer_rel, mat, co_outer);
331 sub_v3_v3(proj_outer_rel, gz->matrix_basis[3]);
332
333 float proj_mval_new_rel[3];
334 float proj_mval_init_rel[3];
335 float dial_plane[4];
336
337 plane_from_point_normal_v3(dial_plane, gz->matrix_basis[3], axis_vec);
338
339 const auto fail = [&]() {
340 /* If we can't project (unlikely). */
341 *r_start = 0.0;
342 *r_delta = 0.0;
343 };
344
346 region, dial_plane, inter->init.mval, false, proj_mval_init_rel))
347 {
348 fail();
349 return;
350 }
351 sub_v3_v3(proj_mval_init_rel, gz->matrix_basis[3]);
352
353 if (!ED_view3d_win_to_3d_on_plane(region, dial_plane, mval, false, proj_mval_new_rel)) {
354 fail();
355 return;
356 }
357 sub_v3_v3(proj_mval_new_rel, gz->matrix_basis[3]);
358
359 const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
360
361 /* Start direction from mouse or set by user. */
362 const float *proj_init_rel = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y) ?
363 gz->matrix_basis[1] :
364 proj_mval_init_rel;
365
366 /* Return angles. */
367 const float start = angle_wrap_rad(
368 angle_signed_on_axis_v3v3_v3(proj_outer_rel, proj_init_rel, axis_vec));
369 const float delta = angle_wrap_rad(
370 angle_signed_on_axis_v3v3_v3(proj_mval_init_rel, proj_mval_new_rel, axis_vec));
371
372 /* Change of sign, we passed the 180 degree threshold. This means we need to add a turn
373 * to distinguish between transition from 0 to -1 and -PI to +PI, use comparison with PI/2.
374 * Logic taken from #BLI_dial_angle */
375 if ((delta * inter->prev.angle < 0.0f) && (fabsf(inter->prev.angle) > float(M_PI_2))) {
376 if (inter->prev.angle < 0.0f) {
377 inter->rotations--;
378 }
379 else {
380 inter->rotations++;
381 }
382 }
383 inter->prev.angle = delta;
384
385 const bool wrap_angle = RNA_boolean_get(gz->ptr, "wrap_angle");
386 const double delta_final = double(delta) + ((2 * M_PI) * double(inter->rotations));
387 *r_start = start;
388 *r_delta = float(wrap_angle ? fmod(delta_final, 2 * M_PI) : delta_final);
389}
390
391static void dial_ghostarc_draw_with_helplines(const float angle_ofs,
392 const float angle_delta,
393 const float arc_inner_factor,
394 const float color_helpline[4],
395 const int draw_options)
396{
397 /* Coordinate at which the arc drawing will be started. */
398 const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f};
399 const float color_arc_inner[4] = {0.8f, 0.8f, 0.8f, 0.2f};
400 dial_ghostarc_draw(angle_ofs, angle_delta, arc_inner_factor, color_arc_inner);
401
402 float line_width = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE) ? 3.0f : 1.0f;
403 dial_ghostarc_draw_helpline(angle_ofs, co_outer, color_helpline, 1.0f);
404 dial_ghostarc_draw_helpline(angle_ofs + angle_delta, co_outer, color_helpline, line_width);
405}
406
407static void dial_draw_intern(const bContext *C,
408 wmGizmo *gz,
409 const bool select,
410 const bool highlight,
411 const bool use_clip_plane)
412{
413 float matrix_final[4][4];
414 float color[4];
415
416 (void)C;
417 BLI_assert(CTX_wm_area(C)->spacetype == SPACE_VIEW3D);
418
419 gizmo_color_get(gz, highlight, color);
420
421 WM_gizmo_calc_matrix_final(gz, matrix_final);
422
423 float clip_plane[4];
424 if (use_clip_plane) {
425 ARegion *region = CTX_wm_region(C);
426 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
427
428 copy_v3_v3(clip_plane, rv3d->viewinv[2]);
429 clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], gz->matrix_basis[3]);
430 /* NOTE: scaling by the pixel size has been needed since v3.4x,
431 * afterwards the behavior of the `ClipPlane` seems to have changed.
432 * While this works, it may be worth restoring the old behavior, see #111060. */
433 clip_plane[3] += (DIAL_CLIP_BIAS *
435 }
436
437 const float arc_partial_angle = RNA_float_get(gz->ptr, "arc_partial_angle");
438 const float arc_inner_factor = RNA_float_get(gz->ptr, "arc_inner_factor");
439 int draw_options = RNA_enum_get(gz->ptr, "draw_options");
440 float angle_ofs = 0.0f;
441 float angle_delta = 0.0f;
442 float angle_increment = 0.0f;
443
444 if (select) {
446 }
447
448 if (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE && (gz->flag & WM_GIZMO_DRAW_VALUE)) {
449 DialInteraction *inter = static_cast<DialInteraction *>(gz->interaction_data);
450 if (inter) {
451 angle_ofs = inter->output.angle_ofs;
452 angle_delta = inter->output.angle_delta;
453 angle_increment = inter->angle_increment;
454 }
455 else {
456 wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
458 angle_delta = WM_gizmo_target_property_float_get(gz, gz_prop);
459 }
460 if (gz->state & WM_GIZMO_STATE_MODAL) {
461 angle_increment = RNA_float_get(gz->ptr, "incremental_angle");
462 }
463 }
464 }
465
467 params.draw_options = draw_options;
468 params.angle_ofs = angle_ofs;
469 params.angle_delta = angle_delta;
470 params.angle_increment = angle_increment;
471 params.arc_partial_angle = arc_partial_angle;
472 params.arc_inner_factor = arc_inner_factor;
473 params.clip_plane = use_clip_plane ? clip_plane : nullptr;
474
475 const float line_width = (gz->line_width * U.pixelsize) + WM_gizmo_select_bias(select);
476 dial_3d_draw_util(matrix_final, line_width, color, select, &params);
477}
478
479static void gizmo_dial_draw_select(const bContext *C, wmGizmo *gz, int select_id)
480{
481 const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
482 const bool use_clip_plane = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_CLIP);
483
484 GPU_select_load_id(select_id);
485 dial_draw_intern(C, gz, true, false, use_clip_plane);
486}
487
488static void gizmo_dial_draw(const bContext *C, wmGizmo *gz)
489{
490 const bool is_modal = gz->state & WM_GIZMO_STATE_MODAL;
491 const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
492 const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
493 const bool use_clip_plane = !is_modal && (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_CLIP);
494
496 dial_draw_intern(C, gz, false, is_highlight, use_clip_plane);
498}
499
501 wmGizmo *gz,
502 const wmEvent *event,
503 eWM_GizmoFlagTweak tweak_flag)
504{
505 DialInteraction *inter = static_cast<DialInteraction *>(gz->interaction_data);
506 if (!inter) {
507 return OPERATOR_CANCELLED;
508 }
509
510 if ((event->type != MOUSEMOVE) && (inter->prev.tweak_flag == tweak_flag)) {
512 }
513 /* Coordinate at which the arc drawing will be started. */
514 const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f};
515 float angle_ofs, angle_delta, angle_increment = 0.0f;
516
518 gz, event, CTX_wm_region(C), gz->matrix_basis, co_outer, &angle_ofs, &angle_delta);
519
520 if (tweak_flag & WM_GIZMO_TWEAK_SNAP) {
521 angle_increment = RNA_float_get(gz->ptr, "incremental_angle");
522 angle_delta = roundf(double(angle_delta) / angle_increment) * angle_increment;
523 }
524 if (tweak_flag & WM_GIZMO_TWEAK_PRECISE) {
525 angle_increment *= 0.2f;
526 angle_delta *= 0.2f;
527 }
528 if (angle_delta != 0.0f) {
529 inter->has_drag = true;
530 }
531
532 inter->angle_increment = angle_increment;
533 inter->output.angle_delta = angle_delta;
534 inter->output.angle_ofs = angle_ofs;
535
536 /* Set the property for the operator and call its modal function. */
537 wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
539 WM_gizmo_target_property_float_set(C, gz, gz_prop, inter->init.prop_angle + angle_delta);
540 }
541
542 inter->prev.tweak_flag = tweak_flag;
543
545}
546
547static void gizmo_dial_exit(bContext *C, wmGizmo *gz, const bool cancel)
548{
549 DialInteraction *inter = static_cast<DialInteraction *>(gz->interaction_data);
550 if (inter) {
551 bool use_reset_value = false;
552 float reset_value = 0.0f;
553
554 if (cancel) {
555 /* Set the property for the operator and call its modal function. */
556 wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
558 use_reset_value = true;
559 reset_value = inter->init.prop_angle;
560 }
561 }
562 else {
563 if (inter->has_drag == false) {
564 PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "click_value");
565 if (RNA_property_is_set(gz->ptr, prop)) {
566 use_reset_value = true;
567 reset_value = RNA_property_float_get(gz->ptr, prop);
568 }
569 }
570 }
571
572 if (use_reset_value) {
573 wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
575 WM_gizmo_target_property_float_set(C, gz, gz_prop, reset_value);
576 }
577 }
578 }
579
580 if (!cancel) {
581 wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
584 }
585 }
586}
587
588static void gizmo_dial_setup(wmGizmo *gz)
589{
590 const float dir_default[3] = {0.0f, 0.0f, 1.0f};
591
592 /* defaults */
593 copy_v3_v3(gz->matrix_basis[2], dir_default);
594}
595
597{
598 if (gz->custom_modal) {
599 /* #DialInteraction is only used for the inner modal. */
601 }
602
604
605 inter->init.mval[0] = event->mval[0];
606 inter->init.mval[1] = event->mval[1];
607
608 wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
611 }
612
613 gz->interaction_data = inter;
614
616}
617
618/* -------------------------------------------------------------------- */
621
622static void dial_3d_draw_util(const float matrix_final[4][4],
623 const float line_width,
624 const float color[4],
625 const bool select,
627{
629 GPU_matrix_mul(matrix_final);
630
631 GPU_polygon_smooth(false);
632
633 if ((params->draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE) != 0) {
634 /* Draw rotation indicator arc first. */
636 params->angle_delta,
637 params->arc_inner_factor,
638 color,
639 params->draw_options);
640
641 if ((params->draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR) != 0) {
643 params->angle_delta,
644 params->arc_inner_factor,
645 color,
646 params->draw_options);
647 }
648 }
649
650 if (params->angle_increment) {
652 params->angle_increment, params->angle_ofs, params->angle_delta);
653 }
654
655 /* Draw actual dial gizmo. */
656 dial_geom_draw(color,
657 line_width,
658 select,
659 matrix_final,
660 params->clip_plane,
661 params->arc_partial_angle,
662 params->arc_inner_factor,
663 params->draw_options);
664
666}
667
669{
670 /* identifiers */
671 gzt->idname = "GIZMO_GT_dial_3d";
672
673 /* API callbacks. */
674 gzt->draw = gizmo_dial_draw;
676 gzt->setup = gizmo_dial_setup;
678 gzt->modal = gizmo_dial_modal;
679 gzt->exit = gizmo_dial_exit;
680
681 gzt->struct_size = sizeof(wmGizmo);
682
683 /* rna */
684 static const EnumPropertyItem rna_enum_draw_options[] = {
685 {ED_GIZMO_DIAL_DRAW_FLAG_CLIP, "CLIP", 0, "Clipped", ""},
686 {ED_GIZMO_DIAL_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""},
687 {ED_GIZMO_DIAL_DRAW_FLAG_FILL_SELECT, "FILL_SELECT", 0, "Use fill for selection test", ""},
688 {ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR, "ANGLE_MIRROR", 0, "Angle Mirror", ""},
689 {ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y, "ANGLE_START_Y", 0, "Angle Start Y", ""},
690 {ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE, "ANGLE_VALUE", 0, "Show Angle Value", ""},
691 {0, nullptr, 0, nullptr, nullptr},
692 };
693 RNA_def_enum_flag(gzt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", "");
694 RNA_def_boolean(gzt->srna, "wrap_angle", true, "Wrap Angle", "");
696 gzt->srna, "arc_inner_factor", 0.0f, 0.0f, 1.0f, "Arc Inner Factor", "", 0.0f, 1.0f);
698 "arc_partial_angle",
699 0.0f,
700 0.0f,
701 M_PI * 2,
702 "Show Partial Dial",
703 "",
704 0.0f,
705 M_PI * 2);
707 "incremental_angle",
709 0.0f,
710 M_PI * 2,
711 "Incremental Angle",
712 "Angle to snap in steps",
713 0.0f,
714 M_PI * 2);
715 RNA_def_float(gzt->srna,
716 "click_value",
717 0.0f,
718 -FLT_MAX,
719 FLT_MAX,
720 "Click Value",
721 "Value to use for a single click action",
722 -FLT_MAX,
723 FLT_MAX);
724
726}
727
732
ScrArea * CTX_wm_area(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
#define BLI_assert(a)
Definition BLI_assert.h:46
#define M_PI_2
#define RAD2DEGF(_rad)
#define M_PI
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
Definition math_geom.cc:217
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])
unsigned int uint
#define UNUSED_VARS(...)
#define UNPACK3(a)
@ SPACE_VIEW3D
@ OPERATOR_CANCELLED
@ OPERATOR_RUNNING_MODAL
@ 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
#define SNAP_INCREMENTAL_ANGLE
void ED_view3d_global_to_vector(const RegionView3D *rv3d, const float coord[3], float r_out[3])
float ED_view3d_pixel_size_no_ui_scale(const RegionView3D *rv3d, const float co[3])
bool ED_view3d_win_to_3d_on_plane(const ARegion *region, const float plane[4], const float mval[2], bool do_clip, float r_out[3])
void immEnd()
void immUniform2fv(const char *name, const float data[2])
void immUnbindProgram()
void immUniformMatrix4fv(const char *name, const float data[4][4])
void immUniformColor4f(float r, float g, float b, float a)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immVertex3f(uint attr_id, float x, float y, float z)
void immUniform1f(const char *name, float x)
GPUVertFormat * immVertexFormat()
void immUniformColor4fv(const float rgba[4])
void immUniformColor3f(float r, float g, float b)
void immUniform4fv(const char *name, const float data[4])
void immVertex3fv(uint attr_id, const float data[3])
void immBegin(GPUPrimType, uint vertex_len)
void imm_draw_disk_partial_fill_3d(uint pos, float x, float y, float z, float rad_inner, float rad_outer, int nsegments, float start, float sweep)
void imm_draw_circle_partial_wire_3d(uint pos, float x, float y, float z, float radius, int nsegments, float start, float sweep)
void imm_draw_circle_wire_3d(uint pos, float x, float y, float radius, int nsegments)
void imm_draw_circle_fill_3d(uint pos, float x, float y, float radius, int nsegments)
void imm_draw_disk_partial_fill_2d(uint pos, float x, float y, float rad_inner, float rad_outer, int nsegments, float start, float sweep)
void GPU_matrix_push()
#define GPU_matrix_mul(x)
void GPU_matrix_rotate_3f(float deg, float x, float y, float z)
void GPU_matrix_pop()
@ GPU_PRIM_LINES
@ GPU_PRIM_LINE_STRIP
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
@ GPU_BLEND_NONE
Definition GPU_state.hh:85
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:87
void GPU_blend(eGPUBlend blend)
Definition gpu_state.cc:42
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:273
void GPU_polygon_smooth(bool enable)
Definition gpu_state.cc:83
@ GPU_FETCH_FLOAT
uint GPU_vertformat_attr_add(GPUVertFormat *, blender::StringRef name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
Definition IK_Math.h:117
Read Guarded memory(de)allocation.
@ PROP_FLOAT
Definition RNA_types.hh:152
#define C
Definition RandGen.cpp:29
eWM_GizmoFlagTweak
Gizmo tweak flag. Bit-flag passed to gizmo while tweaking.
@ WM_GIZMO_TWEAK_PRECISE
@ WM_GIZMO_TWEAK_SNAP
@ WM_GIZMO_DRAW_VALUE
@ WM_GIZMO_STATE_HIGHLIGHT
@ WM_GIZMO_STATE_MODAL
#define U
ATTR_WARN_UNUSED_RESULT const BMVert * v
ccl_device_inline float wrap_angle(const float a)
#define sinf(x)
#define cosf(x)
#define fmodf(x, y)
#define floorf(x)
#define fabsf(x)
#define DIAL_CLIP_BIAS
static void dial_3d_draw_util(const float matrix_final[4][4], const float line_width, const float color[4], const bool select, Dial3dParams *params)
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 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 dial_geom_draw(const float color[4], const float line_width, const bool select, const float clip_plane_mat[4][4], const float clip_plane[4], const float arc_partial_angle, const float arc_inner_factor, const int draw_options)
static void gizmo_dial_draw_select(const bContext *C, wmGizmo *gz, int select_id)
static void dial_ghostarc_draw_incremental_angle(const float incremental_angle, const float offset, const float angle_delta)
#define DIAL_WIDTH
static wmOperatorStatus gizmo_dial_modal(bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak tweak_flag)
void ED_gizmotypes_dial_3d()
static wmOperatorStatus gizmo_dial_invoke(bContext *, wmGizmo *gz, const wmEvent *event)
static void dial_ghostarc_draw(const float angle_ofs, float angle_delta, const float arc_inner_factor, const float color[4])
static void GIZMO_GT_dial_3d(wmGizmoType *gzt)
static void dial_draw_intern(const bContext *C, wmGizmo *gz, const bool select, const bool highlight, const bool use_clip_plane)
static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[3], const float color[4], const float line_width)
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])
#define DIAL_RESOLUTION
static float WM_gizmo_select_bias(bool select)
uint pos
#define select(A, B, C)
#define output
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
format
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
ccl_device_inline float2 fmod(const float2 a, const float b)
static void init(bNodeTree *, bNode *node)
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
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_factor(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)
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)
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)
#define FLT_MAX
Definition stdcycles.h:14
void * regiondata
float * clip_plane
float arc_inner_factor
float angle_increment
float arc_partial_angle
struct DialInteraction::@102273371222026272101054047233264076344112315200 init
struct DialInteraction::@042323215117172057036057303160115302045374247375 output
struct DialInteraction::@373012375276367240216230315223366220036356070234 prev
eWM_GizmoFlagTweak tweak_flag
float viewinv[4][4]
int ymin
int xmin
wmEventType type
Definition WM_types.hh:754
int xy[2]
Definition WM_types.hh:758
StructRNA * srna
wmGizmoFnDraw draw
wmGizmoFnModal modal
wmGizmoFnSetup setup
const char * idname
wmGizmoFnExit exit
wmGizmoFnInvoke invoke
wmGizmoFnDrawSelect draw_select
void * interaction_data
eWM_GizmoFlagState state
float matrix_basis[4][4]
PointerRNA * ptr
float line_width
eWM_GizmoFlag flag
wmGizmoFnModal custom_modal
i
Definition text_draw.cc:230
@ MOUSEMOVE
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
Definition wm_gizmo.cc:570
void WM_gizmo_target_property_float_set(bContext *C, const wmGizmo *gz, wmGizmoProperty *gz_prop, const float value)
void WM_gizmo_target_property_anim_autokey(bContext *C, const wmGizmo *, wmGizmoProperty *gz_prop)
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)
wmGizmoProperty * WM_gizmo_target_property_find(wmGizmo *gz, const char *idname)
void WM_gizmotype_append(void(*gtfunc)(wmGizmoType *))