Blender  V2.93
cage3d_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 
31 #include "MEM_guardedalloc.h"
32 
33 #include "BLI_math.h"
34 
35 #include "BKE_context.h"
36 
37 #include "GPU_immediate.h"
38 #include "GPU_immediate_util.h"
39 #include "GPU_matrix.h"
40 #include "GPU_select.h"
41 #include "GPU_shader.h"
42 #include "GPU_state.h"
43 
44 #include "RNA_access.h"
45 #include "RNA_define.h"
46 
47 #include "WM_api.h"
48 #include "WM_types.h"
49 
50 #include "ED_gizmo_library.h"
51 #include "ED_screen.h"
52 #include "ED_view3d.h"
53 
54 /* own includes */
55 #include "../gizmo_library_intern.h"
56 
57 #define GIZMO_RESIZER_SIZE 10.0f
58 #define GIZMO_MARGIN_OFFSET_SCALE 1.5f
59 
61  float orig_matrix_final_no_offset[4][4],
62  bool use_space)
63 {
64  float mat_identity[4][4];
65  struct WM_GizmoMatrixParams params = {NULL};
66  unit_m4(mat_identity);
67  if (use_space == false) {
68  params.matrix_basis = mat_identity;
69  }
70  params.matrix_offset = mat_identity;
71  WM_gizmo_calc_matrix_final_params(gz, &params, orig_matrix_final_no_offset);
72 }
73 
74 static void gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[3], float scale[3])
75 {
76  UNUSED_VARS(dims);
77 
78  /* Unlike cage2d, no need to correct for aspect. */
79  float matrix_final_no_offset[4][4];
80 
81  float x_axis[3], y_axis[3], z_axis[3];
82  gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset, false);
83  mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, gz->matrix_offset[0]);
84  mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, gz->matrix_offset[1]);
85  mul_v3_mat3_m4v3(z_axis, matrix_final_no_offset, gz->matrix_offset[2]);
86 
87  scale[0] = 1.0f / len_v3(x_axis);
88  scale[1] = 1.0f / len_v3(y_axis);
89  scale[2] = 1.0f / len_v3(z_axis);
90 }
91 
92 static void gizmo_calc_rect_view_margin(const wmGizmo *gz, const float dims[3], float margin[3])
93 {
94  const float handle_size = 0.15f;
95  /* XXX, the scale isn't taking offset into account, we need to calculate scale per handle! */
96  // handle_size *= gz->scale_final;
97 
98  float scale_xyz[3];
99  gizmo_calc_rect_view_scale(gz, dims, scale_xyz);
100  margin[0] = ((handle_size * scale_xyz[0]));
101  margin[1] = ((handle_size * scale_xyz[1]));
102  margin[2] = ((handle_size * scale_xyz[2]));
103 }
104 
105 /* -------------------------------------------------------------------- */
106 
107 static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[3], bool r_constrain_axis[3])
108 {
112  int range[3];
113  range[2] = index % 3;
114  index = index / 3;
115  range[1] = index % 3;
116  index = index / 3;
117  range[0] = index % 3;
118 
119  const float sign[3] = {0.5f, 0.0f, -0.5f};
120  for (int i = 0; i < 3; i++) {
121  r_pt[i] = sign[range[i]];
122  r_constrain_axis[i] = (range[i] == 1);
123  }
124  }
125 }
126 
127 /* -------------------------------------------------------------------- */
133 static void cage3d_draw_box_corners(const float r[3],
134  const float margin[3],
135  const float color[3],
136  const float line_width)
137 {
139  UNUSED_VARS(margin);
140 
142  immUniformColor3fv(color);
143 
144  float viewport[4];
145  GPU_viewport_size_get_f(viewport);
146  immUniform2fv("viewportSize", &viewport[2]);
147  immUniform1f("lineWidth", line_width * U.pixelsize);
148 
149  imm_draw_cube_wire_3d(pos, (float[3]){0}, r);
150 
152 }
153 
154 static void cage3d_draw_box_interaction(const float color[4],
155  const int highlighted,
156  const float size[3],
157  const float margin[3])
158 {
161  int index = (highlighted - ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z);
162  int range[3];
163  range[2] = index % 3;
164  index = index / 3;
165  range[1] = index % 3;
166  index = index / 3;
167  range[0] = index % 3;
168 
169  const float sign[3] = {-1.0f, 0.0f, 1.0f};
170  float co[3];
171 
172  for (int i = 0; i < 3; i++) {
173  co[i] = size[i] * sign[range[i]];
174  }
175  const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3};
176 
177  {
181  immUniformColor3fv(color);
182  imm_draw_cube_fill_3d(pos, co, rad);
184  }
185  }
186 }
187 
190 /* -------------------------------------------------------------------- */
196 static void imm_draw_point_aspect_3d(uint pos, const float co[3], const float rad[3], bool solid)
197 {
198  if (solid) {
199  imm_draw_cube_fill_3d(pos, co, rad);
200  }
201  else {
202  imm_draw_cube_wire_3d(pos, co, rad);
203  }
204 }
205 
206 static void cage3d_draw_circle_wire(const float r[3],
207  const float margin[3],
208  const float color[3],
209  const int transform_flag,
210  const int draw_options,
211  const float line_width)
212 {
214 
216  immUniformColor3fv(color);
217 
218  float viewport[4];
219  GPU_viewport_size_get_f(viewport);
220  immUniform2fv("viewportSize", &viewport[2]);
221  immUniform1f("lineWidth", line_width * U.pixelsize);
222 
223  imm_draw_cube_wire_3d(pos, (float[3]){0}, r);
224 
225 #if 0
226  if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) {
228  const float rad[2] = {margin[0] / 2, margin[1] / 2};
229  const float center[2] = {0.0f, 0.0f};
230 
232  immVertex2f(pos, center[0] - rad[0], center[1] - rad[1]);
233  immVertex2f(pos, center[0] + rad[0], center[1] + rad[1]);
234  immVertex2f(pos, center[0] + rad[0], center[1] - rad[1]);
235  immVertex2f(pos, center[0] - rad[0], center[1] + rad[1]);
236  immEnd();
237  }
238  }
239 #else
240  UNUSED_VARS(margin, transform_flag, draw_options);
241 #endif
242 
244 }
245 
246 static void cage3d_draw_circle_handles(const RegionView3D *rv3d,
247  const float matrix_final[4][4],
248  const float r[3],
249  const float margin[3],
250  const float color[3],
251  bool solid,
252  float scale)
253 {
255  const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3};
256 
258  immUniformColor3fv(color);
259 
260  const float sign[3] = {-1.0f, 0.0f, 1.0f};
261  for (int x = 0; x < 3; x++) {
262  for (int y = 0; y < 3; y++) {
263  for (int z = 0; z < 3; z++) {
264  if (x == 1 && y == 1 && z == 1) {
265  continue;
266  }
267  const float co[3] = {r[0] * sign[x], r[1] * sign[y], r[2] * sign[z]};
268  float co_test[3];
269  mul_v3_m4v3(co_test, matrix_final, co);
270  float rad_scale[3];
271  mul_v3_v3fl(rad_scale, rad, ED_view3d_pixel_size(rv3d, co_test) * scale);
272  imm_draw_point_aspect_3d(pos, co, rad_scale, solid);
273  }
274  }
275  }
276 
278 }
279 
283  RegionView3D *rv3d, wmGizmo *gz, const bool select, const bool highlight, const int select_id)
284 {
285  // const bool use_clamp = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0;
286  float dims[3];
287  RNA_float_get_array(gz->ptr, "dimensions", dims);
288  float matrix_final[4][4];
289 
290  const int transform_flag = RNA_enum_get(gz->ptr, "transform");
291  const int draw_style = RNA_enum_get(gz->ptr, "draw_style");
292  const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
293 
294  const float size_real[3] = {dims[0] / 2.0f, dims[1] / 2.0f, dims[2] / 2.0f};
295 
296  WM_gizmo_calc_matrix_final(gz, matrix_final);
297 
298  GPU_matrix_push();
299  GPU_matrix_mul(matrix_final);
300 
301  float margin[3];
302  gizmo_calc_rect_view_margin(gz, dims, margin);
303 
304  /* Handy for quick testing draw (if it's outside bounds). */
305  if (false) {
309  immUniformColor4fv((const float[4]){1, 1, 1, 0.5f});
310  float s = 0.5f;
311  immRectf(pos, -s, -s, s, s);
314  }
315 
316  if (select) {
317  /* Expand for hot-spot. */
318 #if 0
319  const float size[3] = {
320  size_real[0] + margin[0] / 2,
321  size_real[1] + margin[1] / 2,
322  size_real[2] + margin[2] / 2,
323  };
324 #else
325  /* just use same value for now. */
326  const float size[3] = {UNPACK3(size_real)};
327 #endif
328 
329  if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE) {
332  i++) {
334  continue;
335  }
336  GPU_select_load_id(select_id | i);
337  cage3d_draw_box_interaction(gz->color, i, size, margin);
338  }
339  }
340  if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) {
341  const int transform_part = ED_GIZMO_CAGE3D_PART_TRANSLATE;
342  GPU_select_load_id(select_id | transform_part);
343  cage3d_draw_box_interaction(gz->color, transform_part, size, margin);
344  }
345  }
346  else {
347 #if 0
348  const rctf _r = {
349  .xmin = -size_real[0],
350  .ymin = -size_real[1],
351  .xmax = size_real[0],
352  .ymax = size_real[1],
353  };
354 #endif
355  if (draw_style == ED_GIZMO_CAGE2D_STYLE_BOX) {
356  float color[4], black[3] = {0, 0, 0};
357  gizmo_color_get(gz, highlight, color);
358 
359  /* corner gizmos */
360  cage3d_draw_box_corners(size_real, margin, black, gz->line_width + 3.0f);
361 
362  /* corner gizmos */
363  cage3d_draw_box_corners(size_real, margin, color, gz->line_width);
364 
365  bool show = false;
367  /* Only show if we're drawing the center handle
368  * otherwise the entire rectangle is the hot-spot. */
370  show = true;
371  }
372  }
373  else {
374  show = true;
375  }
376 
377  if (show) {
378  cage3d_draw_box_interaction(gz->color, gz->highlight_part, size_real, margin);
379  }
380  }
381  else if (draw_style == ED_GIZMO_CAGE2D_STYLE_CIRCLE) {
382  float color[4], black[3] = {0, 0, 0};
383  gizmo_color_get(gz, highlight, color);
384 
386 
388  size_real, margin, black, transform_flag, draw_options, gz->line_width + 3.0f);
390  size_real, margin, color, transform_flag, draw_options, gz->line_width);
391 
392  /* corner gizmos */
393  GPU_polygon_smooth(true);
394  cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, black, true, 60);
395  cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, color, true, 40);
396  GPU_polygon_smooth(false);
397 
399  }
400  else {
401  BLI_assert(0);
402  }
403  }
404 
405  GPU_matrix_pop();
406 }
407 
411 static void gizmo_cage3d_draw_select(const bContext *C, wmGizmo *gz, int select_id)
412 {
413  ARegion *region = CTX_wm_region(C);
414  RegionView3D *rv3d = region->regiondata;
415  gizmo_cage3d_draw_intern(rv3d, gz, true, false, select_id);
416 }
417 
418 static void gizmo_cage3d_draw(const bContext *C, wmGizmo *gz)
419 {
420  ARegion *region = CTX_wm_region(C);
421  RegionView3D *rv3d = region->regiondata;
422  const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
423  gizmo_cage3d_draw_intern(rv3d, gz, false, is_highlight, -1);
424 }
425 
427 {
429  return WM_CURSOR_NSEW_SCROLL;
430  }
431 
432  return WM_CURSOR_DEFAULT;
433 }
434 
435 typedef struct RectTransformInteraction {
436  float orig_mouse[3];
437  float orig_matrix_offset[4][4];
438  float orig_matrix_final_no_offset[4][4];
440 
441 static void gizmo_cage3d_setup(wmGizmo *gz)
442 {
443  gz->flag |= /* WM_GIZMO_DRAW_MODAL | */ /* TODO */
445 }
446 
447 static int gizmo_cage3d_invoke(bContext *C, wmGizmo *gz, const wmEvent *event)
448 {
450  "cage_interaction");
451 
452  copy_m4_m4(data->orig_matrix_offset, gz->matrix_offset);
453  gizmo_calc_matrix_final_no_offset(gz, data->orig_matrix_final_no_offset, true);
454 
456  C, gz, (const float[2]){UNPACK2(event->mval)}, false, data->orig_mouse) == 0) {
457  zero_v3(data->orig_mouse);
458  }
459 
460  gz->interaction_data = data;
461 
462  return OPERATOR_RUNNING_MODAL;
463 }
464 
466  wmGizmo *gz,
467  const wmEvent *event,
468  eWM_GizmoFlagTweak UNUSED(tweak_flag))
469 {
470  if (event->type != MOUSEMOVE) {
471  return OPERATOR_RUNNING_MODAL;
472  }
473  /* For transform logic to be manageable we operate in -0.5..0.5 2D space,
474  * no matter the size of the rectangle, mouse coords are scaled to unit space.
475  * The mouse coords have been projected into the matrix
476  * so we don't need to worry about axis alignment.
477  *
478  * - The cursor offset are multiplied by 'dims'.
479  * - Matrix translation is also multiplied by 'dims'.
480  */
482  float point_local[3];
483 
484  float dims[3];
485  RNA_float_get_array(gz->ptr, "dimensions", dims);
486 
487  {
488  float matrix_back[4][4];
489  copy_m4_m4(matrix_back, gz->matrix_offset);
490  copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
491 
492  bool ok = gizmo_window_project_3d(
493  C, gz, (const float[2]){UNPACK2(event->mval)}, false, point_local);
494  copy_m4_m4(gz->matrix_offset, matrix_back);
495  if (!ok) {
496  return OPERATOR_RUNNING_MODAL;
497  }
498  }
499 
500  const int transform_flag = RNA_enum_get(gz->ptr, "transform");
501  wmGizmoProperty *gz_prop;
502 
503  gz_prop = WM_gizmo_target_property_find(gz, "matrix");
504  if (gz_prop->type != NULL) {
506  }
507 
509  /* do this to prevent clamping from changing size */
510  copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
511  gz->matrix_offset[3][0] = data->orig_matrix_offset[3][0] +
512  (point_local[0] - data->orig_mouse[0]);
513  gz->matrix_offset[3][1] = data->orig_matrix_offset[3][1] +
514  (point_local[1] - data->orig_mouse[1]);
515  gz->matrix_offset[3][2] = data->orig_matrix_offset[3][2] +
516  (point_local[2] - data->orig_mouse[2]);
517  }
519  /* Add this (if we need it). */
520  }
521  else {
522  /* scale */
523  copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
524  float pivot[3];
525  bool constrain_axis[3] = {false};
526 
527  if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) {
528  gizmo_rect_pivot_from_scale_part(gz->highlight_part, pivot, constrain_axis);
529  }
530  else {
531  zero_v3(pivot);
532  }
533 
534  /* Cursor deltas scaled to (-0.5..0.5). */
535  float delta_orig[3], delta_curr[3];
536 
537  for (int i = 0; i < 3; i++) {
538  delta_orig[i] = ((data->orig_mouse[i] - data->orig_matrix_offset[3][i]) / dims[i]) -
539  pivot[i];
540  delta_curr[i] = ((point_local[i] - data->orig_matrix_offset[3][i]) / dims[i]) - pivot[i];
541  }
542 
543  float scale[3] = {1.0f, 1.0f, 1.0f};
544  for (int i = 0; i < 3; i++) {
545  if (constrain_axis[i] == false) {
546  if (delta_orig[i] < 0.0f) {
547  delta_orig[i] *= -1.0f;
548  delta_curr[i] *= -1.0f;
549  }
550  const int sign = signum_i(scale[i]);
551 
552  scale[i] = 1.0f + ((delta_curr[i] - delta_orig[i]) / len_v3(data->orig_matrix_offset[i]));
553 
554  if ((transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_SIGNED) == 0) {
555  if (sign != signum_i(scale[i])) {
556  scale[i] = 0.0f;
557  }
558  }
559  }
560  }
561 
562  if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM) {
563  if (constrain_axis[0] == false && constrain_axis[1] == false) {
564  scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f;
565  }
566  else if (constrain_axis[0] == false) {
567  scale[1] = scale[0];
568  }
569  else if (constrain_axis[1] == false) {
570  scale[0] = scale[1];
571  }
572  else {
573  BLI_assert(0);
574  }
575  }
576 
577  /* scale around pivot */
578  float matrix_scale[4][4];
579  unit_m4(matrix_scale);
580 
581  mul_v3_fl(matrix_scale[0], scale[0]);
582  mul_v3_fl(matrix_scale[1], scale[1]);
583  mul_v3_fl(matrix_scale[2], scale[2]);
584 
586  matrix_scale,
587  (const float[3]){pivot[0] * dims[0], pivot[1] * dims[1], pivot[2] * dims[2]});
588  mul_m4_m4m4(gz->matrix_offset, data->orig_matrix_offset, matrix_scale);
589  }
590 
591  if (gz_prop->type != NULL) {
592  WM_gizmo_target_property_float_set_array(C, gz, gz_prop, &gz->matrix_offset[0][0]);
593  }
594 
595  /* tag the region for redraw */
598 
599  return OPERATOR_RUNNING_MODAL;
600 }
601 
603 {
604  if (STREQ(gz_prop->type->idname, "matrix")) {
605  if (WM_gizmo_target_property_array_length(gz, gz_prop) == 16) {
607  }
608  else {
609  BLI_assert(0);
610  }
611  }
612  else {
613  BLI_assert(0);
614  }
615 }
616 
617 static void gizmo_cage3d_exit(bContext *C, wmGizmo *gz, const bool cancel)
618 {
620 
621  if (!cancel) {
622  return;
623  }
624 
625  wmGizmoProperty *gz_prop;
626 
627  /* reset properties */
628  gz_prop = WM_gizmo_target_property_find(gz, "matrix");
629  if (gz_prop->type != NULL) {
630  WM_gizmo_target_property_float_set_array(C, gz, gz_prop, &data->orig_matrix_offset[0][0]);
631  }
632 
633  copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
634 }
635 
636 /* -------------------------------------------------------------------- */
640 static void GIZMO_GT_cage_3d(wmGizmoType *gzt)
641 {
642  /* identifiers */
643  gzt->idname = "GIZMO_GT_cage_3d";
644 
645  /* api callbacks */
646  gzt->draw = gizmo_cage3d_draw;
648  gzt->setup = gizmo_cage3d_setup;
651  gzt->modal = gizmo_cage3d_modal;
652  gzt->exit = gizmo_cage3d_exit;
654 
655  gzt->struct_size = sizeof(wmGizmo);
656 
657  /* rna */
658  static EnumPropertyItem rna_enum_draw_style[] = {
659  {ED_GIZMO_CAGE2D_STYLE_BOX, "BOX", 0, "Box", ""},
660  {ED_GIZMO_CAGE2D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""},
661  {0, NULL, 0, NULL, NULL},
662  };
663  static EnumPropertyItem rna_enum_transform[] = {
664  {ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Move", ""},
665  {ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""},
666  {ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""},
667  {0, NULL, 0, NULL, NULL},
668  };
669  static EnumPropertyItem rna_enum_draw_options[] = {
671  "XFORM_CENTER_HANDLE",
672  0,
673  "Center Handle",
674  ""},
675  {0, NULL, 0, NULL, NULL},
676  };
677  static float unit_v3[3] = {1.0f, 1.0f, 1.0f};
679  gzt->srna, "dimensions", 3, unit_v3, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX);
680  RNA_def_enum_flag(gzt->srna, "transform", rna_enum_transform, 0, "Transform Options", "");
681  RNA_def_enum(gzt->srna,
682  "draw_style",
683  rna_enum_draw_style,
685  "Draw Style",
686  "");
687  RNA_def_enum_flag(gzt->srna,
688  "draw_options",
689  rna_enum_draw_options,
691  "Draw Options",
692  "");
693 
694  WM_gizmotype_target_property_def(gzt, "matrix", PROP_FLOAT, 16);
695 }
696 
698 {
700 }
701 
struct ARegion * CTX_wm_region(const bContext *C)
Definition: context.c:725
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
#define BLI_assert(a)
Definition: BLI_assert.h:58
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:262
void unit_m4(float m[4][4])
Definition: rct.c:1140
void transform_pivot_set_m4(float mat[4][4], const float pivot[3])
Definition: math_matrix.c:2411
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:95
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
Definition: math_matrix.c:742
void mul_v3_mat3_m4v3(float r[3], const float M[4][4], const float v[3])
Definition: math_matrix.c:804
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:83
#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_CAGE2D_XFORM_FLAG_TRANSLATE
@ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_SIGNED
@ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE
@ ED_GIZMO_CAGE2D_XFORM_FLAG_SCALE_UNIFORM
@ 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
void ED_region_tag_redraw_editor_overlays(struct ARegion *region)
Definition: area.c:706
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 imm_draw_cube_fill_3d(uint pos, const float co[3], const float aspect[3])
void immRectf(uint pos, float x1, float y1, float x2, float y2)
void imm_draw_cube_wire_3d(uint pos, const float co[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:142
#define GPU_matrix_mul(x)
Definition: GPU_matrix.h:223
void GPU_matrix_push(void)
Definition: gpu_matrix.cc:135
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:36
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_UNIFORM_COLOR
Definition: GPU_shader.h:200
@ 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_DRAW_NO_SCALE
@ WM_GIZMOGROUPTYPE_3D
@ WM_GIZMO_STATE_HIGHLIGHT
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:602
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:133
static void gizmo_cage3d_draw_select(const bContext *C, wmGizmo *gz, int select_id)
Definition: cage3d_gizmo.c:411
static void gizmo_cage3d_draw_intern(RegionView3D *rv3d, wmGizmo *gz, const bool select, const bool highlight, const int select_id)
Definition: cage3d_gizmo.c:282
static void gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[3], float scale[3])
Definition: cage3d_gizmo.c:74
static int gizmo_cage3d_modal(bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak UNUSED(tweak_flag))
Definition: cage3d_gizmo.c:465
struct RectTransformInteraction RectTransformInteraction
static int gizmo_cage3d_get_cursor(wmGizmo *gz)
Definition: cage3d_gizmo.c:426
static void gizmo_cage3d_setup(wmGizmo *gz)
Definition: cage3d_gizmo.c:441
static int gizmo_cage3d_invoke(bContext *C, wmGizmo *gz, const wmEvent *event)
Definition: cage3d_gizmo.c:447
void ED_gizmotypes_cage_3d(void)
Definition: cage3d_gizmo.c:697
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:206
static void GIZMO_GT_cage_3d(wmGizmoType *gzt)
Definition: cage3d_gizmo.c:640
static void gizmo_cage3d_draw(const bContext *C, wmGizmo *gz)
Definition: cage3d_gizmo.c:418
static void gizmo_calc_rect_view_margin(const wmGizmo *gz, const float dims[3], float margin[3])
Definition: cage3d_gizmo.c:92
static void cage3d_draw_box_interaction(const float color[4], const int highlighted, const float size[3], const float margin[3])
Definition: cage3d_gizmo.c:154
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, float scale)
Definition: cage3d_gizmo.c:246
static void imm_draw_point_aspect_3d(uint pos, const float co[3], const float rad[3], bool solid)
Definition: cage3d_gizmo.c:196
static void gizmo_cage3d_exit(bContext *C, wmGizmo *gz, const bool cancel)
Definition: cage3d_gizmo.c:617
static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[3], bool r_constrain_axis[3])
Definition: cage3d_gizmo.c:107
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:60
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, const 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:45
double sign(double arg)
Definition: utility.h:250
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
Definition: rna_access.c:6378
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6402
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_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:3851
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:3771
void * regiondata
float orig_matrix_offset[4][4]
Definition: cage2d_gizmo.c:912
float orig_matrix_final_no_offset[4][4]
Definition: cage2d_gizmo.c:913
float xmin
Definition: DNA_vec_types.h:85
int mval[2]
Definition: WM_types.h:583
short type
Definition: WM_types.h:577
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
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: util_avxb.h:167
@ WM_CURSOR_NSEW_SCROLL
Definition: wm_cursors.h:67
@ WM_CURSOR_DEFAULT
Definition: wm_cursors.h:34
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:549
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
Definition: wm_gizmo.c:601
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 *))