Blender V5.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_geom_c.hh"
21#include "BLI_math_matrix_c.hh"
24#include "BLI_utildefines.hh"
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_transform.hh"
47#include "ED_view3d.hh"
48
49/* own includes */
50#include "../gizmo_geometry.h"
52
53namespace blender {
54
55// /** To use custom arrows exported to `geom_arrow_gizmo.cc`. */
56// #define USE_GIZMO_CUSTOM_ARROWS
57
58/* Margin to add when selecting the arrow. */
59#define ARROW_SELECT_THRESHOLD_PX (5)
60
65
70
71/* -------------------------------------------------------------------- */
72
73static void gizmo_arrow_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4])
74{
75 ArrowGizmo3D *arrow = reinterpret_cast<ArrowGizmo3D *>(const_cast<wmGizmo *>(gz));
76
77 copy_m4_m4(r_matrix, arrow->gizmo.matrix_basis);
78 madd_v3_v3fl(r_matrix[3], arrow->gizmo.matrix_basis[2], arrow->data.offset);
79}
80
81static void arrow_draw_geom(const ArrowGizmo3D *arrow,
82 const bool select,
83 const float color[4],
84 const float arrow_length)
85{
86 uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32_32);
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
92
93 float viewport[4];
95 immUniform2fv("viewportSize", &viewport[2]);
96
97 if (draw_style == ED_GIZMO_ARROW_STYLE_CROSS) {
98 immUniform1f("lineWidth", U.pixelsize + WM_gizmo_select_bias(select));
100
102 immVertex3f(pos, -1.0f, 0.0f, 0.0f);
103 immVertex3f(pos, 1.0f, 0.0f, 0.0f);
104 immVertex3f(pos, 0.0f, -1.0f, 0.0f);
105 immVertex3f(pos, 0.0f, 1.0f, 0.0f);
106 immEnd();
107 }
108 else if (draw_style == ED_GIZMO_ARROW_STYLE_CONE) {
109 float aspect[2];
110 RNA_float_get_array(arrow->gizmo.ptr, "aspect", aspect);
111 const float unitx = aspect[0];
112 const float unity = aspect[1];
113 const float vec[4][3] = {
114 {-unitx, -unity, 0},
115 {unitx, -unity, 0},
116 {unitx, unity, 0},
117 {-unitx, unity, 0},
118 };
119
120 immUniform1f("lineWidth",
121 (arrow->gizmo.line_width * U.pixelsize) + WM_gizmo_select_bias(select));
123 }
124 else if (draw_style == ED_GIZMO_ARROW_STYLE_PLANE) {
125 /* Increase the size a bit during selection. These are relatively easy to hit. */
126 const float scale = select ? 0.15f : 0.1f;
127 const float verts[4][3] = {
128 {0, 0, 0},
129 {scale, 0, scale},
130 {0, 0, 2 * scale},
131 {-scale, 0, scale},
132 };
133
134 const float color_inner[4] = {UNPACK3(color), color[3] * 0.5f};
135
136 /* Translate to line end. */
138 GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length);
139
140 immUniform1f("lineWidth",
141 (arrow->gizmo.line_width * U.pixelsize) + WM_gizmo_select_bias(select));
143
146 wm_gizmo_vec_draw(color_inner, verts, ARRAY_SIZE(verts), pos, GPU_PRIM_TRI_FAN);
148 }
149 else {
150#ifdef USE_GIZMO_CUSTOM_ARROWS
152#else
153 const float vec[2][3] = {
154 {0.0f, 0.0f, 0.0f},
155 {0.0f, 0.0f, arrow_length},
156 };
157
158 if (draw_options & ED_GIZMO_ARROW_DRAW_FLAG_STEM) {
159 immUniform1f("lineWidth",
160 (arrow->gizmo.line_width * U.pixelsize) + WM_gizmo_select_bias(select));
162 }
163 else {
165 }
166
167 /* *** draw arrow head *** */
168
170
171 /* NOTE: ideally #ARROW_SELECT_THRESHOLD_PX would be added here, however adding a
172 * margin in pixel space isn't so simple, nor is it as important as for the arrow stem. */
173 if (draw_style == ED_GIZMO_ARROW_STYLE_BOX) {
174 /* Increase the size during selection so it is wider than other lines. */
175 const float size = select ? 0.11f : 0.05f;
176
177 /* translate to line end with some extra offset so box starts exactly where line ends */
178 GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length + size);
179 /* scale down to box size */
180 GPU_matrix_scale_3f(size, size, size);
181
182 /* draw cube */
184 unbind_shader = false;
186 }
187 else {
189
190 /* Increase the size during selection, but mostly wider. */
191 const float len = select ? 0.35f : 0.25f;
192 const float width = select ? 0.12f : 0.06f;
193
194 /* translate to line end */
195 GPU_matrix_translate_3f(0.0f, 0.0f, arrow_length);
196
200
201 imm_draw_circle_fill_3d(pos, 0.0, 0.0, width, 8);
202 imm_draw_cylinder_fill_3d(pos, width, 0.0, len, 8, 1);
203 }
204
206#endif /* USE_GIZMO_CUSTOM_ARROWS */
207 }
208
209 if (unbind_shader) {
211 }
212
213 if (draw_options & ED_GIZMO_ARROW_DRAW_FLAG_ORIGIN) {
214 const float point_size = 10 * U.pixelsize;
217 immUniform1f("size", point_size);
220 immVertex3f(pos, 0.0f, 0.0f, 0.0f);
221 immEnd();
224 }
225}
226
227static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool highlight)
228{
229 wmGizmo *gz = &arrow->gizmo;
230 const float arrow_length = RNA_float_get(gz->ptr, "length");
231 float color[4];
232 float matrix_final[4][4];
233
234 gizmo_color_get(gz, highlight, color);
235
236 WM_gizmo_calc_matrix_final(gz, matrix_final);
237
239 GPU_matrix_mul(matrix_final);
241 arrow_draw_geom(arrow, select, color, arrow_length);
243
245
246 if (gz->interaction_data) {
247 ArrowGizmoInteraction *arrow_inter = static_cast<ArrowGizmoInteraction *>(
248 gz->interaction_data);
249
252
254 arrow_draw_geom(arrow, select, float4{0.5f, 0.5f, 0.5f, 0.5f}, arrow_inter->init_arrow_length);
256
258 }
259}
260
261static void gizmo_arrow_draw_select(const bContext * /*C*/, wmGizmo *gz, int select_id)
262{
263 GPU_select_load_id(select_id);
264 arrow_draw_intern(reinterpret_cast<ArrowGizmo3D *>(gz), true, false);
265}
266
267static void gizmo_arrow_draw(const bContext * /*C*/, wmGizmo *gz)
268{
270 reinterpret_cast<ArrowGizmo3D *>(gz), false, (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0);
271}
272
276static int gizmo_arrow_test_select(bContext * /*C*/, wmGizmo *gz, const int mval[2])
277{
278 /* This following values are based on manual inspection of `verts[]` defined in
279 * `geom_arrow_gizmo.cc`. */
280 const float head_center_z = (0.974306f + 1.268098f) / 2;
281 const float head_geo_x = 0.051304f;
282 const float stem_geo_x = 0.012320f;
283
284 /* Project into 2D space since it simplifies pixel threshold tests. */
285 ArrowGizmo3D *arrow = reinterpret_cast<ArrowGizmo3D *>(gz);
286 const float arrow_length = RNA_float_get(arrow->gizmo.ptr, "length") * head_center_z;
287
288 float matrix_final[4][4];
289 WM_gizmo_calc_matrix_final(gz, matrix_final);
290
291 /* Arrow in pixel space. */
292 const float arrow_start[2] = {matrix_final[3][0], matrix_final[3][1]};
293 float arrow_end[2];
294 {
295 float co[3] = {0, 0, arrow_length};
296 mul_m4_v3(matrix_final, co);
297 copy_v2_v2(arrow_end, co);
298 }
299
300 const float scale_final = mat4_to_scale(matrix_final);
301 const float head_width = ARROW_SELECT_THRESHOLD_PX * scale_final * head_geo_x;
302 const float stem_width = ARROW_SELECT_THRESHOLD_PX * scale_final * stem_geo_x;
303 float select_threshold_base = gz->line_width * U.pixelsize;
304
305 const float mval_fl[2] = {float(mval[0]), float(mval[1])};
306
307 /* Distance to arrow head. */
308 if (len_squared_v2v2(mval_fl, arrow_end) < square_f(select_threshold_base + head_width)) {
309 return 0;
310 }
311
312 /* Distance to arrow stem. */
313 float co_isect[2];
314 const float lambda = closest_to_line_v2(co_isect, mval_fl, arrow_start, arrow_end);
315 /* Clamp inside the line, to avoid overlapping with other gizmos,
316 * especially around the start of the arrow. */
317 if (lambda >= 0.0f && lambda <= 1.0f) {
318 if (len_squared_v2v2(mval_fl, co_isect) < square_f(select_threshold_base + stem_width)) {
319 return 0;
320 }
321 }
322
323 return -1;
324}
325
331 wmGizmo *gz,
332 const wmEvent *event,
333 eWM_GizmoFlagTweak tweak_flag)
334{
335 GizmoInteraction *inter = static_cast<GizmoInteraction *>(gz->interaction_data);
336
337 /* Can happen if another (e.g. Python-based) modal operator finishes, see #151241. */
338 if (inter == nullptr) {
339 return OPERATOR_CANCELLED;
340 }
341
342 if (event->type != MOUSEMOVE) {
344 }
345 ArrowGizmo3D *arrow = reinterpret_cast<ArrowGizmo3D *>(gz);
346 ARegion *region = CTX_wm_region(C);
347 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
348
349 float offset[3];
350 float facdir = 1.0f;
351
352 /* A pair: (source, destination). */
353 struct {
354 float2 mval;
355 float ray_origin[3], ray_direction[3];
356 float location[3];
357 } proj[2] = {};
358
359 proj[0].mval = {UNPACK2(inter->init_mval)};
360 proj[1].mval = {float(event->mval[0]), float(event->mval[1])};
361
362 float arrow_co[3];
363 float arrow_no[3];
364 copy_v3_v3(arrow_co, inter->init_matrix_basis[3]);
365 normalize_v3_v3(arrow_no, arrow->gizmo.matrix_basis[2]);
366
367 int ok = 0;
368
369 for (int j = 0; j < 2; j++) {
370 ED_view3d_win_to_ray(region, proj[j].mval, proj[j].ray_origin, proj[j].ray_direction);
371 /* Force Y axis if we're view aligned */
372 if (j == 0) {
373 if (RAD2DEGF(acosf(dot_v3v3(proj[j].ray_direction, arrow->gizmo.matrix_basis[2]))) < 5.0f) {
374 normalize_v3_v3(arrow_no, rv3d->viewinv[1]);
375 }
376 }
377
378 float arrow_no_proj[3];
379 project_plane_v3_v3v3(arrow_no_proj, arrow_no, proj[j].ray_direction);
380 normalize_v3(arrow_no_proj);
381
382 float lambda;
383 if (isect_ray_plane_v3_factor(arrow_co, arrow_no, proj[j].ray_origin, arrow_no_proj, &lambda))
384 {
385 madd_v3_v3v3fl(proj[j].location, arrow_co, arrow_no, lambda);
386 ok++;
387 }
388 }
389
390 if (ok != 2) {
392 }
393
394 sub_v3_v3v3(offset, proj[1].location, proj[0].location);
395 facdir = dot_v3v3(arrow_no, offset) < 0.0f ? -1 : 1;
396
397 GizmoCommonData *data = &arrow->data;
398 const float ofs_new = facdir * len_v3(offset);
399
400 wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
401
402 /* set the property for the operator and call its modal function */
404 const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
405 const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
406 const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
407 const bool use_precision = (tweak_flag & WM_GIZMO_TWEAK_PRECISE) != 0;
408 float value = gizmo_value_from_offset(
409 data, inter, ofs_new, constrained, inverted, use_precision);
410
411 if (tweak_flag & WM_GIZMO_TWEAK_SNAP) {
412 const float incremental_snap_step = RNA_float_get(gz->ptr, "incremental_snap_step");
413 value = roundf(value / incremental_snap_step) * incremental_snap_step;
414 }
415 WM_gizmo_target_property_float_set(C, gz, gz_prop, value);
416 /* get clamped value */
417 value = WM_gizmo_target_property_float_get(gz, gz_prop);
418
419 data->offset = gizmo_offset_from_value(data, value, constrained, inverted);
420 }
421 else {
422 data->offset = ofs_new;
423 }
424
425 /* tag the region for redraw */
427
429}
430
432{
433 ArrowGizmo3D *arrow = reinterpret_cast<ArrowGizmo3D *>(gz);
434
436
437 arrow->data.range_fac = 1.0f;
438}
439
441{
442 ArrowGizmo3D *arrow = reinterpret_cast<ArrowGizmo3D *>(gz);
444 GizmoInteraction *inter = &arrow_inter->inter;
445 wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
446
447 /* Some gizmos don't use properties. */
450 }
451
452 inter->init_offset = arrow->data.offset;
453
454 inter->init_mval[0] = event->mval[0];
455 inter->init_mval[1] = event->mval[1];
456
459
460 arrow_inter->init_arrow_length = RNA_float_get(gz->ptr, "length");
461
462 gz->interaction_data = arrow_inter;
463
465}
466
468{
469 ArrowGizmo3D *arrow = reinterpret_cast<ArrowGizmo3D *>(gz);
470 const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
471 const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
472 const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
473 gizmo_property_data_update(gz, &arrow->data, gz_prop, constrained, inverted);
474}
475
476static void gizmo_arrow_exit(bContext *C, wmGizmo *gz, const bool cancel)
477{
478 ArrowGizmo3D *arrow = reinterpret_cast<ArrowGizmo3D *>(gz);
479 GizmoCommonData *data = &arrow->data;
480 wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
481 const bool is_prop_valid = WM_gizmo_target_property_is_valid(gz_prop);
482
483 if (cancel) {
484 GizmoInteraction *inter = static_cast<GizmoInteraction *>(gz->interaction_data);
485 /* Can happen if another (e.g. Python-based) modal operator finishes, see #151241. */
486 if (inter == nullptr) {
487 return;
488 }
489 if (is_prop_valid) {
490 gizmo_property_value_reset(C, gz, inter, gz_prop);
491 }
492 data->offset = inter->init_offset;
493 }
494 else {
495 /* Assign in case applying the operation needs an updated offset
496 * edit-mesh bisect needs this. */
497 if (is_prop_valid) {
498 const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform");
499 const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0;
500 const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0;
501 const float value = WM_gizmo_target_property_float_get(gz, gz_prop);
502 data->offset = gizmo_offset_from_value(data, value, constrained, inverted);
503 }
504 }
505
506 if (!cancel) {
507 if (is_prop_valid) {
509 }
510 }
511}
512
513/* -------------------------------------------------------------------- */
516
517void ED_gizmo_arrow3d_set_ui_range(wmGizmo *gz, const float min, const float max)
518{
519 ArrowGizmo3D *arrow = reinterpret_cast<ArrowGizmo3D *>(gz);
520
521 BLI_assert(min < max);
523 "Make sure this function is called before WM_gizmo_target_property_def_rna");
524
525 arrow->data.range = max - min;
526 arrow->data.min = min;
527 arrow->data.max = max;
528 arrow->data.is_custom_range_set = true;
529}
530
531void ED_gizmo_arrow3d_set_range_fac(wmGizmo *gz, const float range_fac)
532{
533 ArrowGizmo3D *arrow = reinterpret_cast<ArrowGizmo3D *>(gz);
535 "Make sure this function is called before WM_gizmo_target_property_def_rna");
536
537 arrow->data.range_fac = range_fac;
538}
539
541{
542 ArrowGizmo3D *arrow = reinterpret_cast<ArrowGizmo3D *>(gz);
543 arrow->data.offset = 0.0f;
544}
545
547{
548 /* identifiers */
549 gzt->idname = "GIZMO_GT_arrow_3d";
550
551 /* API callbacks. */
552 gzt->draw = gizmo_arrow_draw;
560 gzt->exit = gizmo_arrow_exit;
561
562 gzt->struct_size = sizeof(ArrowGizmo3D);
563
564 /* rna */
565 static const EnumPropertyItem rna_enum_draw_style_items[] = {
566 {ED_GIZMO_ARROW_STYLE_NORMAL, "NORMAL", 0, "Normal", ""},
567 {ED_GIZMO_ARROW_STYLE_CROSS, "CROSS", 0, "Cross", ""},
568 {ED_GIZMO_ARROW_STYLE_BOX, "BOX", 0, "Box", ""},
569 {ED_GIZMO_ARROW_STYLE_CONE, "CONE", 0, "Cone", ""},
570 {ED_GIZMO_ARROW_STYLE_PLANE, "PLANE", 0, "Plane", ""},
571 {0, nullptr, 0, nullptr, nullptr},
572 };
573 static const EnumPropertyItem rna_enum_draw_options_items[] = {
574 {ED_GIZMO_ARROW_DRAW_FLAG_STEM, "STEM", 0, "Stem", ""},
575 {ED_GIZMO_ARROW_DRAW_FLAG_ORIGIN, "ORIGIN", 0, "Origin", ""},
576 {0, nullptr, 0, nullptr, nullptr},
577 };
578 static const EnumPropertyItem rna_enum_transform_items[] = {
579 {ED_GIZMO_ARROW_XFORM_FLAG_INVERTED, "INVERT", 0, "Inverted", ""},
580 {ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED, "CONSTRAIN", 0, "Constrained", ""},
581 {0, nullptr, 0, nullptr, nullptr},
582 };
583
584 RNA_def_enum(gzt->srna,
585 "draw_style",
586 rna_enum_draw_style_items,
588 "Draw Style",
589 "");
591 "draw_options",
592 rna_enum_draw_options_items,
594 "Draw Options",
595 "");
596 RNA_def_enum_flag(gzt->srna, "transform", rna_enum_transform_items, 0, "Transform", "");
597
599 gzt->srna, "length", 1.0f, -FLT_MAX, FLT_MAX, "Arrow Line Length", "", -FLT_MAX, FLT_MAX);
601 gzt->srna, "aspect", 2, nullptr, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX);
602 RNA_def_float(gzt->srna,
603 "incremental_snap_step",
605 0.0f,
606 FLT_MAX,
607 "Incremental snap step",
608 "Offset to snap in steps",
609 0.0f,
610 FLT_MAX);
612}
613
618
620
621} // namespace blender
#define RAD2DEGF(_rad)
#define SNAP_INCREMENTAL_SNAP_STEP
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define ARROW_SELECT_THRESHOLD_PX
#define UNPACK2(a)
#define UNPACK3(a)
#define BLI_assert_msg(a, msg)
btScalar max
#define acosf(x)
#define roundf(x)
#define FLT_MAX
#define point_size
float3x3 scale(float3x3 mat, float2 scale)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
ccl_device_inline float3x3 inverted(const float3x3 m)
BMesh Iterators.
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)
void ED_gizmotypes_arrow_3d()
float gizmo_offset_from_value(GizmoCommonData *data, float value, bool constrained, bool inverted)
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static wmOperatorStatus gizmo_arrow_invoke(bContext *, wmGizmo *gz, const wmEvent *event)
static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool highlight)
static void gizmo_arrow_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop)
void wm_gizmo_geometryinfo_draw(const GizmoGeomInfo *info, const bool, const float color[4])
static void gizmo_arrow_draw_select(const bContext *, wmGizmo *gz, int select_id)
void ED_gizmo_arrow3d_set_range_fac(wmGizmo *gz, const float range_fac)
int RNA_enum_get(PointerRNA *ptr, const char *name)
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()
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
void imm_draw_cylinder_fill_3d(uint pos, float base, float top, float height, int slices, int stacks)
bool GPU_select_load_id(unsigned int id)
GizmoGeomInfo wm_gizmo_geom_data_cube
static int gizmo_arrow_test_select(bContext *, wmGizmo *gz, const int mval[2])
void WM_gizmotype_append(void(*gtfunc)(wmGizmoType *))
float mat4_to_scale(const float mat[4][4])
void ED_gizmo_arrow3d_reset_offset(wmGizmo *gz)
MINLINE void copy_v2_v2(float r[2], const float a[2])
GPUVertFormat * immVertexFormat()
void WM_gizmo_target_property_anim_autokey(bContext *C, const wmGizmo *, wmGizmoProperty *gz_prop)
void GPU_matrix_scale_3f(float x, float y, float z)
void immBegin(GPUPrimType, uint vertex_len)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
static void gizmo_arrow_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4])
@ GPU_PRIM_LINE_STRIP
@ GPU_PRIM_LINE_LOOP
@ ED_GIZMO_ARROW_DRAW_FLAG_ORIGIN
@ ED_GIZMO_ARROW_DRAW_FLAG_STEM
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
Definition wm_gizmo.cc:569
void immUniformColor4fv(const float rgba[4])
void WM_gizmotype_target_property_def(wmGizmoType *gzt, const char *idname, int data_type, int array_length)
static wmOperatorStatus gizmo_arrow_modal(bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak tweak_flag)
void ED_region_tag_redraw_editor_overlays(ARegion *region)
Definition area.cc:745
void immUnbindProgram()
static void gizmo_arrow_setup(wmGizmo *gz)
void GPU_matrix_mul(const float m[4][4])
void WM_gizmo_target_property_float_set(bContext *C, const wmGizmo *gz, wmGizmoProperty *gz_prop, const float value)
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)
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
static void gizmo_arrow_draw(const bContext *, wmGizmo *gz)
VecBase< float, 4 > float4
static float WM_gizmo_select_bias(bool select)
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void mul_m4_v3(const float M[4][4], float r[3])
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
VecBase< float, 2 > float2
void immUniform1f(const char *name, float x)
void wm_gizmo_vec_draw(const float color[4], const float(*verts)[3], uint vert_count, uint pos, uint primitive_type)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
float gizmo_value_from_offset(GizmoCommonData *data, GizmoInteraction *inter, float offset, bool constrained, bool inverted, bool use_precision)
eWM_GizmoFlagTweak
Gizmo tweak flag. Bit-flag passed to gizmo while tweaking.
@ WM_GIZMO_TWEAK_PRECISE
@ ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED
@ ED_GIZMO_ARROW_XFORM_FLAG_INVERTED
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:258
BMesh const char void * data
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
@ GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA
wmGizmoProperty * WM_gizmo_target_property_find(wmGizmo *gz, const char *idname)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
bool WM_gizmo_target_property_is_valid(const wmGizmoProperty *gz_prop)
void GPU_program_point_size(bool enable)
Definition gpu_state.cc:165
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
void gizmo_color_get(const wmGizmo *gz, bool highlight, float r_color[4])
void imm_draw_circle_fill_3d(uint pos, float x, float y, float radius, int nsegments)
static void gizmo_arrow_exit(bContext *C, wmGizmo *gz, const bool cancel)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
static void GIZMO_GT_arrow_3d(wmGizmoType *gzt)
@ ED_GIZMO_ARROW_STYLE_CONE
@ ED_GIZMO_ARROW_STYLE_NORMAL
@ ED_GIZMO_ARROW_STYLE_CROSS
@ ED_GIZMO_ARROW_STYLE_PLANE
@ ED_GIZMO_ARROW_STYLE_BOX
void project_plane_v3_v3v3(float out[3], const float p[3], const float v_plane[3])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
void gizmo_property_data_update(wmGizmo *gz, GizmoCommonData *data, wmGizmoProperty *gz_prop, bool constrained, bool inverted)
@ WM_GIZMO_DRAW_MODAL
MINLINE float normalize_v3(float n[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
@ WM_GIZMO_STATE_HIGHLIGHT
void ED_gizmo_arrow3d_set_ui_range(wmGizmo *gz, const float min, const float max)
float closest_to_line_v2(float r_close[2], const float p[2], const float l1[2], const float l2[2])
MINLINE float square_f(float a)
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)
void immUniform2fv(const char *name, const float data[2])
void immVertex3f(uint attr_id, float x, float y, float z)
static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const float color[4], const float arrow_length)
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void GPU_matrix_translate_3f(float x, float y, float z)
MINLINE float len_squared_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT
void GPU_matrix_pop()
GizmoGeomInfo wm_gizmo_geom_data_arrow
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)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void gizmo_property_value_reset(bContext *C, const wmGizmo *gz, GizmoInteraction *inter, wmGizmoProperty *gz_prop)
ARegion * CTX_wm_region(const bContext *C)
float RNA_float_get(PointerRNA *ptr, const char *name)
void GPU_matrix_push()
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
float WM_gizmo_target_property_float_get(const wmGizmo *gz, wmGizmoProperty *gz_prop)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
GizmoCommonData data
wmEventType type
Definition WM_types.hh:817
wmGizmoFnInvoke invoke
wmGizmoFnDrawSelect draw_select
wmGizmoFnMatrixBasisGet matrix_basis_get
wmGizmoFnPropertyUpdate property_update
wmGizmoFnTestSelect test_select
float matrix_basis[4][4]
eWM_GizmoFlag flag
eWM_GizmoFlagState state