Blender V5.3
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_c.hh"
19#include "BLI_math_vector_c.hh"
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
43namespace blender {
44
45#define GIZMO_MARGIN_OFFSET_SCALE 1.5f
46
48 float orig_matrix_final_no_offset[4][4],
49 bool use_space)
50{
51 float mat_identity[4][4];
52 wmGizmoMatrixParams params = {nullptr};
53 unit_m4(mat_identity);
54 if (use_space == false) {
55 params.matrix_basis = mat_identity;
56 }
57 params.matrix_offset = mat_identity;
58 WM_gizmo_calc_matrix_final_params(gz, &params, orig_matrix_final_no_offset);
59}
60
61static void gizmo_calc_rect_view_scale(const wmGizmo *gz, const float dims[3], float scale[3])
62{
63 UNUSED_VARS(dims);
64
65 /* Unlike cage2d, no need to correct for aspect. */
66 float matrix_final_no_offset[4][4];
67
68 float x_axis[3], y_axis[3], z_axis[3];
69 gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset, false);
70 mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, gz->matrix_offset[0]);
71 mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, gz->matrix_offset[1]);
72 mul_v3_mat3_m4v3(z_axis, matrix_final_no_offset, gz->matrix_offset[2]);
73
74 scale[0] = 1.0f / len_v3(x_axis);
75 scale[1] = 1.0f / len_v3(y_axis);
76 scale[2] = 1.0f / len_v3(z_axis);
77}
78
79static void gizmo_calc_rect_view_margin(const wmGizmo *gz, const float dims[3], float margin[3])
80{
81 const float handle_size = 9.0f;
82 /* XXX, the scale isn't taking offset into account, we need to calculate scale per handle! */
83 // handle_size *= gz->scale_final;
84
85 float scale_xyz[3];
86 gizmo_calc_rect_view_scale(gz, dims, scale_xyz);
87 margin[0] = (handle_size * scale_xyz[0]);
88 margin[1] = (handle_size * scale_xyz[1]);
89 margin[2] = (handle_size * scale_xyz[2]);
90}
91
92/* -------------------------------------------------------------------- */
93
95 float r_pt[3],
96 bool r_constrain_axis[3],
97 bool has_translation)
98{
101 {
103 int range[3];
104 range[2] = index % 3;
105 index = index / 3;
106 range[1] = index % 3;
107 index = index / 3;
108 range[0] = index % 3;
109
110 const float sign[3] = {0.5f, 0.0f, -0.5f};
111 for (int i = 0; i < 3; i++) {
112 r_pt[i] = has_translation ? sign[range[i]] : 0.0f;
113 r_constrain_axis[i] = (range[i] == 1);
114 }
115 }
116}
117
118/* -------------------------------------------------------------------- */
123
124static void cage3d_draw_box_corners(const float r[3],
125 const float margin[3],
126 const float color[3],
127 const float line_width)
128{
129 uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32_32);
130 UNUSED_VARS(margin);
131
134
135 float viewport[4];
136 GPU_viewport_size_get_f(viewport);
137 immUniform2fv("viewportSize", &viewport[2]);
138 immUniform1f("lineWidth", line_width * U.pixelsize);
139
140 imm_draw_cube_wire_3d(pos, float3(0.0f), r);
141
143}
144
146 const float matrix_final[4][4],
147 const float color[4],
148 const int highlighted,
149 const float size[3],
150 const float margin[3])
151{
154 {
156 int range[3];
157 range[2] = index % 3;
158 index = index / 3;
159 range[1] = index % 3;
160 index = index / 3;
161 range[0] = index % 3;
162
163 const float sign[3] = {-1.0f, 0.0f, 1.0f};
164 float co[3];
165
166 for (int i = 0; i < 3; i++) {
167 co[i] = size[i] * sign[range[i]];
168 }
169 const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3};
170 float co_test[3];
171 mul_v3_m4v3(co_test, matrix_final, co);
172 float rad_scale[3];
173 mul_v3_v3fl(rad_scale, rad, ED_view3d_pixel_size(rv3d, co_test));
174
175 {
177 immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32_32);
180 imm_draw_cube_fill_3d(pos, co, rad_scale);
182 }
183 }
184}
185
187
188/* -------------------------------------------------------------------- */
193
194static void imm_draw_point_aspect_3d(uint pos, const float co[3], const float rad[3], bool solid)
195{
196 if (solid) {
197 imm_draw_cube_fill_3d(pos, co, rad);
198 }
199 else {
200 imm_draw_cube_wire_3d(pos, co, rad);
201 }
202}
203
204static void cage3d_draw_circle_wire(const float r[3],
205 const float margin[3],
206 const float color[3],
207 const int transform_flag,
208 const int draw_options,
209 const float line_width)
210{
211 uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32_32);
212
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
221 imm_draw_cube_wire_3d(pos, float3(0.0f), r);
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{
252 uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32_32);
253 const float rad[3] = {margin[0] / 3, margin[1] / 3, margin[2] / 3};
254
257
258 const float sign[3] = {-1.0f, 0.0f, 1.0f};
259 for (int x = 0; x < 3; x++) {
260 for (int y = 0; y < 3; y++) {
261 for (int z = 0; z < 3; z++) {
262 if (x == 1 && y == 1 && z == 1) {
263 continue;
264 }
265 const float co[3] = {r[0] * sign[x], r[1] * sign[y], r[2] * sign[z]};
266 float co_test[3];
267 mul_v3_m4v3(co_test, matrix_final, co);
268 float rad_scale[3];
269 mul_v3_v3fl(rad_scale, rad, ED_view3d_pixel_size(rv3d, co_test) * handle_scale);
270 imm_draw_point_aspect_3d(pos, co, rad_scale, solid);
271 }
272 }
273 }
274
276}
277
279
281 RegionView3D *rv3d, wmGizmo *gz, const bool select, const bool highlight, const int select_id)
282{
283 // const bool use_clamp = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0;
284 float dims[3];
285 RNA_float_get_array(gz->ptr, "dimensions", dims);
286 float matrix_final[4][4];
287
288 const int transform_flag = RNA_enum_get(gz->ptr, "transform");
289 const int draw_style = RNA_enum_get(gz->ptr, "draw_style");
290 const int draw_options = RNA_enum_get(gz->ptr, "draw_options");
291
292 const float size_real[3] = {dims[0] / 2.0f, dims[1] / 2.0f, dims[2] / 2.0f};
293
294 WM_gizmo_calc_matrix_final(gz, matrix_final);
295
297 GPU_matrix_mul(matrix_final);
298
299 float margin[3];
300 gizmo_calc_rect_view_margin(gz, dims, margin);
301
302 /* Handy for quick testing draw (if it's outside bounds). */
303 if (false) {
306 immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32_32);
308 immUniformColor4f(1, 1, 1, 0.5f);
309 float s = 0.5f;
310 immRectf(pos, -s, -s, s, s);
313 }
314
315 if (select) {
316/* Expand for hot-spot. */
317#if 0
318 const float size[3] = {
319 size_real[0] + margin[0] / 2,
320 size_real[1] + margin[1] / 2,
321 size_real[2] + margin[2] / 2,
322 };
323#else
324 /* just use same value for now. */
325 const float size[3] = {UNPACK3(size_real)};
326#endif
327
328 if (transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_SCALE) {
331 i++)
332 {
334 continue;
335 }
336 GPU_select_load_id(select_id | i);
337 cage3d_draw_box_interaction(rv3d, matrix_final, gz->color, i, size, margin);
338 }
339 }
340 if (transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_TRANSLATE) {
341 const int transform_part = ED_GIZMO_CAGE3D_PART_TRANSLATE;
342 GPU_select_load_id(select_id | transform_part);
343 cage3d_draw_box_interaction(rv3d, matrix_final, gz->color, transform_part, size, margin);
344 }
345 }
346 else {
347#if 0
348 rctf _r {}
349 _r.xmin = -size_real[0];
350 _r.ymin = -size_real[1];
351 _r.xmax = size_real[0];
352 _r.ymax = size_real[1];
353#endif
354 if (draw_style == ED_GIZMO_CAGE3D_STYLE_BOX) {
355 float color[4], black[3] = {0, 0, 0};
356 gizmo_color_get(gz, highlight, color);
357
358 /* corner gizmos */
359 cage3d_draw_box_corners(size_real, margin, black, gz->line_width + 3.0f);
360
361 /* corner gizmos */
362 cage3d_draw_box_corners(size_real, margin, color, gz->line_width);
363
364 bool show = false;
366 /* Only show if we're drawing the center handle
367 * otherwise the entire rectangle is the hot-spot. */
369 show = true;
370 }
371 }
372 else {
373 show = true;
374 }
375
376 if (show) {
378 rv3d, matrix_final, gz->color, gz->highlight_part, size_real, margin);
379 }
380 }
381 else if (draw_style == ED_GIZMO_CAGE3D_STYLE_CIRCLE) {
382 float color[4], black[3] = {0, 0, 0};
383 gizmo_color_get(gz, highlight, color);
384
386
388 size_real, margin, black, transform_flag, draw_options, gz->line_width + 3.0f);
390 size_real, margin, color, transform_flag, draw_options, gz->line_width);
391
392 /* Corner gizmos (draw the outer & inner so there is a visible outline). */
393 GPU_polygon_smooth(true);
394 cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, black, true, 1.0f);
395 cage3d_draw_circle_handles(rv3d, matrix_final, size_real, margin, color, true, 1.0f / 1.5f);
396 GPU_polygon_smooth(false);
397
399 }
400 else {
401 BLI_assert(0);
402 }
403 }
404
406}
407
411static void gizmo_cage3d_draw_select(const bContext *C, wmGizmo *gz, int select_id)
412{
413 ARegion *region = CTX_wm_region(C);
414 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
415 gizmo_cage3d_draw_intern(rv3d, gz, true, false, select_id);
416}
417
418static void gizmo_cage3d_draw(const bContext *C, wmGizmo *gz)
419{
420 ARegion *region = CTX_wm_region(C);
421 RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
422 const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
423 gizmo_cage3d_draw_intern(rv3d, gz, false, is_highlight, -1);
424}
425
427{
430 }
431
432 return WM_CURSOR_DEFAULT;
433}
434
435namespace {
436
437struct RectTransformInteraction {
438 float orig_mouse[3];
439 float orig_matrix_offset[4][4];
440 float orig_matrix_final_no_offset[4][4];
441};
442
443} // namespace
444
446{
447 gz->flag |= /* WM_GIZMO_DRAW_MODAL | */ /* TODO */
449}
450
452{
453 RectTransformInteraction *data = MEM_new_zeroed<RectTransformInteraction>("cage_interaction");
454
455 copy_m4_m4(data->orig_matrix_offset, gz->matrix_offset);
456 gizmo_calc_matrix_final_no_offset(gz, data->orig_matrix_final_no_offset, true);
457
458 if (gizmo_window_project_3d(C, gz, float2(int2(event->mval)), false, data->orig_mouse) == 0) {
459 zero_v3(data->orig_mouse);
460 }
461
463
465}
466
468 wmGizmo *gz,
469 const wmEvent *event,
470 eWM_GizmoFlagTweak /*tweak_flag*/)
471{
472 if (event->type != MOUSEMOVE) {
474 }
475 /* For transform logic to be manageable we operate in -0.5..0.5 2D space,
476 * no matter the size of the rectangle, mouse coords are scaled to unit space.
477 * The mouse coords have been projected into the matrix
478 * so we don't need to worry about axis alignment.
479 *
480 * - The cursor offset are multiplied by 'dims'.
481 * - Matrix translation is also multiplied by 'dims'.
482 */
483 RectTransformInteraction *data = static_cast<RectTransformInteraction *>(gz->interaction_data);
484 float point_local[3];
485
486 float dims[3];
487 RNA_float_get_array(gz->ptr, "dimensions", dims);
488
489 {
490 float matrix_back[4][4];
491 copy_m4_m4(matrix_back, gz->matrix_offset);
492 copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
493
494 bool ok = gizmo_window_project_3d(C, gz, float2(int2(event->mval)), false, point_local);
495 copy_m4_m4(gz->matrix_offset, matrix_back);
496 if (!ok) {
498 }
499 }
500
501 const int transform_flag = RNA_enum_get(gz->ptr, "transform");
502 wmGizmoProperty *gz_prop;
503
504 gz_prop = WM_gizmo_target_property_find(gz, "matrix");
505 if (gz_prop->type != nullptr) {
507 }
508
510 /* do this to prevent clamping from changing size */
511 copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
512 gz->matrix_offset[3][0] = data->orig_matrix_offset[3][0] +
513 (point_local[0] - data->orig_mouse[0]);
514 gz->matrix_offset[3][1] = data->orig_matrix_offset[3][1] +
515 (point_local[1] - data->orig_mouse[1]);
516 gz->matrix_offset[3][2] = data->orig_matrix_offset[3][2] +
517 (point_local[2] - data->orig_mouse[2]);
518 }
520 /* Add this (if we need it). */
521 }
522 else {
523 /* scale */
524 copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
525
526 float pivot[3];
527 bool constrain_axis[3] = {false};
528 bool has_translation = transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_TRANSLATE;
529 gizmo_rect_pivot_from_scale_part(gz->highlight_part, pivot, constrain_axis, has_translation);
530
531 float scale[3] = {1.0f, 1.0f, 1.0f};
532 for (int i = 0; i < 3; i++) {
533 if (constrain_axis[i] == false) {
534 /* Original cursor position relative to pivot, remapped to [-1, 1] */
535 const float delta_orig = (data->orig_mouse[i] - data->orig_matrix_offset[3][i]) /
536 (dims[i] * len_v3(data->orig_matrix_offset[i])) -
537 pivot[i];
538 const float delta_curr = (point_local[i] - data->orig_matrix_offset[3][i]) /
539 (dims[i] * len_v3(data->orig_matrix_offset[i])) -
540 pivot[i];
541
542 if ((transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_SCALE_SIGNED) == 0) {
543 if (signum_i(delta_orig) != signum_i(delta_curr)) {
544 scale[i] = 0.0f;
545 continue;
546 }
547 }
548
549 /* Original cursor position does not exactly lie on the cage boundary due to margin. */
550 const float delta_boundary = signf(delta_orig) * 0.5f - pivot[i];
551 scale[i] = delta_curr / delta_boundary;
552 }
553 }
554
555 if (transform_flag & ED_GIZMO_CAGE_XFORM_FLAG_SCALE_UNIFORM) {
556 if (constrain_axis[0] == false && constrain_axis[1] == false) {
557 scale[1] = scale[0] = (scale[1] + scale[0]) / 2.0f;
558 }
559 else if (constrain_axis[0] == false) {
560 scale[1] = scale[0];
561 }
562 else if (constrain_axis[1] == false) {
563 scale[0] = scale[1];
564 }
565 else {
566 BLI_assert(0);
567 }
568 }
569
570 /* scale around pivot */
571 float matrix_scale[4][4];
572 unit_m4(matrix_scale);
573
574 mul_v3_fl(matrix_scale[0], scale[0]);
575 mul_v3_fl(matrix_scale[1], scale[1]);
576 mul_v3_fl(matrix_scale[2], scale[2]);
577
578 transform_pivot_set_m4(matrix_scale,
579 float3(pivot[0] * dims[0], pivot[1] * dims[1], pivot[2] * dims[2]));
580 mul_m4_m4m4(gz->matrix_offset, data->orig_matrix_offset, matrix_scale);
581 }
582
583 if (gz_prop->type != nullptr) {
585 }
586
587 /* tag the region for redraw */
589
591}
592
594{
595 if (STREQ(gz_prop->type->idname, "matrix")) {
596 if (WM_gizmo_target_property_array_length(gz, gz_prop) == 16) {
598 }
599 else {
600 BLI_assert(0);
601 }
602 }
603 else {
604 BLI_assert(0);
605 }
606}
607
608static void gizmo_cage3d_exit(bContext *C, wmGizmo *gz, const bool cancel)
609{
610 RectTransformInteraction *data = static_cast<RectTransformInteraction *>(gz->interaction_data);
611
612 if (!cancel) {
613 return;
614 }
615
616 wmGizmoProperty *gz_prop;
617
618 /* reset properties */
619 gz_prop = WM_gizmo_target_property_find(gz, "matrix");
620 if (gz_prop->type != nullptr) {
621 WM_gizmo_target_property_float_set_array(C, gz, gz_prop, &data->orig_matrix_offset[0][0]);
622 }
623
624 copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset);
625}
626
627/* -------------------------------------------------------------------- */
630
632{
633 /* identifiers */
634 gzt->idname = "GIZMO_GT_cage_3d";
635
636 /* API callbacks. */
637 gzt->draw = gizmo_cage3d_draw;
643 gzt->exit = gizmo_cage3d_exit;
645
646 gzt->struct_size = sizeof(wmGizmo);
647
648 /* rna */
649 static const EnumPropertyItem rna_enum_draw_style[] = {
650 {ED_GIZMO_CAGE3D_STYLE_BOX, "BOX", 0, "Box", ""},
651 {ED_GIZMO_CAGE3D_STYLE_CIRCLE, "CIRCLE", 0, "Circle", ""},
652 {0, nullptr, 0, nullptr, nullptr},
653 };
654 static const EnumPropertyItem rna_enum_transform[] = {
655 {ED_GIZMO_CAGE_XFORM_FLAG_TRANSLATE, "TRANSLATE", 0, "Move", ""},
656 {ED_GIZMO_CAGE_XFORM_FLAG_SCALE, "SCALE", 0, "Scale", ""},
657 {ED_GIZMO_CAGE_XFORM_FLAG_SCALE_UNIFORM, "SCALE_UNIFORM", 0, "Scale Uniform", ""},
658 {0, nullptr, 0, nullptr, nullptr},
659 };
660 static const EnumPropertyItem rna_enum_draw_options[] = {
661 {ED_GIZMO_CAGE_DRAW_FLAG_XFORM_CENTER_HANDLE, "XFORM_CENTER_HANDLE", 0, "Center Handle", ""},
662 {0, nullptr, 0, nullptr, nullptr},
663 };
664 static const float unit_v3[3] = {1.0f, 1.0f, 1.0f};
666 gzt->srna, "dimensions", 3, unit_v3, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX);
667 RNA_def_enum_flag(gzt->srna, "transform", rna_enum_transform, 0, "Transform Options", "");
668 RNA_def_enum(gzt->srna,
669 "draw_style",
670 rna_enum_draw_style,
672 "Draw Style",
673 "");
675 "draw_options",
676 rna_enum_draw_options,
678 "Draw Options",
679 "");
680
682}
683
688
690
691} // namespace blender
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define UNUSED_VARS(...)
#define UNPACK3(a)
#define STREQ(a, b)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
#define FLT_MAX
constexpr T sign(T) RET
float3x3 scale(float3x3 mat, float2 scale)
BMesh Iterators.
static void gizmo_calc_rect_view_margin(const wmGizmo *gz, float margin[2])
UserDef U
Definition blender.cc:58
static void GIZMO_GT_cage_3d(wmGizmoType *gzt)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
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])
int RNA_enum_get(PointerRNA *ptr, const char *name)
static void gizmo_cage3d_draw(const bContext *C, wmGizmo *gz)
void immEnd()
unsigned int uint
Definition BKE_text.h:55
void GPU_polygon_smooth(bool enable)
Definition gpu_state.cc:85
bool GPU_select_load_id(unsigned int id)
bool gizmo_window_project_3d(bContext *C, const wmGizmo *gz, const float mval[2], bool use_offset, float r_co[3])
void WM_gizmotype_append(void(*gtfunc)(wmGizmoType *))
void WM_gizmo_target_property_float_get_array(const wmGizmo *gz, wmGizmoProperty *gz_prop, float *value)
void ED_gizmotypes_cage_3d()
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
float ED_view3d_pixel_size(const RegionView3D *rv3d, const float co[3])
GPUVertFormat * immVertexFormat()
void WM_gizmo_calc_matrix_final_params(const wmGizmo *gz, const wmGizmoMatrixParams *params, float r_mat[4][4])
Definition wm_gizmo.cc:519
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)
void mul_v3_mat3_m4v3(float r[3], const float mat[4][4], const float vec[3])
static void gizmo_cage3d_setup(wmGizmo *gz)
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
Definition wm_gizmo.cc:569
static void cage3d_draw_box_corners(const float r[3], const float margin[3], const float color[3], const float line_width)
void WM_gizmotype_target_property_def(wmGizmoType *gzt, const char *idname, int data_type, int array_length)
@ ED_GIZMO_CAGE_XFORM_FLAG_SCALE
@ ED_GIZMO_CAGE_XFORM_FLAG_TRANSLATE
@ ED_GIZMO_CAGE_XFORM_FLAG_SCALE_SIGNED
@ ED_GIZMO_CAGE_XFORM_FLAG_SCALE_UNIFORM
void ED_region_tag_redraw_editor_overlays(ARegion *region)
Definition area.cc:745
void imm_draw_cube_wire_3d(uint pos, const float center[3], const float aspect[3])
void immUnbindProgram()
void GPU_matrix_mul(const float m[4][4])
MINLINE void mul_v3_fl(float r[3], float f)
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
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
@ ED_GIZMO_CAGE3D_PART_TRANSLATE
@ ED_GIZMO_CAGE3D_PART_ROTATE
@ ED_GIZMO_CAGE3D_PART_SCALE_MID_X_MID_Y_MID_Z
@ ED_GIZMO_CAGE3D_PART_SCALE_MAX_X_MAX_Y_MAX_Z
@ ED_GIZMO_CAGE3D_PART_SCALE_MIN_X_MIN_Y_MIN_Z
void WM_gizmo_target_property_float_set_array(bContext *C, const wmGizmo *gz, wmGizmoProperty *gz_prop, const float *value)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void immUniform1f(const char *name, float x)
static void gizmo_calc_rect_view_scale(const wmGizmo *gz, float scale[2])
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void immVertex2f(uint attr_id, float x, float y)
static void gizmo_cage3d_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop)
static wmOperatorStatus gizmo_cage3d_invoke(bContext *C, wmGizmo *gz, const wmEvent *event)
eWM_GizmoFlagTweak
Gizmo tweak flag. Bit-flag passed to gizmo while tweaking.
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:258
MINLINE int signum_i(float a)
BMesh const char void * data
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_modal(bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak)
MINLINE float signf(float f)
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
wmGizmoProperty * WM_gizmo_target_property_find(wmGizmo *gz, const char *idname)
static void gizmo_cage3d_draw_select(const bContext *C, wmGizmo *gz, int select_id)
void immUniformColor4f(float r, float g, float b, float a)
void unit_m4(float m[4][4])
void transform_pivot_set_m4(float mat[4][4], const float pivot[3])
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])
@ ED_GIZMO_CAGE3D_STYLE_BOX
@ ED_GIZMO_CAGE3D_STYLE_CIRCLE
MINLINE void zero_v3(float r[3])
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
@ WM_GIZMO_DRAW_NO_SCALE
static void gizmo_rect_pivot_from_scale_part(int part, float r_pt[3], bool r_constrain_axis[3], bool has_translation)
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)
@ WM_CURSOR_NSEW_SCROLL
Definition wm_cursors.hh:54
@ WM_CURSOR_DEFAULT
Definition wm_cursors.hh:17
@ WM_GIZMO_STATE_HIGHLIGHT
static int gizmo_cage3d_get_cursor(wmGizmo *gz)
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])
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)
@ ED_GIZMO_CAGE_DRAW_FLAG_XFORM_CENTER_HANDLE
void immUniformColor3fv(const float rgb[3])
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
void copy_m4_m4(float m1[4][4], const float m2[4][4])
VecBase< float, 3 > float3
void GPU_matrix_pop()
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)
void immRectf(uint pos, float x1, float y1, float x2, float y2)
ARegion * CTX_wm_region(const bContext *C)
int WM_gizmo_target_property_array_length(const wmGizmo *, wmGizmoProperty *gz_prop)
void GPU_matrix_push()
static void gizmo_cage3d_draw_intern(RegionView3D *rv3d, wmGizmo *gz, const bool select, const bool highlight, const int select_id)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
void imm_draw_cube_fill_3d(uint pos, const float center[3], const float aspect[3])
wmEventType type
Definition WM_types.hh:817
eWM_GizmoFlagGroupTypeFlag flag
wmGizmoGroupType * type
const float(* matrix_basis)[4]
const float(* matrix_offset)[4]
const wmGizmoPropertyType * type
wmGizmoFnInvoke invoke
wmGizmoFnDrawSelect draw_select
wmGizmoFnCursorGet cursor_get
wmGizmoFnPropertyUpdate property_update
float matrix_offset[4][4]
wmGizmoGroup * parent_gzgroup
eWM_GizmoFlag flag
eWM_GizmoFlagState state