Blender V5.0
arrow3d_gizmo.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2014 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
19
20#include "BLI_math_geom.h"
21#include "BLI_math_matrix.h"
22#include "BLI_math_rotation.h"
24#include "BLI_utildefines.h"
25
26#include "DNA_view3d_types.h"
27
28#include "BKE_context.hh"
29
30#include "GPU_immediate.hh"
31#include "GPU_immediate_util.hh"
32#include "GPU_matrix.hh"
33#include "GPU_select.hh"
34#include "GPU_state.hh"
35
36#include "MEM_guardedalloc.h"
37
38#include "RNA_access.hh"
39#include "RNA_define.hh"
40
41#include "WM_api.hh"
42#include "WM_types.hh"
43
44#include "ED_gizmo_library.hh"
45#include "ED_screen.hh"
46#include "ED_view3d.hh"
47
48/* own includes */
49#include "../gizmo_geometry.h"
51
52// /** To use custom arrows exported to `geom_arrow_gizmo.cc`. */
53// #define USE_GIZMO_CUSTOM_ARROWS
54
55/* Margin to add when selecting the arrow. */
56#define ARROW_SELECT_THRESHOLD_PX (5)
57
62
67
68/* -------------------------------------------------------------------- */
69
70static void gizmo_arrow_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4])
71{
72 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
73
74 copy_m4_m4(r_matrix, arrow->gizmo.matrix_basis);
75 madd_v3_v3fl(r_matrix[3], arrow->gizmo.matrix_basis[2], arrow->data.offset);
76}
77
78static void arrow_draw_geom(const ArrowGizmo3D *arrow,
79 const bool select,
80 const float color[4],
81 const float arrow_length)
82{
84 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32_32);
85 bool unbind_shader = true;
86 const int draw_style = RNA_enum_get(arrow->gizmo.ptr, "draw_style");
87 const int draw_options = RNA_enum_get(arrow->gizmo.ptr, "draw_options");
88
90
91 float viewport[4];
93 immUniform2fv("viewportSize", &viewport[2]);
94
95 if (draw_style == ED_GIZMO_ARROW_STYLE_CROSS) {
96 immUniform1f("lineWidth", U.pixelsize + WM_gizmo_select_bias(select));
97 immUniformColor4fv(color);
98
100 immVertex3f(pos, -1.0f, 0.0f, 0.0f);
101 immVertex3f(pos, 1.0f, 0.0f, 0.0f);
102 immVertex3f(pos, 0.0f, -1.0f, 0.0f);
103 immVertex3f(pos, 0.0f, 1.0f, 0.0f);
104 immEnd();
105 }
106 else if (draw_style == ED_GIZMO_ARROW_STYLE_CONE) {
107 float aspect[2];
108 RNA_float_get_array(arrow->gizmo.ptr, "aspect", aspect);
109 const float unitx = aspect[0];
110 const float unity = aspect[1];
111 const float vec[4][3] = {
112 {-unitx, -unity, 0},
113 {unitx, -unity, 0},
114 {unitx, unity, 0},
115 {-unitx, unity, 0},
116 };
117
118 immUniform1f("lineWidth",
119 (arrow->gizmo.line_width * U.pixelsize) + WM_gizmo_select_bias(select));
121 }
122 else if (draw_style == ED_GIZMO_ARROW_STYLE_PLANE) {
123 /* Increase the size a bit during selection. These are relatively easy to hit. */
124 const float scale = select ? 0.15f : 0.1f;
125 const float verts[4][3] = {
126 {0, 0, 0},
127 {scale, 0, scale},
128 {0, 0, 2 * scale},
129 {-scale, 0, scale},
130 };
131
132 const float color_inner[4] = {UNPACK3(color), color[3] * 0.5f};
133
134 /* Translate to line end. */
136 GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length);
137
138 immUniform1f("lineWidth",
139 (arrow->gizmo.line_width * U.pixelsize) + WM_gizmo_select_bias(select));
141
146 }
147 else {
148#ifdef USE_GIZMO_CUSTOM_ARROWS
150#else
151 const float vec[2][3] = {
152 {0.0f, 0.0f, 0.0f},
153 {0.0f, 0.0f, arrow_length},
154 };
155
156 if (draw_options & ED_GIZMO_ARROW_DRAW_FLAG_STEM) {
157 immUniform1f("lineWidth",
158 (arrow->gizmo.line_width * U.pixelsize) + WM_gizmo_select_bias(select));
160 }
161 else {
162 immUniformColor4fv(color);
163 }
164
165 /* *** draw arrow head *** */
166
168
169 /* NOTE: ideally #ARROW_SELECT_THRESHOLD_PX would be added here, however adding a
170 * margin in pixel space isn't so simple, nor is it as important as for the arrow stem. */
171 if (draw_style == ED_GIZMO_ARROW_STYLE_BOX) {
172 /* Increase the size during selection so it is wider than other lines. */
173 const float size = select ? 0.11f : 0.05f;
174
175 /* translate to line end with some extra offset so box starts exactly where line ends */
176 GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length + size);
177 /* scale down to box size */
179
180 /* draw cube */
182 unbind_shader = false;
184 }
185 else {
187
188 /* Increase the size during selection, but mostly wider. */
189 const float len = select ? 0.35f : 0.25f;
190 const float width = select ? 0.12f : 0.06f;
191
192 /* translate to line end */
193 GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length);
194
197 immUniformColor4fv(color);
198
199 imm_draw_circle_fill_3d(pos, 0.0, 0.0, width, 8);
200 imm_draw_cylinder_fill_3d(pos, width, 0.0, len, 8, 1);
201 }
202
204#endif /* USE_GIZMO_CUSTOM_ARROWS */
205 }
206
207 if (unbind_shader) {
209 }
210
211 if (draw_options & ED_GIZMO_ARROW_DRAW_FLAG_ORIGIN) {
212 const float point_size = 10 * U.pixelsize;
215 immUniform1f("size", point_size);
216 immUniformColor4fv(color);
218 immVertex3f(pos, 0.0f, 0.0f, 0.0f);
219 immEnd();
222 }
223}
224
225static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool highlight)
226{
227 wmGizmo *gz = &arrow->gizmo;
228 const float arrow_length = RNA_float_get(gz->ptr, "length");
229 float color[4];
230 float matrix_final[4][4];
231
232 gizmo_color_get(gz, highlight, color);
233
234 WM_gizmo_calc_matrix_final(gz, matrix_final);
235
237 GPU_matrix_mul(matrix_final);
239 arrow_draw_geom(arrow, select, color, arrow_length);
241
243
244 if (gz->interaction_data) {
245 ArrowGizmoInteraction *arrow_inter = static_cast<ArrowGizmoInteraction *>(
246 gz->interaction_data);
247
250
253 arrow, select, blender::float4{0.5f, 0.5f, 0.5f, 0.5f}, arrow_inter->init_arrow_length);
255
257 }
258}
259
260static void gizmo_arrow_draw_select(const bContext * /*C*/, wmGizmo *gz, int select_id)
261{
262 GPU_select_load_id(select_id);
263 arrow_draw_intern((ArrowGizmo3D *)gz, true, false);
264}
265
266static void gizmo_arrow_draw(const bContext * /*C*/, wmGizmo *gz)
267{
269}
270
274static int gizmo_arrow_test_select(bContext * /*C*/, wmGizmo *gz, const int mval[2])
275{
276 /* This following values are based on manual inspection of `verts[]` defined in
277 * `geom_arrow_gizmo.cc`. */
278 const float head_center_z = (0.974306f + 1.268098f) / 2;
279 const float head_geo_x = 0.051304f;
280 const float stem_geo_x = 0.012320f;
281
282 /* Project into 2D space since it simplifies pixel threshold tests. */
283 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
284 const float arrow_length = RNA_float_get(arrow->gizmo.ptr, "length") * head_center_z;
285
286 float matrix_final[4][4];
287 WM_gizmo_calc_matrix_final(gz, matrix_final);
288
289 /* Arrow in pixel space. */
290 const float arrow_start[2] = {matrix_final[3][0], matrix_final[3][1]};
291 float arrow_end[2];
292 {
293 float co[3] = {0, 0, arrow_length};
294 mul_m4_v3(matrix_final, co);
295 copy_v2_v2(arrow_end, co);
296 }
297
298 const float scale_final = mat4_to_scale(matrix_final);
299 const float head_width = ARROW_SELECT_THRESHOLD_PX * scale_final * head_geo_x;
300 const float stem_width = ARROW_SELECT_THRESHOLD_PX * scale_final * stem_geo_x;
301 float select_threshold_base = gz->line_width * U.pixelsize;
302
303 const float mval_fl[2] = {float(mval[0]), float(mval[1])};
304
305 /* Distance to arrow head. */
306 if (len_squared_v2v2(mval_fl, arrow_end) < square_f(select_threshold_base + head_width)) {
307 return 0;
308 }
309
310 /* Distance to arrow stem. */
311 float co_isect[2];
312 const float lambda = closest_to_line_v2(co_isect, mval_fl, arrow_start, arrow_end);
313 /* Clamp inside the line, to avoid overlapping with other gizmos,
314 * especially around the start of the arrow. */
315 if (lambda >= 0.0f && lambda <= 1.0f) {
316 if (len_squared_v2v2(mval_fl, co_isect) < square_f(select_threshold_base + stem_width)) {
317 return 0;
318 }
319 }
320
321 return -1;
322}
323
329 wmGizmo *gz,
330 const wmEvent *event,
331 eWM_GizmoFlagTweak tweak_flag)
332{
333 if (event->type != MOUSEMOVE) {
335 }
336 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
337 GizmoInteraction *inter = static_cast<GizmoInteraction *>(gz->interaction_data);
338 ARegion *region = CTX_wm_region(C);
339 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
340
341 float offset[3];
342 float facdir = 1.0f;
343
344 /* A pair: (source, destination). */
345 struct {
346 blender::float2 mval;
347 float ray_origin[3], ray_direction[3];
348 float location[3];
349 } proj[2] = {};
350
351 proj[0].mval = {UNPACK2(inter->init_mval)};
352 proj[1].mval = {float(event->mval[0]), float(event->mval[1])};
353
354 float arrow_co[3];
355 float arrow_no[3];
356 copy_v3_v3(arrow_co, inter->init_matrix_basis[3]);
357 normalize_v3_v3(arrow_no, arrow->gizmo.matrix_basis[2]);
358
359 int ok = 0;
360
361 for (int j = 0; j < 2; j++) {
362 ED_view3d_win_to_ray(region, proj[j].mval, proj[j].ray_origin, proj[j].ray_direction);
363 /* Force Y axis if we're view aligned */
364 if (j == 0) {
365 if (RAD2DEGF(acosf(dot_v3v3(proj[j].ray_direction, arrow->gizmo.matrix_basis[2]))) < 5.0f) {
366 normalize_v3_v3(arrow_no, rv3d->viewinv[1]);
367 }
368 }
369
370 float arrow_no_proj[3];
371 project_plane_v3_v3v3(arrow_no_proj, arrow_no, proj[j].ray_direction);
372 normalize_v3(arrow_no_proj);
373
374 float lambda;
375 if (isect_ray_plane_v3_factor(arrow_co, arrow_no, proj[j].ray_origin, arrow_no_proj, &lambda))
376 {
377 madd_v3_v3v3fl(proj[j].location, arrow_co, arrow_no, lambda);
378 ok++;
379 }
380 }
381
382 if (ok != 2) {
384 }
385
386 sub_v3_v3v3(offset, proj[1].location, proj[0].location);
387 facdir = dot_v3v3(arrow_no, offset) < 0.0f ? -1 : 1;
388
389 GizmoCommonData *data = &arrow->data;
390 const float ofs_new = facdir * len_v3(offset);
391
392 wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
393
394 /* set the property for the operator and call its modal function */
396 const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
397 const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
398 const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
399 const bool use_precision = (tweak_flag & WM_GIZMO_TWEAK_PRECISE) != 0;
400 float value = gizmo_value_from_offset(
401 data, inter, ofs_new, constrained, inverted, use_precision);
402
403 WM_gizmo_target_property_float_set(C, gz, gz_prop, value);
404 /* get clamped value */
405 value = WM_gizmo_target_property_float_get(gz, gz_prop);
406
407 data->offset = gizmo_offset_from_value(data, value, constrained, inverted);
408 }
409 else {
410 data->offset = ofs_new;
411 }
412
413 /* tag the region for redraw */
415
417}
418
420{
421 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
422
424
425 arrow->data.range_fac = 1.0f;
426}
427
429{
430 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
431 GizmoInteraction *inter = static_cast<GizmoInteraction *>(
432 MEM_callocN(sizeof(ArrowGizmoInteraction), __func__));
433 wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
434
435 /* Some gizmos don't use properties. */
438 }
439
440 inter->init_offset = arrow->data.offset;
441
442 inter->init_mval[0] = event->mval[0];
443 inter->init_mval[1] = event->mval[1];
444
447
448 ((ArrowGizmoInteraction *)inter)->init_arrow_length = RNA_float_get(gz->ptr, "length");
449
450 gz->interaction_data = inter;
451
453}
454
456{
457 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
458 const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
459 const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
460 const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
461 gizmo_property_data_update(gz, &arrow->data, gz_prop, constrained, inverted);
462}
463
464static void gizmo_arrow_exit(bContext *C, wmGizmo *gz, const bool cancel)
465{
466 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
467 GizmoCommonData *data = &arrow->data;
468 wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
469 const bool is_prop_valid = WM_gizmo_target_property_is_valid(gz_prop);
470
471 if (cancel) {
472 GizmoInteraction *inter = static_cast<GizmoInteraction *>(gz->interaction_data);
473 if (is_prop_valid) {
474 gizmo_property_value_reset(C, gz, inter, gz_prop);
475 }
476 data->offset = inter->init_offset;
477 }
478 else {
479 /* Assign in case applying the operation needs an updated offset
480 * edit-mesh bisect needs this. */
481 if (is_prop_valid) {
482 const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
483 const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
484 const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
485 const float value = WM_gizmo_target_property_float_get(gz, gz_prop);
486 data->offset = gizmo_offset_from_value(data, value, constrained, inverted);
487 }
488 }
489
490 if (!cancel) {
491 if (is_prop_valid) {
493 }
494 }
495}
496
497/* -------------------------------------------------------------------- */
500
501void ED_gizmo_arrow3d_set_ui_range(wmGizmo *gz, const float min, const float max)
502{
503 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
504
505 BLI_assert(min < max);
507 "Make sure this function is called before WM_gizmo_target_property_def_rna");
508
509 arrow->data.range = max - min;
510 arrow->data.min = min;
511 arrow->data.max = max;
512 arrow->data.is_custom_range_set = true;
513}
514
515void ED_gizmo_arrow3d_set_range_fac(wmGizmo *gz, const float range_fac)
516{
517 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
519 "Make sure this function is called before WM_gizmo_target_property_def_rna");
520
521 arrow->data.range_fac = range_fac;
522}
523
525{
526 /* identifiers */
527 gzt->idname = "GIZMO_GT_arrow_3d";
528
529 /* API callbacks. */
530 gzt->draw = gizmo_arrow_draw;
538 gzt->exit = gizmo_arrow_exit;
539
540 gzt->struct_size = sizeof(ArrowGizmo3D);
541
542 /* rna */
543 static const EnumPropertyItem rna_enum_draw_style_items[] = {
544 {ED_GIZMO_ARROW_STYLE_NORMAL, "NORMAL", 0, "Normal", ""},
545 {ED_GIZMO_ARROW_STYLE_CROSS, "CROSS", 0, "Cross", ""},
546 {ED_GIZMO_ARROW_STYLE_BOX, "BOX", 0, "Box", ""},
547 {ED_GIZMO_ARROW_STYLE_CONE, "CONE", 0, "Cone", ""},
548 {ED_GIZMO_ARROW_STYLE_PLANE, "PLANE", 0, "Plane", ""},
549 {0, nullptr, 0, nullptr, nullptr},
550 };
551 static const EnumPropertyItem rna_enum_draw_options_items[] = {
552 {ED_GIZMO_ARROW_DRAW_FLAG_STEM, "STEM", 0, "Stem", ""},
553 {ED_GIZMO_ARROW_DRAW_FLAG_ORIGIN, "ORIGIN", 0, "Origin", ""},
554 {0, nullptr, 0, nullptr, nullptr},
555 };
556 static const EnumPropertyItem rna_enum_transform_items[] = {
557 {ED_GIZMO_ARROW_XFORM_FLAG_INVERTED, "INVERT", 0, "Inverted", ""},
558 {ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED, "CONSTRAIN", 0, "Constrained", ""},
559 {0, nullptr, 0, nullptr, nullptr},
560 };
561
562 RNA_def_enum(gzt->srna,
563 "draw_style",
564 rna_enum_draw_style_items,
566 "Draw Style",
567 "");
569 "draw_options",
570 rna_enum_draw_options_items,
572 "Draw Options",
573 "");
574 RNA_def_enum_flag(gzt->srna, "transform", rna_enum_transform_items, 0, "Transform", "");
575
577 gzt->srna, "length", 1.0f, -FLT_MAX, FLT_MAX, "Arrow Line Length", "", -FLT_MAX, FLT_MAX);
579 gzt->srna, "aspect", 2, nullptr, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX);
580
582}
583
588
ARegion * CTX_wm_region(const bContext *C)
#define BLI_assert(a)
Definition BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:53
MINLINE float square_f(float a)
#define RAD2DEGF(_rad)
bool isect_ray_plane_v3_factor(const float ray_origin[3], const float ray_direction[3], const float plane_co[3], const float plane_no[3], float *r_lambda)
float closest_to_line_v2(float r_close[2], const float p[2], const float l1[2], const float l2[2])
float mat4_to_scale(const float mat[4][4])
void mul_m4_v3(const float M[4][4], float r[3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
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 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])
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 normalize_v3(float n[3])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
unsigned int uint
#define UNPACK2(a)
#define ARRAY_SIZE(arr)
#define UNPACK3(a)
@ OPERATOR_RUNNING_MODAL
@ ED_GIZMO_ARROW_DRAW_FLAG_ORIGIN
@ ED_GIZMO_ARROW_DRAW_FLAG_STEM
@ ED_GIZMO_ARROW_STYLE_CROSS
@ ED_GIZMO_ARROW_STYLE_PLANE
@ ED_GIZMO_ARROW_STYLE_BOX
@ ED_GIZMO_ARROW_STYLE_NORMAL
@ ED_GIZMO_ARROW_STYLE_CONE
@ ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED
@ ED_GIZMO_ARROW_XFORM_FLAG_INVERTED
void ED_region_tag_redraw_editor_overlays(ARegion *region)
Definition area.cc:654
void ED_view3d_win_to_ray(const ARegion *region, const float mval[2], float r_ray_start[3], float r_ray_normal[3])
void immEnd()
void immUniform2fv(const char *name, const float data[2])
void immUnbindProgram()
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void immVertex3f(uint attr_id, float x, float y, float z)
void immUniform1f(const char *name, float x)
GPUVertFormat * immVertexFormat()
void immUniformColor4fv(const float rgba[4])
void immBegin(GPUPrimType, uint vertex_len)
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)
void GPU_matrix_push()
#define GPU_matrix_mul(x)
void GPU_matrix_scale_3f(float x, float y, float z)
void GPU_matrix_translate_3f(float x, float y, float z)
void GPU_matrix_pop()
@ GPU_PRIM_TRI_FAN
@ GPU_PRIM_LINE_LOOP
@ GPU_PRIM_LINES
@ GPU_PRIM_POINTS
@ GPU_PRIM_LINE_STRIP
bool GPU_select_load_id(unsigned int id)
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
@ GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA
@ GPU_SHADER_3D_UNIFORM_COLOR
void GPU_program_point_size(bool enable)
Definition gpu_state.cc:180
@ GPU_BLEND_NONE
Definition GPU_state.hh:85
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:87
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:42
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:273
uint GPU_vertformat_attr_add(GPUVertFormat *format, blender::StringRef name, blender::gpu::VertAttrType type)
Read Guarded memory(de)allocation.
@ PROP_FLOAT
Definition RNA_types.hh:164
#define C
Definition RandGen.cpp:29
eWM_GizmoFlagTweak
Gizmo tweak flag. Bit-flag passed to gizmo while tweaking.
@ WM_GIZMO_TWEAK_PRECISE
@ WM_GIZMO_DRAW_MODAL
@ WM_GIZMO_STATE_HIGHLIGHT
static int gizmo_arrow_test_select(bContext *, wmGizmo *gz, const int mval[2])
static void gizmo_arrow_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4])
static void gizmo_arrow_setup(wmGizmo *gz)
static void gizmo_arrow_draw_select(const bContext *, wmGizmo *gz, int select_id)
static wmOperatorStatus gizmo_arrow_invoke(bContext *, wmGizmo *gz, const wmEvent *event)
static wmOperatorStatus gizmo_arrow_modal(bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak tweak_flag)
#define ARROW_SELECT_THRESHOLD_PX
void ED_gizmo_arrow3d_set_range_fac(wmGizmo *gz, const float range_fac)
static void GIZMO_GT_arrow_3d(wmGizmoType *gzt)
void ED_gizmotypes_arrow_3d()
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 arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const float color[4], const float arrow_length)
static void gizmo_arrow_draw(const bContext *, wmGizmo *gz)
#define U
BMesh const char void * data
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
nullptr float
#define acosf(x)
GizmoGeomInfo wm_gizmo_geom_data_arrow
static float verts[][3]
GizmoGeomInfo wm_gizmo_geom_data_cube
void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info, const bool, const float color[4])
void wm_gizmo_vec_draw(const float color[4], const float(*verts)[3], uint vert_count, uint pos, uint primitive_type)
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_color_get(const wmGizmo *gz, bool highlight, float r_color[4])
void gizmo_property_data_update(wmGizmo *gz, GizmoCommonData *data, wmGizmoProperty *gz_prop, bool constrained, bool inverted)
static float WM_gizmo_select_bias(bool select)
void gizmo_property_value_reset(bContext *C, const wmGizmo *gz, GizmoInteraction *inter, wmGizmoProperty *gz_prop)
uint pos
#define select(A, B, C)
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
VecBase< float, 4 > float4
VecBase< float, 2 > float2
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
float RNA_float_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
#define min(a, b)
Definition sort.cc:36
#define FLT_MAX
Definition stdcycles.h:14
void * regiondata
GizmoCommonData data
GizmoInteraction inter
float viewinv[4][4]
wmEventType type
Definition WM_types.hh:757
int mval[2]
Definition WM_types.hh:763
StructRNA * srna
wmGizmoFnDraw draw
wmGizmoFnModal modal
wmGizmoFnSetup setup
wmGizmoFnMatrixBasisGet matrix_basis_get
const char * idname
wmGizmoFnTestSelect test_select
wmGizmoFnExit exit
wmGizmoFnInvoke invoke
wmGizmoFnDrawSelect draw_select
wmGizmoFnPropertyUpdate property_update
void * interaction_data
eWM_GizmoFlagState state
float matrix_basis[4][4]
PointerRNA * ptr
float line_width
eWM_GizmoFlag flag
max
Definition text_draw.cc:251
uint len
@ MOUSEMOVE
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
Definition wm_gizmo.cc:572
void WM_gizmo_target_property_float_set(bContext *C, const wmGizmo *gz, wmGizmoProperty *gz_prop, const float value)
void WM_gizmo_target_property_anim_autokey(bContext *C, const wmGizmo *, wmGizmoProperty *gz_prop)
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)
wmGizmoProperty * WM_gizmo_target_property_find(wmGizmo *gz, const char *idname)
void WM_gizmotype_append(void(*gtfunc)(wmGizmoType *))