Blender  V3.3
arrow3d_gizmo.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2014 Blender Foundation. All rights reserved. */
3 
19 #include "BLI_math.h"
20 #include "BLI_utildefines.h"
21 
22 #include "DNA_view3d_types.h"
23 
24 #include "BKE_context.h"
25 
26 #include "GPU_immediate.h"
27 #include "GPU_immediate_util.h"
28 #include "GPU_matrix.h"
29 #include "GPU_select.h"
30 #include "GPU_state.h"
31 
32 #include "MEM_guardedalloc.h"
33 
34 #include "RNA_access.h"
35 #include "RNA_define.h"
36 
37 #include "WM_api.h"
38 #include "WM_types.h"
39 
40 #include "ED_gizmo_library.h"
41 #include "ED_screen.h"
42 #include "ED_view3d.h"
43 
44 #include "UI_interface.h"
45 
46 /* own includes */
47 #include "../gizmo_geometry.h"
48 #include "../gizmo_library_intern.h"
49 
50 /* to use custom arrows exported to geom_arrow_gizmo.c */
51 //#define USE_GIZMO_CUSTOM_ARROWS
52 
53 /* Margin to add when selecting the arrow. */
54 #define ARROW_SELECT_THRESHOLD_PX (5)
55 
56 typedef struct ArrowGizmo3D {
60 
61 typedef struct ArrowGizmoInteraction {
65 
66 /* -------------------------------------------------------------------- */
67 
68 static void gizmo_arrow_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4])
69 {
70  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
71 
72  copy_m4_m4(r_matrix, arrow->gizmo.matrix_basis);
73  madd_v3_v3fl(r_matrix[3], arrow->gizmo.matrix_basis[2], arrow->data.offset);
74 }
75 
76 static void arrow_draw_geom(const ArrowGizmo3D *arrow,
77  const bool select,
78  const float color[4],
79  const float arrow_length)
80 {
82  bool unbind_shader = true;
83  const int draw_style = RNA_enum_get(arrow->gizmo.ptr, "draw_style");
84  const int draw_options = RNA_enum_get(arrow->gizmo.ptr, "draw_options");
85 
87 
88  float viewport[4];
89  GPU_viewport_size_get_f(viewport);
90  immUniform2fv("viewportSize", &viewport[2]);
91 
92  if (draw_style == ED_GIZMO_ARROW_STYLE_CROSS) {
93  immUniform1f("lineWidth", U.pixelsize);
95 
97  immVertex3f(pos, -1.0f, 0.0f, 0.0f);
98  immVertex3f(pos, 1.0f, 0.0f, 0.0f);
99  immVertex3f(pos, 0.0f, -1.0f, 0.0f);
100  immVertex3f(pos, 0.0f, 1.0f, 0.0f);
101  immEnd();
102  }
103  else if (draw_style == ED_GIZMO_ARROW_STYLE_CONE) {
104  float aspect[2];
105  RNA_float_get_array(arrow->gizmo.ptr, "aspect", aspect);
106  const float unitx = aspect[0];
107  const float unity = aspect[1];
108  const float vec[4][3] = {
109  {-unitx, -unity, 0},
110  {unitx, -unity, 0},
111  {unitx, unity, 0},
112  {-unitx, unity, 0},
113  };
114 
115  immUniform1f("lineWidth", arrow->gizmo.line_width * U.pixelsize);
117  }
118  else {
119 #ifdef USE_GIZMO_CUSTOM_ARROWS
121 #else
122  const float vec[2][3] = {
123  {0.0f, 0.0f, 0.0f},
124  {0.0f, 0.0f, arrow_length},
125  };
126 
127  if (draw_options & ED_GIZMO_ARROW_DRAW_FLAG_STEM) {
128  const float stem_width = arrow->gizmo.line_width * U.pixelsize +
129  (select ? ARROW_SELECT_THRESHOLD_PX * U.dpi_fac : 0);
130  immUniform1f("lineWidth", stem_width);
132  }
133  else {
135  }
136 
137  /* *** draw arrow head *** */
138 
139  GPU_matrix_push();
140 
141  /* NOTE: ideally #ARROW_SELECT_THRESHOLD_PX would be added here, however adding a
142  * margin in pixel space isn't so simple, nor is it as important as for the arrow stem. */
143  if (draw_style == ED_GIZMO_ARROW_STYLE_BOX) {
144  const float size = 0.05f;
145 
146  /* translate to line end with some extra offset so box starts exactly where line ends */
147  GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length + size);
148  /* scale down to box size */
150 
151  /* draw cube */
153  unbind_shader = false;
155  }
156  else {
158 
159  const float len = 0.25f;
160  const float width = 0.06f;
161 
162  /* translate to line end */
163  GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length);
164 
168 
169  imm_draw_circle_fill_3d(pos, 0.0, 0.0, width, 8);
170  imm_draw_cylinder_fill_3d(pos, width, 0.0, len, 8, 1);
171  }
172 
173  GPU_matrix_pop();
174 #endif /* USE_GIZMO_CUSTOM_ARROWS */
175  }
176 
177  if (unbind_shader) {
179  }
180 }
181 
182 static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool highlight)
183 {
184  wmGizmo *gz = &arrow->gizmo;
185  const float arrow_length = RNA_float_get(gz->ptr, "length");
186  float color[4];
187  float matrix_final[4][4];
188 
189  gizmo_color_get(gz, highlight, color);
190 
191  WM_gizmo_calc_matrix_final(gz, matrix_final);
192 
193  GPU_matrix_push();
194  GPU_matrix_mul(matrix_final);
196  arrow_draw_geom(arrow, select, color, arrow_length);
198 
199  GPU_matrix_pop();
200 
201  if (gz->interaction_data) {
202  ArrowGizmoInteraction *arrow_inter = gz->interaction_data;
203 
204  GPU_matrix_push();
205  GPU_matrix_mul(arrow_inter->inter.init_matrix_final);
206 
209  arrow, select, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}, arrow_inter->init_arrow_length);
211 
212  GPU_matrix_pop();
213  }
214 }
215 
216 static void gizmo_arrow_draw_select(const bContext *UNUSED(C), wmGizmo *gz, int select_id)
217 {
218  GPU_select_load_id(select_id);
219  arrow_draw_intern((ArrowGizmo3D *)gz, true, false);
220 }
221 
222 static void gizmo_arrow_draw(const bContext *UNUSED(C), wmGizmo *gz)
223 {
224  arrow_draw_intern((ArrowGizmo3D *)gz, false, (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0);
225 }
226 
230 static int gizmo_arrow_test_select(bContext *UNUSED(C), wmGizmo *gz, const int mval[2])
231 {
232  /* This following values are based on manual inspection of `verts[]` defined in
233  * geom_arrow_gizmo.c */
234  const float head_center_z = (0.974306f + 1.268098f) / 2;
235  const float head_geo_x = 0.051304f;
236  const float stem_geo_x = 0.012320f;
237 
238  /* Project into 2D space since it simplifies pixel threshold tests. */
239  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
240  const float arrow_length = RNA_float_get(arrow->gizmo.ptr, "length") * head_center_z;
241 
242  float matrix_final[4][4];
243  WM_gizmo_calc_matrix_final(gz, matrix_final);
244 
245  /* Arrow in pixel space. */
246  const float arrow_start[2] = {matrix_final[3][0], matrix_final[3][1]};
247  float arrow_end[2];
248  {
249  float co[3] = {0, 0, arrow_length};
250  mul_m4_v3(matrix_final, co);
251  copy_v2_v2(arrow_end, co);
252  }
253 
254  const float scale_final = mat4_to_scale(matrix_final);
255  const float head_width = ARROW_SELECT_THRESHOLD_PX * scale_final * head_geo_x;
256  const float stem_width = ARROW_SELECT_THRESHOLD_PX * scale_final * stem_geo_x;
257  float select_threshold_base = gz->line_width * U.pixelsize;
258 
259  const float mval_fl[2] = {UNPACK2(mval)};
260 
261  /* Distance to arrow head. */
262  if (len_squared_v2v2(mval_fl, arrow_end) < square_f(select_threshold_base + head_width)) {
263  return 0;
264  }
265 
266  /* Distance to arrow stem. */
267  float co_isect[2];
268  const float lambda = closest_to_line_v2(co_isect, mval_fl, arrow_start, arrow_end);
269  /* Clamp inside the line, to avoid overlapping with other gizmos,
270  * especially around the start of the arrow. */
271  if (lambda >= 0.0f && lambda <= 1.0f) {
272  if (len_squared_v2v2(mval_fl, co_isect) < square_f(select_threshold_base + stem_width)) {
273  return 0;
274  }
275  }
276 
277  return -1;
278 }
279 
285  wmGizmo *gz,
286  const wmEvent *event,
287  eWM_GizmoFlagTweak tweak_flag)
288 {
289  if (event->type != MOUSEMOVE) {
290  return OPERATOR_RUNNING_MODAL;
291  }
292  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
293  GizmoInteraction *inter = gz->interaction_data;
294  ARegion *region = CTX_wm_region(C);
295  RegionView3D *rv3d = region->regiondata;
296 
297  float offset[3];
298  float facdir = 1.0f;
299 
300  /* (src, dst) */
301  struct {
302  float mval[2];
303  float ray_origin[3], ray_direction[3];
304  float location[3];
305  } proj[2] = {
306  {.mval = {UNPACK2(inter->init_mval)}},
307  {.mval = {UNPACK2(event->mval)}},
308  };
309 
310  float arrow_co[3];
311  float arrow_no[3];
312  copy_v3_v3(arrow_co, inter->init_matrix_basis[3]);
313  normalize_v3_v3(arrow_no, arrow->gizmo.matrix_basis[2]);
314 
315  int ok = 0;
316 
317  for (int j = 0; j < 2; j++) {
318  ED_view3d_win_to_ray(region, proj[j].mval, proj[j].ray_origin, proj[j].ray_direction);
319  /* Force Y axis if we're view aligned */
320  if (j == 0) {
321  if (RAD2DEGF(acosf(dot_v3v3(proj[j].ray_direction, arrow->gizmo.matrix_basis[2]))) < 5.0f) {
322  normalize_v3_v3(arrow_no, rv3d->viewinv[1]);
323  }
324  }
325 
326  float arrow_no_proj[3];
327  project_plane_v3_v3v3(arrow_no_proj, arrow_no, proj[j].ray_direction);
328 
329  normalize_v3(arrow_no_proj);
330 
331  float plane[4];
332  plane_from_point_normal_v3(plane, proj[j].ray_origin, arrow_no_proj);
333 
334  float lambda;
335  if (isect_ray_plane_v3(arrow_co, arrow_no, plane, &lambda, false)) {
336  madd_v3_v3v3fl(proj[j].location, arrow_co, arrow_no, lambda);
337  ok++;
338  }
339  }
340 
341  if (ok != 2) {
342  return OPERATOR_RUNNING_MODAL;
343  }
344 
345  sub_v3_v3v3(offset, proj[1].location, proj[0].location);
346  facdir = dot_v3v3(arrow_no, offset) < 0.0f ? -1 : 1;
347 
348  GizmoCommonData *data = &arrow->data;
349  const float ofs_new = facdir * len_v3(offset);
350 
351  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
352 
353  /* set the property for the operator and call its modal function */
354  if (WM_gizmo_target_property_is_valid(gz_prop)) {
355  const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
356  const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
357  const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
358  const bool use_precision = (tweak_flag & WM_GIZMO_TWEAK_PRECISE) != 0;
359  float value = gizmo_value_from_offset(
360  data, inter, ofs_new, constrained, inverted, use_precision);
361 
362  WM_gizmo_target_property_float_set(C, gz, gz_prop, value);
363  /* get clamped value */
364  value = WM_gizmo_target_property_float_get(gz, gz_prop);
365 
366  data->offset = gizmo_offset_from_value(data, value, constrained, inverted);
367  }
368  else {
369  data->offset = ofs_new;
370  }
371 
372  /* tag the region for redraw */
375 
376  return OPERATOR_RUNNING_MODAL;
377 }
378 
379 static void gizmo_arrow_setup(wmGizmo *gz)
380 {
381  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
382 
383  arrow->gizmo.flag |= WM_GIZMO_DRAW_MODAL;
384 
385  arrow->data.range_fac = 1.0f;
386 }
387 
388 static int gizmo_arrow_invoke(bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
389 {
390  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
391  GizmoInteraction *inter = MEM_callocN(sizeof(ArrowGizmoInteraction), __func__);
392  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
393 
394  /* Some gizmos don't use properties. */
395  if (WM_gizmo_target_property_is_valid(gz_prop)) {
396  inter->init_value = WM_gizmo_target_property_float_get(gz, gz_prop);
397  }
398 
399  inter->init_offset = arrow->data.offset;
400 
401  inter->init_mval[0] = event->mval[0];
402  inter->init_mval[1] = event->mval[1];
403 
406 
407  ((ArrowGizmoInteraction *)inter)->init_arrow_length = RNA_float_get(gz->ptr, "length");
408 
409  gz->interaction_data = inter;
410 
411  return OPERATOR_RUNNING_MODAL;
412 }
413 
415 {
416  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
417  const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
418  const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
419  const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
420  gizmo_property_data_update(gz, &arrow->data, gz_prop, constrained, inverted);
421 }
422 
423 static void gizmo_arrow_exit(bContext *C, wmGizmo *gz, const bool cancel)
424 {
425  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
426  GizmoCommonData *data = &arrow->data;
427  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
428  const bool is_prop_valid = WM_gizmo_target_property_is_valid(gz_prop);
429 
430  if (cancel) {
431  GizmoInteraction *inter = gz->interaction_data;
432  if (is_prop_valid) {
433  gizmo_property_value_reset(C, gz, inter, gz_prop);
434  }
435  data->offset = inter->init_offset;
436  }
437  else {
438  /* Assign in case applying the operation needs an updated offset
439  * edit-mesh bisect needs this. */
440  if (is_prop_valid) {
441  const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
442  const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
443  const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
444  const float value = WM_gizmo_target_property_float_get(gz, gz_prop);
445  data->offset = gizmo_offset_from_value(data, value, constrained, inverted);
446  }
447  }
448 
449  if (!cancel) {
450  if (is_prop_valid) {
452  }
453  }
454 }
455 
456 /* -------------------------------------------------------------------- */
460 void ED_gizmo_arrow3d_set_ui_range(wmGizmo *gz, const float min, const float max)
461 {
462  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
463 
464  BLI_assert(min < max);
466  "Make sure this function is called before WM_gizmo_target_property_def_rna"));
467 
468  arrow->data.range = max - min;
469  arrow->data.min = min;
470  arrow->data.max = max;
471  arrow->data.is_custom_range_set = true;
472 }
473 
474 void ED_gizmo_arrow3d_set_range_fac(wmGizmo *gz, const float range_fac)
475 {
476  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
478  "Make sure this function is called before WM_gizmo_target_property_def_rna"));
479 
480  arrow->data.range_fac = range_fac;
481 }
482 
484 {
485  /* identifiers */
486  gzt->idname = "GIZMO_GT_arrow_3d";
487 
488  /* api callbacks */
489  gzt->draw = gizmo_arrow_draw;
493  gzt->modal = gizmo_arrow_modal;
494  gzt->setup = gizmo_arrow_setup;
495  gzt->invoke = gizmo_arrow_invoke;
497  gzt->exit = gizmo_arrow_exit;
498 
499  gzt->struct_size = sizeof(ArrowGizmo3D);
500 
501  /* rna */
502  static EnumPropertyItem rna_enum_draw_style_items[] = {
503  {ED_GIZMO_ARROW_STYLE_NORMAL, "NORMAL", 0, "Normal", ""},
504  {ED_GIZMO_ARROW_STYLE_CROSS, "CROSS", 0, "Cross", ""},
505  {ED_GIZMO_ARROW_STYLE_BOX, "BOX", 0, "Box", ""},
506  {ED_GIZMO_ARROW_STYLE_CONE, "CONE", 0, "Cone", ""},
507  {0, NULL, 0, NULL, NULL},
508  };
509  static EnumPropertyItem rna_enum_draw_options_items[] = {
510  {ED_GIZMO_ARROW_DRAW_FLAG_STEM, "STEM", 0, "Stem", ""},
511  {0, NULL, 0, NULL, NULL},
512  };
513  static EnumPropertyItem rna_enum_transform_items[] = {
514  {ED_GIZMO_ARROW_XFORM_FLAG_INVERTED, "INVERT", 0, "Inverted", ""},
515  {ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED, "CONSTRAIN", 0, "Constrained", ""},
516  {0, NULL, 0, NULL, NULL},
517  };
518 
519  RNA_def_enum(gzt->srna,
520  "draw_style",
521  rna_enum_draw_style_items,
523  "Draw Style",
524  "");
525  RNA_def_enum_flag(gzt->srna,
526  "draw_options",
527  rna_enum_draw_options_items,
529  "Draw Options",
530  "");
531  RNA_def_enum_flag(gzt->srna, "transform", rna_enum_transform_items, 0, "Transform", "");
532 
534  gzt->srna, "length", 1.0f, -FLT_MAX, FLT_MAX, "Arrow Line Length", "", -FLT_MAX, FLT_MAX);
536  gzt->srna, "aspect", 2, NULL, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX);
537 
538  WM_gizmotype_target_property_def(gzt, "offset", PROP_FLOAT, 1);
539 }
540 
542 {
544 }
545 
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 float square_f(float a)
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
Definition: math_geom.c:209
bool isect_ray_plane_v3(const float ray_origin[3], const float ray_direction[3], const float plane[4], float *r_lambda, bool clip)
Definition: math_geom.c:1713
float closest_to_line_v2(float r_close[2], const float p[2], const float l1[2], const float l2[2])
Definition: math_geom.c:3183
void mul_m4_v3(const float M[4][4], float r[3])
Definition: math_matrix.c:729
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:77
float mat4_to_scale(const float M[4][4])
Definition: math_matrix.c:2185
#define RAD2DEGF(_rad)
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v3(float r[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
void project_plane_v3_v3v3(float out[3], const float p[3], const float v_plane[3])
Definition: math_vector.c:638
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[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 ARRAY_SIZE(arr)
#define UNUSED(x)
@ OPERATOR_RUNNING_MODAL
@ ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED
@ ED_GIZMO_ARROW_XFORM_FLAG_INVERTED
@ ED_GIZMO_ARROW_DRAW_FLAG_STEM
@ ED_GIZMO_ARROW_STYLE_CROSS
@ ED_GIZMO_ARROW_STYLE_BOX
@ ED_GIZMO_ARROW_STYLE_NORMAL
@ ED_GIZMO_ARROW_STYLE_CONE
void ED_region_tag_redraw_editor_overlays(struct ARegion *region)
Definition: area.c:690
void ED_view3d_win_to_ray(const struct ARegion *region, const float mval[2], float r_ray_start[3], float r_ray_normal[3])
void immUniform2fv(const char *name, const float data[2])
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 immBegin(GPUPrimType, uint vertex_len)
void immEnd(void)
void imm_draw_cylinder_fill_3d(uint pos, float base, float top, float height, int slices, int stacks)
void imm_draw_circle_fill_3d(uint pos, float x, float y, float radius, int nsegments)
_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 width
void GPU_matrix_pop(void)
Definition: gpu_matrix.cc:126
#define GPU_matrix_mul(x)
Definition: GPU_matrix.h:224
void GPU_matrix_scale_3f(float x, float y, float z)
Definition: gpu_matrix.cc:231
void GPU_matrix_push(void)
Definition: gpu_matrix.cc:119
void GPU_matrix_translate_3f(float x, float y, float z)
Definition: gpu_matrix.cc:188
@ GPU_PRIM_LINE_LOOP
Definition: GPU_primitive.h:23
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:20
@ GPU_PRIM_LINE_STRIP
Definition: GPU_primitive.h:22
bool GPU_select_load_id(unsigned int id)
Definition: gpu_select.c:117
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
Definition: GPU_shader.h:253
@ GPU_SHADER_3D_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
@ 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
eWM_GizmoFlagTweak
Gizmo tweak flag. Bit-flag passed to gizmo while tweaking.
@ WM_GIZMO_TWEAK_PRECISE
@ WM_GIZMO_DRAW_MODAL
@ WM_GIZMO_STATE_HIGHLIGHT
struct ArrowGizmoInteraction ArrowGizmoInteraction
static void gizmo_arrow_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4])
Definition: arrow3d_gizmo.c:68
static void gizmo_arrow_setup(wmGizmo *gz)
static int gizmo_arrow_test_select(bContext *UNUSED(C), wmGizmo *gz, const int mval[2])
static int gizmo_arrow_invoke(bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
void ED_gizmotypes_arrow_3d(void)
#define ARROW_SELECT_THRESHOLD_PX
Definition: arrow3d_gizmo.c:54
void ED_gizmo_arrow3d_set_range_fac(wmGizmo *gz, const float range_fac)
struct ArrowGizmo3D ArrowGizmo3D
static int gizmo_arrow_modal(bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak tweak_flag)
static void GIZMO_GT_arrow_3d(wmGizmoType *gzt)
static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool highlight)
static void gizmo_arrow_exit(bContext *C, wmGizmo *gz, const bool cancel)
void ED_gizmo_arrow3d_set_ui_range(wmGizmo *gz, const float min, const float max)
static void gizmo_arrow_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop)
static void gizmo_arrow_draw_select(const bContext *UNUSED(C), wmGizmo *gz, int select_id)
static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const float color[4], const float arrow_length)
Definition: arrow3d_gizmo.c:76
static void gizmo_arrow_draw(const bContext *UNUSED(C), wmGizmo *gz)
__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
int len
Definition: draw_manager.c:108
GizmoGeomInfo wm_gizmo_geom_data_arrow
GizmoGeomInfo wm_gizmo_geom_data_cube
void wm_gizmo_vec_draw(const float color[4], const float(*verts)[3], uint vert_count, uint pos, uint primitive_type)
void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info, const bool UNUSED(select), const float color[4])
float gizmo_value_from_offset(GizmoCommonData *data, GizmoInteraction *inter, float offset, bool constrained, bool inverted, bool use_precision)
float gizmo_offset_from_value(GizmoCommonData *data, float value, bool constrained, bool inverted)
void gizmo_property_value_reset(bContext *C, const struct wmGizmo *gz, GizmoInteraction *inter, wmGizmoProperty *gz_prop)
void gizmo_color_get(const struct wmGizmo *gz, bool highlight, float r_color[4])
void gizmo_property_data_update(struct wmGizmo *gz, GizmoCommonData *data, wmGizmoProperty *gz_prop, bool constrained, bool inverted)
uint pos
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
#define acosf(x)
Definition: metal/compat.h:222
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
Definition: rna_access.c:4980
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4957
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3836
PropertyRNA * RNA_def_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
#define min(a, b)
Definition: sort.c:35
void * regiondata
wmGizmo gizmo
Definition: arrow3d_gizmo.c:57
GizmoCommonData data
Definition: arrow3d_gizmo.c:58
GizmoInteraction inter
Definition: arrow3d_gizmo.c:62
float init_matrix_basis[4][4]
float init_matrix_final[4][4]
float viewinv[4][4]
int mval[2]
Definition: WM_types.h:684
short type
Definition: WM_types.h:678
wmGizmoFnDraw draw
wmGizmoFnModal modal
wmGizmoFnSetup setup
wmGizmoFnMatrixBasisGet matrix_basis_get
const char * idname
wmGizmoFnTestSelect test_select
wmGizmoFnExit exit
struct StructRNA * srna
wmGizmoFnInvoke invoke
wmGizmoFnDrawSelect draw_select
wmGizmoFnPropertyUpdate property_update
void * interaction_data
eWM_GizmoFlagState state
float matrix_basis[4][4]
struct PointerRNA * ptr
float line_width
eWM_GizmoFlag flag
float max
void WM_event_add_mousemove(wmWindow *win)
@ MOUSEMOVE
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
Definition: wm_gizmo.c:554
void WM_gizmo_target_property_float_set(bContext *C, const wmGizmo *gz, wmGizmoProperty *gz_prop, const float value)
wmGizmoProperty * WM_gizmo_target_property_find(wmGizmo *gz, const char *idname)
bool WM_gizmo_target_property_is_valid(const wmGizmoProperty *gz_prop)
void WM_gizmotype_target_property_def(wmGizmoType *gzt, const char *idname, int data_type, int array_length)
float WM_gizmo_target_property_float_get(const wmGizmo *gz, wmGizmoProperty *gz_prop)
void WM_gizmo_target_property_anim_autokey(bContext *C, const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop)
void WM_gizmotype_append(void(*gtfunc)(struct wmGizmoType *))
Definition: wm_gizmo_type.c:93