Blender  V3.3
dial3d_gizmo.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2014 Blender Foundation. All rights reserved. */
3 
19 #include "MEM_guardedalloc.h"
20 
21 #include "BLI_math.h"
22 
23 #include "BKE_context.h"
24 
25 #include "GPU_immediate.h"
26 #include "GPU_immediate_util.h"
27 #include "GPU_matrix.h"
28 #include "GPU_select.h"
29 #include "GPU_state.h"
30 
31 #include "RNA_access.h"
32 #include "RNA_define.h"
33 
34 #include "WM_api.h"
35 #include "WM_types.h"
36 
37 #include "ED_gizmo_library.h"
38 #include "ED_screen.h"
39 #include "ED_transform.h"
40 #include "ED_view3d.h"
41 
42 /* own includes */
43 #include "../gizmo_geometry.h"
44 #include "../gizmo_library_intern.h"
45 
46 /* To use custom dials exported to geom_dial_gizmo.c */
47 // #define USE_GIZMO_CUSTOM_DIAL
48 
49 typedef struct DialInteraction {
50  struct {
51  float mval[2];
52  /* Only for when using properties. */
53  float prop_angle;
54  } init;
55  struct {
56  /* Cache the last angle to detect rotations bigger than -/+ PI. */
58  float angle;
59  } prev;
60 
61  /* Number of full rotations. */
62  int rotations;
63  bool has_drag;
65 
66  /* Final output values, used for drawing. */
67  struct {
68  float angle_ofs;
69  float angle_delta;
70  } output;
72 
73 #define DIAL_WIDTH 1.0f
74 #define DIAL_RESOLUTION 48
75 
76 /* Could make option, negative to clip more (don't show when view aligned). */
77 #define DIAL_CLIP_BIAS 0.02
78 
79 /* -------------------------------------------------------------------- */
80 struct Dial3dParams {
82  float angle_ofs;
83  float angle_delta;
87  float *clip_plane;
88 };
89 static void dial_3d_draw_util(const float matrix_basis[4][4],
90  const float matrix_final[4][4],
91  const float line_width,
92  const float color[4],
93  const bool select,
94  struct Dial3dParams *params);
95 
96 static void dial_geom_draw(const float color[4],
97  const float line_width,
98  const bool select,
99  const float axis_modal_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", axis_modal_mat);
122  }
123  else {
126  }
127 
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 * U.pixelsize);
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 
186 static 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 {
191  GPU_matrix_push();
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 
204 
206  immVertex3f(pos, 0.0f, 0.0f, 0.0f);
207  immVertex3fv(pos, co_outer);
208  immEnd();
209 
211 
212  GPU_matrix_pop();
213 }
214 
218 static void dial_ghostarc_draw_incremental_angle(const float incremental_angle, const float offset)
219 {
220  const int tot_incr = (2 * M_PI) / incremental_angle;
221 
224 
225  immUniformColor3f(1.0f, 1.0f, 1.0f);
226 
227  float viewport[4];
228  GPU_viewport_size_get_f(viewport);
229  immUniform2fv("viewportSize", &viewport[2]);
230  immUniform1f("lineWidth", U.pixelsize);
231 
232  immBegin(GPU_PRIM_LINES, tot_incr * 2);
233 
234  float v[3] = {0};
235  for (int i = 0; i < tot_incr; i++) {
236  v[0] = sinf(offset + incremental_angle * i);
237  v[1] = cosf(offset + incremental_angle * i);
238 
239  mul_v2_fl(v, DIAL_WIDTH * 1.1f);
240  immVertex3fv(pos, v);
241 
242  mul_v2_fl(v, 1.1f);
243  immVertex3fv(pos, v);
244  }
245 
246  immEnd();
248 }
249 
250 static void dial_ghostarc_draw(const float angle_ofs,
251  float angle_delta,
252  const float arc_inner_factor,
253  const float color[4])
254 {
255  const float width_inner = DIAL_WIDTH;
259 
260  /* Avoid artifacts by drawing the main arc over the span of one rotation only. */
261  const float pi2 = (float)(M_PI * 2.0);
262  int rotation_count = (int)floorf(fabsf(angle_delta) / pi2);
263  angle_delta = fmod(angle_delta, pi2);
264 
265  /* Calculate the remaining angle that can be filled with the background color. */
266  const float angle_background = angle_delta >= 0 ? (pi2 - angle_delta) : -(pi2 + angle_delta);
267 
268  float color_background[4] = {0};
269  if (arc_inner_factor != 0.0) {
270  color_background[3] = color[3] / 2.0f;
271  }
272 
273  if (rotation_count != 0) {
274  /* Calculate the background color to visualize the rotation count. */
275  copy_v4_v4(color_background, color);
276  color_background[3] = color[3] * rotation_count;
277  }
278 
279  immUniformColor4fv(color_background);
281  0,
282  0,
283  arc_inner_factor,
284  width_inner,
286  RAD2DEGF(angle_ofs + angle_delta),
287  RAD2DEGF(angle_background));
288 
289  immUniformColor4f(UNPACK3(color), color[3] * (rotation_count + 1));
291  0,
292  0,
293  arc_inner_factor,
294  width_inner,
296  RAD2DEGF(angle_ofs),
297  RAD2DEGF(angle_delta));
299 }
300 
301 static void dial_ghostarc_get_angles(const wmGizmo *gz,
302  const wmEvent *event,
303  const ARegion *region,
304  const float mat[4][4],
305  const float co_outer[3],
306  float *r_start,
307  float *r_delta)
308 {
309  DialInteraction *inter = gz->interaction_data;
310  const RegionView3D *rv3d = region->regiondata;
311  const float mval[2] = {event->xy[0] - region->winrct.xmin, event->xy[1] - region->winrct.ymin};
312 
313  /* We might need to invert the direction of the angles. */
314  float view_vec[3], axis_vec[3];
315  ED_view3d_global_to_vector(rv3d, gz->matrix_basis[3], view_vec);
316  normalize_v3_v3(axis_vec, gz->matrix_basis[2]);
317 
318  float proj_outer_rel[3];
319  mul_v3_project_m4_v3(proj_outer_rel, mat, co_outer);
320  sub_v3_v3(proj_outer_rel, gz->matrix_basis[3]);
321 
322  float proj_mval_new_rel[3];
323  float proj_mval_init_rel[3];
324  float dial_plane[4];
325 
326  plane_from_point_normal_v3(dial_plane, gz->matrix_basis[3], axis_vec);
327 
329  region, dial_plane, inter->init.mval, false, proj_mval_init_rel)) {
330  goto fail;
331  }
332  sub_v3_v3(proj_mval_init_rel, gz->matrix_basis[3]);
333 
334  if (!ED_view3d_win_to_3d_on_plane(region, dial_plane, mval, false, proj_mval_new_rel)) {
335  goto fail;
336  }
337  sub_v3_v3(proj_mval_new_rel, gz->matrix_basis[3]);
338 
339  const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
340 
341  /* Start direction from mouse or set by user. */
342  const float *proj_init_rel = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y) ?
343  gz->matrix_basis[1] :
344  proj_mval_init_rel;
345 
346  /* Return angles. */
347  const float start = angle_wrap_rad(
348  angle_signed_on_axis_v3v3_v3(proj_outer_rel, proj_init_rel, axis_vec));
349  const float delta = angle_wrap_rad(
350  angle_signed_on_axis_v3v3_v3(proj_mval_init_rel, proj_mval_new_rel, axis_vec));
351 
352  /* Change of sign, we passed the 180 degree threshold. This means we need to add a turn
353  * to distinguish between transition from 0 to -1 and -PI to +PI, use comparison with PI/2.
354  * Logic taken from #BLI_dial_angle */
355  if ((delta * inter->prev.angle < 0.0f) && (fabsf(inter->prev.angle) > (float)M_PI_2)) {
356  if (inter->prev.angle < 0.0f) {
357  inter->rotations--;
358  }
359  else {
360  inter->rotations++;
361  }
362  }
363  inter->prev.angle = delta;
364 
365  const bool wrap_angle = RNA_boolean_get(gz->ptr, "wrap_angle");
366  const double delta_final = (double)delta + ((2 * M_PI) * (double)inter->rotations);
367  *r_start = start;
368  *r_delta = (float)(wrap_angle ? fmod(delta_final, 2 * M_PI) : delta_final);
369  return;
370 
371  /* If we can't project (unlikely). */
372 fail:
373  *r_start = 0.0;
374  *r_delta = 0.0;
375 }
376 
377 static void dial_ghostarc_draw_with_helplines(const float angle_ofs,
378  const float angle_delta,
379  const float arc_inner_factor,
380  const float color_helpline[4],
381  const int draw_options)
382 {
383  /* Coordinate at which the arc drawing will be started. */
384  const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f};
385  const float color_arc_inner[4] = {0.8f, 0.8f, 0.8f, 0.2f};
386  dial_ghostarc_draw(angle_ofs, angle_delta, arc_inner_factor, color_arc_inner);
387 
388  float line_width = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE) ? 3.0f : 1.0f;
389  dial_ghostarc_draw_helpline(angle_ofs, co_outer, color_helpline, 1.0f);
390  dial_ghostarc_draw_helpline(angle_ofs + angle_delta, co_outer, color_helpline, line_width);
391 }
392 
393 static void dial_draw_intern(
394  const bContext *C, wmGizmo *gz, const bool select, const bool highlight, float clip_plane[4])
395 {
396  float matrix_final[4][4];
397  float color[4];
398 
399  (void)C;
400  BLI_assert(CTX_wm_area(C)->spacetype == SPACE_VIEW3D);
401 
402  gizmo_color_get(gz, highlight, color);
403 
404  WM_gizmo_calc_matrix_final(gz, matrix_final);
405 
406  const float arc_partial_angle = RNA_float_get(gz->ptr, "arc_partial_angle");
407  const float arc_inner_factor = RNA_float_get(gz->ptr, "arc_inner_factor");
408  int draw_options = RNA_enum_get(gz->ptr, "draw_options");
409  float angle_ofs = 0.0f;
410  float angle_delta = 0.0f;
411  float angle_increment = 0.0f;
412 
413  if (select) {
414  draw_options &= ~ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE;
415  }
416 
417  if (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE && (gz->flag & WM_GIZMO_DRAW_VALUE)) {
418  DialInteraction *inter = gz->interaction_data;
419  if (inter) {
420  angle_ofs = inter->output.angle_ofs;
421  angle_delta = inter->output.angle_delta;
422  angle_increment = inter->angle_increment;
423  }
424  else {
425  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
426  if (WM_gizmo_target_property_is_valid(gz_prop)) {
427  angle_delta = WM_gizmo_target_property_float_get(gz, gz_prop);
428  }
429  if (gz->state & WM_GIZMO_STATE_MODAL) {
430  angle_increment = RNA_float_get(gz->ptr, "incremental_angle");
431  }
432  }
433  }
434 
436  matrix_final,
437  gz->line_width,
438  color,
439  select,
440  &(struct Dial3dParams){
441  .draw_options = draw_options,
442  .angle_ofs = angle_ofs,
443  .angle_delta = angle_delta,
444  .angle_increment = angle_increment,
445  .arc_partial_angle = arc_partial_angle,
446  .arc_inner_factor = arc_inner_factor,
447  .clip_plane = clip_plane,
448  });
449 }
450 
451 static void gizmo_dial_draw_select(const bContext *C, wmGizmo *gz, int select_id)
452 {
453  float clip_plane_buf[4];
454  const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
455  float *clip_plane = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_CLIP) ? clip_plane_buf : NULL;
456 
457  if (clip_plane) {
458  ARegion *region = CTX_wm_region(C);
459  RegionView3D *rv3d = region->regiondata;
460 
461  copy_v3_v3(clip_plane, rv3d->viewinv[2]);
462  clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], gz->matrix_basis[3]);
463  clip_plane[3] += DIAL_CLIP_BIAS;
464  }
465 
466  GPU_select_load_id(select_id);
467  dial_draw_intern(C, gz, true, false, clip_plane);
468 }
469 
470 static void gizmo_dial_draw(const bContext *C, wmGizmo *gz)
471 {
472  const bool is_modal = gz->state & WM_GIZMO_STATE_MODAL;
473  const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
474  float clip_plane_buf[4];
475  const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
476  float *clip_plane = (!is_modal && (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_CLIP)) ?
477  clip_plane_buf :
478  NULL;
479 
480  if (clip_plane) {
481  ARegion *region = CTX_wm_region(C);
482  RegionView3D *rv3d = region->regiondata;
483 
484  copy_v3_v3(clip_plane, rv3d->viewinv[2]);
485  clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], gz->matrix_basis[3]);
486  clip_plane[3] += DIAL_CLIP_BIAS;
487  }
488 
490  dial_draw_intern(C, gz, false, is_highlight, clip_plane);
492 }
493 
495  wmGizmo *gz,
496  const wmEvent *event,
497  eWM_GizmoFlagTweak tweak_flag)
498 {
499  DialInteraction *inter = gz->interaction_data;
500  if (!inter) {
501  return OPERATOR_CANCELLED;
502  }
503 
504  if ((event->type != MOUSEMOVE) && (inter->prev.tweak_flag == tweak_flag)) {
505  return OPERATOR_RUNNING_MODAL;
506  }
507  /* Coordinate at which the arc drawing will be started. */
508  const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f};
509  float angle_ofs, angle_delta, angle_increment = 0.0f;
510 
512  gz, event, CTX_wm_region(C), gz->matrix_basis, co_outer, &angle_ofs, &angle_delta);
513 
514  if (tweak_flag & WM_GIZMO_TWEAK_SNAP) {
515  angle_increment = RNA_float_get(gz->ptr, "incremental_angle");
516  angle_delta = (float)roundf((double)angle_delta / angle_increment) * angle_increment;
517  }
518  if (tweak_flag & WM_GIZMO_TWEAK_PRECISE) {
519  angle_increment *= 0.2f;
520  angle_delta *= 0.2f;
521  }
522  if (angle_delta != 0.0f) {
523  inter->has_drag = true;
524  }
525 
526  inter->angle_increment = angle_increment;
527  inter->output.angle_delta = angle_delta;
528  inter->output.angle_ofs = angle_ofs;
529 
530  /* Set the property for the operator and call its modal function. */
531  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
532  if (WM_gizmo_target_property_is_valid(gz_prop)) {
533  WM_gizmo_target_property_float_set(C, gz, gz_prop, inter->init.prop_angle + angle_delta);
534  }
535 
536  inter->prev.tweak_flag = tweak_flag;
537 
538  return OPERATOR_RUNNING_MODAL;
539 }
540 
541 static void gizmo_dial_exit(bContext *C, wmGizmo *gz, const bool cancel)
542 {
543  DialInteraction *inter = gz->interaction_data;
544  if (inter) {
545  bool use_reset_value = false;
546  float reset_value = 0.0f;
547 
548  if (cancel) {
549  /* Set the property for the operator and call its modal function. */
550  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
551  if (WM_gizmo_target_property_is_valid(gz_prop)) {
552  use_reset_value = true;
553  reset_value = inter->init.prop_angle;
554  }
555  }
556  else {
557  if (inter->has_drag == false) {
558  PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "click_value");
559  if (RNA_property_is_set(gz->ptr, prop)) {
560  use_reset_value = true;
561  reset_value = RNA_property_float_get(gz->ptr, prop);
562  }
563  }
564  }
565 
566  if (use_reset_value) {
567  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
568  if (WM_gizmo_target_property_is_valid(gz_prop)) {
569  WM_gizmo_target_property_float_set(C, gz, gz_prop, reset_value);
570  }
571  }
572  }
573 
574  if (!cancel) {
575  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
576  if (WM_gizmo_target_property_is_valid(gz_prop)) {
578  }
579  }
580 }
581 
582 static void gizmo_dial_setup(wmGizmo *gz)
583 {
584  const float dir_default[3] = {0.0f, 0.0f, 1.0f};
585 
586  /* defaults */
587  copy_v3_v3(gz->matrix_basis[2], dir_default);
588 }
589 
590 static int gizmo_dial_invoke(bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
591 {
592  if (gz->custom_modal) {
593  /* #DialInteraction is only used for the inner modal. */
594  return OPERATOR_RUNNING_MODAL;
595  }
596 
597  DialInteraction *inter = MEM_callocN(sizeof(DialInteraction), __func__);
598 
599  inter->init.mval[0] = event->mval[0];
600  inter->init.mval[1] = event->mval[1];
601 
602  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
603  if (WM_gizmo_target_property_is_valid(gz_prop)) {
604  inter->init.prop_angle = WM_gizmo_target_property_float_get(gz, gz_prop);
605  }
606 
607  gz->interaction_data = inter;
608 
609  return OPERATOR_RUNNING_MODAL;
610 }
611 
612 /* -------------------------------------------------------------------- */
616 static void dial_3d_draw_util(const float matrix_basis[4][4],
617  const float matrix_final[4][4],
618  const float line_width,
619  const float color[4],
620  const bool select,
621  struct Dial3dParams *params)
622 {
623  GPU_matrix_push();
624  GPU_matrix_mul(matrix_final);
625 
626  GPU_polygon_smooth(false);
627 
628  if ((params->draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE) != 0) {
629  /* Draw rotation indicator arc first. */
631  params->angle_delta,
632  params->arc_inner_factor,
633  color,
634  params->draw_options);
635 
636  if ((params->draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR) != 0) {
638  params->angle_delta,
639  params->arc_inner_factor,
640  color,
641  params->draw_options);
642  }
643  }
644 
645  if (params->angle_increment) {
646  dial_ghostarc_draw_incremental_angle(params->angle_increment, params->angle_ofs);
647  }
648 
649  /* Draw actual dial gizmo. */
651  line_width,
652  select,
653  matrix_basis,
654  params->clip_plane,
655  params->arc_partial_angle,
656  params->arc_inner_factor,
657  params->draw_options);
658 
659  GPU_matrix_pop();
660 }
661 
662 static void GIZMO_GT_dial_3d(wmGizmoType *gzt)
663 {
664  /* identifiers */
665  gzt->idname = "GIZMO_GT_dial_3d";
666 
667  /* api callbacks */
668  gzt->draw = gizmo_dial_draw;
670  gzt->setup = gizmo_dial_setup;
671  gzt->invoke = gizmo_dial_invoke;
672  gzt->modal = gizmo_dial_modal;
673  gzt->exit = gizmo_dial_exit;
674 
675  gzt->struct_size = sizeof(wmGizmo);
676 
677  /* rna */
678  static EnumPropertyItem rna_enum_draw_options[] = {
679  {ED_GIZMO_DIAL_DRAW_FLAG_CLIP, "CLIP", 0, "Clipped", ""},
680  {ED_GIZMO_DIAL_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""},
681  {ED_GIZMO_DIAL_DRAW_FLAG_FILL_SELECT, "FILL_SELECT", 0, "Use fill for selection test", ""},
682  {ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR, "ANGLE_MIRROR", 0, "Angle Mirror", ""},
683  {ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y, "ANGLE_START_Y", 0, "Angle Start Y", ""},
684  {ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE, "ANGLE_VALUE", 0, "Show Angle Value", ""},
685  {0, NULL, 0, NULL, NULL},
686  };
687  RNA_def_enum_flag(gzt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", "");
688  RNA_def_boolean(gzt->srna, "wrap_angle", true, "Wrap Angle", "");
690  gzt->srna, "arc_inner_factor", 0.0f, 0.0f, 1.0f, "Arc Inner Factor", "", 0.0f, 1.0f);
692  "arc_partial_angle",
693  0.0f,
694  0.0f,
695  M_PI * 2,
696  "Show Partial Dial",
697  "",
698  0.0f,
699  M_PI * 2);
701  "incremental_angle",
703  0.0f,
704  M_PI * 2,
705  "Incremental Angle",
706  "Angle to snap in steps",
707  0.0f,
708  M_PI * 2);
709  RNA_def_float(gzt->srna,
710  "click_value",
711  0.0f,
712  -FLT_MAX,
713  FLT_MAX,
714  "Click Value",
715  "Value to use for a single click action",
716  -FLT_MAX,
717  FLT_MAX);
718 
719  WM_gizmotype_target_property_def(gzt, "offset", PROP_FLOAT, 1);
720 }
721 
723 {
725 }
726 
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:738
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:749
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define M_PI_2
Definition: BLI_math_base.h:23
#define M_PI
Definition: BLI_math_base.h:20
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
Definition: math_geom.c:209
void mul_v3_project_m4_v3(float r[3], const float mat[4][4], const float vec[3])
Definition: math_matrix.c:831
#define RAD2DEGF(_rad)
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
Definition: math_vector.c:488
MINLINE float normalize_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition: BLI_sys_types.h:67
#define UNUSED_VARS(...)
#define UNUSED(x)
#define UNPACK3(a)
typedef double(DMatrix)[4][4]
@ 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
Definition: ED_transform.h:172
bool ED_view3d_win_to_3d_on_plane(const struct ARegion *region, const float plane[4], const float mval[2], 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 immUniform2fv(const char *name, const float data[2])
void immUniformMatrix4fv(const char *name, const float data[4][4])
void immUniformColor4f(float r, float g, float b, float a)
void immUnbindProgram(void)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immVertex3f(uint attr_id, float x, float y, float z)
void immUniform1f(const char *name, float x)
void immUniformColor4fv(const float rgba[4])
GPUVertFormat * immVertexFormat(void)
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 immEnd(void)
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_pop(void)
Definition: gpu_matrix.cc:126
#define GPU_matrix_mul(x)
Definition: GPU_matrix.h:224
void GPU_matrix_push(void)
Definition: gpu_matrix.cc:119
void GPU_matrix_rotate_3f(float deg, float x, float y, float z)
Definition: gpu_matrix.cc:261
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:20
@ GPU_PRIM_LINE_STRIP
Definition: GPU_primitive.h:22
bool GPU_select_load_id(unsigned int id)
Definition: gpu_select.c:117
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
Definition: GPU_shader.h:253
@ GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR
Definition: GPU_shader.h:231
@ GPU_SHADER_3D_UNIFORM_COLOR
Definition: GPU_shader.h:230
@ GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR
Definition: GPU_shader.h:254
@ GPU_BLEND_NONE
Definition: GPU_state.h:60
@ GPU_BLEND_ALPHA
Definition: GPU_state.h:62
void GPU_blend(eGPUBlend blend)
Definition: gpu_state.cc:39
void GPU_viewport_size_get_f(float coords[4])
Definition: gpu_state.cc:259
void GPU_polygon_smooth(bool enable)
Definition: gpu_state.cc:80
@ GPU_FETCH_FLOAT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
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
@ PROP_FLOAT
Definition: RNA_types.h:61
#define C
Definition: RandGen.cpp:25
struct wmGizmo wmGizmo
Definition: WM_api.h:68
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
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: avxb.h:154
ATTR_WARN_UNUSED_RESULT const BMVert * v
ccl_device_inline float wrap_angle(float a)
unsigned int U
Definition: btGjkEpa3.h:78
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
#define sinf(x)
Definition: cuda/compat.h:102
#define cosf(x)
Definition: cuda/compat.h:101
#define DIAL_CLIP_BIAS
Definition: dial3d_gizmo.c:77
static void dial_ghostarc_draw_incremental_angle(const float incremental_angle, const float offset)
Definition: dial3d_gizmo.c:218
static void 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)
Definition: dial3d_gizmo.c:616
static void gizmo_dial_exit(bContext *C, wmGizmo *gz, const bool cancel)
Definition: dial3d_gizmo.c:541
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)
Definition: dial3d_gizmo.c:301
static int gizmo_dial_modal(bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak tweak_flag)
Definition: dial3d_gizmo.c:494
static void gizmo_dial_setup(wmGizmo *gz)
Definition: dial3d_gizmo.c:582
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)
Definition: dial3d_gizmo.c:377
static void gizmo_dial_draw(const bContext *C, wmGizmo *gz)
Definition: dial3d_gizmo.c:470
static void gizmo_dial_draw_select(const bContext *C, wmGizmo *gz, int select_id)
Definition: dial3d_gizmo.c:451
#define DIAL_RESOLUTION
Definition: dial3d_gizmo.c:74
#define DIAL_WIDTH
Definition: dial3d_gizmo.c:73
static void dial_draw_intern(const bContext *C, wmGizmo *gz, const bool select, const bool highlight, float clip_plane[4])
Definition: dial3d_gizmo.c:393
void ED_gizmotypes_dial_3d(void)
Definition: dial3d_gizmo.c:722
static void dial_ghostarc_draw(const float angle_ofs, float angle_delta, const float arc_inner_factor, const float color[4])
Definition: dial3d_gizmo.c:250
struct DialInteraction DialInteraction
static void GIZMO_GT_dial_3d(wmGizmoType *gzt)
Definition: dial3d_gizmo.c:662
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)
Definition: dial3d_gizmo.c:96
static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[3], const float color[4], const float line_width)
Definition: dial3d_gizmo.c:186
static int gizmo_dial_invoke(bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
Definition: dial3d_gizmo.c:590
SyclQueue void void size_t num_bytes void
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, bool highlight, float r_color[4])
uint pos
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
format
Definition: logImageCore.h:38
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
#define floorf(x)
Definition: metal/compat.h:224
#define fabsf(x)
Definition: metal/compat.h:219
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2767
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:5271
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:717
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4957
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4863
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
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)
Definition: rna_define.c:3836
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3806
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)
Definition: rna_define.c:4144
void * regiondata
float * clip_plane
Definition: dial3d_gizmo.c:87
float arc_inner_factor
Definition: dial3d_gizmo.c:86
float angle_ofs
Definition: dial3d_gizmo.c:82
float angle_increment
Definition: dial3d_gizmo.c:84
float arc_partial_angle
Definition: dial3d_gizmo.c:85
float angle_delta
Definition: dial3d_gizmo.c:83
struct DialInteraction::@344 init
struct DialInteraction::@345 prev
struct DialInteraction::@346 output
float angle_increment
Definition: dial3d_gizmo.c:64
eWM_GizmoFlagTweak tweak_flag
Definition: dial3d_gizmo.c:57
float viewinv[4][4]
int ymin
Definition: DNA_vec_types.h:64
int xmin
Definition: DNA_vec_types.h:63
short type
Definition: WM_types.h:678
wmGizmoFnDraw draw
wmGizmoFnModal modal
wmGizmoFnSetup setup
const char * idname
wmGizmoFnExit exit
struct StructRNA * srna
wmGizmoFnInvoke invoke
wmGizmoFnDrawSelect draw_select
void * interaction_data
eWM_GizmoFlagState state
float matrix_basis[4][4]
struct PointerRNA * ptr
float line_width
eWM_GizmoFlag flag
wmGizmoFnModal custom_modal
@ MOUSEMOVE
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
Definition: wm_gizmo.c:554
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 *))
Definition: wm_gizmo_type.c:93