Blender  V3.3
mball_edit.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #include <math.h>
9 #include <string.h>
10 
11 #include "MEM_guardedalloc.h"
12 
13 #include "BLI_blenlib.h"
14 #include "BLI_kdtree.h"
15 #include "BLI_math.h"
16 #include "BLI_rand.h"
17 #include "BLI_utildefines.h"
18 
19 #include "DNA_defs.h"
20 #include "DNA_meta_types.h"
21 #include "DNA_object_types.h"
22 #include "DNA_scene_types.h"
23 
24 #include "RNA_access.h"
25 #include "RNA_define.h"
26 
27 #include "BKE_context.h"
28 #include "BKE_layer.h"
29 #include "BKE_mball.h"
30 #include "BKE_object.h"
31 
32 #include "DEG_depsgraph.h"
33 
34 #include "GPU_select.h"
35 
36 #include "ED_mball.h"
37 #include "ED_object.h"
38 #include "ED_screen.h"
39 #include "ED_select_utils.h"
40 #include "ED_view3d.h"
41 
42 #include "WM_api.h"
43 #include "WM_types.h"
44 
45 #include "mball_intern.h"
46 
47 /* -------------------------------------------------------------------- */
52 {
53  MetaBall *mb = (MetaBall *)obedit->data;
54 
55  mb->editelems = NULL;
56  mb->lastelem = NULL;
57 }
58 
60 {
61  MetaBall *mb = (MetaBall *)obedit->data;
62  MetaElem *ml; /*, *newml;*/
63 
64  ml = mb->elems.first;
65 
66  while (ml) {
67  if (ml->flag & SELECT) {
68  mb->lastelem = ml;
69  }
70  ml = ml->next;
71  }
72 
73  mb->editelems = &mb->elems;
74 }
75 
77 {
78 }
79 
82 /* -------------------------------------------------------------------- */
87 {
89  ViewContext vc;
91  uint bases_len = 0;
93  vc.view_layer, vc.v3d, &bases_len);
94  bool changed_multi = BKE_mball_deselect_all_multi_ex(bases, bases_len);
95  MEM_freeN(bases);
96  return changed_multi;
97 }
98 
101 /* -------------------------------------------------------------------- */
106  bContext *UNUSED(C), Object *obedit, bool obedit_is_new, float mat[4][4], float dia, int type)
107 {
108  MetaBall *mball = (MetaBall *)obedit->data;
109  MetaElem *ml;
110 
111  /* Deselect all existing metaelems */
112  ml = mball->editelems->first;
113  while (ml) {
114  ml->flag &= ~SELECT;
115  ml = ml->next;
116  }
117 
118  ml = BKE_mball_element_add(mball, type);
119  ml->rad *= dia;
120 
121  if (obedit_is_new) {
122  mball->wiresize *= dia;
123  mball->rendersize *= dia;
124  }
125  copy_v3_v3(&ml->x, mat[3]);
126  /* MB_ELIPSOID works differently (intentional?). Whatever the case,
127  * on testing this needs to be skipped otherwise it doesn't behave like other types. */
128  if (type != MB_ELIPSOID) {
129  mul_v3_fl(&ml->expx, dia);
130  }
131 
132  ml->flag |= SELECT;
133  mball->lastelem = ml;
134  return ml;
135 }
136 
139 /* -------------------------------------------------------------------- */
143 /* Select or deselect all MetaElements */
145 {
146  int action = RNA_enum_get(op->ptr, "action");
147 
148  ViewLayer *view_layer = CTX_data_view_layer(C);
149  uint bases_len = 0;
151  view_layer, CTX_wm_view3d(C), &bases_len);
152 
153  if (action == SEL_TOGGLE) {
154  action = BKE_mball_is_any_selected_multi(bases, bases_len) ? SEL_DESELECT : SEL_SELECT;
155  }
156 
157  switch (action) {
158  case SEL_SELECT:
159  BKE_mball_select_all_multi_ex(bases, bases_len);
160  break;
161  case SEL_DESELECT:
162  BKE_mball_deselect_all_multi_ex(bases, bases_len);
163  break;
164  case SEL_INVERT:
165  BKE_mball_select_swap_multi_ex(bases, bases_len);
166  break;
167  }
168 
169  for (uint base_index = 0; base_index < bases_len; base_index++) {
170  Object *obedit = bases[base_index]->object;
171  MetaBall *mb = (MetaBall *)obedit->data;
174  }
175 
176  MEM_freeN(bases);
177 
178  return OPERATOR_FINISHED;
179 }
180 
182 {
183  /* identifiers */
184  ot->name = "(De)select All";
185  ot->description = "Change selection of all metaball elements";
186  ot->idname = "MBALL_OT_select_all";
187 
188  /* callback functions */
191 
192  /* flags */
194 
196 }
197 
200 /* -------------------------------------------------------------------- */
204 enum {
209 };
210 
212  {SIMMBALL_TYPE, "TYPE", 0, "Type", ""},
213  {SIMMBALL_RADIUS, "RADIUS", 0, "Radius", ""},
214  {SIMMBALL_STIFFNESS, "STIFFNESS", 0, "Stiffness", ""},
215  {SIMMBALL_ROTATION, "ROTATION", 0, "Rotation", ""},
216  {0, NULL, 0, NULL, NULL},
217 };
218 
220  Object *obedit, MetaBall *mb, int type, KDTree_1d *tree_1d, KDTree_3d *tree_3d)
221 {
222  float tree_entry[3] = {0.0f, 0.0f, 0.0f};
223  MetaElem *ml;
224  int tree_index = 0;
225  for (ml = mb->editelems->first; ml; ml = ml->next) {
226  if (ml->flag & SELECT) {
227  switch (type) {
228  case SIMMBALL_RADIUS: {
229  float radius = ml->rad;
230  /* Radius in world space. */
231  float smat[3][3];
232  float radius_vec[3] = {radius, radius, radius};
233  BKE_object_scale_to_mat3(obedit, smat);
234  mul_m3_v3(smat, radius_vec);
235  radius = (radius_vec[0] + radius_vec[1] + radius_vec[2]) / 3;
236  tree_entry[0] = radius;
237  break;
238  }
239  case SIMMBALL_STIFFNESS: {
240  tree_entry[0] = ml->s;
241  break;
242  } break;
243  case SIMMBALL_ROTATION: {
244  float dir[3] = {1.0f, 0.0f, 0.0f};
245  float rmat[3][3];
246  mul_qt_v3(ml->quat, dir);
247  BKE_object_rot_to_mat3(obedit, rmat, true);
248  mul_m3_v3(rmat, dir);
249  copy_v3_v3(tree_entry, dir);
250  break;
251  }
252  }
253  if (tree_1d) {
254  BLI_kdtree_1d_insert(tree_1d, tree_index++, tree_entry);
255  }
256  else {
257  BLI_kdtree_3d_insert(tree_3d, tree_index++, tree_entry);
258  }
259  }
260  }
261 }
262 
263 static bool mball_select_similar_type(Object *obedit,
264  MetaBall *mb,
265  int type,
266  const KDTree_1d *tree_1d,
267  const KDTree_3d *tree_3d,
268  const float thresh)
269 {
270  MetaElem *ml;
271  bool changed = false;
272  for (ml = mb->editelems->first; ml; ml = ml->next) {
273  bool select = false;
274  switch (type) {
275  case SIMMBALL_RADIUS: {
276  float radius = ml->rad;
277  /* Radius in world space is the average of the
278  * scaled radius in x, y and z directions. */
279  float smat[3][3];
280  float radius_vec[3] = {radius, radius, radius};
281  BKE_object_scale_to_mat3(obedit, smat);
282  mul_m3_v3(smat, radius_vec);
283  radius = (radius_vec[0] + radius_vec[1] + radius_vec[2]) / 3;
284 
285  if (ED_select_similar_compare_float_tree(tree_1d, radius, thresh, SIM_CMP_EQ)) {
286  select = true;
287  }
288  break;
289  }
290  case SIMMBALL_STIFFNESS: {
291  float s = ml->s;
292  if (ED_select_similar_compare_float_tree(tree_1d, s, thresh, SIM_CMP_EQ)) {
293  select = true;
294  }
295  break;
296  }
297  case SIMMBALL_ROTATION: {
298  float dir[3] = {1.0f, 0.0f, 0.0f};
299  float rmat[3][3];
300  mul_qt_v3(ml->quat, dir);
301  BKE_object_rot_to_mat3(obedit, rmat, true);
302  mul_m3_v3(rmat, dir);
303 
304  float thresh_cos = cosf(thresh * (float)M_PI_2);
305 
306  KDTreeNearest_3d nearest;
307  if (BLI_kdtree_3d_find_nearest(tree_3d, dir, &nearest) != -1) {
308  float orient = angle_normalized_v3v3(dir, nearest.co);
309  /* Map to 0-1 to compare orientation. */
310  float delta = thresh_cos - fabsf(cosf(orient));
311  if (ED_select_similar_compare_float(delta, thresh, SIM_CMP_EQ)) {
312  select = true;
313  }
314  }
315  break;
316  }
317  }
318 
319  if (select) {
320  changed = true;
321  ml->flag |= SELECT;
322  }
323  }
324  return changed;
325 }
326 
328 {
329  const int type = RNA_enum_get(op->ptr, "type");
330  const float thresh = RNA_float_get(op->ptr, "threshold");
331  int tot_mball_selected_all = 0;
332 
333  ViewLayer *view_layer = CTX_data_view_layer(C);
334  uint bases_len = 0;
336  view_layer, CTX_wm_view3d(C), &bases_len);
337 
338  tot_mball_selected_all = BKE_mball_select_count_multi(bases, bases_len);
339 
340  short type_ref = 0;
341  KDTree_1d *tree_1d = NULL;
342  KDTree_3d *tree_3d = NULL;
343 
344  switch (type) {
345  case SIMMBALL_RADIUS:
346  case SIMMBALL_STIFFNESS:
347  tree_1d = BLI_kdtree_1d_new(tot_mball_selected_all);
348  break;
349  case SIMMBALL_ROTATION:
350  tree_3d = BLI_kdtree_3d_new(tot_mball_selected_all);
351  break;
352  }
353 
354  /* Get type of selected MetaBall */
355  for (uint base_index = 0; base_index < bases_len; base_index++) {
356  Object *obedit = bases[base_index]->object;
357  MetaBall *mb = (MetaBall *)obedit->data;
358 
359  switch (type) {
360  case SIMMBALL_TYPE: {
361  MetaElem *ml;
362  for (ml = mb->editelems->first; ml; ml = ml->next) {
363  if (ml->flag & SELECT) {
364  short mball_type = 1 << (ml->type + 1);
365  type_ref |= mball_type;
366  }
367  }
368  break;
369  }
370  case SIMMBALL_RADIUS:
371  case SIMMBALL_STIFFNESS:
372  case SIMMBALL_ROTATION:
373  mball_select_similar_type_get(obedit, mb, type, tree_1d, tree_3d);
374  break;
375  default:
376  BLI_assert(0);
377  break;
378  }
379  }
380 
381  if (tree_1d != NULL) {
382  BLI_kdtree_1d_deduplicate(tree_1d);
383  BLI_kdtree_1d_balance(tree_1d);
384  }
385  if (tree_3d != NULL) {
386  BLI_kdtree_3d_deduplicate(tree_3d);
387  BLI_kdtree_3d_balance(tree_3d);
388  }
389  /* Select MetaBalls with desired type. */
390  for (uint base_index = 0; base_index < bases_len; base_index++) {
391  Object *obedit = bases[base_index]->object;
392  MetaBall *mb = (MetaBall *)obedit->data;
393  bool changed = false;
394 
395  switch (type) {
396  case SIMMBALL_TYPE: {
397  MetaElem *ml;
398  for (ml = mb->editelems->first; ml; ml = ml->next) {
399  short mball_type = 1 << (ml->type + 1);
400  if (mball_type & type_ref) {
401  ml->flag |= SELECT;
402  changed = true;
403  }
404  }
405  break;
406  }
407  case SIMMBALL_RADIUS:
408  case SIMMBALL_STIFFNESS:
409  case SIMMBALL_ROTATION:
410  changed = mball_select_similar_type(obedit, mb, type, tree_1d, tree_3d, thresh);
411  break;
412  default:
413  BLI_assert(0);
414  break;
415  }
416 
417  if (changed) {
420  }
421  }
422 
423  MEM_freeN(bases);
424  if (tree_1d != NULL) {
425  BLI_kdtree_1d_free(tree_1d);
426  }
427  if (tree_3d != NULL) {
428  BLI_kdtree_3d_free(tree_3d);
429  }
430  return OPERATOR_FINISHED;
431 }
432 
434 {
435  /* identifiers */
436  ot->name = "Select Similar";
437  ot->idname = "MBALL_OT_select_similar";
438 
439  /* callback functions */
443  ot->description = "Select similar metaballs by property types";
444 
445  /* flags */
447 
448  /* properties */
449  ot->prop = RNA_def_enum(ot->srna, "type", prop_similar_types, 0, "Type", "");
450 
451  RNA_def_float(ot->srna, "threshold", 0.1, 0.0, FLT_MAX, "Threshold", "", 0.01, 1.0);
452 }
453 
456 /* -------------------------------------------------------------------- */
461 {
462  const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
463  const float randfac = RNA_float_get(op->ptr, "ratio");
465 
466  ViewLayer *view_layer = CTX_data_view_layer(C);
467  uint objects_len = 0;
469  view_layer, CTX_wm_view3d(C), &objects_len);
470  for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
471  Object *obedit = objects[ob_index];
472  MetaBall *mb = (MetaBall *)obedit->data;
474  continue;
475  }
476  int seed_iter = seed;
477 
478  /* This gives a consistent result regardless of object order. */
479  if (ob_index) {
480  seed_iter += BLI_ghashutil_strhash_p(obedit->id.name);
481  }
482 
483  RNG *rng = BLI_rng_new_srandom(seed_iter);
484 
485  LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
486  if (BLI_rng_get_float(rng) < randfac) {
487  if (select) {
488  ml->flag |= SELECT;
489  }
490  else {
491  ml->flag &= ~SELECT;
492  }
493  }
494  }
495 
496  BLI_rng_free(rng);
497 
500  }
501  MEM_freeN(objects);
502  return OPERATOR_FINISHED;
503 }
504 
506 {
507  /* identifiers */
508  ot->name = "Select Random";
509  ot->description = "Randomly select metaball elements";
510  ot->idname = "MBALL_OT_select_random_metaelems";
511 
512  /* callback functions */
515 
516  /* flags */
518 
519  /* properties */
521 }
522 
525 /* -------------------------------------------------------------------- */
529 /* Duplicate selected MetaElements */
531 {
532  ViewLayer *view_layer = CTX_data_view_layer(C);
533  uint objects_len = 0;
535  view_layer, CTX_wm_view3d(C), &objects_len);
536  for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
537  Object *obedit = objects[ob_index];
538  MetaBall *mb = (MetaBall *)obedit->data;
539  MetaElem *ml, *newml;
540 
542  continue;
543  }
544 
545  ml = mb->editelems->last;
546  if (ml) {
547  while (ml) {
548  if (ml->flag & SELECT) {
549  newml = MEM_dupallocN(ml);
550  BLI_addtail(mb->editelems, newml);
551  mb->lastelem = newml;
552  ml->flag &= ~SELECT;
553  }
554  ml = ml->prev;
555  }
557  DEG_id_tag_update(obedit->data, 0);
558  }
559  }
560  MEM_freeN(objects);
561  return OPERATOR_FINISHED;
562 }
563 
565 {
566  /* identifiers */
567  ot->name = "Duplicate Metaball Elements";
568  ot->description = "Duplicate selected metaball element(s)";
569  ot->idname = "MBALL_OT_duplicate_metaelems";
570 
571  /* callback functions */
574 
575  /* flags */
577 }
578 
581 /* -------------------------------------------------------------------- */
588 {
589  ViewLayer *view_layer = CTX_data_view_layer(C);
590  uint objects_len = 0;
592  view_layer, CTX_wm_view3d(C), &objects_len);
593  for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
594  Object *obedit = objects[ob_index];
595  MetaBall *mb = (MetaBall *)obedit->data;
596  MetaElem *ml, *next;
597 
599  continue;
600  }
601 
602  ml = mb->editelems->first;
603  if (ml) {
604  while (ml) {
605  next = ml->next;
606  if (ml->flag & SELECT) {
607  if (mb->lastelem == ml) {
608  mb->lastelem = NULL;
609  }
610  BLI_remlink(mb->editelems, ml);
611  MEM_freeN(ml);
612  }
613  ml = next;
614  }
616  DEG_id_tag_update(obedit->data, 0);
617  }
618  }
619  MEM_freeN(objects);
620  return OPERATOR_FINISHED;
621 }
622 
624 {
625  /* identifiers */
626  ot->name = "Delete";
627  ot->description = "Delete selected metaball element(s)";
628  ot->idname = "MBALL_OT_delete_metaelems";
629 
630  /* callback functions */
634 
635  /* flags */
637 }
638 
641 /* -------------------------------------------------------------------- */
646 {
647  Object *obedit = CTX_data_edit_object(C);
648  MetaBall *mb = (MetaBall *)obedit->data;
649  MetaElem *ml;
650  const bool invert = RNA_boolean_get(op->ptr, "unselected") ? SELECT : 0;
651 
652  ml = mb->editelems->first;
653 
654  if (ml) {
655  while (ml) {
656  if ((ml->flag & SELECT) != invert) {
657  ml->flag |= MB_HIDE;
658  }
659  ml = ml->next;
660  }
662  DEG_id_tag_update(obedit->data, 0);
663  }
664 
665  return OPERATOR_FINISHED;
666 }
667 
669 {
670  /* identifiers */
671  ot->name = "Hide Selected";
672  ot->description = "Hide (un)selected metaball element(s)";
673  ot->idname = "MBALL_OT_hide_metaelems";
674 
675  /* callback functions */
678 
679  /* flags */
681 
682  /* props */
684  ot->srna, "unselected", false, "Unselected", "Hide unselected rather than selected");
685 }
686 
689 /* -------------------------------------------------------------------- */
694 {
695  Object *obedit = CTX_data_edit_object(C);
696  MetaBall *mb = (MetaBall *)obedit->data;
697  const bool select = RNA_boolean_get(op->ptr, "select");
698  bool changed = false;
699 
700  LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
701  if (ml->flag & MB_HIDE) {
702  SET_FLAG_FROM_TEST(ml->flag, select, SELECT);
703  ml->flag &= ~MB_HIDE;
704  changed = true;
705  }
706  }
707  if (changed) {
709  DEG_id_tag_update(obedit->data, 0);
710  }
711 
712  return OPERATOR_FINISHED;
713 }
714 
716 {
717  /* identifiers */
718  ot->name = "Reveal Hidden";
719  ot->description = "Reveal all hidden metaball elements";
720  ot->idname = "MBALL_OT_reveal_metaelems";
721 
722  /* callback functions */
725 
726  /* flags */
728 
729  /* props */
730  RNA_def_boolean(ot->srna, "select", true, "Select", "");
731 }
732 
735 /* -------------------------------------------------------------------- */
740  uint bases_len,
741  const uint select_id,
742  MetaElem **r_ml)
743 {
744  const uint hit_object = select_id & 0xFFFF;
745  Base *base = NULL;
746  MetaElem *ml = NULL;
747  /* TODO(campbell): optimize, eg: sort & binary search. */
748  for (uint base_index = 0; base_index < bases_len; base_index++) {
749  if (bases[base_index]->object->runtime.select_id == hit_object) {
750  base = bases[base_index];
751  break;
752  }
753  }
754  if (base != NULL) {
755  const uint hit_elem = (select_id & ~MBALLSEL_ANY) >> 16;
756  MetaBall *mb = base->object->data;
757  ml = BLI_findlink(mb->editelems, hit_elem);
758  }
759  *r_ml = ml;
760  return base;
761 }
762 
764  const int mval[2],
765  bool use_cycle,
766  Base **r_base,
767  MetaElem **r_ml,
768  uint *r_selmask)
769 {
771  ViewContext vc;
772  int a, hits;
774  rcti rect;
775  bool found = false;
776 
778 
779  BLI_rcti_init_pt_radius(&rect, mval, 12);
780 
781  hits = view3d_opengl_select(&vc,
782  buffer,
784  &rect,
787 
788  if (hits == 0) {
789  return false;
790  }
791 
792  uint bases_len = 0;
793  Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(vc.view_layer, vc.v3d, &bases_len);
794 
795  int hit_cycle_offset = 0;
796  if (use_cycle) {
797  /* When cycling, use the hit directly after the current active meta-element (when set). */
798  const int base_index = vc.obact->runtime.select_id;
799  MetaBall *mb = (MetaBall *)vc.obact->data;
800  MetaElem *ml = mb->lastelem;
801  if (ml && (ml->flag & SELECT)) {
802  const int ml_index = BLI_findindex(mb->editelems, ml);
803  BLI_assert(ml_index != -1);
804 
805  /* Count backwards in case the active meta-element has multiple entries,
806  * ensure this steps onto the next meta-element. */
807  a = hits;
808  while (a--) {
809  const int select_id = buffer[a].id;
810  if (select_id == -1) {
811  continue;
812  }
813 
814  if (((select_id & 0xFFFF) == base_index) &&
815  ((select_id & ~MBALLSEL_ANY) >> 16 == ml_index)) {
816  hit_cycle_offset = a + 1;
817  break;
818  }
819  }
820  }
821  }
822 
823  for (a = 0; a < hits; a++) {
824  const int index = (hit_cycle_offset == 0) ? a : ((a + hit_cycle_offset) % hits);
825  const uint select_id = buffer[index].id;
826  if (select_id == -1) {
827  continue;
828  }
829 
830  MetaElem *ml;
831  Base *base = ED_mball_base_and_elem_from_select_buffer(bases, bases_len, select_id, &ml);
832  if (ml == NULL) {
833  continue;
834  }
835  *r_base = base;
836  *r_ml = ml;
837  *r_selmask = select_id & MBALLSEL_ANY;
838  found = true;
839  break;
840  }
841 
842  MEM_freeN(bases);
843 
844  return found;
845 }
846 
847 bool ED_mball_select_pick(bContext *C, const int mval[2], const struct SelectPick_Params *params)
848 {
849  Base *base = NULL;
850  MetaElem *ml = NULL;
851  uint selmask = 0;
852 
853  bool changed = false;
854 
855  bool found = ed_mball_findnearest_metaelem(C, mval, true, &base, &ml, &selmask);
856 
857  if (params->sel_op == SEL_OP_SET) {
858  if ((found && params->select_passthrough) && (ml->flag & SELECT)) {
859  found = false;
860  }
861  else if (found || params->deselect_all) {
862  /* Deselect everything. */
863  changed |= ED_mball_deselect_all_multi(C);
864  }
865  }
866 
867  if (found) {
868  if (selmask & MBALLSEL_RADIUS) {
869  ml->flag |= MB_SCALE_RAD;
870  }
871  else if (selmask & MBALLSEL_STIFF) {
872  ml->flag &= ~MB_SCALE_RAD;
873  }
874 
875  switch (params->sel_op) {
876  case SEL_OP_ADD: {
877  ml->flag |= SELECT;
878  break;
879  }
880  case SEL_OP_SUB: {
881  ml->flag &= ~SELECT;
882  break;
883  }
884  case SEL_OP_XOR: {
885  if (ml->flag & SELECT) {
886  ml->flag &= ~SELECT;
887  }
888  else {
889  ml->flag |= SELECT;
890  }
891  break;
892  }
893  case SEL_OP_SET: {
894  /* Deselect has already been performed. */
895  ml->flag |= SELECT;
896  break;
897  }
898  case SEL_OP_AND: {
899  BLI_assert_unreachable(); /* Doesn't make sense for picking. */
900  break;
901  }
902  }
903 
904  ViewLayer *view_layer = CTX_data_view_layer(C);
905  MetaBall *mb = (MetaBall *)base->object->data;
906  mb->lastelem = ml;
907 
910 
911  if (view_layer->basact != base) {
912  ED_object_base_activate(C, base);
913  }
914 
915  changed = true;
916  }
917 
918  return changed || found;
919 }
920 
struct Object * CTX_data_edit_object(const bContext *C)
Definition: context.c:1370
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1100
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Definition: context.c:1528
struct View3D * CTX_wm_view3d(const bContext *C)
Definition: context.c:784
#define BKE_view_layer_array_from_bases_in_edit_mode(view_layer, v3d, r_len)
Definition: BKE_layer.h:539
#define BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, v3d, r_len)
Definition: BKE_layer.h:542
#define BKE_view_layer_array_from_bases_in_edit_mode_unique_data(view_layer, v3d, r_len)
Definition: BKE_layer.h:546
struct MetaElem * BKE_mball_element_add(struct MetaBall *mb, int type)
Definition: mball.c:209
int BKE_mball_select_count_multi(struct Base **bases, int bases_len)
Definition: mball.c:657
bool BKE_mball_is_any_selected(const struct MetaBall *mb)
bool BKE_mball_deselect_all_multi_ex(struct Base **bases, int bases_len)
Definition: mball.c:703
bool BKE_mball_select_swap_multi_ex(struct Base **bases, int bases_len)
Definition: mball.c:725
bool BKE_mball_is_any_selected_multi(struct Base **bases, int bases_len)
Definition: mball.c:404
bool BKE_mball_is_any_unselected(const struct MetaBall *mb)
bool BKE_mball_select_all_multi_ex(struct Base **bases, int bases_len)
Definition: mball.c:680
General operations, lookup, etc. for blender objects.
void BKE_object_rot_to_mat3(const struct Object *ob, float r_mat[3][3], bool use_drot)
void BKE_object_scale_to_mat3(struct Object *ob, float r_mat[3][3])
Definition: object.cc:2887
#define BLI_assert_unreachable()
Definition: BLI_assert.h:93
#define BLI_assert(a)
Definition: BLI_assert.h:46
unsigned int BLI_ghashutil_strhash_p(const void *ptr)
A KD-tree for nearest neighbor search.
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:100
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define M_PI_2
Definition: BLI_math_base.h:23
void mul_m3_v3(const float M[3][3], float r[3])
Definition: math_matrix.c:926
void mul_qt_v3(const float q[4], float r[3])
Definition: math_rotation.c:59
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
float angle_normalized_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
Definition: math_vector.c:445
Random number functions.
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
Definition: rand.cc:58
struct RNG * BLI_rng_new_srandom(unsigned int seed)
Definition: rand.cc:46
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition: rand.cc:93
void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size)
Definition: rct.c:469
unsigned int uint
Definition: BLI_sys_types.h:67
#define ARRAY_SIZE(arr)
#define UNUSED(x)
#define SET_FLAG_FROM_TEST(value, test, flag)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_SELECT
Definition: DNA_ID.h:818
#define MB_ELIPSOID
#define MB_HIDE
#define MB_SCALE_RAD
Object is a sort of wrapper for general info.
@ OPERATOR_FINISHED
#define MBALLSEL_ANY
Definition: ED_mball.h:74
#define MBALLSEL_STIFF
Definition: ED_mball.h:72
#define MBALLSEL_RADIUS
Definition: ED_mball.h:73
void ED_object_base_activate(struct bContext *C, struct Base *base)
bool ED_operator_editmball(struct bContext *C)
Definition: screen_ops.c:653
@ SEL_SELECT
@ SEL_INVERT
@ SEL_DESELECT
@ SEL_TOGGLE
bool ED_select_similar_compare_float(float delta, float thresh, eSimilarCmp compare)
Definition: select_utils.c:69
@ SIM_CMP_EQ
bool ED_select_similar_compare_float_tree(const struct KDTree_1d *tree, float length, float thresh, eSimilarCmp compare)
@ SEL_OP_ADD
@ SEL_OP_SUB
@ SEL_OP_SET
@ SEL_OP_AND
@ SEL_OP_XOR
int view3d_opengl_select(struct ViewContext *vc, struct GPUSelectResult *buffer, unsigned int buffer_len, const struct rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter)
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc, struct Depsgraph *depsgraph)
#define MAXPICKELEMS
Definition: ED_view3d.h:894
@ VIEW3D_SELECT_PICK_ALL
Definition: ED_view3d.h:900
@ VIEW3D_SELECT_PICK_NEAREST
Definition: ED_view3d.h:902
@ VIEW3D_SELECT_FILTER_NOP
Definition: ED_view3d.h:907
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:25
@ OPTYPE_UNDO
Definition: WM_types.h:148
@ OPTYPE_REGISTER
Definition: WM_types.h:146
#define NC_GEOM
Definition: WM_types.h:343
#define ND_DATA
Definition: WM_types.h:456
#define ND_SELECT
Definition: WM_types.h:455
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: avxb.h:154
static unsigned long seed
Definition: btSoftBody.h:39
#define cosf(x)
Definition: cuda/compat.h:101
#define SELECT
const Depsgraph * depsgraph
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
Definition: invert.h:8
ccl_global float * buffer
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:28
static ulong * next
void MBALL_OT_select_all(wmOperatorType *ot)
Definition: mball_edit.c:181
void MBALL_OT_hide_metaelems(wmOperatorType *ot)
Definition: mball_edit.c:668
Base * ED_mball_base_and_elem_from_select_buffer(Base **bases, uint bases_len, const uint select_id, MetaElem **r_ml)
Definition: mball_edit.c:739
bool ED_mball_deselect_all_multi(bContext *C)
Definition: mball_edit.c:86
static void mball_select_similar_type_get(Object *obedit, MetaBall *mb, int type, KDTree_1d *tree_1d, KDTree_3d *tree_3d)
Definition: mball_edit.c:219
void ED_mball_editmball_free(Object *obedit)
Definition: mball_edit.c:51
static const EnumPropertyItem prop_similar_types[]
Definition: mball_edit.c:211
static int select_random_metaelems_exec(bContext *C, wmOperator *op)
Definition: mball_edit.c:460
void MBALL_OT_duplicate_metaelems(wmOperatorType *ot)
Definition: mball_edit.c:564
static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mball_edit.c:530
static bool mball_select_similar_type(Object *obedit, MetaBall *mb, int type, const KDTree_1d *tree_1d, const KDTree_3d *tree_3d, const float thresh)
Definition: mball_edit.c:263
static int mball_select_all_exec(bContext *C, wmOperator *op)
Definition: mball_edit.c:144
@ SIMMBALL_STIFFNESS
Definition: mball_edit.c:207
@ SIMMBALL_TYPE
Definition: mball_edit.c:205
@ SIMMBALL_RADIUS
Definition: mball_edit.c:206
@ SIMMBALL_ROTATION
Definition: mball_edit.c:208
static bool ed_mball_findnearest_metaelem(bContext *C, const int mval[2], bool use_cycle, Base **r_base, MetaElem **r_ml, uint *r_selmask)
Definition: mball_edit.c:763
static int delete_metaelems_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mball_edit.c:587
void MBALL_OT_select_similar(wmOperatorType *ot)
Definition: mball_edit.c:433
void ED_mball_editmball_load(Object *UNUSED(obedit))
Definition: mball_edit.c:76
void MBALL_OT_delete_metaelems(wmOperatorType *ot)
Definition: mball_edit.c:623
void MBALL_OT_reveal_metaelems(wmOperatorType *ot)
Definition: mball_edit.c:715
static int reveal_metaelems_exec(bContext *C, wmOperator *op)
Definition: mball_edit.c:693
static int hide_metaelems_exec(bContext *C, wmOperator *op)
Definition: mball_edit.c:645
void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot)
Definition: mball_edit.c:505
MetaElem * ED_mball_add_primitive(bContext *UNUSED(C), Object *obedit, bool obedit_is_new, float mat[4][4], float dia, int type)
Definition: mball_edit.c:105
static int mball_select_similar_exec(bContext *C, wmOperator *op)
Definition: mball_edit.c:327
bool ED_mball_select_pick(bContext *C, const int mval[2], const struct SelectPick_Params *params)
Definition: mball_edit.c:847
void ED_mball_editmball_make(Object *obedit)
Definition: mball_edit.c:59
#define fabsf(x)
Definition: metal/compat.h:219
static unsigned a[3]
Definition: RandGen.cpp:78
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4957
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4863
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
Definition: rna_define.c:3836
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3783
struct Object * object
char name[66]
Definition: DNA_ID.h:378
void * last
Definition: DNA_listBase.h:31
void * first
Definition: DNA_listBase.h:31
MetaElem * lastelem
ListBase elems
float rendersize
float wiresize
ListBase * editelems
struct MetaElem * next
short type
float quat[4]
struct MetaElem * prev
short flag
Object_Runtime runtime
void * data
Definition: rand.cc:33
struct ViewLayer * view_layer
Definition: ED_view3d.h:66
struct Object * obact
Definition: ED_view3d.h:67
struct View3D * v3d
Definition: ED_view3d.h:70
struct Base * basact
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:919
const char * name
Definition: WM_types.h:888
const char * idname
Definition: WM_types.h:890
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:943
struct StructRNA * srna
Definition: WM_types.h:969
const char * description
Definition: WM_types.h:893
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:903
PropertyRNA * prop
Definition: WM_types.h:981
struct PointerRNA * ptr
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition: wm_files.c:3479
int WM_operator_properties_select_random_seed_increment_get(wmOperator *op)
void WM_operator_properties_select_random(wmOperatorType *ot)
void WM_operator_properties_select_all(wmOperatorType *ot)
int WM_operator_confirm(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))