Blender  V2.93
mball_edit.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
24 #include <math.h>
25 #include <string.h>
26 
27 #include "MEM_guardedalloc.h"
28 
29 #include "BLI_blenlib.h"
30 #include "BLI_kdtree.h"
31 #include "BLI_math.h"
32 #include "BLI_rand.h"
33 #include "BLI_utildefines.h"
34 
35 #include "DNA_defs.h"
36 #include "DNA_meta_types.h"
37 #include "DNA_object_types.h"
38 #include "DNA_scene_types.h"
39 
40 #include "RNA_access.h"
41 #include "RNA_define.h"
42 
43 #include "BKE_context.h"
44 #include "BKE_layer.h"
45 #include "BKE_mball.h"
46 #include "BKE_object.h"
47 
48 #include "DEG_depsgraph.h"
49 
50 #include "ED_mball.h"
51 #include "ED_object.h"
52 #include "ED_screen.h"
53 #include "ED_select_utils.h"
54 #include "ED_view3d.h"
55 
56 #include "WM_api.h"
57 #include "WM_types.h"
58 
59 #include "mball_intern.h"
60 
61 /* -------------------------------------------------------------------- */
65 /* This function is used to free all MetaElems from MetaBall */
67 {
68  MetaBall *mb = (MetaBall *)obedit->data;
69 
70  mb->editelems = NULL;
71  mb->lastelem = NULL;
72 }
73 
74 /* This function is called, when MetaBall Object is
75  * switched from object mode to edit mode */
77 {
78  MetaBall *mb = (MetaBall *)obedit->data;
79  MetaElem *ml; /*, *newml;*/
80 
81  ml = mb->elems.first;
82 
83  while (ml) {
84  if (ml->flag & SELECT) {
85  mb->lastelem = ml;
86  }
87  ml = ml->next;
88  }
89 
90  mb->editelems = &mb->elems;
91 }
92 
93 /* This function is called, when MetaBall Object switched from
94  * edit mode to object mode. List of MetaElements is copied
95  * from object->data->edit_elems to object->data->elems. */
97 {
98 }
99 
102 /* -------------------------------------------------------------------- */
107 {
109  ViewContext vc;
111  uint bases_len = 0;
113  vc.view_layer, vc.v3d, &bases_len);
114  bool changed_multi = BKE_mball_deselect_all_multi_ex(bases, bases_len);
115  MEM_freeN(bases);
116  return changed_multi;
117 }
118 
121 /* -------------------------------------------------------------------- */
129  bContext *UNUSED(C), Object *obedit, bool obedit_is_new, float mat[4][4], float dia, int type)
130 {
131  MetaBall *mball = (MetaBall *)obedit->data;
132  MetaElem *ml;
133 
134  /* Deselect all existing metaelems */
135  ml = mball->editelems->first;
136  while (ml) {
137  ml->flag &= ~SELECT;
138  ml = ml->next;
139  }
140 
141  ml = BKE_mball_element_add(mball, type);
142  ml->rad *= dia;
143 
144  if (obedit_is_new) {
145  mball->wiresize *= dia;
146  mball->rendersize *= dia;
147  }
148  copy_v3_v3(&ml->x, mat[3]);
149  /* MB_ELIPSOID works differently (intentional?). Whatever the case,
150  * on testing this needs to be skipped otherwise it doesn't behave like other types. */
151  if (type != MB_ELIPSOID) {
152  mul_v3_fl(&ml->expx, dia);
153  }
154 
155  ml->flag |= SELECT;
156  mball->lastelem = ml;
157  return ml;
158 }
159 
162 /* -------------------------------------------------------------------- */
166 /* Select or deselect all MetaElements */
168 {
169  int action = RNA_enum_get(op->ptr, "action");
170 
171  ViewLayer *view_layer = CTX_data_view_layer(C);
172  uint bases_len = 0;
174  view_layer, CTX_wm_view3d(C), &bases_len);
175 
176  if (action == SEL_TOGGLE) {
177  action = BKE_mball_is_any_selected_multi(bases, bases_len) ? SEL_DESELECT : SEL_SELECT;
178  }
179 
180  switch (action) {
181  case SEL_SELECT:
182  BKE_mball_select_all_multi_ex(bases, bases_len);
183  break;
184  case SEL_DESELECT:
185  BKE_mball_deselect_all_multi_ex(bases, bases_len);
186  break;
187  case SEL_INVERT:
188  BKE_mball_select_swap_multi_ex(bases, bases_len);
189  break;
190  }
191 
192  for (uint base_index = 0; base_index < bases_len; base_index++) {
193  Object *obedit = bases[base_index]->object;
194  MetaBall *mb = (MetaBall *)obedit->data;
197  }
198 
199  MEM_freeN(bases);
200 
201  return OPERATOR_FINISHED;
202 }
203 
205 {
206  /* identifiers */
207  ot->name = "(De)select All";
208  ot->description = "Change selection of all metaball elements";
209  ot->idname = "MBALL_OT_select_all";
210 
211  /* callback functions */
214 
215  /* flags */
217 
219 }
220 
223 /* -------------------------------------------------------------------- */
227 enum {
232 };
233 
235  {SIMMBALL_TYPE, "TYPE", 0, "Type", ""},
236  {SIMMBALL_RADIUS, "RADIUS", 0, "Radius", ""},
237  {SIMMBALL_STIFFNESS, "STIFFNESS", 0, "Stiffness", ""},
238  {SIMMBALL_ROTATION, "ROTATION", 0, "Rotation", ""},
239  {0, NULL, 0, NULL, NULL},
240 };
241 
243  Object *obedit, MetaBall *mb, int type, KDTree_1d *tree_1d, KDTree_3d *tree_3d)
244 {
245  float tree_entry[3] = {0.0f, 0.0f, 0.0f};
246  MetaElem *ml;
247  int tree_index = 0;
248  for (ml = mb->editelems->first; ml; ml = ml->next) {
249  if (ml->flag & SELECT) {
250  switch (type) {
251  case SIMMBALL_RADIUS: {
252  float radius = ml->rad;
253  /* Radius in world space. */
254  float smat[3][3];
255  float radius_vec[3] = {radius, radius, radius};
256  BKE_object_scale_to_mat3(obedit, smat);
257  mul_m3_v3(smat, radius_vec);
258  radius = (radius_vec[0] + radius_vec[1] + radius_vec[2]) / 3;
259  tree_entry[0] = radius;
260  break;
261  }
262  case SIMMBALL_STIFFNESS: {
263  tree_entry[0] = ml->s;
264  break;
265  } break;
266  case SIMMBALL_ROTATION: {
267  float dir[3] = {1.0f, 0.0f, 0.0f};
268  float rmat[3][3];
269  mul_qt_v3(ml->quat, dir);
270  BKE_object_rot_to_mat3(obedit, rmat, true);
271  mul_m3_v3(rmat, dir);
272  copy_v3_v3(tree_entry, dir);
273  break;
274  }
275  }
276  if (tree_1d) {
277  BLI_kdtree_1d_insert(tree_1d, tree_index++, tree_entry);
278  }
279  else {
280  BLI_kdtree_3d_insert(tree_3d, tree_index++, tree_entry);
281  }
282  }
283  }
284 }
285 
286 static bool mball_select_similar_type(Object *obedit,
287  MetaBall *mb,
288  int type,
289  const KDTree_1d *tree_1d,
290  const KDTree_3d *tree_3d,
291  const float thresh)
292 {
293  MetaElem *ml;
294  bool changed = false;
295  for (ml = mb->editelems->first; ml; ml = ml->next) {
296  bool select = false;
297  switch (type) {
298  case SIMMBALL_RADIUS: {
299  float radius = ml->rad;
300  /* Radius in world space is the average of the
301  * scaled radius in x, y and z directions. */
302  float smat[3][3];
303  float radius_vec[3] = {radius, radius, radius};
304  BKE_object_scale_to_mat3(obedit, smat);
305  mul_m3_v3(smat, radius_vec);
306  radius = (radius_vec[0] + radius_vec[1] + radius_vec[2]) / 3;
307 
308  if (ED_select_similar_compare_float_tree(tree_1d, radius, thresh, SIM_CMP_EQ)) {
309  select = true;
310  }
311  break;
312  }
313  case SIMMBALL_STIFFNESS: {
314  float s = ml->s;
315  if (ED_select_similar_compare_float_tree(tree_1d, s, thresh, SIM_CMP_EQ)) {
316  select = true;
317  }
318  break;
319  }
320  case SIMMBALL_ROTATION: {
321  float dir[3] = {1.0f, 0.0f, 0.0f};
322  float rmat[3][3];
323  mul_qt_v3(ml->quat, dir);
324  BKE_object_rot_to_mat3(obedit, rmat, true);
325  mul_m3_v3(rmat, dir);
326 
327  float thresh_cos = cosf(thresh * (float)M_PI_2);
328 
329  KDTreeNearest_3d nearest;
330  if (BLI_kdtree_3d_find_nearest(tree_3d, dir, &nearest) != -1) {
331  float orient = angle_normalized_v3v3(dir, nearest.co);
332  /* Map to 0-1 to compare orientation. */
333  float delta = thresh_cos - fabsf(cosf(orient));
334  if (ED_select_similar_compare_float(delta, thresh, SIM_CMP_EQ)) {
335  select = true;
336  }
337  }
338  break;
339  }
340  }
341 
342  if (select) {
343  changed = true;
344  ml->flag |= SELECT;
345  }
346  }
347  return changed;
348 }
349 
351 {
352  const int type = RNA_enum_get(op->ptr, "type");
353  const float thresh = RNA_float_get(op->ptr, "threshold");
354  int tot_mball_selected_all = 0;
355 
356  ViewLayer *view_layer = CTX_data_view_layer(C);
357  uint bases_len = 0;
359  view_layer, CTX_wm_view3d(C), &bases_len);
360 
361  tot_mball_selected_all = BKE_mball_select_count_multi(bases, bases_len);
362 
363  short type_ref = 0;
364  KDTree_1d *tree_1d = NULL;
365  KDTree_3d *tree_3d = NULL;
366 
367  switch (type) {
368  case SIMMBALL_RADIUS:
369  case SIMMBALL_STIFFNESS:
370  tree_1d = BLI_kdtree_1d_new(tot_mball_selected_all);
371  break;
372  case SIMMBALL_ROTATION:
373  tree_3d = BLI_kdtree_3d_new(tot_mball_selected_all);
374  break;
375  }
376 
377  /* Get type of selected MetaBall */
378  for (uint base_index = 0; base_index < bases_len; base_index++) {
379  Object *obedit = bases[base_index]->object;
380  MetaBall *mb = (MetaBall *)obedit->data;
381 
382  switch (type) {
383  case SIMMBALL_TYPE: {
384  MetaElem *ml;
385  for (ml = mb->editelems->first; ml; ml = ml->next) {
386  if (ml->flag & SELECT) {
387  short mball_type = 1 << (ml->type + 1);
388  type_ref |= mball_type;
389  }
390  }
391  break;
392  }
393  case SIMMBALL_RADIUS:
394  case SIMMBALL_STIFFNESS:
395  case SIMMBALL_ROTATION:
396  mball_select_similar_type_get(obedit, mb, type, tree_1d, tree_3d);
397  break;
398  default:
399  BLI_assert(0);
400  break;
401  }
402  }
403 
404  if (tree_1d != NULL) {
405  BLI_kdtree_1d_deduplicate(tree_1d);
406  BLI_kdtree_1d_balance(tree_1d);
407  }
408  if (tree_3d != NULL) {
409  BLI_kdtree_3d_deduplicate(tree_3d);
410  BLI_kdtree_3d_balance(tree_3d);
411  }
412  /* Select MetaBalls with desired type. */
413  for (uint base_index = 0; base_index < bases_len; base_index++) {
414  Object *obedit = bases[base_index]->object;
415  MetaBall *mb = (MetaBall *)obedit->data;
416  bool changed = false;
417 
418  switch (type) {
419  case SIMMBALL_TYPE: {
420  MetaElem *ml;
421  for (ml = mb->editelems->first; ml; ml = ml->next) {
422  short mball_type = 1 << (ml->type + 1);
423  if (mball_type & type_ref) {
424  ml->flag |= SELECT;
425  changed = true;
426  }
427  }
428  break;
429  }
430  case SIMMBALL_RADIUS:
431  case SIMMBALL_STIFFNESS:
432  case SIMMBALL_ROTATION:
433  changed = mball_select_similar_type(obedit, mb, type, tree_1d, tree_3d, thresh);
434  break;
435  default:
436  BLI_assert(0);
437  break;
438  }
439 
440  if (changed) {
443  }
444  }
445 
446  MEM_freeN(bases);
447  if (tree_1d != NULL) {
448  BLI_kdtree_1d_free(tree_1d);
449  }
450  if (tree_3d != NULL) {
451  BLI_kdtree_3d_free(tree_3d);
452  }
453  return OPERATOR_FINISHED;
454 }
455 
457 {
458  /* identifiers */
459  ot->name = "Select Similar";
460  ot->idname = "MBALL_OT_select_similar";
461 
462  /* callback functions */
466  ot->description = "Select similar metaballs by property types";
467 
468  /* flags */
470 
471  /* properties */
472  ot->prop = RNA_def_enum(ot->srna, "type", prop_similar_types, 0, "Type", "");
473 
474  RNA_def_float(ot->srna, "threshold", 0.1, 0.0, FLT_MAX, "Threshold", "", 0.01, 1.0);
475 }
476 
479 /* -------------------------------------------------------------------- */
484 {
485  const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
486  const float randfac = RNA_float_get(op->ptr, "ratio");
488 
489  ViewLayer *view_layer = CTX_data_view_layer(C);
490  uint objects_len = 0;
492  view_layer, CTX_wm_view3d(C), &objects_len);
493  for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
494  Object *obedit = objects[ob_index];
495  MetaBall *mb = (MetaBall *)obedit->data;
497  continue;
498  }
499  int seed_iter = seed;
500 
501  /* This gives a consistent result regardless of object order. */
502  if (ob_index) {
503  seed_iter += BLI_ghashutil_strhash_p(obedit->id.name);
504  }
505 
506  RNG *rng = BLI_rng_new_srandom(seed_iter);
507 
508  LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
509  if (BLI_rng_get_float(rng) < randfac) {
510  if (select) {
511  ml->flag |= SELECT;
512  }
513  else {
514  ml->flag &= ~SELECT;
515  }
516  }
517  }
518 
519  BLI_rng_free(rng);
520 
523  }
524  MEM_freeN(objects);
525  return OPERATOR_FINISHED;
526 }
527 
529 {
530  /* identifiers */
531  ot->name = "Select Random";
532  ot->description = "Randomly select metaball elements";
533  ot->idname = "MBALL_OT_select_random_metaelems";
534 
535  /* callback functions */
538 
539  /* flags */
541 
542  /* properties */
544 }
545 
548 /* -------------------------------------------------------------------- */
552 /* Duplicate selected MetaElements */
554 {
555  ViewLayer *view_layer = CTX_data_view_layer(C);
556  uint objects_len = 0;
558  view_layer, CTX_wm_view3d(C), &objects_len);
559  for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
560  Object *obedit = objects[ob_index];
561  MetaBall *mb = (MetaBall *)obedit->data;
562  MetaElem *ml, *newml;
563 
565  continue;
566  }
567 
568  ml = mb->editelems->last;
569  if (ml) {
570  while (ml) {
571  if (ml->flag & SELECT) {
572  newml = MEM_dupallocN(ml);
573  BLI_addtail(mb->editelems, newml);
574  mb->lastelem = newml;
575  ml->flag &= ~SELECT;
576  }
577  ml = ml->prev;
578  }
580  DEG_id_tag_update(obedit->data, 0);
581  }
582  }
583  MEM_freeN(objects);
584  return OPERATOR_FINISHED;
585 }
586 
588 {
589  /* identifiers */
590  ot->name = "Duplicate Metaball Elements";
591  ot->description = "Duplicate selected metaball element(s)";
592  ot->idname = "MBALL_OT_duplicate_metaelems";
593 
594  /* callback functions */
597 
598  /* flags */
600 }
601 
604 /* -------------------------------------------------------------------- */
611 {
612  ViewLayer *view_layer = CTX_data_view_layer(C);
613  uint objects_len = 0;
615  view_layer, CTX_wm_view3d(C), &objects_len);
616  for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
617  Object *obedit = objects[ob_index];
618  MetaBall *mb = (MetaBall *)obedit->data;
619  MetaElem *ml, *next;
620 
622  continue;
623  }
624 
625  ml = mb->editelems->first;
626  if (ml) {
627  while (ml) {
628  next = ml->next;
629  if (ml->flag & SELECT) {
630  if (mb->lastelem == ml) {
631  mb->lastelem = NULL;
632  }
633  BLI_remlink(mb->editelems, ml);
634  MEM_freeN(ml);
635  }
636  ml = next;
637  }
639  DEG_id_tag_update(obedit->data, 0);
640  }
641  }
642  MEM_freeN(objects);
643  return OPERATOR_FINISHED;
644 }
645 
647 {
648  /* identifiers */
649  ot->name = "Delete";
650  ot->description = "Delete selected metaball element(s)";
651  ot->idname = "MBALL_OT_delete_metaelems";
652 
653  /* callback functions */
657 
658  /* flags */
660 }
661 
664 /* -------------------------------------------------------------------- */
669 {
670  Object *obedit = CTX_data_edit_object(C);
671  MetaBall *mb = (MetaBall *)obedit->data;
672  MetaElem *ml;
673  const bool invert = RNA_boolean_get(op->ptr, "unselected") ? SELECT : 0;
674 
675  ml = mb->editelems->first;
676 
677  if (ml) {
678  while (ml) {
679  if ((ml->flag & SELECT) != invert) {
680  ml->flag |= MB_HIDE;
681  }
682  ml = ml->next;
683  }
685  DEG_id_tag_update(obedit->data, 0);
686  }
687 
688  return OPERATOR_FINISHED;
689 }
690 
692 {
693  /* identifiers */
694  ot->name = "Hide Selected";
695  ot->description = "Hide (un)selected metaball element(s)";
696  ot->idname = "MBALL_OT_hide_metaelems";
697 
698  /* callback functions */
701 
702  /* flags */
704 
705  /* props */
707  ot->srna, "unselected", false, "Unselected", "Hide unselected rather than selected");
708 }
709 
712 /* -------------------------------------------------------------------- */
717 {
718  Object *obedit = CTX_data_edit_object(C);
719  MetaBall *mb = (MetaBall *)obedit->data;
720  const bool select = RNA_boolean_get(op->ptr, "select");
721  bool changed = false;
722 
723  LISTBASE_FOREACH (MetaElem *, ml, mb->editelems) {
724  if (ml->flag & MB_HIDE) {
725  SET_FLAG_FROM_TEST(ml->flag, select, SELECT);
726  ml->flag &= ~MB_HIDE;
727  changed = true;
728  }
729  }
730  if (changed) {
732  DEG_id_tag_update(obedit->data, 0);
733  }
734 
735  return OPERATOR_FINISHED;
736 }
737 
739 {
740  /* identifiers */
741  ot->name = "Reveal Hidden";
742  ot->description = "Reveal all hidden metaball elements";
743  ot->idname = "MBALL_OT_reveal_metaelems";
744 
745  /* callback functions */
748 
749  /* flags */
751 
752  /* props */
753  RNA_def_boolean(ot->srna, "select", true, "Select", "");
754 }
755 
758 /* -------------------------------------------------------------------- */
762 /* Select MetaElement with mouse click (user can select radius circle or
763  * stiffness circle) */
764 bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle)
765 {
767  static MetaElem *startelem = NULL;
768  ViewContext vc;
769  int a, hits;
771  rcti rect;
772 
774 
775  BLI_rcti_init_pt_radius(&rect, mval, 12);
776 
777  hits = view3d_opengl_select(
779 
781  ED_view3d_viewcontext_init_object(&vc, base->object);
782  MetaBall *mb = (MetaBall *)base->object->data;
783  MetaElem *ml, *ml_act = NULL;
784 
785  /* does startelem exist? */
786  ml = mb->editelems->first;
787  while (ml) {
788  if (ml == startelem) {
789  break;
790  }
791  ml = ml->next;
792  }
793 
794  if (ml == NULL) {
795  startelem = mb->editelems->first;
796  }
797 
798  if (hits > 0) {
799  int metaelem_id = 0;
800  ml = startelem;
801  while (ml) {
802  for (a = 0; a < hits; a++) {
803  int hitresult = buffer[(4 * a) + 3];
804  if (hitresult == -1) {
805  continue;
806  }
807 
808  const uint hit_object = hitresult & 0xFFFF;
809  if (vc.obedit->runtime.select_id != hit_object) {
810  continue;
811  }
812 
813  if (metaelem_id != (hitresult & 0xFFFF0000 & ~MBALLSEL_ANY)) {
814  continue;
815  }
816 
817  if (hitresult & MBALLSEL_RADIUS) {
818  ml->flag |= MB_SCALE_RAD;
819  ml_act = ml;
820  break;
821  }
822 
823  if (hitresult & MBALLSEL_STIFF) {
824  ml->flag &= ~MB_SCALE_RAD;
825  ml_act = ml;
826  break;
827  }
828  }
829 
830  if (ml_act) {
831  break;
832  }
833  ml = ml->next;
834  if (ml == NULL) {
835  ml = mb->editelems->first;
836  }
837  if (ml == startelem) {
838  break;
839  }
840 
841  metaelem_id += 0x10000;
842  }
843 
844  /* When some metaelem was found, then it is necessary to select or deselect it. */
845  if (ml_act) {
846  if (!extend && !deselect && !toggle) {
847  uint objects_len;
849  vc.view_layer, vc.v3d, &objects_len);
850  for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
851  Object *ob_iter = objects[ob_index];
852 
853  if (ob_iter == base->object) {
854  continue;
855  }
856 
857  BKE_mball_deselect_all((MetaBall *)ob_iter->data);
860  }
861  MEM_freeN(objects);
862  }
863 
864  if (extend) {
865  ml_act->flag |= SELECT;
866  }
867  else if (deselect) {
868  ml_act->flag &= ~SELECT;
869  }
870  else if (toggle) {
871  if (ml_act->flag & SELECT) {
872  ml_act->flag &= ~SELECT;
873  }
874  else {
875  ml_act->flag |= SELECT;
876  }
877  }
878  else {
879  /* Deselect all existing metaelems */
881 
882  /* Select only metaelem clicked on */
883  ml_act->flag |= SELECT;
884  }
885 
886  mb->lastelem = ml_act;
887 
890 
891  if (vc.view_layer->basact != base) {
892  ED_object_base_activate(C, base);
893  }
894 
895  return true;
896  }
897  }
898  }
900 
901  return false;
902 }
903 
struct Object * CTX_data_edit_object(const bContext *C)
Definition: context.c:1296
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1044
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Definition: context.c:1424
struct View3D * CTX_wm_view3d(const bContext *C)
Definition: context.c:760
#define FOREACH_BASE_IN_EDIT_MODE_BEGIN(_view_layer, _v3d, _instance)
Definition: BKE_layer.h:275
#define BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, v3d, r_len)
Definition: BKE_layer.h:426
#define BKE_view_layer_array_from_bases_in_edit_mode_unique_data(view_layer, v3d, r_len)
Definition: BKE_layer.h:430
#define FOREACH_BASE_IN_EDIT_MODE_END
Definition: BKE_layer.h:278
bool BKE_mball_deselect_all(struct MetaBall *mb)
Definition: mball.c:696
int BKE_mball_select_count_multi(struct Base **bases, int bases_len)
Definition: mball.c:662
bool BKE_mball_is_any_selected(const struct MetaBall *mb)
struct MetaElem * BKE_mball_element_add(struct MetaBall *mb, const int type)
Definition: mball.c:225
bool BKE_mball_deselect_all_multi_ex(struct Base **bases, int bases_len)
Definition: mball.c:708
bool BKE_mball_select_swap_multi_ex(struct Base **bases, int bases_len)
Definition: mball.c:730
bool BKE_mball_is_any_selected_multi(struct Base **bases, int bases_len)
Definition: mball.c:436
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:685
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.c:3038
#define BLI_assert(a)
Definition: BLI_assert.h:58
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:172
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:110
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:133
#define M_PI_2
Definition: BLI_math_base.h:41
void mul_m3_v3(const float M[3][3], float r[3])
Definition: math_matrix.c:930
void mul_qt_v3(const float q[4], float r[3])
Definition: math_rotation.c:97
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:505
Random number functions.
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
Definition: rand.cc:76
struct RNG * BLI_rng_new_srandom(unsigned int seed)
Definition: rand.cc:64
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition: rand.cc:120
void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size)
Definition: rct.c:508
unsigned int uint
Definition: BLI_sys_types.h:83
#define UNUSED(x)
#define SET_FLAG_FROM_TEST(value, test, flag)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
void DEG_id_tag_update(struct ID *id, int flag)
@ ID_RECALC_SELECT
Definition: DNA_ID.h:638
#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:62
#define MBALLSEL_STIFF
Definition: ED_mball.h:60
#define MBALLSEL_RADIUS
Definition: ED_mball.h:61
void ED_object_base_activate(struct bContext *C, struct Base *base)
bool ED_operator_editmball(struct bContext *C)
Definition: screen_ops.c:607
int ED_select_similar_compare_float(const float delta, const float thresh, const int compare)
Definition: select_utils.c:87
@ SEL_SELECT
@ SEL_INVERT
@ SEL_DESELECT
@ SEL_TOGGLE
bool ED_select_similar_compare_float_tree(const struct KDTree_1d *tree, const float length, const float thresh, const int compare)
@ SIM_CMP_EQ
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc, struct Depsgraph *depsgraph)
#define MAXPICKBUF
Definition: ED_view3d.h:511
void ED_view3d_viewcontext_init_object(struct ViewContext *vc, struct Object *obact)
@ VIEW3D_SELECT_PICK_NEAREST
Definition: ED_view3d.h:519
int view3d_opengl_select(struct ViewContext *vc, unsigned int *buffer, unsigned int bufsize, const struct rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter)
@ VIEW3D_SELECT_FILTER_NOP
Definition: ED_view3d.h:524
_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:39
#define NC_GEOM
Definition: WM_types.h:294
@ OPTYPE_UNDO
Definition: WM_types.h:155
@ OPTYPE_REGISTER
Definition: WM_types.h:153
#define ND_DATA
Definition: WM_types.h:408
#define ND_SELECT
Definition: WM_types.h:407
static unsigned long seed
Definition: btSoftBody.h:39
#define SELECT
const Depsgraph * depsgraph
#define cosf(x)
#define fabsf(x)
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int ccl_global char ccl_global unsigned int ccl_global float * buffer
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:42
static ulong * next
void MBALL_OT_select_all(wmOperatorType *ot)
Definition: mball_edit.c:204
void MBALL_OT_hide_metaelems(wmOperatorType *ot)
Definition: mball_edit.c:691
bool ED_mball_deselect_all_multi(bContext *C)
Definition: mball_edit.c:106
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:242
void ED_mball_editmball_free(Object *obedit)
Definition: mball_edit.c:66
static const EnumPropertyItem prop_similar_types[]
Definition: mball_edit.c:234
static int select_random_metaelems_exec(bContext *C, wmOperator *op)
Definition: mball_edit.c:483
void MBALL_OT_duplicate_metaelems(wmOperatorType *ot)
Definition: mball_edit.c:587
@ SIMMBALL_STIFFNESS
Definition: mball_edit.c:230
@ SIMMBALL_TYPE
Definition: mball_edit.c:228
@ SIMMBALL_RADIUS
Definition: mball_edit.c:229
@ SIMMBALL_ROTATION
Definition: mball_edit.c:231
static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mball_edit.c:553
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:286
static int mball_select_all_exec(bContext *C, wmOperator *op)
Definition: mball_edit.c:167
bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle)
Definition: mball_edit.c:764
static int delete_metaelems_exec(bContext *C, wmOperator *UNUSED(op))
Definition: mball_edit.c:610
void MBALL_OT_select_similar(wmOperatorType *ot)
Definition: mball_edit.c:456
void ED_mball_editmball_load(Object *UNUSED(obedit))
Definition: mball_edit.c:96
void MBALL_OT_delete_metaelems(wmOperatorType *ot)
Definition: mball_edit.c:646
void MBALL_OT_reveal_metaelems(wmOperatorType *ot)
Definition: mball_edit.c:738
static int reveal_metaelems_exec(bContext *C, wmOperator *op)
Definition: mball_edit.c:716
static int hide_metaelems_exec(bContext *C, wmOperator *op)
Definition: mball_edit.c:668
void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot)
Definition: mball_edit.c:528
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:128
static int mball_select_similar_exec(bContext *C, wmOperator *op)
Definition: mball_edit.c:350
void ED_mball_editmball_make(Object *obedit)
Definition: mball_edit.c:76
static unsigned a[3]
Definition: RandGen.cpp:92
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6355
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6261
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6402
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:3825
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3481
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:3771
struct Object * object
char name[66]
Definition: DNA_ID.h:283
void * last
Definition: DNA_listBase.h:47
void * first
Definition: DNA_listBase.h:47
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:48
struct ViewLayer * view_layer
Definition: ED_view3d.h:77
struct Object * obedit
Definition: ED_view3d.h:79
struct View3D * v3d
Definition: ED_view3d.h:81
struct Base * basact
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:752
const char * name
Definition: WM_types.h:721
const char * idname
Definition: WM_types.h:723
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:776
struct StructRNA * srna
Definition: WM_types.h:802
const char * description
Definition: WM_types.h:726
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:736
PropertyRNA * prop
Definition: WM_types.h:814
struct PointerRNA * ptr
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
Definition: svm_invert.h:19
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: util_avxb.h:167
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition: wm_files.c:3156
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))
Definition: wm_operators.c:982