Blender  V2.93
arrow3d_gizmo.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2014 Blender Foundation.
17  * All rights reserved.
18  */
19 
35 #include "BLI_math.h"
36 #include "BLI_utildefines.h"
37 
38 #include "DNA_view3d_types.h"
39 
40 #include "BKE_context.h"
41 
42 #include "GPU_immediate.h"
43 #include "GPU_immediate_util.h"
44 #include "GPU_matrix.h"
45 #include "GPU_select.h"
46 #include "GPU_state.h"
47 
48 #include "MEM_guardedalloc.h"
49 
50 #include "RNA_access.h"
51 #include "RNA_define.h"
52 
53 #include "WM_api.h"
54 #include "WM_types.h"
55 
56 #include "ED_gizmo_library.h"
57 #include "ED_screen.h"
58 #include "ED_view3d.h"
59 
60 #include "UI_interface.h"
61 
62 /* own includes */
63 #include "../gizmo_geometry.h"
64 #include "../gizmo_library_intern.h"
65 
66 /* to use custom arrows exported to geom_arrow_gizmo.c */
67 //#define USE_GIZMO_CUSTOM_ARROWS
68 
69 typedef struct ArrowGizmo3D {
73 
74 /* -------------------------------------------------------------------- */
75 
76 static void gizmo_arrow_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4])
77 {
78  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
79 
80  copy_m4_m4(r_matrix, arrow->gizmo.matrix_basis);
81  madd_v3_v3fl(r_matrix[3], arrow->gizmo.matrix_basis[2], arrow->data.offset);
82 }
83 
84 static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const float color[4])
85 {
87  bool unbind_shader = true;
88  const int draw_style = RNA_enum_get(arrow->gizmo.ptr, "draw_style");
89  const int draw_options = RNA_enum_get(arrow->gizmo.ptr, "draw_options");
90 
93 
94  float viewport[4];
95  GPU_viewport_size_get_f(viewport);
96  immUniform2fv("viewportSize", &viewport[2]);
97 
98  if (draw_style == ED_GIZMO_ARROW_STYLE_CROSS) {
99  immUniform1f("lineWidth", U.pixelsize);
100  immUniformColor4fv(color);
101 
103  immVertex3f(pos, -1.0f, 0.0f, 0.0f);
104  immVertex3f(pos, 1.0f, 0.0f, 0.0f);
105  immVertex3f(pos, 0.0f, -1.0f, 0.0f);
106  immVertex3f(pos, 0.0f, 1.0f, 0.0f);
107  immEnd();
108  }
109  else if (draw_style == ED_GIZMO_ARROW_STYLE_CONE) {
110  float aspect[2];
111  RNA_float_get_array(arrow->gizmo.ptr, "aspect", aspect);
112  const float unitx = aspect[0];
113  const float unity = aspect[1];
114  const float vec[4][3] = {
115  {-unitx, -unity, 0},
116  {unitx, -unity, 0},
117  {unitx, unity, 0},
118  {-unitx, unity, 0},
119  };
120 
121  immUniform1f("lineWidth", arrow->gizmo.line_width * U.pixelsize);
123  }
124  else {
125 #ifdef USE_GIZMO_CUSTOM_ARROWS
127 #else
128  const float arrow_length = RNA_float_get(arrow->gizmo.ptr, "length");
129 
130  const float vec[2][3] = {
131  {0.0f, 0.0f, 0.0f},
132  {0.0f, 0.0f, arrow_length},
133  };
134 
135  if (draw_options & ED_GIZMO_ARROW_DRAW_FLAG_STEM) {
136  immUniform1f("lineWidth", arrow->gizmo.line_width * U.pixelsize);
138  }
139  else {
140  immUniformColor4fv(color);
141  }
142 
143  /* *** draw arrow head *** */
144 
145  GPU_matrix_push();
146 
147  if (draw_style == ED_GIZMO_ARROW_STYLE_BOX) {
148  const float size = 0.05f;
149 
150  /* translate to line end with some extra offset so box starts exactly where line ends */
151  GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length + size);
152  /* scale down to box size */
154 
155  /* draw cube */
157  unbind_shader = false;
159  }
160  else {
162 
163  const float len = 0.25f;
164  const float width = 0.06f;
165 
166  /* translate to line end */
167  GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length);
168 
171  immUniformColor4fv(color);
172 
173  imm_draw_circle_fill_3d(pos, 0.0, 0.0, width, 8);
174  imm_draw_cylinder_fill_3d(pos, width, 0.0, len, 8, 1);
175  }
176 
177  GPU_matrix_pop();
178 #endif /* USE_GIZMO_CUSTOM_ARROWS */
179  }
180 
181  if (unbind_shader) {
183  }
184 }
185 
186 static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool highlight)
187 {
188  wmGizmo *gz = &arrow->gizmo;
189  float color[4];
190  float matrix_final[4][4];
191 
192  gizmo_color_get(gz, highlight, color);
193 
194  WM_gizmo_calc_matrix_final(gz, matrix_final);
195 
196  GPU_matrix_push();
197  GPU_matrix_mul(matrix_final);
199  arrow_draw_geom(arrow, select, color);
201 
202  GPU_matrix_pop();
203 
204  if (gz->interaction_data) {
205  GizmoInteraction *inter = gz->interaction_data;
206 
207  GPU_matrix_push();
209 
211  arrow_draw_geom(arrow, select, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f});
213 
214  GPU_matrix_pop();
215  }
216 }
217 
218 static void gizmo_arrow_draw_select(const bContext *UNUSED(C), wmGizmo *gz, int select_id)
219 {
220  GPU_select_load_id(select_id);
221  arrow_draw_intern((ArrowGizmo3D *)gz, true, false);
222 }
223 
224 static void gizmo_arrow_draw(const bContext *UNUSED(C), wmGizmo *gz)
225 {
226  arrow_draw_intern((ArrowGizmo3D *)gz, false, (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0);
227 }
228 
232 static int gizmo_arrow_test_select(bContext *UNUSED(C), wmGizmo *gz, const int mval[2])
233 {
234  /* Project into 2D space since it simplifies pixel threshold tests. */
235  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
236  const float arrow_length = RNA_float_get(arrow->gizmo.ptr, "length");
237 
238  float matrix_final[4][4];
239  WM_gizmo_calc_matrix_final(gz, matrix_final);
240 
241  /* Arrow in pixel space. */
242  const float arrow_start[2] = {matrix_final[3][0], matrix_final[3][1]};
243  float arrow_end[2];
244  {
245  float co[3] = {0, 0, arrow_length};
246  mul_m4_v3(matrix_final, co);
247  copy_v2_v2(arrow_end, co);
248  }
249 
250  const float mval_fl[2] = {UNPACK2(mval)};
251  const float arrow_stem_threshold_px = 5 * UI_DPI_FAC;
252  const float arrow_head_threshold_px = 12 * UI_DPI_FAC;
253 
254  /* Distance to arrow head. */
255  if (len_squared_v2v2(mval_fl, arrow_end) < square_f(arrow_head_threshold_px)) {
256  return 0;
257  }
258 
259  /* Distance to arrow stem. */
260  float co_isect[2];
261  const float lambda = closest_to_line_v2(co_isect, mval_fl, arrow_start, arrow_end);
262  /* Clamp inside the line, to avoid overlapping with other gizmos,
263  * especially around the start of the arrow. */
264  if (lambda >= 0.0 && lambda <= 1.0) {
265  if (len_squared_v2v2(mval_fl, co_isect) < square_f(arrow_stem_threshold_px)) {
266  return 0;
267  }
268  }
269 
270  return -1;
271 }
272 
278  wmGizmo *gz,
279  const wmEvent *event,
280  eWM_GizmoFlagTweak tweak_flag)
281 {
282  if (event->type != MOUSEMOVE) {
283  return OPERATOR_RUNNING_MODAL;
284  }
285  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
286  GizmoInteraction *inter = gz->interaction_data;
287  ARegion *region = CTX_wm_region(C);
288  RegionView3D *rv3d = region->regiondata;
289 
290  float offset[3];
291  float facdir = 1.0f;
292 
293  /* (src, dst) */
294  struct {
295  float mval[2];
296  float ray_origin[3], ray_direction[3];
297  float location[3];
298  } proj[2] = {
299  {.mval = {UNPACK2(inter->init_mval)}},
300  {.mval = {UNPACK2(event->mval)}},
301  };
302 
303  float arrow_co[3];
304  float arrow_no[3];
305  copy_v3_v3(arrow_co, inter->init_matrix_basis[3]);
306  normalize_v3_v3(arrow_no, arrow->gizmo.matrix_basis[2]);
307 
308  int ok = 0;
309 
310  for (int j = 0; j < 2; j++) {
311  ED_view3d_win_to_ray(region, proj[j].mval, proj[j].ray_origin, proj[j].ray_direction);
312  /* Force Y axis if we're view aligned */
313  if (j == 0) {
314  if (RAD2DEGF(acosf(dot_v3v3(proj[j].ray_direction, arrow->gizmo.matrix_basis[2]))) < 5.0f) {
315  normalize_v3_v3(arrow_no, rv3d->viewinv[1]);
316  }
317  }
318 
319  float arrow_no_proj[3];
320  project_plane_v3_v3v3(arrow_no_proj, arrow_no, proj[j].ray_direction);
321 
322  normalize_v3(arrow_no_proj);
323 
324  float plane[4];
325  plane_from_point_normal_v3(plane, proj[j].ray_origin, arrow_no_proj);
326 
327  float lambda;
328  if (isect_ray_plane_v3(arrow_co, arrow_no, plane, &lambda, false)) {
329  madd_v3_v3v3fl(proj[j].location, arrow_co, arrow_no, lambda);
330  ok++;
331  }
332  }
333 
334  if (ok != 2) {
335  return OPERATOR_RUNNING_MODAL;
336  }
337 
338  sub_v3_v3v3(offset, proj[1].location, proj[0].location);
339  facdir = dot_v3v3(arrow_no, offset) < 0.0f ? -1 : 1;
340 
341  GizmoCommonData *data = &arrow->data;
342  const float ofs_new = facdir * len_v3(offset);
343 
344  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
345 
346  /* set the property for the operator and call its modal function */
347  if (WM_gizmo_target_property_is_valid(gz_prop)) {
348  const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
349  const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
350  const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
351  const bool use_precision = (tweak_flag & WM_GIZMO_TWEAK_PRECISE) != 0;
352  float value = gizmo_value_from_offset(
353  data, inter, ofs_new, constrained, inverted, use_precision);
354 
355  WM_gizmo_target_property_float_set(C, gz, gz_prop, value);
356  /* get clamped value */
357  value = WM_gizmo_target_property_float_get(gz, gz_prop);
358 
359  data->offset = gizmo_offset_from_value(data, value, constrained, inverted);
360  }
361  else {
362  data->offset = ofs_new;
363  }
364 
365  /* tag the region for redraw */
368 
369  return OPERATOR_RUNNING_MODAL;
370 }
371 
372 static void gizmo_arrow_setup(wmGizmo *gz)
373 {
374  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
375 
376  arrow->gizmo.flag |= WM_GIZMO_DRAW_MODAL;
377 
378  arrow->data.range_fac = 1.0f;
379 }
380 
381 static int gizmo_arrow_invoke(bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event)
382 {
383  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
384  GizmoInteraction *inter = MEM_callocN(sizeof(GizmoInteraction), __func__);
385  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
386 
387  /* Some gizmos don't use properties. */
388  if (WM_gizmo_target_property_is_valid(gz_prop)) {
389  inter->init_value = WM_gizmo_target_property_float_get(gz, gz_prop);
390  }
391 
392  inter->init_offset = arrow->data.offset;
393 
394  inter->init_mval[0] = event->mval[0];
395  inter->init_mval[1] = event->mval[1];
396 
399 
400  gz->interaction_data = inter;
401 
402  return OPERATOR_RUNNING_MODAL;
403 }
404 
406 {
407  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
408  const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
409  const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
410  const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
411  gizmo_property_data_update(gz, &arrow->data, gz_prop, constrained, inverted);
412 }
413 
414 static void gizmo_arrow_exit(bContext *C, wmGizmo *gz, const bool cancel)
415 {
416  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
417  GizmoCommonData *data = &arrow->data;
418  wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
419  const bool is_prop_valid = WM_gizmo_target_property_is_valid(gz_prop);
420 
421  if (cancel) {
422  GizmoInteraction *inter = gz->interaction_data;
423  if (is_prop_valid) {
424  gizmo_property_value_reset(C, gz, inter, gz_prop);
425  }
426  data->offset = inter->init_offset;
427  }
428  else {
429  /* Assign in case applying the operation needs an updated offset
430  * edit-mesh bisect needs this. */
431  if (is_prop_valid) {
432  const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
433  const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
434  const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
435  const float value = WM_gizmo_target_property_float_get(gz, gz_prop);
436  data->offset = gizmo_offset_from_value(data, value, constrained, inverted);
437  }
438  }
439 
440  if (!cancel) {
441  if (is_prop_valid) {
443  }
444  }
445 }
446 
447 /* -------------------------------------------------------------------- */
456 void ED_gizmo_arrow3d_set_ui_range(wmGizmo *gz, const float min, const float max)
457 {
458  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
459 
460  BLI_assert(min < max);
462  "Make sure this function is called before WM_gizmo_target_property_def_rna"));
463 
464  arrow->data.range = max - min;
465  arrow->data.min = min;
466  arrow->data.max = max;
467  arrow->data.is_custom_range_set = true;
468 }
469 
475 void ED_gizmo_arrow3d_set_range_fac(wmGizmo *gz, const float range_fac)
476 {
477  ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
479  "Make sure this function is called before WM_gizmo_target_property_def_rna"));
480 
481  arrow->data.range_fac = range_fac;
482 }
483 
485 {
486  /* identifiers */
487  gzt->idname = "GIZMO_GT_arrow_3d";
488 
489  /* api callbacks */
490  gzt->draw = gizmo_arrow_draw;
494  gzt->modal = gizmo_arrow_modal;
495  gzt->setup = gizmo_arrow_setup;
496  gzt->invoke = gizmo_arrow_invoke;
498  gzt->exit = gizmo_arrow_exit;
499 
500  gzt->struct_size = sizeof(ArrowGizmo3D);
501 
502  /* rna */
503  static EnumPropertyItem rna_enum_draw_style_items[] = {
504  {ED_GIZMO_ARROW_STYLE_NORMAL, "NORMAL", 0, "Normal", ""},
505  {ED_GIZMO_ARROW_STYLE_CROSS, "CROSS", 0, "Cross", ""},
506  {ED_GIZMO_ARROW_STYLE_BOX, "BOX", 0, "Box", ""},
507  {ED_GIZMO_ARROW_STYLE_CONE, "CONE", 0, "Cone", ""},
508  {0, NULL, 0, NULL, NULL},
509  };
510  static EnumPropertyItem rna_enum_draw_options_items[] = {
511  {ED_GIZMO_ARROW_DRAW_FLAG_STEM, "STEM", 0, "Stem", ""},
512  {0, NULL, 0, NULL, NULL},
513  };
514  static EnumPropertyItem rna_enum_transform_items[] = {
515  {ED_GIZMO_ARROW_XFORM_FLAG_INVERTED, "INVERT", 0, "Inverted", ""},
516  {ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED, "CONSTRAIN", 0, "Constrained", ""},
517  {0, NULL, 0, NULL, NULL},
518  };
519 
520  RNA_def_enum(gzt->srna,
521  "draw_style",
522  rna_enum_draw_style_items,
524  "Draw Style",
525  "");
526  RNA_def_enum_flag(gzt->srna,
527  "draw_options",
528  rna_enum_draw_options_items,
530  "Draw Options",
531  "");
532  RNA_def_enum_flag(gzt->srna, "transform", rna_enum_transform_items, 0, "Transform", "");
533 
534  RNA_def_float(gzt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, 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:725
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
#define BLI_assert(a)
Definition: BLI_assert.h:58
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:243
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:3371
bool isect_ray_plane_v3(const float ray_origin[3], const float ray_direction[3], const float plane[4], float *r_lambda, const bool clip)
Definition: math_geom.c:1808
void mul_m4_v3(const float M[4][4], float r[3])
Definition: math_matrix.c:732
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:95
#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:740
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:83
#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:706
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:142
#define GPU_matrix_mul(x)
Definition: GPU_matrix.h:223
void GPU_matrix_scale_3f(float x, float y, float z)
Definition: gpu_matrix.cc:247
void GPU_matrix_push(void)
Definition: gpu_matrix.cc:135
void GPU_matrix_translate_3f(float x, float y, float z)
Definition: gpu_matrix.cc:204
@ GPU_PRIM_LINE_LOOP
Definition: GPU_primitive.h:39
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:36
@ GPU_PRIM_LINE_STRIP
Definition: GPU_primitive.h:38
bool GPU_select_load_id(unsigned int id)
Definition: gpu_select.c:108
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
Definition: GPU_shader.h:223
@ GPU_SHADER_3D_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
@ 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
#define UI_DPI_FAC
Definition: UI_interface.h:309
eWM_GizmoFlagTweak
Gizmo tweak flag. Bitflag passed to gizmo while tweaking.
@ WM_GIZMO_TWEAK_PRECISE
@ WM_GIZMO_DRAW_MODAL
@ WM_GIZMO_STATE_HIGHLIGHT
static void gizmo_arrow_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4])
Definition: arrow3d_gizmo.c:76
static void gizmo_arrow_setup(wmGizmo *gz)
static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const float color[4])
Definition: arrow3d_gizmo.c:84
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)
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 gizmo_arrow_draw(const bContext *UNUSED(C), wmGizmo *gz)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
unsigned int U
Definition: btGjkEpa3.h:78
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, const float offset, const bool constrained, const bool inverted, const bool use_precision)
void gizmo_color_get(const struct wmGizmo *gz, const bool highlight, float r_color[4])
void gizmo_property_value_reset(bContext *C, const struct wmGizmo *gz, GizmoInteraction *inter, wmGizmoProperty *gz_prop)
void gizmo_property_data_update(struct wmGizmo *gz, GizmoCommonData *data, wmGizmoProperty *gz_prop, const bool constrained, const bool inverted)
float gizmo_offset_from_value(GizmoCommonData *data, const float value, const bool constrained, const bool inverted)
uint pos
#define acosf(x)
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
Definition: rna_access.c:6378
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6355
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6402
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3825
PropertyRNA * RNA_def_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
#define min(a, b)
Definition: sort.c:51
void * regiondata
wmGizmo gizmo
Definition: arrow3d_gizmo.c:70
GizmoCommonData data
Definition: arrow3d_gizmo.c:71
float init_matrix_basis[4][4]
float init_matrix_final[4][4]
float viewinv[4][4]
int mval[2]
Definition: WM_types.h:583
short type
Definition: WM_types.h:577
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
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: util_avxb.h:167
uint len
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:601
void WM_gizmo_target_property_float_set(bContext *C, const wmGizmo *gz, wmGizmoProperty *gz_prop, const float value)
wmGizmoProperty * WM_gizmo_target_property_find(wmGizmo *gz, const char *idname)
bool WM_gizmo_target_property_is_valid(const wmGizmoProperty *gz_prop)
void WM_gizmotype_target_property_def(wmGizmoType *gzt, const char *idname, int data_type, int array_length)
float WM_gizmo_target_property_float_get(const wmGizmo *gz, wmGizmoProperty *gz_prop)
void WM_gizmo_target_property_anim_autokey(bContext *C, const wmGizmo *UNUSED(gz), wmGizmoProperty *gz_prop)
void WM_gizmotype_append(void(*gtfunc)(struct wmGizmoType *))