Blender  V3.3
wm_gizmo.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2014 Blender Foundation. All rights reserved. */
3 
8 #include "MEM_guardedalloc.h"
9 
10 #include "BLI_listbase.h"
11 #include "BLI_math.h"
12 
13 #include "BKE_context.h"
14 
15 #include "GPU_batch.h"
16 
17 #include "RNA_access.h"
18 #include "RNA_define.h"
19 #include "RNA_prototypes.h"
20 
21 #include "BKE_global.h"
22 #include "BKE_idprop.h"
23 #include "BKE_main.h"
24 
25 #include "WM_api.h"
26 #include "WM_toolsystem.h"
27 #include "WM_types.h"
28 
29 #include "ED_screen.h"
30 #include "ED_view3d.h"
31 
32 #include "UI_interface.h"
33 
34 #ifdef WITH_PYTHON
35 # include "BPY_extern.h"
36 #endif
37 
38 /* only for own init/exit calls (wm_gizmotype_init/wm_gizmotype_free) */
39 #include "wm.h"
40 
41 /* own includes */
42 #include "wm_gizmo_intern.h"
43 #include "wm_gizmo_wmapi.h"
44 
45 static void wm_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz);
46 
50 static wmGizmo *wm_gizmo_create(const wmGizmoType *gzt, PointerRNA *properties)
51 {
52  BLI_assert(gzt != NULL);
53  BLI_assert(gzt->struct_size >= sizeof(wmGizmo));
54 
55  wmGizmo *gz = MEM_callocN(
56  gzt->struct_size + (sizeof(wmGizmoProperty) * gzt->target_property_defs_len), __func__);
57  gz->type = gzt;
58 
59  /* initialize properties, either copy or create */
60  gz->ptr = MEM_callocN(sizeof(PointerRNA), "wmGizmoPtrRNA");
61  if (properties && properties->data) {
62  gz->properties = IDP_CopyProperty(properties->data);
63  }
64  else {
65  IDPropertyTemplate val = {0};
66  gz->properties = IDP_New(IDP_GROUP, &val, "wmGizmoProperties");
67  }
68  RNA_pointer_create(G_MAIN->wm.first, gzt->srna, gz->properties, gz->ptr);
69 
71 
72  unit_m4(gz->matrix_space);
73  unit_m4(gz->matrix_basis);
75 
76  gz->drag_part = -1;
77 
78  return gz;
79 }
80 
81 wmGizmo *WM_gizmo_new_ptr(const wmGizmoType *gzt, wmGizmoGroup *gzgroup, PointerRNA *properties)
82 {
83  wmGizmo *gz = wm_gizmo_create(gzt, properties);
84 
85  wm_gizmo_register(gzgroup, gz);
86 
87  if (gz->type->setup != NULL) {
88  gz->type->setup(gz);
89  }
90 
91  return gz;
92 }
93 
94 wmGizmo *WM_gizmo_new(const char *idname, wmGizmoGroup *gzgroup, PointerRNA *properties)
95 {
96  const wmGizmoType *gzt = WM_gizmotype_find(idname, false);
97  return WM_gizmo_new_ptr(gzt, gzgroup, properties);
98 }
99 
103 static void gizmo_init(wmGizmo *gz)
104 {
105  const float color_default[4] = {1.0f, 1.0f, 1.0f, 1.0f};
106 
107  gz->scale_basis = 1.0f;
108  gz->line_width = 1.0f;
109 
110  /* defaults */
111  copy_v4_v4(gz->color, color_default);
112  copy_v4_v4(gz->color_hi, color_default);
113 }
114 
120 static void wm_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz)
121 {
122  gizmo_init(gz);
123  wm_gizmogroup_gizmo_register(gzgroup, gz);
124 }
125 
127 {
128  if (gz->type->free != NULL) {
129  gz->type->free(gz);
130  }
131 
132 #ifdef WITH_PYTHON
133  if (gz->py_instance) {
134  /* do this first in case there are any __del__ functions or
135  * similar that use properties */
137  }
138 #endif
139 
140  if (gz->op_data) {
141  for (int i = 0; i < gz->op_data_len; i++) {
143  }
144  MEM_freeN(gz->op_data);
145  }
146 
147  if (gz->ptr != NULL) {
149  MEM_freeN(gz->ptr);
150  }
151 
152  if (gz->type->target_property_defs_len != 0) {
153  wmGizmoProperty *gz_prop_array = WM_gizmo_target_property_array(gz);
154  for (int i = 0; i < gz->type->target_property_defs_len; i++) {
155  wmGizmoProperty *gz_prop = &gz_prop_array[i];
156  if (gz_prop->custom_func.free_fn) {
157  gz_prop->custom_func.free_fn(gz, gz_prop);
158  }
159  }
160  }
161 
162  MEM_freeN(gz);
163 }
164 
165 void WM_gizmo_unlink(ListBase *gizmolist, wmGizmoMap *gzmap, wmGizmo *gz, bContext *C)
166 {
167  if (gz->state & WM_GIZMO_STATE_HIGHLIGHT) {
168  wm_gizmomap_highlight_set(gzmap, C, NULL, 0);
169  }
170  if (gz->state & WM_GIZMO_STATE_MODAL) {
171  wm_gizmomap_modal_set(gzmap, C, gz, NULL, false);
172  }
173  /* Unlink instead of setting so we don't run callbacks. */
174  if (gz->state & WM_GIZMO_STATE_SELECT) {
175  WM_gizmo_select_unlink(gzmap, gz);
176  }
177 
178  if (gizmolist) {
179  BLI_remlink(gizmolist, gz);
180  }
181 
182  BLI_assert(gzmap->gzmap_context.highlight != gz);
183  BLI_assert(gzmap->gzmap_context.modal != gz);
184 
185  WM_gizmo_free(gz);
186 }
187 
188 /* -------------------------------------------------------------------- */
195 struct wmGizmoOpElem *WM_gizmo_operator_get(wmGizmo *gz, int part_index)
196 {
197  if (gz->op_data && ((part_index >= 0) && (part_index < gz->op_data_len))) {
198  return &gz->op_data[part_index];
199  }
200  return NULL;
201 }
202 
204  int part_index,
206  IDProperty *properties)
207 {
208  BLI_assert(part_index < 255);
209  /* We could pre-allocate these but using multiple is such a rare thing. */
210  if (part_index >= gz->op_data_len) {
211  gz->op_data_len = part_index + 1;
212  gz->op_data = MEM_recallocN(gz->op_data, sizeof(*gz->op_data) * gz->op_data_len);
213  }
214  wmGizmoOpElem *gzop = &gz->op_data[part_index];
215  gzop->type = ot;
216 
217  if (gzop->ptr.data) {
219  }
221 
222  if (properties) {
223  gzop->ptr.data = properties;
224  }
225 
226  return &gzop->ptr;
227 }
228 
230 {
231  if (gz->flag & WM_GIZMO_OPERATOR_TOOL_INIT) {
232  /* Merge toolsettings into the gizmo properties. */
233  PointerRNA tref_ptr;
235  if (tref && WM_toolsystem_ref_properties_get_from_operator(tref, gzop->type, &tref_ptr)) {
236  if (gzop->ptr.data == NULL) {
237  IDPropertyTemplate val = {0};
238  gzop->ptr.data = IDP_New(IDP_GROUP, &val, "wmOperatorProperties");
239  }
240  IDP_MergeGroup(gzop->ptr.data, tref_ptr.data, false);
241  }
242  }
243  return WM_operator_name_call_ptr(C, gzop->type, WM_OP_INVOKE_DEFAULT, &gzop->ptr, event);
244 }
245 
247  const float z_axis[3])
248 {
249  /* old code, seems we can use simpler method */
250 #if 0
251  const float z_global[3] = {0.0f, 0.0f, 1.0f};
252  float rot[3][3];
253 
254  rotation_between_vecs_to_mat3(rot, z_global, z_axis);
255  copy_v3_v3(matrix[0], rot[0]);
256  copy_v3_v3(matrix[1], rot[1]);
257  copy_v3_v3(matrix[2], rot[2]);
258 #else
259  normalize_v3_v3(matrix[2], z_axis);
260  ortho_basis_v3v3_v3(matrix[0], matrix[1], matrix[2]);
261 #endif
262 }
263 
265  const float y_axis[3],
266  const float z_axis[3])
267 {
268  normalize_v3_v3(matrix[1], y_axis);
269  normalize_v3_v3(matrix[2], z_axis);
270  cross_v3_v3v3(matrix[0], matrix[1], matrix[2]);
271  normalize_v3(matrix[0]);
272 }
273 
274 void WM_gizmo_set_matrix_rotation_from_z_axis(wmGizmo *gz, const float z_axis[3])
275 {
277 }
279  const float y_axis[3],
280  const float z_axis[3])
281 {
283 }
284 void WM_gizmo_set_matrix_location(wmGizmo *gz, const float origin[3])
285 {
286  copy_v3_v3(gz->matrix_basis[3], origin);
287 }
288 
290 {
292 }
294  const float y_axis[3],
295  const float z_axis[3])
296 {
298 }
300 {
302 }
303 
304 void WM_gizmo_set_flag(wmGizmo *gz, const int flag, const bool enable)
305 {
306  if (enable) {
307  gz->flag |= flag;
308  }
309  else {
310  gz->flag &= ~flag;
311  }
312 }
313 
314 void WM_gizmo_set_scale(wmGizmo *gz, const float scale)
315 {
316  gz->scale_basis = scale;
317 }
318 
319 void WM_gizmo_set_line_width(wmGizmo *gz, const float line_width)
320 {
321  gz->line_width = line_width;
322 }
323 
324 void WM_gizmo_get_color(const wmGizmo *gz, float color[4])
325 {
326  copy_v4_v4(color, gz->color);
327 }
328 void WM_gizmo_set_color(wmGizmo *gz, const float color[4])
329 {
330  copy_v4_v4(gz->color, color);
331 }
332 
333 void WM_gizmo_get_color_highlight(const wmGizmo *gz, float color_hi[4])
334 {
335  copy_v4_v4(color_hi, gz->color_hi);
336 }
337 void WM_gizmo_set_color_highlight(wmGizmo *gz, const float color_hi[4])
338 {
339  copy_v4_v4(gz->color_hi, color_hi);
340 }
341  /* Gizmo Creation API. */
343 
344 /* -------------------------------------------------------------------- */
349 {
350  gz->custom_modal = fn;
351 }
352 
355 /* -------------------------------------------------------------------- */
356 
358  wmGizmoMap *gzmap, wmGizmo *gz, bool select, bool use_array, bool use_callback)
359 {
360  bool changed = false;
361 
362  if (select) {
363  if ((gz->state & WM_GIZMO_STATE_SELECT) == 0) {
364  if (use_array) {
366  }
368  changed = true;
369  }
370  }
371  else {
372  if (gz->state & WM_GIZMO_STATE_SELECT) {
373  if (use_array) {
375  }
377  changed = true;
378  }
379  }
380 
381  /* In the case of unlinking we only want to remove from the array
382  * and not write to the external state */
383  if (use_callback && changed) {
384  if (gz->type->select_refresh) {
385  gz->type->select_refresh(gz);
386  }
387  }
388 
389  return changed;
390 }
391 
393 {
394  return wm_gizmo_select_set_ex(gzmap, gz, false, true, false);
395 }
396 
398 {
399  return wm_gizmo_select_set_ex(gzmap, gz, select, true, true);
400 }
401 
403 {
404  return wm_gizmomap_highlight_set(gzmap, NULL, gz, gz ? gz->highlight_part : 0);
405 }
406 
408 {
409  if (WM_gizmo_select_set(gzmap, gz, true)) {
410  wm_gizmomap_highlight_set(gzmap, C, gz, gz->highlight_part);
411  return true;
412  }
413  return false;
414 }
415 
417  struct bContext *C,
418  struct wmGizmo *gz,
419  int part_index,
420  const wmEvent *event)
421 {
422  gz->highlight_part = part_index;
423  WM_gizmo_highlight_set(gzmap, gz);
424  if (false) {
425  wm_gizmomap_modal_set(gzmap, C, gz, event, true);
426  }
427  else {
428  /* WEAK: but it works. */
429  WM_operator_name_call(C, "GIZMOGROUP_OT_gizmo_tweak", WM_OP_INVOKE_DEFAULT, NULL, event);
430  }
431 }
432 
434 {
435  const RegionView3D *rv3d = CTX_wm_region_view3d(C);
436  float scale = UI_DPI_FAC;
437 
438  if ((gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_SCALE) == 0) {
439  scale *= U.gizmo_size;
440  if (rv3d) {
441  /* 'ED_view3d_pixel_size' includes 'U.pixelsize', remove it. */
442  float matrix_world[4][4];
443  if (gz->type->matrix_basis_get) {
444  float matrix_basis[4][4];
445  gz->type->matrix_basis_get(gz, matrix_basis);
446  mul_m4_m4m4(matrix_world, gz->matrix_space, matrix_basis);
447  }
448  else {
449  mul_m4_m4m4(matrix_world, gz->matrix_space, gz->matrix_basis);
450  }
451 
452  /* Exclude matrix_offset from scale. */
453  scale *= ED_view3d_pixel_size_no_ui_scale(rv3d, matrix_world[3]);
454  }
455  }
456 
457  gz->scale_final = gz->scale_basis * scale;
458 }
459 
461 {
462  /* gizmo property might have been changed, so update gizmo */
463  if (gz->type->property_update) {
464  wmGizmoProperty *gz_prop_array = WM_gizmo_target_property_array(gz);
465  for (int i = 0; i < gz->type->target_property_defs_len; i++) {
466  wmGizmoProperty *gz_prop = &gz_prop_array[i];
467  if (WM_gizmo_target_property_is_valid(gz_prop)) {
468  gz->type->property_update(gz, gz_prop);
469  }
470  }
471  }
472 }
473 
474 void wm_gizmo_update(wmGizmo *gz, const bContext *C, const bool refresh_map)
475 {
476  if (refresh_map) {
478  }
480 }
481 
483 {
484  if (gz->flag & WM_GIZMO_HIDDEN) {
485  return 0;
486  }
487  if ((gz->state & WM_GIZMO_STATE_MODAL) &&
489  /* don't draw while modal (dragging) */
490  return 0;
491  }
492  if ((gz->flag & WM_GIZMO_DRAW_HOVER) && !(gz->state & WM_GIZMO_STATE_HIGHLIGHT) &&
493  !(gz->state & WM_GIZMO_STATE_SELECT)) /* still draw selected gizmos */
494  {
495  /* update but don't draw */
497  }
498 
500 }
501 
503  const struct WM_GizmoMatrixParams *params,
504  float r_mat[4][4])
505 {
506  const float(*const matrix_space)[4] = params->matrix_space ? params->matrix_space :
507  gz->matrix_space;
508  const float(*const matrix_basis)[4] = params->matrix_basis ? params->matrix_basis :
509  gz->matrix_basis;
510  const float(*const matrix_offset)[4] = params->matrix_offset ? params->matrix_offset :
511  gz->matrix_offset;
512  const float *scale_final = params->scale_final ? params->scale_final : &gz->scale_final;
513 
514  float final_matrix[4][4];
515  if (params->matrix_basis == NULL && gz->type->matrix_basis_get) {
516  gz->type->matrix_basis_get(gz, final_matrix);
517  }
518  else {
519  copy_m4_m4(final_matrix, matrix_basis);
520  }
521 
522  if (gz->flag & WM_GIZMO_DRAW_NO_SCALE) {
523  mul_m4_m4m4(final_matrix, final_matrix, matrix_offset);
524  }
525  else {
526  if (gz->flag & WM_GIZMO_DRAW_OFFSET_SCALE) {
527  mul_mat3_m4_fl(final_matrix, *scale_final);
528  mul_m4_m4m4(final_matrix, final_matrix, matrix_offset);
529  }
530  else {
531  mul_m4_m4m4(final_matrix, final_matrix, matrix_offset);
532  mul_mat3_m4_fl(final_matrix, *scale_final);
533  }
534  }
535 
536  mul_m4_m4m4(r_mat, matrix_space, final_matrix);
537 }
538 
539 void WM_gizmo_calc_matrix_final_no_offset(const wmGizmo *gz, float r_mat[4][4])
540 {
541  float mat_identity[4][4];
542  unit_m4(mat_identity);
543 
545  &((struct WM_GizmoMatrixParams){
546  .matrix_space = NULL,
547  .matrix_basis = NULL,
548  .matrix_offset = mat_identity,
549  .scale_final = NULL,
550  }),
551  r_mat);
552 }
553 
554 void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
555 {
557  &((struct WM_GizmoMatrixParams){
558  .matrix_space = NULL,
559  .matrix_basis = NULL,
560  .matrix_offset = NULL,
561  .scale_final = NULL,
562  }),
563  r_mat);
564 }
565 
566 /* -------------------------------------------------------------------- */
574 {
576 }
577 
578 void WM_gizmo_properties_create(PointerRNA *ptr, const char *gtstring)
579 {
580  const wmGizmoType *gzt = WM_gizmotype_find(gtstring, false);
581 
582  if (gzt) {
584  }
585  else {
586  RNA_pointer_create(NULL, &RNA_GizmoProperties, NULL, ptr);
587  }
588 }
589 
590 void WM_gizmo_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *gtstring)
591 {
592  if (*properties == NULL) {
593  IDPropertyTemplate val = {0};
594  *properties = IDP_New(IDP_GROUP, &val, "wmOpItemProp");
595  }
596 
597  if (*ptr == NULL) {
598  *ptr = MEM_callocN(sizeof(PointerRNA), "wmOpItemPtr");
599  WM_gizmo_properties_create(*ptr, gtstring);
600  }
601 
602  (*ptr)->data = *properties;
603 }
604 
605 void WM_gizmo_properties_sanitize(PointerRNA *ptr, const bool no_context)
606 {
607  RNA_STRUCT_BEGIN (ptr, prop) {
608  switch (RNA_property_type(prop)) {
609  case PROP_ENUM:
610  if (no_context) {
612  }
613  else {
615  }
616  break;
617  case PROP_POINTER: {
618  StructRNA *ptype = RNA_property_pointer_type(ptr, prop);
619 
620  /* recurse into gizmo properties */
621  if (RNA_struct_is_a(ptype, &RNA_GizmoProperties)) {
622  PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
623  WM_gizmo_properties_sanitize(&opptr, no_context);
624  }
625  break;
626  }
627  default:
628  break;
629  }
630  }
632 }
633 
634 bool WM_gizmo_properties_default(PointerRNA *ptr, const bool do_update)
635 {
636  bool changed = false;
637  RNA_STRUCT_BEGIN (ptr, prop) {
638  switch (RNA_property_type(prop)) {
639  case PROP_POINTER: {
640  StructRNA *ptype = RNA_property_pointer_type(ptr, prop);
641  if (ptype != &RNA_Struct) {
642  PointerRNA opptr = RNA_property_pointer_get(ptr, prop);
643  changed |= WM_gizmo_properties_default(&opptr, do_update);
644  }
645  break;
646  }
647  default:
648  if ((do_update == false) || (RNA_property_is_set(ptr, prop) == false)) {
649  if (RNA_property_reset(ptr, prop, -1)) {
650  changed = true;
651  }
652  }
653  break;
654  }
655  }
657 
658  return changed;
659 }
660 
662 {
663  if (gz->ptr->data) {
664  PropertyRNA *iterprop;
665  iterprop = RNA_struct_iterator_property(gz->type->srna);
666 
667  RNA_PROP_BEGIN (gz->ptr, itemptr, iterprop) {
668  PropertyRNA *prop = itemptr.data;
669 
670  if ((RNA_property_flag(prop) & PROP_SKIP_SAVE) == 0) {
671  const char *identifier = RNA_property_identifier(prop);
672  RNA_struct_idprops_unset(gz->ptr, identifier);
673  }
674  }
675  RNA_PROP_END;
676  }
677 }
678 
680 {
681  IDProperty *properties = ptr->data;
682 
683  if (properties) {
684  IDP_ClearProperty(properties);
685  }
686 }
687 
689 {
690  IDProperty *properties = ptr->data;
691 
692  if (properties) {
693  IDP_FreeProperty(properties);
694  ptr->data = NULL; /* just in case */
695  }
696 }
697 
700 /* -------------------------------------------------------------------- */
705 {
706  switch (step) {
708  break;
709  }
712  if (ED_screen_animation_playing(wm)) {
713  return false;
714  }
715  break;
716  }
717  }
718  return true;
719 }
720 
typedef float(TangentPoint)[2]
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:713
struct RegionView3D * CTX_wm_region_view3d(const bContext *C)
Definition: context.c:793
#define G_MAIN
Definition: BKE_global.h:267
struct IDProperty * IDP_New(char type, const IDPropertyTemplate *val, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: idprop.c:887
void IDP_MergeGroup(struct IDProperty *dest, const struct IDProperty *src, bool do_overwrite) ATTR_NONNULL()
void IDP_FreeProperty(struct IDProperty *prop)
Definition: idprop.c:1093
void IDP_ClearProperty(struct IDProperty *prop)
Definition: idprop.c:1099
struct IDProperty * IDP_CopyProperty(const struct IDProperty *prop) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
#define BLI_assert(a)
Definition: BLI_assert.h:46
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:100
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:259
void mul_mat3_m4_fl(float R[4][4], float f)
Definition: math_matrix.c:978
void unit_m4(float m[4][4])
Definition: rct.c:1090
void copy_m4_m4(float m1[4][4], const float m2[4][4])
Definition: math_matrix.c:77
void rotation_between_vecs_to_mat3(float m[3][3], const float v1[3], const float v2[3])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE float normalize_v3(float r[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
void ortho_basis_v3v3_v3(float r_n1[3], float r_n2[3], const float n[3])
Definition: math_vector.c:707
void BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr)
@ IDP_GROUP
Definition: DNA_ID.h:141
bScreen * ED_screen_animation_playing(const struct wmWindowManager *wm)
float ED_view3d_pixel_size_no_ui_scale(const struct RegionView3D *rv3d, const float co[3])
Read Guarded memory(de)allocation.
#define MEM_recallocN(vmemh, len)
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 Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input 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 a color
#define RNA_PROP_END
Definition: RNA_access.h:563
#define RNA_STRUCT_BEGIN(sptr, prop)
Definition: RNA_access.h:569
#define RNA_STRUCT_END
Definition: RNA_access.h:589
#define RNA_PROP_BEGIN(sptr, itemptr, prop)
Definition: RNA_access.h:556
@ PROP_ENUM
Definition: RNA_types.h:63
@ PROP_POINTER
Definition: RNA_types.h:64
@ PROP_ENUM_NO_CONTEXT
Definition: RNA_types.h:292
@ PROP_SKIP_SAVE
Definition: RNA_types.h:218
#define C
Definition: RandGen.cpp:25
#define UI_DPI_FAC
Definition: UI_interface.h:305
eWM_GizmoFlagMapDrawStep
@ WM_GIZMOMAP_DRAWSTEP_3D
@ WM_GIZMOMAP_DRAWSTEP_2D
@ WM_GIZMO_DRAW_NO_SCALE
@ WM_GIZMO_HIDDEN
@ WM_GIZMO_OPERATOR_TOOL_INIT
@ WM_GIZMO_DRAW_VALUE
@ WM_GIZMO_DRAW_MODAL
@ WM_GIZMO_DRAW_HOVER
@ WM_GIZMO_DRAW_OFFSET_SCALE
@ WM_GIZMOGROUPTYPE_SCALE
@ WM_GIZMO_STATE_HIGHLIGHT
@ WM_GIZMO_STATE_MODAL
@ WM_GIZMO_STATE_SELECT
#define WM_toolsystem_ref_properties_get_from_operator(tref, ot, r_ptr)
@ WM_OP_INVOKE_DEFAULT
Definition: WM_types.h:201
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: avxb.h:154
unsigned int U
Definition: btGjkEpa3.h:78
#define rot(x, k)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
Definition: rna_access.c:695
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:136
const char * RNA_property_identifier(const PropertyRNA *prop)
Definition: rna_access.c:1000
bool RNA_property_reset(PointerRNA *ptr, PropertyRNA *prop, int index)
Definition: rna_access.c:6649
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:5271
PropertyType RNA_property_type(PropertyRNA *prop)
Definition: rna_access.c:1010
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:3493
StructRNA * RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:1405
int RNA_property_flag(PropertyRNA *prop)
Definition: rna_access.c:1055
bool RNA_struct_idprops_unset(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:680
PropertyRNA * RNA_struct_iterator_property(StructRNA *type)
Definition: rna_access.c:634
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1495
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1490
void * data
Definition: RNA_types.h:38
eWM_GizmoFlagGroupTypeFlag flag
struct wmGizmoGroupType * type
struct wmGizmo * modal
struct wmGizmo * highlight
struct wmGizmoMap::@1182 gzmap_context
Gizmo map runtime context.
PointerRNA ptr
struct wmOperatorType * type
wmGizmoPropertyFnFree free_fn
struct wmGizmoProperty::@1185 custom_func
wmGizmoFnSelectRefresh select_refresh
wmGizmoFnSetup setup
int target_property_defs_len
wmGizmoFnMatrixBasisGet matrix_basis_get
struct StructRNA * srna
wmGizmoFnFree free
wmGizmoFnPropertyUpdate property_update
eWM_GizmoFlagState state
struct wmGizmoGroup * parent_gzgroup
int highlight_part
float matrix_basis[4][4]
void * py_instance
float matrix_offset[4][4]
wmGizmoOpElem * op_data
float color_hi[4]
float scale_final
int op_data_len
float color[4]
struct PointerRNA * ptr
float scale_basis
float matrix_space[4][4]
float line_width
eWM_GizmoFlag flag
wmGizmoFnModal custom_modal
const struct wmGizmoType * type
struct IDProperty * properties
int WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
int WM_operator_name_call(bContext *C, const char *opstring, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
PointerRNA * ptr
Definition: wm_files.c:3480
wmOperatorType * ot
Definition: wm_files.c:3479
bool wm_gizmo_select_set_ex(wmGizmoMap *gzmap, wmGizmo *gz, bool select, bool use_array, bool use_callback)
Definition: wm_gizmo.c:357
void WM_gizmo_set_matrix_offset_location(wmGizmo *gz, const float offset[3])
Definition: wm_gizmo.c:299
bool WM_gizmo_context_check_drawstep(const struct bContext *C, eWM_GizmoFlagMapDrawStep step)
Definition: wm_gizmo.c:704
static void wm_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz)
Definition: wm_gizmo.c:120
void WM_gizmo_set_fn_custom_modal(struct wmGizmo *gz, wmGizmoFnModal fn)
Definition: wm_gizmo.c:348
static void gizmo_update_prop_data(wmGizmo *gz)
Definition: wm_gizmo.c:460
void WM_gizmo_calc_matrix_final_params(const wmGizmo *gz, const struct WM_GizmoMatrixParams *params, float r_mat[4][4])
Definition: wm_gizmo.c:502
PointerRNA * WM_gizmo_operator_set(wmGizmo *gz, int part_index, wmOperatorType *ot, IDProperty *properties)
Definition: wm_gizmo.c:203
void WM_gizmo_set_color_highlight(wmGizmo *gz, const float color_hi[4])
Definition: wm_gizmo.c:337
void WM_gizmo_set_line_width(wmGizmo *gz, const float line_width)
Definition: wm_gizmo.c:319
bool wm_gizmo_select_and_highlight(bContext *C, wmGizmoMap *gzmap, wmGizmo *gz)
Definition: wm_gizmo.c:407
void WM_gizmo_get_color_highlight(const wmGizmo *gz, float color_hi[4])
Definition: wm_gizmo.c:333
void WM_gizmo_modal_set_from_setup(struct wmGizmoMap *gzmap, struct bContext *C, struct wmGizmo *gz, int part_index, const wmEvent *event)
Definition: wm_gizmo.c:416
void WM_gizmo_free(wmGizmo *gz)
Definition: wm_gizmo.c:126
void WM_gizmo_set_matrix_offset_rotation_from_yz_axis(wmGizmo *gz, const float y_axis[3], const float z_axis[3])
Definition: wm_gizmo.c:293
void WM_gizmo_calc_matrix_final(const wmGizmo *gz, float r_mat[4][4])
Definition: wm_gizmo.c:554
int WM_gizmo_operator_invoke(bContext *C, wmGizmo *gz, wmGizmoOpElem *gzop, const wmEvent *event)
Definition: wm_gizmo.c:229
void WM_gizmo_set_matrix_rotation_from_yz_axis(wmGizmo *gz, const float y_axis[3], const float z_axis[3])
Definition: wm_gizmo.c:278
void WM_gizmo_properties_create_ptr(PointerRNA *ptr, wmGizmoType *gzt)
Definition: wm_gizmo.c:573
wmGizmo * WM_gizmo_new_ptr(const wmGizmoType *gzt, wmGizmoGroup *gzgroup, PointerRNA *properties)
Definition: wm_gizmo.c:81
static void wm_gizmo_set_matrix_rotation_from_yz_axis__internal(float matrix[4][4], const float y_axis[3], const float z_axis[3])
Definition: wm_gizmo.c:264
void WM_gizmo_get_color(const wmGizmo *gz, float color[4])
Definition: wm_gizmo.c:324
void WM_gizmo_calc_matrix_final_no_offset(const wmGizmo *gz, float r_mat[4][4])
Definition: wm_gizmo.c:539
void wm_gizmo_update(wmGizmo *gz, const bContext *C, const bool refresh_map)
Definition: wm_gizmo.c:474
bool WM_gizmo_highlight_set(wmGizmoMap *gzmap, wmGizmo *gz)
Definition: wm_gizmo.c:402
void WM_gizmo_set_matrix_offset_rotation_from_z_axis(wmGizmo *gz, const float z_axis[3])
Definition: wm_gizmo.c:289
static void gizmo_init(wmGizmo *gz)
Definition: wm_gizmo.c:103
void WM_gizmo_set_scale(wmGizmo *gz, const float scale)
Definition: wm_gizmo.c:314
void WM_gizmo_set_matrix_location(wmGizmo *gz, const float origin[3])
Definition: wm_gizmo.c:284
bool WM_gizmo_select_unlink(wmGizmoMap *gzmap, wmGizmo *gz)
Definition: wm_gizmo.c:392
void WM_gizmo_set_flag(wmGizmo *gz, const int flag, const bool enable)
Definition: wm_gizmo.c:304
void WM_gizmo_set_matrix_rotation_from_z_axis(wmGizmo *gz, const float z_axis[3])
Definition: wm_gizmo.c:274
static wmGizmo * wm_gizmo_create(const wmGizmoType *gzt, PointerRNA *properties)
Definition: wm_gizmo.c:50
static void wm_gizmo_set_matrix_rotation_from_z_axis__internal(float matrix[4][4], const float z_axis[3])
Definition: wm_gizmo.c:246
struct wmGizmoOpElem * WM_gizmo_operator_get(wmGizmo *gz, int part_index)
Definition: wm_gizmo.c:195
bool WM_gizmo_select_set(wmGizmoMap *gzmap, wmGizmo *gz, bool select)
Definition: wm_gizmo.c:397
void WM_gizmo_properties_sanitize(PointerRNA *ptr, const bool no_context)
Definition: wm_gizmo.c:605
wmGizmo * WM_gizmo_new(const char *idname, wmGizmoGroup *gzgroup, PointerRNA *properties)
Definition: wm_gizmo.c:94
void WM_gizmo_properties_free(PointerRNA *ptr)
Definition: wm_gizmo.c:688
void WM_gizmo_properties_reset(wmGizmo *gz)
Definition: wm_gizmo.c:661
void WM_gizmo_properties_clear(PointerRNA *ptr)
Definition: wm_gizmo.c:679
void wm_gizmo_calculate_scale(wmGizmo *gz, const bContext *C)
Definition: wm_gizmo.c:433
bool WM_gizmo_properties_default(PointerRNA *ptr, const bool do_update)
Definition: wm_gizmo.c:634
void WM_gizmo_properties_create(PointerRNA *ptr, const char *gtstring)
Definition: wm_gizmo.c:578
void WM_gizmo_set_color(wmGizmo *gz, const float color[4])
Definition: wm_gizmo.c:328
int wm_gizmo_is_visible(wmGizmo *gz)
Definition: wm_gizmo.c:482
void WM_gizmo_properties_alloc(PointerRNA **ptr, IDProperty **properties, const char *gtstring)
Definition: wm_gizmo.c:590
void WM_gizmo_unlink(ListBase *gizmolist, wmGizmoMap *gzmap, wmGizmo *gz, bContext *C)
Definition: wm_gizmo.c:165
int(* wmGizmoFnModal)(struct bContext *, struct wmGizmo *, const struct wmEvent *, eWM_GizmoFlagTweak)
Definition: wm_gizmo_fn.h:42
void wm_gizmogroup_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz)
@ WM_GIZMO_IS_VISIBLE_DRAW
@ WM_GIZMO_IS_VISIBLE_UPDATE
void wm_gizmomap_select_array_remove(struct wmGizmoMap *gzmap, wmGizmo *gz)
Definition: wm_gizmo_map.c:129
void wm_gizmomap_select_array_push_back(struct wmGizmoMap *gzmap, wmGizmo *gz)
Definition: wm_gizmo_map.c:118
void wm_gizmomap_modal_set(wmGizmoMap *gzmap, bContext *C, wmGizmo *gz, const wmEvent *event, bool enable)
bool wm_gizmomap_highlight_set(wmGizmoMap *gzmap, const bContext *C, wmGizmo *gz, int part)
Definition: wm_gizmo_map.c:983
bool WM_gizmo_target_property_is_valid(const wmGizmoProperty *gz_prop)
wmGizmoProperty * WM_gizmo_target_property_array(wmGizmo *gz)
const wmGizmoType * WM_gizmotype_find(const char *idname, bool quiet)
Definition: wm_gizmo_type.c:45
void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot)
Definition: wm_operators.c:661
void WM_operator_properties_free(PointerRNA *ptr)
Definition: wm_operators.c:783
struct bToolRef * WM_toolsystem_ref_from_context(struct bContext *C)
Definition: wm_toolsystem.c:57