Blender  V3.3
cage3d_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 
15 #include "MEM_guardedalloc.h"
16 
17 #include "BLI_math.h"
18 
19 #include "BKE_context.h"
20 
21 #include "GPU_immediate.h"
22 #include "GPU_immediate_util.h"
23 #include "GPU_matrix.h"
24 #include "GPU_select.h"
25 #include "GPU_shader.h"
26 #include "GPU_state.h"
27 
28 #include "RNA_access.h"
29 #include "RNA_define.h"
30 
31 #include "WM_api.h"
32 #include "WM_types.h"
33 
34 #include "ED_gizmo_library.h"
35 #include "ED_screen.h"
36 #include "ED_view3d.h"
37 
38 /* own includes */
39 #include "../gizmo_library_intern.h"
40 
41 #define GIZMO_RESIZER_SIZE 10.0f
42 #define GIZMO_MARGIN_OFFSET_SCALE 1.5f
43 
45  float orig_matrix_final_no_offset[4][4],
46  bool use_space)
47 {
48  float mat_identity[4][4];
49  struct WM_GizmoMatrixParams params = {NULL};
50  unit_m4(mat_identity);
51  if (use_space == false) {
52  params.matrix_basis = mat_identity;
53  }
54  params.matrix_offset = mat_identity;
55  WM_gizmo_calc_matrix_final_params(gz, &params, orig_matrix_final_no_offset);
56 }
57 
58 static void gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[3], float scale[3])
59 {
60  UNUSED_VARS(dims);
61 
62  /* Unlike cage2d, no need to correct for aspect. */
63  float matrix_final_no_offset[4][4];
64 
65  float x_axis[3], y_axis[3], z_axis[3];
66  gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset, false);
67  mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, gz->matrix_offset[0]);
68  mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, gz->matrix_offset[1]);
69  mul_v3_mat3_m4v3(z_axis, matrix_final_no_offset, gz->matrix_offset[2]);
70 
71  scale[0] = 1.0f / len_v3(x_axis);
72  scale[1] = 1.0f / len_v3(y_axis);
73  scale[2] = 1.0f / len_v3(z_axis);
74 }
75 
76 static void gizmo_calc_rect_view_margin(const wmGizmo *gz, const float dims[3], float margin[3])
77 {
78  const float handle_size = 9.0f;
79  /* XXX, the scale isn't taking offset into account, we need to calculate scale per handle! */
80  // handle_size *= gz->scale_final;
81 
82  float scale_xyz[3];
83  gizmo_calc_rect_view_scale(gz, dims, scale_xyz);
84  margin[0] = ((handle_size * scale_xyz[0]));
85  margin[1] = ((handle_size * scale_xyz[1]));
86  margin[2] = ((handle_size * scale_xyz[2]));
87 }
88 
89 /* -------------------------------------------------------------------- */
90 
91 static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[3], bool r_constrain_axis[3])
92 {
96  int range[3];
97  range[2] = index % 3;
98  index = index / 3;
99  range[1] = index % 3;
100  index = index / 3;
101  range[0] = index % 3;
102 
103  const float sign[3] = {0.5f, 0.0f, -0.5f};
104  for (int i = 0; i < 3; i++) {
105  r_pt[i] = sign[range[i]];
106  r_constrain_axis[i] = (range[i] == 1);
107  }
108  }
109 }
110 
111 /* -------------------------------------------------------------------- */
117 static void cage3d_draw_box_corners(const float r[3],
118  const float margin[3],
119  const float color[3],
120  const float line_width)
121 {
123  UNUSED_VARS(margin);
124 
127 
128  float viewport[4];
129  GPU_viewport_size_get_f(viewport);
130  immUniform2fv("viewportSize", &viewport[2]);
131  immUniform1f("lineWidth", line_width * U.pixelsize);
132 
133  imm_draw_cube_wire_3d(pos, (float[3]){0}, r);
134 
136 }
137 
139  const float matrix_final[4][4],
140  const float color[4],
141  const int highlighted,
142  const float size[3],
143  const float margin[3])
144 {
147  int index = (highlighted - ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z);
148  int range[3];
149  range[2] = index % 3;
150  index = index / 3;
151  range[1] = index % 3;
152  index = index / 3;
153  range[0] = index % 3;
154 
155  const float sign[3] = {-1.0f, 0.0f, 1.0f};
156  float co[3];
157 
158  for (int i = 0; i < 3; i++) {
159  co[i] = size[i] * sign[range[i]];
160  }
161  const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3};
162  float co_test[3];
163  mul_v3_m4v3(co_test, matrix_final, co);
164  float rad_scale[3];
165  mul_v3_v3fl(rad_scale, rad, ED_view3d_pixel_size(rv3d, co_test));
166 
167  {
172  imm_draw_cube_fill_3d(pos, co, rad_scale);
174  }
175  }
176 }
177 
180 /* -------------------------------------------------------------------- */
186 static void imm_draw_point_aspect_3d(uint pos, const float co[3], const float rad[3], bool solid)
187 {
188  if (solid) {
189  imm_draw_cube_fill_3d(pos, co, rad);
190  }
191  else {
192  imm_draw_cube_wire_3d(pos, co, rad);
193  }
194 }
195 
196 static void cage3d_draw_circle_wire(const float r[3],
197  const float margin[3],
198  const float color[3],
199  const int transform_flag,
200  const int draw_options,
201  const float line_width)
202 {
204 
207 
208  float viewport[4];
209  GPU_viewport_size_get_f(viewport);
210  immUniform2fv("viewportSize", &viewport[2]);
211  immUniform1f("lineWidth", line_width * U.pixelsize);
212 
213  imm_draw_cube_wire_3d(pos, (const float[3]){0}, r);
214 
215 #if 0
216  if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) {
218  const float rad[2] = {margin[0] / 2, margin[1] / 2};
219  const float center[2] = {0.0f, 0.0f};
220 
222  immVertex2f(pos, center[0] - rad[0], center[1] - rad[1]);
223  immVertex2f(pos, center[0] + rad[0], center[1] + rad[1]);
224  immVertex2f(pos, center[0] + rad[0], center[1] - rad[1]);
225  immVertex2f(pos, center[0] - rad[0], center[1] + rad[1]);
226  immEnd();
227  }
228  }
229 #else
230  UNUSED_VARS(margin, transform_flag, draw_options);
231 #endif
232 
234 }
235 
236 static void cage3d_draw_circle_handles(const RegionView3D *rv3d,
237  const float matrix_final[4][4],
238  const float r[3],
239  const float margin[3],
240  const float color[3],
241  bool solid,
242  const float handle_scale)
243 {
245  const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3};
246 
249 
250  const float sign[3] = {-1.0f, 0.0f, 1.0f};
251  for (int x = 0; x < 3; x++) {
252  for (int y = 0; y < 3; y++) {
253  for (int z = 0; z < 3; z++) {
254  if (x == 1 && y == 1 && z == 1) {
255  continue;
256  }
257  const float co[3] = {r[0] * sign[x], r[1] * sign[y], r[2] * sign[z]};
258  float co_test[3];
259  mul_v3_m4v3(co_test, matrix_final, co);
260  float rad_scale[3];
261  mul_v3_v3fl(rad_scale, rad, ED_view3d_pixel_size(rv3d, co_test) * handle_scale);
262  imm_draw_point_aspect_3d(pos, co, rad_scale, solid);
263  }
264  }
265  }
266 
268 }
269 
273  RegionView3D *rv3d, wmGizmo *gz, const bool select, const bool highlight, const int select_id)
274 {
275  // const bool use_clamp = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0;
276  float dims[3];
277  RNA_float_get_array(gz->ptr, "dimensions", dims);
278  float matrix_final[4][4];
279 
280  const int transform_flag = RNA_enum_get(gz->ptr, "transform");
281  const int draw_style = RNA_enum_get(gz->ptr, "draw_style");
282  const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
283 
284  const float size_real[3] = {dims[0] / 2.0f, dims[1] / 2.0f, dims[2] / 2.0f};
285 
286  WM_gizmo_calc_matrix_final(gz, matrix_final);
287 
288  GPU_matrix_push();
289  GPU_matrix_mul(matrix_final);
290 
291  float margin[3];
292  gizmo_calc_rect_view_margin(gz, dims, margin);
293 
294  /* Handy for quick testing draw (if it's outside bounds). */
295  if (false) {
299  immUniformColor4fv((const float[4]){1, 1, 1, 0.5f});
300  float s = 0.5f;
301  immRectf(pos, -s, -s, s, s);
304  }
305 
306  if (select) {
307  /* Expand for hot-spot. */
308 #if 0
309  const float size[3] = {
310  size_real[0] + margin[0] / 2,
311  size_real[1] + margin[1] / 2,
312  size_real[2] + margin[2] / 2,
313  };
314 #else
315  /* just use same value for now. */
316  const float size[3] = {UNPACK3(size_real)};
317 #endif
318 
319  if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE) {
322  i++) {
324  continue;
325  }
326  GPU_select_load_id(select_id | i);
327  cage3d_draw_box_interaction(rv3d, matrix_final, gz->color, i, size, margin);
328  }
329  }
330  if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) {
331  const int transform_part = ED_GIZMO_CAGE3D_PART_TRANSLATE;
332  GPU_select_load_id(select_id | transform_part);
333  cage3d_draw_box_interaction(rv3d, matrix_final, gz->color, transform_part, size, margin);
334  }
335  }
336  else {
337 #if 0
338  const rctf _r = {
339  .xmin = -size_real[0],
340  .ymin = -size_real[1],
341  .xmax = size_real[0],
342  .ymax = size_real[1],
343  };
344 #endif
345  if (draw_style == ED_GIZMO_CAGE2D_STYLE_BOX) {
346  float color[4], black[3] = {0, 0, 0};
347  gizmo_color_get(gz, highlight, color);
348 
349  /* corner gizmos */
350  cage3d_draw_box_corners(size_real, margin, black, gz->line_width + 3.0f);
351 
352  /* corner gizmos */
353  cage3d_draw_box_corners(size_real, margin, color, gz->line_width);
354 
355  bool show = false;
357  /* Only show if we're drawing the center handle
358  * otherwise the entire rectangle is the hot-spot. */
360  show = true;
361  }
362  }
363  else {
364  show = true;
365  }
366 
367  if (show) {
369  rv3d, matrix_final, gz->color, gz->highlight_part, size_real, margin);
370  }
371  }
372  else if (draw_style == ED_GIZMO_CAGE2D_STYLE_CIRCLE) {
373  float color[4], black[3] = {0, 0, 0};
374  gizmo_color_get(gz, highlight, color);
375 
377 
379  size_real, margin, black, transform_flag, draw_options, gz->line_width + 3.0f);
381  size_real, margin, color, transform_flag, draw_options, gz->line_width);
382 
383  /* Corner gizmos (draw the outer & inner so there is a visible outline). */
384  GPU_polygon_smooth(true);
385  cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, black, true, 1.0f);
386  cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, color, true, 1.0f / 1.5f);
387  GPU_polygon_smooth(false);
388 
390  }
391  else {
392  BLI_assert(0);
393  }
394  }
395 
396  GPU_matrix_pop();
397 }
398 
402 static void gizmo_cage3d_draw_select(const bContext *C, wmGizmo *gz, int select_id)
403 {
404  ARegion *region = CTX_wm_region(C);
405  RegionView3D *rv3d = region->regiondata;
406  gizmo_cage3d_draw_intern(rv3d, gz, true, false, select_id);
407 }
408 
409 static void gizmo_cage3d_draw(const bContext *C, wmGizmo *gz)
410 {
411  ARegion *region = CTX_wm_region(C);
412  RegionView3D *rv3d = region->regiondata;
413  const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
414  gizmo_cage3d_draw_intern(rv3d, gz, false, is_highlight, -1);
415 }
416 
418 {
420  return WM_CURSOR_NSEW_SCROLL;
421  }
422 
423  return WM_CURSOR_DEFAULT;
424 }
425 
426 typedef struct RectTransformInteraction {
427  float orig_mouse[3];
428  float orig_matrix_offset[4][4];
429  float orig_matrix_final_no_offset[4][4];
431 
432 static void gizmo_cage3d_setup(wmGizmo *gz)
433 {
434  gz->flag |= /* WM_GIZMO_DRAW_MODAL | */ /* TODO */
436 }
437 
438 static int gizmo_cage3d_invoke(bContext *C, wmGizmo *gz, const wmEvent *event)
439 {
441  "cage_interaction");
442 
443  copy_m4_m4(data->orig_matrix_offset, gz->matrix_offset);
444  gizmo_calc_matrix_final_no_offset(gz, data->orig_matrix_final_no_offset, true);
445 
447  C, gz, (const float[2]){UNPACK2(event->mval)}, false, data->orig_mouse) == 0) {
448  zero_v3(data->orig_mouse);
449  }
450 
451  gz->interaction_data = data;
452 
453  return OPERATOR_RUNNING_MODAL;
454 }
455 
457  wmGizmo *gz,
458  const wmEvent *event,
459  eWM_GizmoFlagTweak UNUSED(tweak_flag))
460 {
461  if (event->type != MOUSEMOVE) {
462  return OPERATOR_RUNNING_MODAL;
463  }
464  /* For transform logic to be manageable we operate in -0.5..0.5 2D space,
465  * no matter the size of the rectangle, mouse coords are scaled to unit space.
466  * The mouse coords have been projected into the matrix
467  * so we don't need to worry about axis alignment.
468  *
469  * - The cursor offset are multiplied by 'dims'.
470  * - Matrix translation is also multiplied by 'dims'.
471  */
473  float point_local[3];
474 
475  float dims[3];
476  RNA_float_get_array(gz->ptr, "dimensions", dims);
477 
478  {
479  float matrix_back[4][4];
480  copy_m4_m4(matrix_back, gz->matrix_offset);
481  copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
482 
483  bool ok = gizmo_window_project_3d(
484  C, gz, (const float[2]){UNPACK2(event->mval)}, false, point_local);
485  copy_m4_m4(gz->matrix_offset, matrix_back);
486  if (!ok) {
487  return OPERATOR_RUNNING_MODAL;
488  }
489  }
490 
491  const int transform_flag = RNA_enum_get(gz->ptr, "transform");
492  wmGizmoProperty *gz_prop;
493 
494  gz_prop = WM_gizmo_target_property_find(gz, "matrix");
495  if (gz_prop->type != NULL) {
497  }
498 
500  /* do this to prevent clamping from changing size */
501  copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
502  gz->matrix_offset[3][0] = data->orig_matrix_offset[3][0] +
503  (point_local[0] - data->orig_mouse[0]);
504  gz->matrix_offset[3][1] = data->orig_matrix_offset[3][1] +
505  (point_local[1] - data->orig_mouse[1]);
506  gz->matrix_offset[3][2] = data->orig_matrix_offset[3][2] +
507  (point_local[2] - data->orig_mouse[2]);
508  }
510  /* Add this (if we need it). */
511  }
512  else {
513  /* scale */
514  copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
515  float pivot[3];
516  bool constrain_axis[3] = {false};
517 
518  if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) {
519  gizmo_rect_pivot_from_scale_part(gz->highlight_part, pivot, constrain_axis);
520  }
521  else {
522  zero_v3(pivot);
523  }
524 
525  /* Cursor deltas scaled to (-0.5..0.5). */
526  float delta_orig[3], delta_curr[3];
527 
528  for (int i = 0; i < 3; i++) {
529  delta_orig[i] = ((data->orig_mouse[i] - data->orig_matrix_offset[3][i]) / dims[i]) -
530  pivot[i];
531  delta_curr[i] = ((point_local[i] - data->orig_matrix_offset[3][i]) / dims[i]) - pivot[i];
532  }
533 
534  float scale[3] = {1.0f, 1.0f, 1.0f};
535  for (int i = 0; i < 3; i++) {
536  if (constrain_axis[i] == false) {
537  if (delta_orig[i] < 0.0f) {
538  delta_orig[i] *= -1.0f;
539  delta_curr[i] *= -1.0f;
540  }
541  const int sign = signum_i(scale[i]);
542 
543  scale[i] = 1.0f + ((delta_curr[i] - delta_orig[i]) / len_v3(data->orig_matrix_offset[i]));
544 
545  if ((transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_SIGNED) == 0) {
546  if (sign != signum_i(scale[i])) {
547  scale[i] = 0.0f;
548  }
549  }
550  }
551  }
552 
553  if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM) {
554  if (constrain_axis[0] == false && constrain_axis[1] == false) {
555  scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f;
556  }
557  else if (constrain_axis[0] == false) {
558  scale[1] = scale[0];
559  }
560  else if (constrain_axis[1] == false) {
561  scale[0] = scale[1];
562  }
563  else {
564  BLI_assert(0);
565  }
566  }
567 
568  /* scale around pivot */
569  float matrix_scale[4][4];
570  unit_m4(matrix_scale);
571 
572  mul_v3_fl(matrix_scale[0], scale[0]);
573  mul_v3_fl(matrix_scale[1], scale[1]);
574  mul_v3_fl(matrix_scale[2], scale[2]);
575 
577  matrix_scale,
578  (const float[3]){pivot[0] * dims[0], pivot[1] * dims[1], pivot[2] * dims[2]});
579  mul_m4_m4m4(gz->matrix_offset, data->orig_matrix_offset, matrix_scale);
580  }
581 
582  if (gz_prop->type != NULL) {
583  WM_gizmo_target_property_float_set_array(C, gz, gz_prop, &gz->matrix_offset[0][0]);
584  }
585 
586  /* tag the region for redraw */
589 
590  return OPERATOR_RUNNING_MODAL;
591 }
592 
594 {
595  if (STREQ(gz_prop->type->idname, "matrix")) {
596  if (WM_gizmo_target_property_array_length(gz, gz_prop) == 16) {
598  }
599  else {
600  BLI_assert(0);
601  }
602  }
603  else {
604  BLI_assert(0);
605  }
606 }
607 
608 static void gizmo_cage3d_exit(bContext *C, wmGizmo *gz, const bool cancel)
609 {
611 
612  if (!cancel) {
613  return;
614  }
615 
616  wmGizmoProperty *gz_prop;
617 
618  /* reset properties */
619  gz_prop = WM_gizmo_target_property_find(gz, "matrix");
620  if (gz_prop->type != NULL) {
621  WM_gizmo_target_property_float_set_array(C, gz, gz_prop, &data->orig_matrix_offset[0][0]);
622  }
623 
624  copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
625 }
626 
627 /* -------------------------------------------------------------------- */
631 static void GIZMO_GT_cage_3d(wmGizmoType *gzt)
632 {
633  /* identifiers */
634  gzt->idname = "GIZMO_GT_cage_3d";
635 
636  /* api callbacks */
637  gzt->draw = gizmo_cage3d_draw;
639  gzt->setup = gizmo_cage3d_setup;
642  gzt->modal = gizmo_cage3d_modal;
643  gzt->exit = gizmo_cage3d_exit;
645 
646  gzt->struct_size = sizeof(wmGizmo);
647 
648  /* rna */
649  static EnumPropertyItem rna_enum_draw_style[] = {
650  {ED_GIZMO_CAGE2D_STYLE_BOX, "BOX", 0, "Box", ""},
651  {ED_GIZMO_CAGE2D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""},
652  {0, NULL, 0, NULL, NULL},
653  };
654  static EnumPropertyItem rna_enum_transform[] = {
655  {ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Move", ""},
656  {ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""},
657  {ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""},
658  {0, NULL, 0, NULL, NULL},
659  };
660  static EnumPropertyItem rna_enum_draw_options[] = {
662  "XFORM_CENTER_HANDLE",
663  0,
664  "Center Handle",
665  ""},
666  {0, NULL, 0, NULL, NULL},
667  };
668  static float unit_v3[3] = {1.0f, 1.0f, 1.0f};
670  gzt->srna, "dimensions", 3, unit_v3, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX);
671  RNA_def_enum_flag(gzt->srna, "transform", rna_enum_transform, 0, "Transform Options", "");
672  RNA_def_enum(gzt->srna,
673  "draw_style",
674  rna_enum_draw_style,
676  "Draw Style",
677  "");
678  RNA_def_enum_flag(gzt->srna,
679  "draw_options",
680  rna_enum_draw_options,
682  "Draw Options",
683  "");
684 
685  WM_gizmotype_target_property_def(gzt, "matrix", PROP_FLOAT, 16);
686 }
687 
689 {
691 }
692 
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:749
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:723
#define BLI_assert(a)
Definition: BLI_assert.h:46
MINLINE int signum_i(float a)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:259
void unit_m4(float m[4][4])
Definition: rct.c:1090
void transform_pivot_set_m4(float mat[4][4], const float pivot[3])
Definition: math_matrix.c:2369
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:77
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
Definition: math_matrix.c:739
void mul_v3_mat3_m4v3(float r[3], const float M[4][4], const float v[3])
Definition: math_matrix.c:800
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
unsigned int uint
Definition: BLI_sys_types.h:67
#define UNPACK2(a)
#define UNUSED_VARS(...)
#define UNUSED(x)
#define UNPACK3(a)
#define STREQ(a, b)
@ OPERATOR_RUNNING_MODAL
@ ED_GIZMO_CAGE2D_STYLE_BOX
@ ED_GIZMO_CAGE2D_STYLE_CIRCLE
@ ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE
@ ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z
@ ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z
@ ED_GIZMO_CAGE3D_PART_ROTATE
@ ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z
@ ED_GIZMO_CAGE3D_PART_TRANSLATE
@ ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE
@ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_SIGNED
@ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE
@ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM
void ED_region_tag_redraw_editor_overlays(struct ARegion *region)
Definition: area.c:690
float ED_view3d_pixel_size(const struct RegionView3D *rv3d, const float co[3])
NSNotificationCenter * center
void immUniform2fv(const char *name, const float data[2])
void immUnbindProgram(void)
void immVertex2f(uint attr_id, float x, float y)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immUniform1f(const char *name, float x)
void immUniformColor4fv(const float rgba[4])
GPUVertFormat * immVertexFormat(void)
void immBegin(GPUPrimType, uint vertex_len)
void immEnd(void)
void immUniformColor3fv(const float rgb[3])
void immRectf(uint pos, float x1, float y1, float x2, float y2)
void imm_draw_cube_wire_3d(uint pos, const float center[3], const float aspect[3])
void imm_draw_cube_fill_3d(uint pos, const float center[3], const float aspect[3])
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
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
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:20
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_UNIFORM_COLOR
Definition: GPU_shader.h:230
@ 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_DRAW_NO_SCALE
@ WM_GIZMOGROUPTYPE_3D
@ WM_GIZMO_STATE_HIGHLIGHT
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: avxb.h:154
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
unsigned int U
Definition: btGjkEpa3.h:78
static void gizmo_cage3d_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop)
Definition: cage3d_gizmo.c:593
static void cage3d_draw_circle_handles(const RegionView3D *rv3d, const float matrix_final[4][4], const float r[3], const float margin[3], const float color[3], bool solid, const float handle_scale)
Definition: cage3d_gizmo.c:236
static void cage3d_draw_box_corners(const float r[3], const float margin[3], const float color[3], const float line_width)
Definition: cage3d_gizmo.c:117
static void gizmo_cage3d_draw_select(const bContext *C, wmGizmo *gz, int select_id)
Definition: cage3d_gizmo.c:402
static void gizmo_cage3d_draw_intern(RegionView3D *rv3d, wmGizmo *gz, const bool select, const bool highlight, const int select_id)
Definition: cage3d_gizmo.c:272
static void gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[3], float scale[3])
Definition: cage3d_gizmo.c:58
static int gizmo_cage3d_modal(bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak UNUSED(tweak_flag))
Definition: cage3d_gizmo.c:456
struct RectTransformInteraction RectTransformInteraction
static int gizmo_cage3d_get_cursor(wmGizmo *gz)
Definition: cage3d_gizmo.c:417
static void gizmo_cage3d_setup(wmGizmo *gz)
Definition: cage3d_gizmo.c:432
static int gizmo_cage3d_invoke(bContext *C, wmGizmo *gz, const wmEvent *event)
Definition: cage3d_gizmo.c:438
void ED_gizmotypes_cage_3d(void)
Definition: cage3d_gizmo.c:688
static void cage3d_draw_circle_wire(const float r[3], const float margin[3], const float color[3], const int transform_flag, const int draw_options, const float line_width)
Definition: cage3d_gizmo.c:196
static void GIZMO_GT_cage_3d(wmGizmoType *gzt)
Definition: cage3d_gizmo.c:631
static void gizmo_cage3d_draw(const bContext *C, wmGizmo *gz)
Definition: cage3d_gizmo.c:409
static void gizmo_calc_rect_view_margin(const wmGizmo *gz, const float dims[3], float margin[3])
Definition: cage3d_gizmo.c:76
static void imm_draw_point_aspect_3d(uint pos, const float co[3], const float rad[3], bool solid)
Definition: cage3d_gizmo.c:186
static void gizmo_cage3d_exit(bContext *C, wmGizmo *gz, const bool cancel)
Definition: cage3d_gizmo.c:608
static void cage3d_draw_box_interaction(const RegionView3D *rv3d, const float matrix_final[4][4], const float color[4], const int highlighted, const float size[3], const float margin[3])
Definition: cage3d_gizmo.c:138
static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[3], bool r_constrain_axis[3])
Definition: cage3d_gizmo.c:91
static void gizmo_calc_matrix_final_no_offset(const wmGizmo *gz, float orig_matrix_final_no_offset[4][4], bool use_space)
Definition: cage3d_gizmo.c:44
bool gizmo_window_project_3d(bContext *C, const struct wmGizmo *gz, const float mval[2], bool use_offset, float r_co[3])
void gizmo_color_get(const struct wmGizmo *gz, bool highlight, float r_color[4])
uint pos
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
double sign(double arg)
Definition: utility.h:250
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
Definition: rna_access.c:4980
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
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_vector(StructOrFunctionRNA *cont_, const char *identifier, int len, const float *default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3862
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3783
void * regiondata
float orig_matrix_offset[4][4]
Definition: cage2d_gizmo.c:882
float orig_matrix_final_no_offset[4][4]
Definition: cage2d_gizmo.c:883
float xmin
Definition: DNA_vec_types.h:69
int mval[2]
Definition: WM_types.h:684
short type
Definition: WM_types.h:678
eWM_GizmoFlagGroupTypeFlag flag
struct wmGizmoGroupType * type
const struct wmGizmoPropertyType * type
wmGizmoFnDraw draw
wmGizmoFnModal modal
wmGizmoFnSetup setup
const char * idname
wmGizmoFnExit exit
wmGizmoFnCursorGet cursor_get
struct StructRNA * srna
wmGizmoFnInvoke invoke
wmGizmoFnDrawSelect draw_select
wmGizmoFnPropertyUpdate property_update
void * interaction_data
eWM_GizmoFlagState state
struct wmGizmoGroup * parent_gzgroup
int highlight_part
float matrix_offset[4][4]
float color[4]
struct PointerRNA * ptr
float line_width
eWM_GizmoFlag flag
@ WM_CURSOR_NSEW_SCROLL
Definition: wm_cursors.h:51
@ WM_CURSOR_DEFAULT
Definition: wm_cursors.h:18
void WM_event_add_mousemove(wmWindow *win)
@ MOUSEMOVE
void WM_gizmo_calc_matrix_final_params(const wmGizmo *gz, const struct WM_GizmoMatrixParams *params, float r_mat[4][4])
Definition: wm_gizmo.c:502
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
Definition: wm_gizmo.c:554
wmGizmoProperty * WM_gizmo_target_property_find(wmGizmo *gz, const char *idname)
void WM_gizmo_target_property_float_get_array(const wmGizmo *gz, wmGizmoProperty *gz_prop, float *value)
void WM_gizmotype_target_property_def(wmGizmoType *gzt, const char *idname, int data_type, int array_length)
void WM_gizmo_target_property_float_set_array(bContext *C, const wmGizmo *gz, wmGizmoProperty *gz_prop, const float *value)
int WM_gizmo_target_property_array_length(const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop)
void WM_gizmotype_append(void(*gtfunc)(struct wmGizmoType *))
Definition: wm_gizmo_type.c:93