Blender  V2.93
dial3d_gizmo.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2014 Blender Foundation.
17  * All rights reserved.
18  */
19 
35 #include "MEM_guardedalloc.h"
36 
37 #include "BLI_math.h"
38 
39 #include "BKE_context.h"
40 
41 #include "GPU_immediate.h"
42 #include "GPU_immediate_util.h"
43 #include "GPU_matrix.h"
44 #include "GPU_select.h"
45 #include "GPU_state.h"
46 
47 #include "RNA_access.h"
48 #include "RNA_define.h"
49 
50 #include "WM_api.h"
51 #include "WM_types.h"
52 
53 #include "ED_gizmo_library.h"
54 #include "ED_screen.h"
55 #include "ED_transform.h"
56 #include "ED_view3d.h"
57 
58 /* own includes */
59 #include "../gizmo_geometry.h"
60 #include "../gizmo_library_intern.h"
61 
62 /* To use custom dials exported to geom_dial_gizmo.c */
63 // #define USE_GIZMO_CUSTOM_DIAL
64 
65 typedef struct DialInteraction {
66  struct {
67  float mval[2];
68  /* Only for when using properties. */
69  float prop_angle;
70  } init;
71  struct {
72  /* Cache the last angle to detect rotations bigger than -/+ PI. */
74  float angle;
75  } prev;
76 
77  /* Number of full rotations. */
78  int rotations;
79  bool has_drag;
81 
82  /* Final output values, used for drawing. */
83  struct {
84  float angle_ofs;
85  float angle_delta;
86  } output;
88 
89 #define DIAL_WIDTH 1.0f
90 #define DIAL_RESOLUTION 48
91 
92 /* Could make option, negative to clip more (don't show when view aligned). */
93 #define DIAL_CLIP_BIAS 0.02
94 
95 /* -------------------------------------------------------------------- */
96 
97 static void dial_geom_draw(const float color[4],
98  const float line_width,
99  const bool select,
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)
105 {
106 #ifdef USE_GIZMO_CUSTOM_DIAL
107  UNUSED_VARS(gz, axis_modal_mat, clip_plane);
109 #else
110  const bool filled = ((draw_options & (select ? (ED_GIZMO_DIAL_DRAW_FLAG_FILL |
113 
116 
117  if (clip_plane) {
120  immUniform4fv("ClipPlane", clip_plane);
121  immUniformMatrix4fv("ModelMatrix", axis_modal_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) {
134  }
135  else {
137  pos, 0, 0, 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,
144  0,
145  arc_inner_factor,
146  1.0f,
148  -arc_partial_deg / 2,
149  arc_partial_deg);
150  }
151  }
152  else {
153  float viewport[4];
154  GPU_viewport_size_get_f(viewport);
155  immUniform2fv("viewportSize", &viewport[2]);
156  immUniform1f("lineWidth", line_width * U.pixelsize);
157 
158  if (arc_partial_angle == 0.0f) {
160  if (arc_inner_factor != 0.0f) {
161  imm_draw_circle_wire_2d(pos, 0, 0, arc_inner_factor, DIAL_RESOLUTION);
162  }
163  }
164  else {
165  float arc_partial_deg = RAD2DEGF((M_PI * 2) - arc_partial_angle);
167  pos, 0, 0, 1.0, DIAL_RESOLUTION, -arc_partial_deg / 2, arc_partial_deg);
168 # if 0
169  if (arc_inner_factor != 0.0f) {
170  BLI_assert(0);
171  }
172 # endif
173  }
174  }
175 
177 
179 #endif
180 }
181 
185 static void dial_ghostarc_draw_helpline(const float angle,
186  const float co_outer[3],
187  const float color[4],
188  const float line_width)
189 {
190  GPU_matrix_push();
191  GPU_matrix_rotate_3f(RAD2DEGF(angle), 0.0f, 0.0f, -1.0f);
192 
194 
196 
197  float viewport[4];
198  GPU_viewport_size_get_f(viewport);
199  immUniform2fv("viewportSize", &viewport[2]);
200  immUniform1f("lineWidth", line_width * U.pixelsize);
201 
202  immUniformColor4fv(color);
203 
205  immVertex3f(pos, 0.0f, 0, 0.0f);
206  immVertex3fv(pos, co_outer);
207  immEnd();
208 
210 
211  GPU_matrix_pop();
212 }
213 
217 static void dial_ghostarc_draw_incremental_angle(const float incremental_angle, const float offset)
218 {
219  const int tot_incr = (2 * M_PI) / incremental_angle;
220 
223 
224  immUniformColor3f(1.0f, 1.0f, 1.0f);
225 
226  float viewport[4];
227  GPU_viewport_size_get_f(viewport);
228  immUniform2fv("viewportSize", &viewport[2]);
229  immUniform1f("lineWidth", U.pixelsize);
230 
231  immBegin(GPU_PRIM_LINES, tot_incr * 2);
232 
233  float v[3] = {0};
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);
237 
238  mul_v2_fl(v, DIAL_WIDTH * 1.1f);
239  immVertex3fv(pos, v);
240 
241  mul_v2_fl(v, 1.1f);
242  immVertex3fv(pos, v);
243  }
244 
245  immEnd();
247 }
248 
249 static void dial_ghostarc_draw(const float angle_ofs,
250  float angle_delta,
251  const float arc_inner_factor,
252  const float color[4])
253 {
254  const float width_inner = DIAL_WIDTH;
258 
259  /* Avoid artifacts by drawing the main arc over the span of one rotation only. */
260  const float pi2 = (float)(M_PI * 2.0);
261  int rotation_count = (int)floorf(fabsf(angle_delta) / pi2);
262  angle_delta = fmod(angle_delta, pi2);
263 
264  /* Calculate the remaining angle that can be filled with the background color. */
265  const float angle_background = angle_delta >= 0 ? (pi2 - angle_delta) : -(pi2 + angle_delta);
266 
267  float color_background[4] = {0};
268  if (arc_inner_factor != 0.0) {
269  color_background[3] = color[3] / 2.0f;
270  }
271 
272  if (rotation_count != 0) {
273  /* Calculate the background color to visualize the rotation count. */
274  copy_v4_v4(color_background, color);
275  color_background[3] = color[3] * rotation_count;
276  }
277 
278  immUniformColor4fv(color_background);
280  0,
281  0,
282  arc_inner_factor,
283  width_inner,
285  RAD2DEGF(angle_ofs + angle_delta),
286  RAD2DEGF(angle_background));
287 
288  immUniformColor4f(UNPACK3(color), color[3] * (rotation_count + 1));
290  0,
291  0,
292  arc_inner_factor,
293  width_inner,
295  RAD2DEGF(angle_ofs),
296  RAD2DEGF(angle_delta));
298 }
299 
300 static void dial_ghostarc_get_angles(const wmGizmo *gz,
301  const wmEvent *event,
302  const ARegion *region,
303  const float mat[4][4],
304  const float co_outer[3],
305  float *r_start,
306  float *r_delta)
307 {
308  DialInteraction *inter = gz->interaction_data;
309  const RegionView3D *rv3d = region->regiondata;
310  const float mval[2] = {event->x - region->winrct.xmin, event->y - region->winrct.ymin};
311 
312  /* We might need to invert the direction of the angles. */
313  float view_vec[3], axis_vec[3];
314  ED_view3d_global_to_vector(rv3d, gz->matrix_basis[3], view_vec);
315  normalize_v3_v3(axis_vec, gz->matrix_basis[2]);
316 
317  float proj_outer_rel[3];
318  mul_v3_project_m4_v3(proj_outer_rel, mat, co_outer);
319  sub_v3_v3(proj_outer_rel, gz->matrix_basis[3]);
320 
321  float proj_mval_new_rel[3];
322  float proj_mval_init_rel[3];
323  float dial_plane[4];
324 
325  plane_from_point_normal_v3(dial_plane, gz->matrix_basis[3], axis_vec);
326 
328  region, dial_plane, inter->init.mval, false, proj_mval_init_rel)) {
329  goto fail;
330  }
331  sub_v3_v3(proj_mval_init_rel, gz->matrix_basis[3]);
332 
333  if (!ED_view3d_win_to_3d_on_plane(region, dial_plane, mval, false, proj_mval_new_rel)) {
334  goto fail;
335  }
336  sub_v3_v3(proj_mval_new_rel, gz->matrix_basis[3]);
337 
338  const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
339 
340  /* Start direction from mouse or set by user. */
341  const float *proj_init_rel = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y) ?
342  gz->matrix_basis[1] :
343  proj_mval_init_rel;
344 
345  /* Return angles. */
346  const float start = angle_wrap_rad(
347  angle_signed_on_axis_v3v3_v3(proj_outer_rel, proj_init_rel, axis_vec));
348  const float delta = angle_wrap_rad(
349  angle_signed_on_axis_v3v3_v3(proj_mval_init_rel, proj_mval_new_rel, axis_vec));
350 
351  /* Change of sign, we passed the 180 degree threshold. This means we need to add a turn
352  * to distinguish between transition from 0 to -1 and -PI to +PI, use comparison with PI/2.
353  * Logic taken from #BLI_dial_angle */
354  if ((delta * inter->prev.angle < 0.0f) && (fabsf(inter->prev.angle) > (float)M_PI_2)) {
355  if (inter->prev.angle < 0.0f) {
356  inter->rotations--;
357  }
358  else {
359  inter->rotations++;
360  }
361  }
362  inter->prev.angle = delta;
363 
364  const bool wrap_angle = RNA_boolean_get(gz->ptr, "wrap_angle");
365  const double delta_final = (double)delta + ((2 * M_PI) * (double)inter->rotations);
366  *r_start = start;
367  *r_delta = (float)(wrap_angle ? fmod(delta_final, 2 * M_PI) : delta_final);
368  return;
369 
370  /* If we can't project (unlikely). */
371 fail:
372  *r_start = 0.0;
373  *r_delta = 0.0;
374 }
375 
376 static void dial_ghostarc_draw_with_helplines(const float angle_ofs,
377  const float angle_delta,
378  const float arc_inner_factor,
379  const float color_helpline[4],
380  const int draw_options)
381 {
382  /* Coordinate at which the arc drawing will be started. */
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};
385  dial_ghostarc_draw(angle_ofs, angle_delta, arc_inner_factor, color_arc_inner);
386 
387  float line_width = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE) ? 3.0f : 1.0f;
388  dial_ghostarc_draw_helpline(angle_ofs, co_outer, color_helpline, 1.0f);
389  dial_ghostarc_draw_helpline(angle_ofs + angle_delta, co_outer, color_helpline, line_width);
390 }
391 
392 static void dial_draw_intern(
393  const bContext *C, wmGizmo *gz, const bool select, const bool highlight, float clip_plane[4])
394 {
395  float matrix_final[4][4];
396  float color[4];
397 
398  (void)C;
399  BLI_assert(CTX_wm_area(C)->spacetype == SPACE_VIEW3D);
400 
401  gizmo_color_get(gz, highlight, color);
402 
403  WM_gizmo_calc_matrix_final(gz, matrix_final);
404 
405  const float arc_partial_angle = RNA_float_get(gz->ptr, "arc_partial_angle");
406  const float arc_inner_factor = RNA_float_get(gz->ptr, "arc_inner_factor");
407  int draw_options = RNA_enum_get(gz->ptr, "draw_options");
408  float angle_ofs = 0.0f;
409  float angle_delta = 0.0f;
410  float angle_increment = 0.0f;
411 
412  if (select) {
413  draw_options &= ~ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE;
414  }
415 
416  if (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE && (gz->flag & WM_GIZMO_DRAW_VALUE)) {
417  DialInteraction *inter = gz->interaction_data;
418  if (inter) {
419  angle_ofs = inter->output.angle_ofs;
420  angle_delta = inter->output.angle_delta;
421  angle_increment = inter->angle_increment;
422  }
423  else {
424  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
425  if (WM_gizmo_target_property_is_valid(gz_prop)) {
426  angle_delta = WM_gizmo_target_property_float_get(gz, gz_prop);
427  }
428  }
429  }
430 
432  matrix_final,
433  gz->line_width,
434  color,
435  select,
436  &(struct Dial3dParams){
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,
444  });
445 }
446 
447 static void gizmo_dial_draw_select(const bContext *C, wmGizmo *gz, int select_id)
448 {
449  float clip_plane_buf[4];
450  const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
451  float *clip_plane = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_CLIP) ? clip_plane_buf : NULL;
452 
453  if (clip_plane) {
454  ARegion *region = CTX_wm_region(C);
455  RegionView3D *rv3d = region->regiondata;
456 
457  copy_v3_v3(clip_plane, rv3d->viewinv[2]);
458  clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], gz->matrix_basis[3]);
459  clip_plane[3] += DIAL_CLIP_BIAS;
460  }
461 
462  GPU_select_load_id(select_id);
463  dial_draw_intern(C, gz, true, false, clip_plane);
464 }
465 
466 static void gizmo_dial_draw(const bContext *C, wmGizmo *gz)
467 {
468  const bool is_modal = gz->state & WM_GIZMO_STATE_MODAL;
469  const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
470  float clip_plane_buf[4];
471  const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
472  float *clip_plane = (!is_modal && (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_CLIP)) ?
473  clip_plane_buf :
474  NULL;
475 
476  if (clip_plane) {
477  ARegion *region = CTX_wm_region(C);
478  RegionView3D *rv3d = region->regiondata;
479 
480  copy_v3_v3(clip_plane, rv3d->viewinv[2]);
481  clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], gz->matrix_basis[3]);
482  clip_plane[3] += DIAL_CLIP_BIAS;
483  }
484 
486  dial_draw_intern(C, gz, false, is_highlight, clip_plane);
488 }
489 
491  wmGizmo *gz,
492  const wmEvent *event,
493  eWM_GizmoFlagTweak tweak_flag)
494 {
495  DialInteraction *inter = gz->interaction_data;
496  if ((event->type != MOUSEMOVE) && (inter->prev.tweak_flag == tweak_flag)) {
497  return OPERATOR_RUNNING_MODAL;
498  }
499  /* Coordinate at which the arc drawing will be started. */
500  const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f};
501  float angle_ofs, angle_delta, angle_increment = 0.0f;
502 
504  gz, event, CTX_wm_region(C), gz->matrix_basis, co_outer, &angle_ofs, &angle_delta);
505 
506  if (tweak_flag & WM_GIZMO_TWEAK_SNAP) {
507  angle_increment = RNA_float_get(gz->ptr, "incremental_angle");
508  angle_delta = (float)roundf((double)angle_delta / angle_increment) * angle_increment;
509  }
510  if (tweak_flag & WM_GIZMO_TWEAK_PRECISE) {
511  angle_increment *= 0.2f;
512  angle_delta *= 0.2f;
513  }
514  if (angle_delta != 0.0f) {
515  inter->has_drag = true;
516  }
517 
518  inter->angle_increment = angle_increment;
519  inter->output.angle_delta = angle_delta;
520  inter->output.angle_ofs = angle_ofs;
521 
522  /* Set the property for the operator and call its modal function. */
523  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
524  if (WM_gizmo_target_property_is_valid(gz_prop)) {
525  WM_gizmo_target_property_float_set(C, gz, gz_prop, inter->init.prop_angle + angle_delta);
526  }
527 
528  inter->prev.tweak_flag = tweak_flag;
529 
530  return OPERATOR_RUNNING_MODAL;
531 }
532 
533 static void gizmo_dial_exit(bContext *C, wmGizmo *gz, const bool cancel)
534 {
535  DialInteraction *inter = gz->interaction_data;
536  bool use_reset_value = false;
537  float reset_value = 0.0f;
538  if (cancel) {
539  /* Set the property for the operator and call its modal function. */
540  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
541  if (WM_gizmo_target_property_is_valid(gz_prop)) {
542  use_reset_value = true;
543  reset_value = inter->init.prop_angle;
544  }
545  }
546  else {
547  if (inter->has_drag == false) {
548  PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "click_value");
549  if (RNA_property_is_set(gz->ptr, prop)) {
550  use_reset_value = true;
551  reset_value = RNA_property_float_get(gz->ptr, prop);
552  }
553  }
554  }
555 
556  if (use_reset_value) {
557  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
558  if (WM_gizmo_target_property_is_valid(gz_prop)) {
559  WM_gizmo_target_property_float_set(C, gz, gz_prop, reset_value);
560  }
561  }
562 
563  if (!cancel) {
564  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
565  if (WM_gizmo_target_property_is_valid(gz_prop)) {
567  }
568  }
569 }
570 
571 static void gizmo_dial_setup(wmGizmo *gz)
572 {
573  const float dir_default[3] = {0.0f, 0.0f, 1.0f};
574 
575  /* defaults */
576  copy_v3_v3(gz->matrix_basis[2], dir_default);
577 }
578 
579 static int gizmo_dial_invoke(bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
580 {
581  DialInteraction *inter = MEM_callocN(sizeof(DialInteraction), __func__);
582 
583  inter->init.mval[0] = event->mval[0];
584  inter->init.mval[1] = event->mval[1];
585 
586  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
587  if (WM_gizmo_target_property_is_valid(gz_prop)) {
588  inter->init.prop_angle = WM_gizmo_target_property_float_get(gz, gz_prop);
589  }
590 
591  gz->interaction_data = inter;
592 
593  return OPERATOR_RUNNING_MODAL;
594 }
595 
596 /* -------------------------------------------------------------------- */
600 void ED_gizmotypes_dial_3d_draw_util(const float matrix_basis[4][4],
601  const float matrix_final[4][4],
602  const float line_width,
603  const float color[4],
604  const bool select,
605  struct Dial3dParams *params)
606 {
607  GPU_matrix_push();
608  GPU_matrix_mul(matrix_final);
609 
610  GPU_polygon_smooth(false);
611 
612  if ((params->draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE) != 0) {
613  /* Draw rotation indicator arc first. */
615  params->angle_delta,
616  params->arc_inner_factor,
617  color,
618  params->draw_options);
619 
620  if ((params->draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR) != 0) {
622  params->angle_delta,
623  params->arc_inner_factor,
624  color,
625  params->draw_options);
626  }
627  }
628 
629  if (params->angle_increment) {
630  dial_ghostarc_draw_incremental_angle(params->angle_increment, params->angle_ofs);
631  }
632 
633  /* Draw actual dial gizmo. */
634  dial_geom_draw(color,
635  line_width,
636  select,
637  matrix_basis,
638  params->clip_plane,
639  params->arc_partial_angle,
640  params->arc_inner_factor,
641  params->draw_options);
642 
643  GPU_matrix_pop();
644 }
645 
646 static void GIZMO_GT_dial_3d(wmGizmoType *gzt)
647 {
648  /* identifiers */
649  gzt->idname = "GIZMO_GT_dial_3d";
650 
651  /* api callbacks */
652  gzt->draw = gizmo_dial_draw;
654  gzt->setup = gizmo_dial_setup;
655  gzt->invoke = gizmo_dial_invoke;
656  gzt->modal = gizmo_dial_modal;
657  gzt->exit = gizmo_dial_exit;
658 
659  gzt->struct_size = sizeof(wmGizmo);
660 
661  /* rna */
662  static EnumPropertyItem rna_enum_draw_options[] = {
663  {ED_GIZMO_DIAL_DRAW_FLAG_CLIP, "CLIP", 0, "Clipped", ""},
664  {ED_GIZMO_DIAL_DRAW_FLAG_FILL, "FILL", 0, "Filled", ""},
665  {ED_GIZMO_DIAL_DRAW_FLAG_FILL_SELECT, "FILL_SELECT", 0, "Use fill for selection test", ""},
666  {ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR, "ANGLE_MIRROR", 0, "Angle Mirror", ""},
667  {ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y, "ANGLE_START_Y", 0, "Angle Start Y", ""},
668  {ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE, "ANGLE_VALUE", 0, "Show Angle Value", ""},
669  {0, NULL, 0, NULL, NULL},
670  };
671  RNA_def_enum_flag(gzt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", "");
672  RNA_def_boolean(gzt->srna, "wrap_angle", true, "Wrap Angle", "");
674  gzt->srna, "arc_inner_factor", 0.0f, 0.0f, 1.0f, "Arc Inner Factor", "", 0.0f, 1.0f);
676  "arc_partial_angle",
677  0.0f,
678  0.0f,
679  M_PI * 2,
680  "Show Partial Dial",
681  "",
682  0.0f,
683  M_PI * 2);
685  "incremental_angle",
687  0.0f,
688  M_PI * 2,
689  "Incremental Angle",
690  "Angle to snap in steps",
691  0.0f,
692  M_PI * 2);
693  RNA_def_float(gzt->srna,
694  "click_value",
695  0.0f,
696  -FLT_MAX,
697  FLT_MAX,
698  "Click Value",
699  "Value to use for a single click action",
700  -FLT_MAX,
701  FLT_MAX);
702 
703  WM_gizmotype_target_property_def(gzt, "offset", PROP_FLOAT, 1);
704 }
705 
707 {
709 }
710 
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
Definition: context.c:714
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:725
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define M_PI_2
Definition: BLI_math_base.h:41
#define M_PI
Definition: BLI_math_base.h:38
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
Definition: math_geom.c:243
void mul_v3_project_m4_v3(float r[3], const float mat[4][4], const float vec[3])
Definition: math_matrix.c:835
#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:551
MINLINE float normalize_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition: BLI_sys_types.h:83
#define UNUSED_VARS(...)
#define UNUSED(x)
#define UNPACK3(a)
typedef double(DMatrix)[4][4]
@ SPACE_VIEW3D
@ 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:173
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 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_circle_fill_2d(uint shdr_pos, float x, float y, float radius, int nsegments)
void imm_draw_circle_partial_wire_2d(uint pos, float x, float y, float radius, int nsegments, float start, float sweep)
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 imm_draw_circle_wire_2d(uint shdr_pos, float x, float y, float radius, int nsegments)
void GPU_matrix_pop(void)
Definition: gpu_matrix.cc:142
#define GPU_matrix_mul(x)
Definition: GPU_matrix.h:223
void GPU_matrix_push(void)
Definition: gpu_matrix.cc:135
void GPU_matrix_rotate_3f(float deg, float x, float y, float z)
Definition: gpu_matrix.cc:277
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:36
@ GPU_PRIM_LINE_STRIP
Definition: GPU_primitive.h:38
bool GPU_select_load_id(unsigned int id)
Definition: gpu_select.c:108
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
Definition: GPU_shader.h:223
@ GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR
Definition: GPU_shader.h:201
@ GPU_SHADER_3D_UNIFORM_COLOR
Definition: GPU_shader.h:200
@ GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR
Definition: GPU_shader.h:224
@ GPU_BLEND_NONE
Definition: GPU_state.h:55
@ GPU_BLEND_ALPHA
Definition: GPU_state.h:57
void GPU_blend(eGPUBlend blend)
Definition: gpu_state.cc:55
void GPU_viewport_size_get_f(float coords[4])
Definition: gpu_state.cc:279
void GPU_polygon_smooth(bool enable)
Definition: gpu_state.cc:90
@ 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.
@ PROP_FLOAT
Definition: RNA_types.h:75
#define C
Definition: RandGen.cpp:39
struct wmGizmo wmGizmo
Definition: WM_api.h:74
eWM_GizmoFlagTweak
Gizmo tweak flag. Bitflag 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
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 DIAL_CLIP_BIAS
Definition: dial3d_gizmo.c:93
static void dial_ghostarc_draw_incremental_angle(const float incremental_angle, const float offset)
Definition: dial3d_gizmo.c:217
static void gizmo_dial_exit(bContext *C, wmGizmo *gz, const bool cancel)
Definition: dial3d_gizmo.c:533
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:300
static int gizmo_dial_modal(bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak tweak_flag)
Definition: dial3d_gizmo.c:490
static void gizmo_dial_setup(wmGizmo *gz)
Definition: dial3d_gizmo.c:571
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:376
static void gizmo_dial_draw(const bContext *C, wmGizmo *gz)
Definition: dial3d_gizmo.c:466
static void gizmo_dial_draw_select(const bContext *C, wmGizmo *gz, int select_id)
Definition: dial3d_gizmo.c:447
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)
Definition: dial3d_gizmo.c:600
#define DIAL_RESOLUTION
Definition: dial3d_gizmo.c:90
#define DIAL_WIDTH
Definition: dial3d_gizmo.c:89
static void dial_draw_intern(const bContext *C, wmGizmo *gz, const bool select, const bool highlight, float clip_plane[4])
Definition: dial3d_gizmo.c:392
void ED_gizmotypes_dial_3d(void)
Definition: dial3d_gizmo.c:706
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:249
struct DialInteraction DialInteraction
static void GIZMO_GT_dial_3d(wmGizmoType *gzt)
Definition: dial3d_gizmo.c:646
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:97
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:185
static int gizmo_dial_invoke(bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
Definition: dial3d_gizmo.c:579
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])
uint pos
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
#define sinf(x)
#define cosf(x)
#define floorf(x)
#define fabsf(x)
format
Definition: logImageCore.h:47
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2941
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:6655
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:866
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6355
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6261
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6402
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:3825
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3481
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:3795
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:4133
void * regiondata
struct DialInteraction::@320 init
struct DialInteraction::@322 output
struct DialInteraction::@321 prev
float angle_increment
Definition: dial3d_gizmo.c:80
eWM_GizmoFlagTweak tweak_flag
Definition: dial3d_gizmo.c:73
float viewinv[4][4]
int ymin
Definition: DNA_vec_types.h:80
int xmin
Definition: DNA_vec_types.h:79
short type
Definition: WM_types.h:577
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
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: util_avxb.h:167
@ MOUSEMOVE
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
Definition: wm_gizmo.c:601
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 *))