Blender V5.0
cage3d_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
15
16#include "MEM_guardedalloc.h"
17
18#include "BLI_math_matrix.h"
19#include "BLI_math_vector.h"
21
22#include "BKE_context.hh"
23
24#include "GPU_immediate.hh"
25#include "GPU_immediate_util.hh"
26#include "GPU_matrix.hh"
27#include "GPU_select.hh"
28#include "GPU_state.hh"
29
30#include "RNA_access.hh"
31#include "RNA_define.hh"
32
33#include "WM_api.hh"
34#include "WM_types.hh"
35
36#include "ED_gizmo_library.hh"
37#include "ED_screen.hh"
38#include "ED_view3d.hh"
39
40/* own includes */
42
43#define GIZMO_MARGIN_OFFSET_SCALE 1.5f
44
46 float orig_matrix_final_no_offset[4][4],
47 bool use_space)
48{
49 float mat_identity[4][4];
50 WM_GizmoMatrixParams params = {nullptr};
51 unit_m4(mat_identity);
52 if (use_space == false) {
53 params.matrix_basis = mat_identity;
54 }
55 params.matrix_offset = mat_identity;
56 WM_gizmo_calc_matrix_final_params(gz, &params, orig_matrix_final_no_offset);
57}
58
59static void gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[3], float scale[3])
60{
61 UNUSED_VARS(dims);
62
63 /* Unlike cage2d, no need to correct for aspect. */
64 float matrix_final_no_offset[4][4];
65
66 float x_axis[3], y_axis[3], z_axis[3];
67 gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset, false);
68 mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, gz->matrix_offset[0]);
69 mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, gz->matrix_offset[1]);
70 mul_v3_mat3_m4v3(z_axis, matrix_final_no_offset, gz->matrix_offset[2]);
71
72 scale[0] = 1.0f / len_v3(x_axis);
73 scale[1] = 1.0f / len_v3(y_axis);
74 scale[2] = 1.0f / len_v3(z_axis);
75}
76
77static void gizmo_calc_rect_view_margin(const wmGizmo *gz, const float dims[3], float margin[3])
78{
79 const float handle_size = 9.0f;
80 /* XXX, the scale isn't taking offset into account, we need to calculate scale per handle! */
81 // handle_size *= gz->scale_final;
82
83 float scale_xyz[3];
84 gizmo_calc_rect_view_scale(gz, dims, scale_xyz);
85 margin[0] = (handle_size * scale_xyz[0]);
86 margin[1] = (handle_size * scale_xyz[1]);
87 margin[2] = (handle_size * scale_xyz[2]);
88}
89
90/* -------------------------------------------------------------------- */
91
93 float r_pt[3],
94 bool r_constrain_axis[3],
95 bool has_translation)
96{
99 {
101 int range[3];
102 range[2] = index % 3;
103 index = index / 3;
104 range[1] = index % 3;
105 index = index / 3;
106 range[0] = index % 3;
107
108 const float sign[3] = {0.5f, 0.0f, -0.5f};
109 for (int i = 0; i < 3; i++) {
110 r_pt[i] = has_translation ? sign[range[i]] : 0.0f;
111 r_constrain_axis[i] = (range[i] == 1);
112 }
113 }
114}
115
116/* -------------------------------------------------------------------- */
121
122static void cage3d_draw_box_corners(const float r[3],
123 const float margin[3],
124 const float color[3],
125 const float line_width)
126{
128 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32_32);
129 UNUSED_VARS(margin);
130
132 immUniformColor3fv(color);
133
134 float viewport[4];
135 GPU_viewport_size_get_f(viewport);
136 immUniform2fv("viewportSize", &viewport[2]);
137 immUniform1f("lineWidth", line_width * U.pixelsize);
138
140
142}
143
145 const float matrix_final[4][4],
146 const float color[4],
147 const int highlighted,
148 const float size[3],
149 const float margin[3])
150{
153 {
154 int index = (highlighted - ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z);
155 int range[3];
156 range[2] = index % 3;
157 index = index / 3;
158 range[1] = index % 3;
159 index = index / 3;
160 range[0] = index % 3;
161
162 const float sign[3] = {-1.0f, 0.0f, 1.0f};
163 float co[3];
164
165 for (int i = 0; i < 3; i++) {
166 co[i] = size[i] * sign[range[i]];
167 }
168 const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3};
169 float co_test[3];
170 mul_v3_m4v3(co_test, matrix_final, co);
171 float rad_scale[3];
172 mul_v3_v3fl(rad_scale, rad, ED_view3d_pixel_size(rv3d, co_test));
173
174 {
176 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32_32);
178 immUniformColor3fv(color);
179 imm_draw_cube_fill_3d(pos, co, rad_scale);
181 }
182 }
183}
184
186
187/* -------------------------------------------------------------------- */
192
193static void imm_draw_point_aspect_3d(uint pos, const float co[3], const float rad[3], bool solid)
194{
195 if (solid) {
196 imm_draw_cube_fill_3d(pos, co, rad);
197 }
198 else {
199 imm_draw_cube_wire_3d(pos, co, rad);
200 }
201}
202
203static void cage3d_draw_circle_wire(const float r[3],
204 const float margin[3],
205 const float color[3],
206 const int transform_flag,
207 const int draw_options,
208 const float line_width)
209{
211 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32_32);
212
214 immUniformColor3fv(color);
215
216 float viewport[4];
217 GPU_viewport_size_get_f(viewport);
218 immUniform2fv("viewportSize", &viewport[2]);
219 immUniform1f("lineWidth", line_width * U.pixelsize);
220
222
223#if 0
224 if (transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_TRANSLATE) {
226 const float rad[2] = {margin[0] / 2, margin[1] / 2};
227 const float center[2] = {0.0f, 0.0f};
228
230 immVertex2f(pos, center[0] - rad[0], center[1] - rad[1]);
231 immVertex2f(pos, center[0] + rad[0], center[1] + rad[1]);
232 immVertex2f(pos, center[0] + rad[0], center[1] - rad[1]);
233 immVertex2f(pos, center[0] - rad[0], center[1] + rad[1]);
234 immEnd();
235 }
236 }
237#else
238 UNUSED_VARS(margin, transform_flag, draw_options);
239#endif
240
242}
243
245 const float matrix_final[4][4],
246 const float r[3],
247 const float margin[3],
248 const float color[3],
249 bool solid,
250 const float handle_scale)
251{
253 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32_32);
254 const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3};
255
257 immUniformColor3fv(color);
258
259 const float sign[3] = {-1.0f, 0.0f, 1.0f};
260 for (int x = 0; x < 3; x++) {
261 for (int y = 0; y < 3; y++) {
262 for (int z = 0; z < 3; z++) {
263 if (x == 1 && y == 1 && z == 1) {
264 continue;
265 }
266 const float co[3] = {r[0] * sign[x], r[1] * sign[y], r[2] * sign[z]};
267 float co_test[3];
268 mul_v3_m4v3(co_test, matrix_final, co);
269 float rad_scale[3];
270 mul_v3_v3fl(rad_scale, rad, ED_view3d_pixel_size(rv3d, co_test) * handle_scale);
271 imm_draw_point_aspect_3d(pos, co, rad_scale, solid);
272 }
273 }
274 }
275
277}
278
280
282 RegionView3D *rv3d, wmGizmo *gz, const bool select, const bool highlight, const int select_id)
283{
284 // const bool use_clamp = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0;
285 float dims[3];
286 RNA_float_get_array(gz->ptr, "dimensions", dims);
287 float matrix_final[4][4];
288
289 const int transform_flag = RNA_enum_get(gz->ptr, "transform");
290 const int draw_style = RNA_enum_get(gz->ptr, "draw_style");
291 const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
292
293 const float size_real[3] = {dims[0] / 2.0f, dims[1] / 2.0f, dims[2] / 2.0f};
294
295 WM_gizmo_calc_matrix_final(gz, matrix_final);
296
298 GPU_matrix_mul(matrix_final);
299
300 float margin[3];
301 gizmo_calc_rect_view_margin(gz, dims, margin);
302
303 /* Handy for quick testing draw (if it's outside bounds). */
304 if (false) {
307 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32_32);
309 immUniformColor4f(1, 1, 1, 0.5f);
310 float s = 0.5f;
311 immRectf(pos, -s, -s, s, s);
314 }
315
316 if (select) {
317/* Expand for hot-spot. */
318#if 0
319 const float size[3] = {
320 size_real[0] + margin[0] / 2,
321 size_real[1] + margin[1] / 2,
322 size_real[2] + margin[2] / 2,
323 };
324#else
325 /* just use same value for now. */
326 const float size[3] = {UNPACK3(size_real)};
327#endif
328
329 if (transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_SCALE) {
332 i++)
333 {
335 continue;
336 }
337 GPU_select_load_id(select_id | i);
338 cage3d_draw_box_interaction(rv3d, matrix_final, gz->color, i, size, margin);
339 }
340 }
341 if (transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_TRANSLATE) {
342 const int transform_part = ED_GIZMO_CAGE3D_PART_TRANSLATE;
343 GPU_select_load_id(select_id | transform_part);
344 cage3d_draw_box_interaction(rv3d, matrix_final, gz->color, transform_part, size, margin);
345 }
346 }
347 else {
348#if 0
349 rctf _r {}
350 _r.xmin = -size_real[0];
351 _r.ymin = -size_real[1];
352 _r.xmax = size_real[0];
353 _r.ymax = size_real[1];
354#endif
355 if (draw_style == ED_GIZMO_CAGE3D_STYLE_BOX) {
356 float color[4], black[3] = {0, 0, 0};
357 gizmo_color_get(gz, highlight, color);
358
359 /* corner gizmos */
360 cage3d_draw_box_corners(size_real, margin, black, gz->line_width + 3.0f);
361
362 /* corner gizmos */
363 cage3d_draw_box_corners(size_real, margin, color, gz->line_width);
364
365 bool show = false;
367 /* Only show if we're drawing the center handle
368 * otherwise the entire rectangle is the hot-spot. */
370 show = true;
371 }
372 }
373 else {
374 show = true;
375 }
376
377 if (show) {
379 rv3d, matrix_final, gz->color, gz->highlight_part, size_real, margin);
380 }
381 }
382 else if (draw_style == ED_GIZMO_CAGE3D_STYLE_CIRCLE) {
383 float color[4], black[3] = {0, 0, 0};
384 gizmo_color_get(gz, highlight, color);
385
387
389 size_real, margin, black, transform_flag, draw_options, gz->line_width + 3.0f);
391 size_real, margin, color, transform_flag, draw_options, gz->line_width);
392
393 /* Corner gizmos (draw the outer & inner so there is a visible outline). */
394 GPU_polygon_smooth(true);
395 cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, black, true, 1.0f);
396 cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, color, true, 1.0f / 1.5f);
397 GPU_polygon_smooth(false);
398
400 }
401 else {
402 BLI_assert(0);
403 }
404 }
405
407}
408
412static void gizmo_cage3d_draw_select(const bContext *C, wmGizmo *gz, int select_id)
413{
414 ARegion *region = CTX_wm_region(C);
415 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
416 gizmo_cage3d_draw_intern(rv3d, gz, true, false, select_id);
417}
418
419static void gizmo_cage3d_draw(const bContext *C, wmGizmo *gz)
420{
421 ARegion *region = CTX_wm_region(C);
422 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
423 const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
424 gizmo_cage3d_draw_intern(rv3d, gz, false, is_highlight, -1);
425}
426
428{
431 }
432
433 return WM_CURSOR_DEFAULT;
434}
435
436namespace {
437
438struct RectTransformInteraction {
439 float orig_mouse[3];
440 float orig_matrix_offset[4][4];
441 float orig_matrix_final_no_offset[4][4];
442};
443
444} // namespace
445
447{
448 gz->flag |= /* WM_GIZMO_DRAW_MODAL | */ /* TODO */
450}
451
453{
454 RectTransformInteraction *data = MEM_callocN<RectTransformInteraction>("cage_interaction");
455
456 copy_m4_m4(data->orig_matrix_offset, gz->matrix_offset);
457 gizmo_calc_matrix_final_no_offset(gz, data->orig_matrix_final_no_offset, true);
458
460 C, gz, blender::float2(blender::int2(event->mval)), false, data->orig_mouse) == 0)
461 {
462 zero_v3(data->orig_mouse);
463 }
464
466
468}
469
471 wmGizmo *gz,
472 const wmEvent *event,
473 eWM_GizmoFlagTweak /*tweak_flag*/)
474{
475 if (event->type != MOUSEMOVE) {
477 }
478 /* For transform logic to be manageable we operate in -0.5..0.5 2D space,
479 * no matter the size of the rectangle, mouse coords are scaled to unit space.
480 * The mouse coords have been projected into the matrix
481 * so we don't need to worry about axis alignment.
482 *
483 * - The cursor offset are multiplied by 'dims'.
484 * - Matrix translation is also multiplied by 'dims'.
485 */
486 RectTransformInteraction *data = static_cast<RectTransformInteraction *>(gz->interaction_data);
487 float point_local[3];
488
489 float dims[3];
490 RNA_float_get_array(gz->ptr, "dimensions", dims);
491
492 {
493 float matrix_back[4][4];
494 copy_m4_m4(matrix_back, gz->matrix_offset);
495 copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
496
497 bool ok = gizmo_window_project_3d(
498 C, gz, blender::float2(blender::int2(event->mval)), false, point_local);
499 copy_m4_m4(gz->matrix_offset, matrix_back);
500 if (!ok) {
502 }
503 }
504
505 const int transform_flag = RNA_enum_get(gz->ptr, "transform");
506 wmGizmoProperty *gz_prop;
507
508 gz_prop = WM_gizmo_target_property_find(gz, "matrix");
509 if (gz_prop->type != nullptr) {
511 }
512
514 /* do this to prevent clamping from changing size */
515 copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
516 gz->matrix_offset[3][0] = data->orig_matrix_offset[3][0] +
517 (point_local[0] - data->orig_mouse[0]);
518 gz->matrix_offset[3][1] = data->orig_matrix_offset[3][1] +
519 (point_local[1] - data->orig_mouse[1]);
520 gz->matrix_offset[3][2] = data->orig_matrix_offset[3][2] +
521 (point_local[2] - data->orig_mouse[2]);
522 }
524 /* Add this (if we need it). */
525 }
526 else {
527 /* scale */
528 copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
529
530 float pivot[3];
531 bool constrain_axis[3] = {false};
532 bool has_translation = transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_TRANSLATE;
533 gizmo_rect_pivot_from_scale_part(gz->highlight_part, pivot, constrain_axis, has_translation);
534
535 float scale[3] = {1.0f, 1.0f, 1.0f};
536 for (int i = 0; i < 3; i++) {
537 if (constrain_axis[i] == false) {
538 /* Original cursor position relative to pivot, remapped to [-1, 1] */
539 const float delta_orig = (data->orig_mouse[i] - data->orig_matrix_offset[3][i]) /
540 (dims[i] * len_v3(data->orig_matrix_offset[i])) -
541 pivot[i];
542 const float delta_curr = (point_local[i] - data->orig_matrix_offset[3][i]) /
543 (dims[i] * len_v3(data->orig_matrix_offset[i])) -
544 pivot[i];
545
546 if ((transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_SCALE_SIGNED) == 0) {
547 if (signum_i(delta_orig) != signum_i(delta_curr)) {
548 scale[i] = 0.0f;
549 continue;
550 }
551 }
552
553 /* Original cursor position does not exactly lie on the cage boundary due to margin. */
554 const float delta_boundary = signf(delta_orig) * 0.5f - pivot[i];
555 scale[i] = delta_curr / delta_boundary;
556 }
557 }
558
559 if (transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_SCALE_UNIFORM) {
560 if (constrain_axis[0] == false && constrain_axis[1] == false) {
561 scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f;
562 }
563 else if (constrain_axis[0] == false) {
564 scale[1] = scale[0];
565 }
566 else if (constrain_axis[1] == false) {
567 scale[0] = scale[1];
568 }
569 else {
570 BLI_assert(0);
571 }
572 }
573
574 /* scale around pivot */
575 float matrix_scale[4][4];
576 unit_m4(matrix_scale);
577
578 mul_v3_fl(matrix_scale[0], scale[0]);
579 mul_v3_fl(matrix_scale[1], scale[1]);
580 mul_v3_fl(matrix_scale[2], scale[2]);
581
583 matrix_scale, blender::float3(pivot[0] * dims[0], pivot[1] * dims[1], pivot[2] * dims[2]));
584 mul_m4_m4m4(gz->matrix_offset, data->orig_matrix_offset, matrix_scale);
585 }
586
587 if (gz_prop->type != nullptr) {
589 }
590
591 /* tag the region for redraw */
593
595}
596
598{
599 if (STREQ(gz_prop->type->idname, "matrix")) {
600 if (WM_gizmo_target_property_array_length(gz, gz_prop) == 16) {
602 }
603 else {
604 BLI_assert(0);
605 }
606 }
607 else {
608 BLI_assert(0);
609 }
610}
611
612static void gizmo_cage3d_exit(bContext *C, wmGizmo *gz, const bool cancel)
613{
614 RectTransformInteraction *data = static_cast<RectTransformInteraction *>(gz->interaction_data);
615
616 if (!cancel) {
617 return;
618 }
619
620 wmGizmoProperty *gz_prop;
621
622 /* reset properties */
623 gz_prop = WM_gizmo_target_property_find(gz, "matrix");
624 if (gz_prop->type != nullptr) {
625 WM_gizmo_target_property_float_set_array(C, gz, gz_prop, &data->orig_matrix_offset[0][0]);
626 }
627
628 copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
629}
630
631/* -------------------------------------------------------------------- */
634
636{
637 /* identifiers */
638 gzt->idname = "GIZMO_GT_cage_3d";
639
640 /* API callbacks. */
641 gzt->draw = gizmo_cage3d_draw;
647 gzt->exit = gizmo_cage3d_exit;
649
650 gzt->struct_size = sizeof(wmGizmo);
651
652 /* rna */
653 static const EnumPropertyItem rna_enum_draw_style[] = {
654 {ED_GIZMO_CAGE3D_STYLE_BOX, "BOX", 0, "Box", ""},
655 {ED_GIZMO_CAGE3D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""},
656 {0, nullptr, 0, nullptr, nullptr},
657 };
658 static const EnumPropertyItem rna_enum_transform[] = {
659 {ED_GIZMO_CAGE_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Move", ""},
660 {ED_GIZMO_CAGE_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""},
661 {ED_GIZMO_CAGE_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""},
662 {0, nullptr, 0, nullptr, nullptr},
663 };
664 static const EnumPropertyItem rna_enum_draw_options[] = {
665 {ED_GIZMO_CAGE_DRAW_FLAG_XFORM_CENTER_HANDLE, "XFORM_CENTER_HANDLE", 0, "Center Handle", ""},
666 {0, nullptr, 0, nullptr, nullptr},
667 };
668 static const float unit_v3[3] = {1.0f, 1.0f, 1.0f};
670 gzt->srna, "dimensions", 3, unit_v3, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX);
671 RNA_def_enum_flag(gzt->srna, "transform", rna_enum_transform, 0, "Transform Options", "");
672 RNA_def_enum(gzt->srna,
673 "draw_style",
674 rna_enum_draw_style,
676 "Draw Style",
677 "");
679 "draw_options",
680 rna_enum_draw_options,
682 "Draw Options",
683 "");
684
686}
687
692
ARegion * CTX_wm_region(const bContext *C)
#define BLI_assert(a)
Definition BLI_assert.h:46
MINLINE float signf(float f)
MINLINE int signum_i(float a)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void transform_pivot_set_m4(float mat[4][4], const float pivot[3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
void mul_v3_mat3_m4v3(float r[3], const float mat[4][4], const float vec[3])
void unit_m4(float m[4][4])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
unsigned int uint
#define UNUSED_VARS(...)
#define UNPACK3(a)
#define STREQ(a, b)
@ OPERATOR_RUNNING_MODAL
@ ED_GIZMO_CAGE_DRAW_FLAG_XFORM_CENTER_HANDLE
@ ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z
@ ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z
@ ED_GIZMO_CAGE3D_PART_ROTATE
@ ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z
@ ED_GIZMO_CAGE3D_PART_TRANSLATE
@ ED_GIZMO_CAGE_XFORM_FLAG_SCALE
@ ED_GIZMO_CAGE_XFORM_FLAG_TRANSLATE
@ ED_GIZMO_CAGE_XFORM_FLAG_SCALE_UNIFORM
@ ED_GIZMO_CAGE_XFORM_FLAG_SCALE_SIGNED
@ ED_GIZMO_CAGE3D_STYLE_BOX
@ ED_GIZMO_CAGE3D_STYLE_CIRCLE
void ED_region_tag_redraw_editor_overlays(ARegion *region)
Definition area.cc:654
float ED_view3d_pixel_size(const RegionView3D *rv3d, const float co[3])
void immEnd()
void immUniform2fv(const char *name, const float data[2])
void immUnbindProgram()
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void immUniformColor4f(float r, float g, float b, float a)
void immVertex2f(uint attr_id, float x, float y)
void immUniform1f(const char *name, float x)
GPUVertFormat * immVertexFormat()
void immBegin(GPUPrimType, uint vertex_len)
void immUniformColor3fv(const float rgb[3])
void immRectf(uint pos, float x1, float y1, float x2, float y2)
void imm_draw_cube_wire_3d(uint pos, const float center[3], const float aspect[3])
void imm_draw_cube_fill_3d(uint pos, const float center[3], const float aspect[3])
void GPU_matrix_push()
#define GPU_matrix_mul(x)
void GPU_matrix_pop()
@ GPU_PRIM_LINES
bool GPU_select_load_id(unsigned int id)
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
@ GPU_SHADER_3D_UNIFORM_COLOR
@ 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
void GPU_polygon_smooth(bool enable)
Definition gpu_state.cc:83
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_DRAW_NO_SCALE
@ WM_GIZMOGROUPTYPE_3D
@ WM_GIZMO_STATE_HIGHLIGHT
#define U
BMesh const char void * data
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
static void gizmo_cage3d_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop)
static void cage3d_draw_circle_handles(const RegionView3D *rv3d, const float matrix_final[4][4], const float r[3], const float margin[3], const float color[3], bool solid, const float handle_scale)
static void cage3d_draw_box_corners(const float r[3], const float margin[3], const float color[3], const float line_width)
static void gizmo_cage3d_draw_select(const bContext *C, wmGizmo *gz, int select_id)
static void gizmo_cage3d_draw_intern(RegionView3D *rv3d, wmGizmo *gz, const bool select, const bool highlight, const int select_id)
static void gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[3], float scale[3])
static wmOperatorStatus gizmo_cage3d_modal(bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak)
static int gizmo_cage3d_get_cursor(wmGizmo *gz)
static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[3], bool r_constrain_axis[3], bool has_translation)
static void gizmo_cage3d_setup(wmGizmo *gz)
static void cage3d_draw_circle_wire(const float r[3], const float margin[3], const float color[3], const int transform_flag, const int draw_options, const float line_width)
static void GIZMO_GT_cage_3d(wmGizmoType *gzt)
static void gizmo_cage3d_draw(const bContext *C, wmGizmo *gz)
static void gizmo_calc_rect_view_margin(const wmGizmo *gz, const float dims[3], float margin[3])
void ED_gizmotypes_cage_3d()
static void imm_draw_point_aspect_3d(uint pos, const float co[3], const float rad[3], bool solid)
static void gizmo_cage3d_exit(bContext *C, wmGizmo *gz, const bool cancel)
static void cage3d_draw_box_interaction(const RegionView3D *rv3d, const float matrix_final[4][4], const float color[4], const int highlighted, const float size[3], const float margin[3])
static void gizmo_calc_matrix_final_no_offset(const wmGizmo *gz, float orig_matrix_final_no_offset[4][4], bool use_space)
static wmOperatorStatus gizmo_cage3d_invoke(bContext *C, wmGizmo *gz, const wmEvent *event)
void gizmo_color_get(const wmGizmo *gz, bool highlight, float r_color[4])
bool gizmo_window_project_3d(bContext *C, const wmGizmo *gz, const float mval[2], bool use_offset, float r_co[3])
uint pos
constexpr T sign(T) RET
#define select(A, B, C)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< float, 3 > float3
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
int RNA_enum_get(PointerRNA *ptr, const char *name)
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 FLT_MAX
Definition stdcycles.h:14
void * regiondata
float xmax
float xmin
float ymax
float ymin
wmEventType type
Definition WM_types.hh:757
int mval[2]
Definition WM_types.hh:763
eWM_GizmoFlagGroupTypeFlag flag
wmGizmoGroupType * type
const wmGizmoPropertyType * type
StructRNA * srna
wmGizmoFnDraw draw
wmGizmoFnModal modal
wmGizmoFnSetup setup
const char * idname
wmGizmoFnExit exit
wmGizmoFnCursorGet cursor_get
wmGizmoFnInvoke invoke
wmGizmoFnDrawSelect draw_select
wmGizmoFnPropertyUpdate property_update
wmGizmoGroup * parent_gzgroup
void * interaction_data
eWM_GizmoFlagState state
float matrix_offset[4][4]
float color[4]
PointerRNA * ptr
float line_width
eWM_GizmoFlag flag
i
Definition text_draw.cc:230
@ WM_CURSOR_NSEW_SCROLL
Definition wm_cursors.hh:52
@ WM_CURSOR_DEFAULT
Definition wm_cursors.hh:15
@ MOUSEMOVE
void WM_gizmo_calc_matrix_final_params(const wmGizmo *gz, const WM_GizmoMatrixParams *params, float r_mat[4][4])
Definition wm_gizmo.cc:522
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_get_array(const wmGizmo *gz, wmGizmoProperty *gz_prop, float *value)
int WM_gizmo_target_property_array_length(const wmGizmo *, wmGizmoProperty *gz_prop)
void WM_gizmotype_target_property_def(wmGizmoType *gzt, const char *idname, int data_type, int array_length)
void WM_gizmo_target_property_float_set_array(bContext *C, const wmGizmo *gz, wmGizmoProperty *gz_prop, const float *value)
wmGizmoProperty * WM_gizmo_target_property_find(wmGizmo *gz, const char *idname)
void WM_gizmotype_append(void(*gtfunc)(wmGizmoType *))