Blender V4.3
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_matrix.h"
21#include "BLI_math_rotation.h"
23#include "BLI_utildefines.h"
24
25#include "DNA_view3d_types.h"
26
27#include "BKE_context.hh"
28
29#include "GPU_immediate.hh"
30#include "GPU_immediate_util.hh"
31#include "GPU_matrix.hh"
32#include "GPU_select.hh"
33#include "GPU_state.hh"
34
35#include "MEM_guardedalloc.h"
36
37#include "RNA_access.hh"
38#include "RNA_define.hh"
39
40#include "WM_api.hh"
41#include "WM_types.hh"
42
43#include "ED_gizmo_library.hh"
44#include "ED_screen.hh"
45#include "ED_view3d.hh"
46
47/* own includes */
48#include "../gizmo_geometry.h"
50
51// /** To use custom arrows exported to `geom_arrow_gizmo.cc`. */
52// #define USE_GIZMO_CUSTOM_ARROWS
53
54/* Margin to add when selecting the arrow. */
55#define ARROW_SELECT_THRESHOLD_PX (5)
56
61
66
67/* -------------------------------------------------------------------- */
68
69static void gizmo_arrow_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4])
70{
71 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
72
73 copy_m4_m4(r_matrix, arrow->gizmo.matrix_basis);
74 madd_v3_v3fl(r_matrix[3], arrow->gizmo.matrix_basis[2], arrow->data.offset);
75}
76
77static void arrow_draw_geom(const ArrowGizmo3D *arrow,
78 const bool select,
79 const float color[4],
80 const float arrow_length)
81{
83 bool unbind_shader = true;
84 const int draw_style = RNA_enum_get(arrow->gizmo.ptr, "draw_style");
85 const int draw_options = RNA_enum_get(arrow->gizmo.ptr, "draw_options");
86
88
89 float viewport[4];
91 immUniform2fv("viewportSize", &viewport[2]);
92
93 if (draw_style == ED_GIZMO_ARROW_STYLE_CROSS) {
94 immUniform1f("lineWidth", U.pixelsize);
96
98 immVertex3f(pos, -1.0f, 0.0f, 0.0f);
99 immVertex3f(pos, 1.0f, 0.0f, 0.0f);
100 immVertex3f(pos, 0.0f, -1.0f, 0.0f);
101 immVertex3f(pos, 0.0f, 1.0f, 0.0f);
102 immEnd();
103 }
104 else if (draw_style == ED_GIZMO_ARROW_STYLE_CONE) {
105 float aspect[2];
106 RNA_float_get_array(arrow->gizmo.ptr, "aspect", aspect);
107 const float unitx = aspect[0];
108 const float unity = aspect[1];
109 const float vec[4][3] = {
110 {-unitx, -unity, 0},
111 {unitx, -unity, 0},
112 {unitx, unity, 0},
113 {-unitx, unity, 0},
114 };
115
116 immUniform1f("lineWidth", arrow->gizmo.line_width * U.pixelsize);
118 }
119 else if (draw_style == ED_GIZMO_ARROW_STYLE_PLANE) {
120 const float scale = 0.1f;
121 const float verts[4][3] = {
122 {0, 0, 0},
123 {scale, 0, scale},
124 {0, 0, 2 * scale},
125 {-scale, 0, scale},
126 };
127
128 const float color_inner[4] = {UNPACK3(color), color[3] * 0.5f};
129
130 /* Translate to line end. */
132 GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length);
133
134 immUniform1f("lineWidth", arrow->gizmo.line_width * U.pixelsize);
136
141 }
142 else {
143#ifdef USE_GIZMO_CUSTOM_ARROWS
145#else
146 const float vec[2][3] = {
147 {0.0f, 0.0f, 0.0f},
148 {0.0f, 0.0f, arrow_length},
149 };
150
151 if (draw_options & ED_GIZMO_ARROW_DRAW_FLAG_STEM) {
152 const float stem_width = arrow->gizmo.line_width * U.pixelsize +
154 immUniform1f("lineWidth", stem_width);
156 }
157 else {
159 }
160
161 /* *** draw arrow head *** */
162
164
165 /* NOTE: ideally #ARROW_SELECT_THRESHOLD_PX would be added here, however adding a
166 * margin in pixel space isn't so simple, nor is it as important as for the arrow stem. */
167 if (draw_style == ED_GIZMO_ARROW_STYLE_BOX) {
168 const float size = 0.05f;
169
170 /* translate to line end with some extra offset so box starts exactly where line ends */
171 GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length + size);
172 /* scale down to box size */
174
175 /* draw cube */
177 unbind_shader = false;
179 }
180 else {
182
183 const float len = 0.25f;
184 const float width = 0.06f;
185
186 /* translate to line end */
187 GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length);
188
192
193 imm_draw_circle_fill_3d(pos, 0.0, 0.0, width, 8);
194 imm_draw_cylinder_fill_3d(pos, width, 0.0, len, 8, 1);
195 }
196
198#endif /* USE_GIZMO_CUSTOM_ARROWS */
199 }
200
201 if (unbind_shader) {
203 }
204
205 if (draw_options & ED_GIZMO_ARROW_DRAW_FLAG_ORIGIN) {
206 const float point_size = 10 * U.pixelsize;
209 immUniform1f("size", point_size);
212 immVertex3f(pos, 0.0f, 0.0f, 0.0f);
213 immEnd();
216 }
217}
218
219static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool highlight)
220{
221 wmGizmo *gz = &arrow->gizmo;
222 const float arrow_length = RNA_float_get(gz->ptr, "length");
223 float color[4];
224 float matrix_final[4][4];
225
226 gizmo_color_get(gz, highlight, color);
227
228 WM_gizmo_calc_matrix_final(gz, matrix_final);
229
231 GPU_matrix_mul(matrix_final);
233 arrow_draw_geom(arrow, select, color, arrow_length);
235
237
238 if (gz->interaction_data) {
239 ArrowGizmoInteraction *arrow_inter = static_cast<ArrowGizmoInteraction *>(
240 gz->interaction_data);
241
244
247 arrow, select, blender::float4{0.5f, 0.5f, 0.5f, 0.5f}, arrow_inter->init_arrow_length);
249
251 }
252}
253
254static void gizmo_arrow_draw_select(const bContext * /*C*/, wmGizmo *gz, int select_id)
255{
256 GPU_select_load_id(select_id);
257 arrow_draw_intern((ArrowGizmo3D *)gz, true, false);
258}
259
260static void gizmo_arrow_draw(const bContext * /*C*/, wmGizmo *gz)
261{
263}
264
268static int gizmo_arrow_test_select(bContext * /*C*/, wmGizmo *gz, const int mval[2])
269{
270 /* This following values are based on manual inspection of `verts[]` defined in
271 * `geom_arrow_gizmo.cc`. */
272 const float head_center_z = (0.974306f + 1.268098f) / 2;
273 const float head_geo_x = 0.051304f;
274 const float stem_geo_x = 0.012320f;
275
276 /* Project into 2D space since it simplifies pixel threshold tests. */
277 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
278 const float arrow_length = RNA_float_get(arrow->gizmo.ptr, "length") * head_center_z;
279
280 float matrix_final[4][4];
281 WM_gizmo_calc_matrix_final(gz, matrix_final);
282
283 /* Arrow in pixel space. */
284 const float arrow_start[2] = {matrix_final[3][0], matrix_final[3][1]};
285 float arrow_end[2];
286 {
287 float co[3] = {0, 0, arrow_length};
288 mul_m4_v3(matrix_final, co);
289 copy_v2_v2(arrow_end, co);
290 }
291
292 const float scale_final = mat4_to_scale(matrix_final);
293 const float head_width = ARROW_SELECT_THRESHOLD_PX * scale_final * head_geo_x;
294 const float stem_width = ARROW_SELECT_THRESHOLD_PX * scale_final * stem_geo_x;
295 float select_threshold_base = gz->line_width * U.pixelsize;
296
297 const float mval_fl[2] = {float(mval[0]), float(mval[1])};
298
299 /* Distance to arrow head. */
300 if (len_squared_v2v2(mval_fl, arrow_end) < square_f(select_threshold_base + head_width)) {
301 return 0;
302 }
303
304 /* Distance to arrow stem. */
305 float co_isect[2];
306 const float lambda = closest_to_line_v2(co_isect, mval_fl, arrow_start, arrow_end);
307 /* Clamp inside the line, to avoid overlapping with other gizmos,
308 * especially around the start of the arrow. */
309 if (lambda >= 0.0f && lambda <= 1.0f) {
310 if (len_squared_v2v2(mval_fl, co_isect) < square_f(select_threshold_base + stem_width)) {
311 return 0;
312 }
313 }
314
315 return -1;
316}
317
323 wmGizmo *gz,
324 const wmEvent *event,
325 eWM_GizmoFlagTweak tweak_flag)
326{
327 if (event->type != MOUSEMOVE) {
329 }
330 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
331 GizmoInteraction *inter = static_cast<GizmoInteraction *>(gz->interaction_data);
332 ARegion *region = CTX_wm_region(C);
333 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
334
335 float offset[3];
336 float facdir = 1.0f;
337
338 /* A pair: (source, destination). */
339 struct {
340 blender::float2 mval;
341 float ray_origin[3], ray_direction[3];
342 float location[3];
343 } proj[2] = {};
344
345 proj[0].mval = {UNPACK2(inter->init_mval)};
346 proj[1].mval = {float(event->mval[0]), float(event->mval[1])};
347
348 float arrow_co[3];
349 float arrow_no[3];
350 copy_v3_v3(arrow_co, inter->init_matrix_basis[3]);
351 normalize_v3_v3(arrow_no, arrow->gizmo.matrix_basis[2]);
352
353 int ok = 0;
354
355 for (int j = 0; j < 2; j++) {
356 ED_view3d_win_to_ray(region, proj[j].mval, proj[j].ray_origin, proj[j].ray_direction);
357 /* Force Y axis if we're view aligned */
358 if (j == 0) {
359 if (RAD2DEGF(acosf(dot_v3v3(proj[j].ray_direction, arrow->gizmo.matrix_basis[2]))) < 5.0f) {
360 normalize_v3_v3(arrow_no, rv3d->viewinv[1]);
361 }
362 }
363
364 float arrow_no_proj[3];
365 project_plane_v3_v3v3(arrow_no_proj, arrow_no, proj[j].ray_direction);
366 normalize_v3(arrow_no_proj);
367
368 float lambda;
369 if (isect_ray_plane_v3_factor(arrow_co, arrow_no, proj[j].ray_origin, arrow_no_proj, &lambda))
370 {
371 madd_v3_v3v3fl(proj[j].location, arrow_co, arrow_no, lambda);
372 ok++;
373 }
374 }
375
376 if (ok != 2) {
378 }
379
380 sub_v3_v3v3(offset, proj[1].location, proj[0].location);
381 facdir = dot_v3v3(arrow_no, offset) < 0.0f ? -1 : 1;
382
383 GizmoCommonData *data = &arrow->data;
384 const float ofs_new = facdir * len_v3(offset);
385
386 wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
387
388 /* set the property for the operator and call its modal function */
390 const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
391 const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
392 const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
393 const bool use_precision = (tweak_flag & WM_GIZMO_TWEAK_PRECISE) != 0;
394 float value = gizmo_value_from_offset(
395 data, inter, ofs_new, constrained, inverted, use_precision);
396
397 WM_gizmo_target_property_float_set(C, gz, gz_prop, value);
398 /* get clamped value */
399 value = WM_gizmo_target_property_float_get(gz, gz_prop);
400
401 data->offset = gizmo_offset_from_value(data, value, constrained, inverted);
402 }
403 else {
404 data->offset = ofs_new;
405 }
406
407 /* tag the region for redraw */
410
412}
413
415{
416 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
417
419
420 arrow->data.range_fac = 1.0f;
421}
422
423static int gizmo_arrow_invoke(bContext * /*C*/, wmGizmo *gz, const wmEvent *event)
424{
425 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
426 GizmoInteraction *inter = static_cast<GizmoInteraction *>(
427 MEM_callocN(sizeof(ArrowGizmoInteraction), __func__));
428 wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
429
430 /* Some gizmos don't use properties. */
433 }
434
435 inter->init_offset = arrow->data.offset;
436
437 inter->init_mval[0] = event->mval[0];
438 inter->init_mval[1] = event->mval[1];
439
442
443 ((ArrowGizmoInteraction *)inter)->init_arrow_length = RNA_float_get(gz->ptr, "length");
444
445 gz->interaction_data = inter;
446
448}
449
451{
452 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
453 const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
454 const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
455 const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
456 gizmo_property_data_update(gz, &arrow->data, gz_prop, constrained, inverted);
457}
458
459static void gizmo_arrow_exit(bContext *C, wmGizmo *gz, const bool cancel)
460{
461 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
462 GizmoCommonData *data = &arrow->data;
463 wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
464 const bool is_prop_valid = WM_gizmo_target_property_is_valid(gz_prop);
465
466 if (cancel) {
467 GizmoInteraction *inter = static_cast<GizmoInteraction *>(gz->interaction_data);
468 if (is_prop_valid) {
469 gizmo_property_value_reset(C, gz, inter, gz_prop);
470 }
471 data->offset = inter->init_offset;
472 }
473 else {
474 /* Assign in case applying the operation needs an updated offset
475 * edit-mesh bisect needs this. */
476 if (is_prop_valid) {
477 const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
478 const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
479 const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
480 const float value = WM_gizmo_target_property_float_get(gz, gz_prop);
481 data->offset = gizmo_offset_from_value(data, value, constrained, inverted);
482 }
483 }
484
485 if (!cancel) {
486 if (is_prop_valid) {
488 }
489 }
490}
491
492/* -------------------------------------------------------------------- */
495
496void ED_gizmo_arrow3d_set_ui_range(wmGizmo *gz, const float min, const float max)
497{
498 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
499
500 BLI_assert(min < max);
502 "Make sure this function is called before WM_gizmo_target_property_def_rna");
503
504 arrow->data.range = max - min;
505 arrow->data.min = min;
506 arrow->data.max = max;
507 arrow->data.is_custom_range_set = true;
508}
509
510void ED_gizmo_arrow3d_set_range_fac(wmGizmo *gz, const float range_fac)
511{
512 ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz;
514 "Make sure this function is called before WM_gizmo_target_property_def_rna");
515
516 arrow->data.range_fac = range_fac;
517}
518
520{
521 /* identifiers */
522 gzt->idname = "GIZMO_GT_arrow_3d";
523
524 /* api callbacks */
525 gzt->draw = gizmo_arrow_draw;
533 gzt->exit = gizmo_arrow_exit;
534
535 gzt->struct_size = sizeof(ArrowGizmo3D);
536
537 /* rna */
538 static const EnumPropertyItem rna_enum_draw_style_items[] = {
539 {ED_GIZMO_ARROW_STYLE_NORMAL, "NORMAL", 0, "Normal", ""},
540 {ED_GIZMO_ARROW_STYLE_CROSS, "CROSS", 0, "Cross", ""},
541 {ED_GIZMO_ARROW_STYLE_BOX, "BOX", 0, "Box", ""},
542 {ED_GIZMO_ARROW_STYLE_CONE, "CONE", 0, "Cone", ""},
543 {ED_GIZMO_ARROW_STYLE_PLANE, "PLANE", 0, "Plane", ""},
544 {0, nullptr, 0, nullptr, nullptr},
545 };
546 static const EnumPropertyItem rna_enum_draw_options_items[] = {
547 {ED_GIZMO_ARROW_DRAW_FLAG_STEM, "STEM", 0, "Stem", ""},
548 {ED_GIZMO_ARROW_DRAW_FLAG_ORIGIN, "ORIGIN", 0, "Origin", ""},
549 {0, nullptr, 0, nullptr, nullptr},
550 };
551 static const EnumPropertyItem rna_enum_transform_items[] = {
552 {ED_GIZMO_ARROW_XFORM_FLAG_INVERTED, "INVERT", 0, "Inverted", ""},
553 {ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED, "CONSTRAIN", 0, "Constrained", ""},
554 {0, nullptr, 0, nullptr, nullptr},
555 };
556
557 RNA_def_enum(gzt->srna,
558 "draw_style",
559 rna_enum_draw_style_items,
561 "Draw Style",
562 "");
564 "draw_options",
565 rna_enum_draw_options_items,
567 "Draw Options",
568 "");
569 RNA_def_enum_flag(gzt->srna, "transform", rna_enum_transform_items, 0, "Transform", "");
570
572 gzt->srna, "length", 1.0f, -FLT_MAX, FLT_MAX, "Arrow Line Length", "", -FLT_MAX, FLT_MAX);
574 gzt->srna, "aspect", 2, nullptr, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX);
575
577}
578
583
wmWindow * CTX_wm_window(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
#define BLI_assert(a)
Definition BLI_assert.h:50
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:57
MINLINE float square_f(float a)
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])
#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 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)
#define UI_SCALE_FAC
@ OPERATOR_RUNNING_MODAL
@ ED_GIZMO_ARROW_DRAW_FLAG_ORIGIN
@ ED_GIZMO_ARROW_DRAW_FLAG_STEM
@ ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED
@ ED_GIZMO_ARROW_XFORM_FLAG_INVERTED
@ 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
void ED_region_tag_redraw_editor_overlays(ARegion *region)
Definition area.cc:669
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(eGPUBuiltinShader 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:175
@ GPU_BLEND_NONE
Definition GPU_state.hh:85
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:87
void GPU_blend(eGPUBlend blend)
Definition gpu_state.cc:42
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:262
@ 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 Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves 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 Invert a color
@ PROP_FLOAT
Definition RNA_types.hh:67
#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 int gizmo_arrow_invoke(bContext *, wmGizmo *gz, const wmEvent *event)
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)
#define ARROW_SELECT_THRESHOLD_PX
void ED_gizmo_arrow3d_set_range_fac(wmGizmo *gz, const float range_fac)
static int gizmo_arrow_modal(bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak tweak_flag)
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
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
#define acosf(x)
int len
draw_view in_light_buf[] float
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)
void gizmo_property_value_reset(bContext *C, const wmGizmo *gz, GizmoInteraction *inter, wmGizmoProperty *gz_prop)
void *(* MEM_callocN)(size_t len, const char *str)
Definition mallocn.cc:42
ccl_device_inline float4 select(const int4 mask, const float4 a, const float4 b)
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.c:32
#define FLT_MAX
Definition stdcycles.h:14
void * regiondata
GizmoCommonData data
GizmoInteraction inter
float viewinv[4][4]
int mval[2]
Definition WM_types.hh:728
short type
Definition WM_types.hh:722
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
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.cc:569
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 *))