Blender V5.3
mball_edit.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cmath>
10#include <cstring>
11
12#include "MEM_guardedalloc.h"
13
14#include "BLI_ghash.hh"
15#include "BLI_kdtree.hh"
16#include "BLI_listbase.hh"
17#include "BLI_math_matrix_c.hh"
19#include "BLI_math_vector_c.hh"
20#include "BLI_rand_c.hh"
21#include "BLI_rect.hh"
22#include "BLI_utildefines.hh"
23
24#include "DNA_meta_types.h"
25#include "DNA_object_types.h"
26#include "DNA_scene_types.h"
27
28#include "RNA_access.hh"
29#include "RNA_define.hh"
30
31#include "BKE_context.hh"
32#include "BKE_layer.hh"
33#include "BKE_mball.hh"
34#include "BKE_object.hh"
35#include "BKE_object_types.hh"
36
37#include "BLT_translation.hh"
38
39#include "DEG_depsgraph.hh"
40
41#include "GPU_select.hh"
42
43#include "ED_mball.hh"
44#include "ED_object.hh"
45#include "ED_screen.hh"
46#include "ED_select_utils.hh"
47#include "ED_view3d.hh"
48
49#include "WM_api.hh"
50#include "WM_types.hh"
51
52#include "UI_interface_icons.hh"
53
54#include "mball_intern.hh"
55
56namespace blender {
57
58/* -------------------------------------------------------------------- */
61
63{
64 MetaBall *mb = id_cast<MetaBall *>(obedit->data);
65
66 mb->editelems = nullptr;
67 mb->lastelem = nullptr;
68}
69
71{
72 MetaBall *mb = id_cast<MetaBall *>(obedit->data);
73 MetaElem *ml; /*, *newml;*/
74
75 ml = mb->elems.first();
76
77 while (ml) {
78 if (ml->flag & SELECT) {
79 mb->lastelem = ml;
80 }
81 ml = ml->next;
82 }
83
84 mb->editelems = &mb->elems;
85}
86
87void ED_mball_editmball_load(Object * /*obedit*/) {}
88
90
91/* -------------------------------------------------------------------- */
94
103
105
106/* -------------------------------------------------------------------- */
109
111 bContext * /*C*/, Object *obedit, bool obedit_is_new, float mat[4][4], float dia, int type)
112{
113 MetaBall *mball = id_cast<MetaBall *>(obedit->data);
114 MetaElem *ml;
115
116 /* Deselect all existing metaelems */
117 ml = mball->editelems->first();
118 while (ml) {
119 ml->flag &= ~MB_SELECT;
120 ml = ml->next;
121 }
122
123 ml = BKE_mball_element_add(mball, type);
124 ml->rad *= dia;
125
126 if (obedit_is_new) {
127 mball->wiresize *= dia;
128 mball->rendersize *= dia;
129 }
130 copy_v3_v3(&ml->x, mat[3]);
131 /* MB_ELLIPSOID works differently (intentional?). Whatever the case,
132 * on testing this needs to be skipped otherwise it doesn't behave like other types. */
133 if (type != MB_ELLIPSOID) {
134 mul_v3_fl(&ml->expx, dia);
135 }
136
137 ml->flag |= MB_SELECT;
138 mball->lastelem = ml;
139 return ml;
140}
141
143
144/* -------------------------------------------------------------------- */
147
148/* Select or deselect all MetaElements */
150{
151 int action = RNA_enum_get(op->ptr, "action");
152
153 const Main *bmain = CTX_data_main(C);
154 const Scene *scene = CTX_data_scene(C);
155 ViewLayer *view_layer = CTX_data_view_layer(C);
157 *bmain, scene, view_layer, CTX_wm_view3d(C));
158
159 if (action == SEL_TOGGLE) {
161 }
162
163 switch (action) {
164 case SEL_SELECT:
166 break;
167 case SEL_DESELECT:
169 break;
170 case SEL_INVERT:
172 break;
173 }
174
175 for (Base *base : bases) {
176 Object *obedit = base->object;
177 MetaBall *mb = id_cast<MetaBall *>(obedit->data);
180 }
181
182 return OPERATOR_FINISHED;
183}
184
186{
187 /* identifiers */
188 ot->name = "(De)select All";
189 ot->description = "Change selection of all metaball elements";
190 ot->idname = "MBALL_OT_select_all";
191
192 /* callback functions */
195
196 /* flags */
198
200}
201
203
204/* -------------------------------------------------------------------- */
207
208enum {
213};
214
216 {SIMMBALL_TYPE, "TYPE", 0, "Type", ""},
217 {SIMMBALL_RADIUS, "RADIUS", 0, "Radius", ""},
218 {SIMMBALL_STIFFNESS, "STIFFNESS", 0, "Stiffness", ""},
219 {SIMMBALL_ROTATION, "ROTATION", 0, "Rotation", ""},
220 {0, nullptr, 0, nullptr, nullptr},
221};
222
224 MetaBall *mb,
225 int type,
226 Map<float, int> &points_1d,
227 Map<float3, int> &points_3d)
228{
229 float tree_entry[3] = {0.0f, 0.0f, 0.0f};
230 int tree_index = 0;
231 for (MetaElem &ml : *mb->editelems) {
232 if (ml.flag & SELECT) {
233 switch (type) {
234 case SIMMBALL_RADIUS: {
235 float radius = ml.rad;
236 /* Radius in world space. */
237 float smat[3][3];
238 float radius_vec[3] = {radius, radius, radius};
239 BKE_object_scale_to_mat3(obedit, smat);
240 mul_m3_v3(smat, radius_vec);
241 radius = (radius_vec[0] + radius_vec[1] + radius_vec[2]) / 3;
242 tree_entry[0] = radius;
243 break;
244 }
245 case SIMMBALL_STIFFNESS: {
246 tree_entry[0] = ml.s;
247 break;
248 }
249 case SIMMBALL_ROTATION: {
250 float dir[3] = {1.0f, 0.0f, 0.0f};
251 float rmat[3][3];
252 mul_qt_v3(ml.quat, dir);
253 BKE_object_rot_to_mat3(obedit, rmat, true);
254 mul_m3_v3(rmat, dir);
255 copy_v3_v3(tree_entry, dir);
256 break;
257 }
258 }
259
260 switch (type) {
261 case SIMMBALL_RADIUS:
263 points_1d.add(tree_entry[0], tree_index++);
264 break;
266 points_3d.add(tree_entry, tree_index++);
267 break;
268 }
269 }
270 }
271}
272
274 MetaBall *mb,
275 int type,
276 const KDTree<float> *tree_1d,
277 const KDTree<float3> *tree_3d,
278 const float thresh)
279{
280 bool changed = false;
281 for (MetaElem &ml : *mb->editelems) {
282 bool select = false;
283 switch (type) {
284 case SIMMBALL_RADIUS: {
285 float radius = ml.rad;
286 /* Radius in world space is the average of the
287 * scaled radius in x, y and z directions. */
288 float smat[3][3];
289 float radius_vec[3] = {radius, radius, radius};
290 BKE_object_scale_to_mat3(obedit, smat);
291 mul_m3_v3(smat, radius_vec);
292 radius = (radius_vec[0] + radius_vec[1] + radius_vec[2]) / 3;
293
294 if (ED_select_similar_compare_float_tree(tree_1d, radius, thresh, SIM_CMP_EQ)) {
295 select = true;
296 }
297 break;
298 }
299 case SIMMBALL_STIFFNESS: {
300 float s = ml.s;
301 if (ED_select_similar_compare_float_tree(tree_1d, s, thresh, SIM_CMP_EQ)) {
302 select = true;
303 }
304 break;
305 }
306 case SIMMBALL_ROTATION: {
307 float dir[3] = {1.0f, 0.0f, 0.0f};
308 float rmat[3][3];
309 mul_qt_v3(ml.quat, dir);
310 BKE_object_rot_to_mat3(obedit, rmat, true);
311 mul_m3_v3(rmat, dir);
312
313 float thresh_cos = cosf(thresh * float(M_PI_2));
314
315 KDTreeNearest<float3> nearest;
316 if (kdtree_find_nearest<float3>(tree_3d, dir, &nearest) != -1) {
317 float orient = angle_normalized_v3v3(dir, nearest.co);
318 /* Map to 0-1 to compare orientation. */
319 float delta = thresh_cos - fabsf(cosf(orient));
320 if (ED_select_similar_compare_float(delta, thresh, SIM_CMP_EQ)) {
321 select = true;
322 }
323 }
324 break;
325 }
326 }
327
328 if (select) {
329 changed = true;
330 ml.flag |= MB_SELECT;
331 }
332 }
333 return changed;
334}
335
337{
338 const int type = RNA_enum_get(op->ptr, "type");
339 const float thresh = RNA_float_get(op->ptr, "threshold");
340
341 const Main *bmain = CTX_data_main(C);
342 const Scene *scene = CTX_data_scene(C);
343 ViewLayer *view_layer = CTX_data_view_layer(C);
345 *bmain, scene, view_layer, CTX_wm_view3d(C));
346
347 Map<float, int> points_1d;
348 Map<float3, int> points_3d;
349
350 short type_ref = 0;
351
352 /* Get type of selected MetaBall */
353 for (Base *base : bases) {
354 Object *obedit = base->object;
355 MetaBall *mb = id_cast<MetaBall *>(obedit->data);
356
357 switch (type) {
358 case SIMMBALL_TYPE: {
359 for (MetaElem &ml : *mb->editelems) {
360 if (ml.flag & SELECT) {
361 short mball_type = 1 << (ml.type + 1);
362 type_ref |= mball_type;
363 }
364 }
365 break;
366 }
367 case SIMMBALL_RADIUS:
370 mball_select_similar_type_get(obedit, mb, type, points_1d, points_3d);
371 break;
372 default:
373 BLI_assert(0);
374 break;
375 }
376 }
377
378 KDTree<float> *tree_1d = nullptr;
379 KDTree<float3> *tree_3d = nullptr;
380
381 switch (type) {
382 case SIMMBALL_RADIUS:
383 case SIMMBALL_STIFFNESS: {
384 tree_1d = kdtree_new<float>(points_1d.size());
385 for (const auto &[pos, index] : points_1d.items()) {
386 kdtree_insert(tree_1d, index, pos);
387 }
388 kdtree_balance<float>(tree_1d);
389 break;
390 }
391 case SIMMBALL_ROTATION: {
392 tree_3d = kdtree_new<float3>(points_3d.size());
393 for (const auto &[pos, index] : points_3d.items()) {
394 kdtree_insert(tree_3d, index, pos);
395 }
396 kdtree_balance<float3>(tree_3d);
397 break;
398 }
399 }
400
401 /* Select MetaBalls with desired type. */
402 for (Base *base : bases) {
403 Object *obedit = base->object;
404 MetaBall *mb = id_cast<MetaBall *>(obedit->data);
405 bool changed = false;
406
407 switch (type) {
408 case SIMMBALL_TYPE: {
409 for (MetaElem &ml : *mb->editelems) {
410 short mball_type = 1 << (ml.type + 1);
411 if (mball_type & type_ref) {
412 ml.flag |= MB_SELECT;
413 changed = true;
414 }
415 }
416 break;
417 }
418 case SIMMBALL_RADIUS:
421 changed = mball_select_similar_type(obedit, mb, type, tree_1d, tree_3d, thresh);
422 break;
423 default:
424 BLI_assert(0);
425 break;
426 }
427
428 if (changed) {
431 }
432 }
433
434 if (tree_1d != nullptr) {
435 kdtree_free<float>(tree_1d);
436 }
437 if (tree_3d != nullptr) {
438 kdtree_free<float3>(tree_3d);
439 }
440 return OPERATOR_FINISHED;
441}
442
444{
445 /* identifiers */
446 ot->name = "Select Similar";
447 ot->idname = "MBALL_OT_select_similar";
448
449 /* callback functions */
453 ot->description = "Select similar metaballs by property types";
454
455 /* flags */
457
458 /* properties */
459 ot->prop = RNA_def_enum(ot->srna, "type", prop_similar_types, 0, "Type", "");
460
461 RNA_def_float(ot->srna, "threshold", 0.1, 0.0, FLT_MAX, "Threshold", "", 0.01, 1.0);
462}
463
465
466/* -------------------------------------------------------------------- */
469
471{
472 const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT);
473 const float randfac = RNA_float_get(op->ptr, "ratio");
475
476 const Main *bmain = CTX_data_main(C);
477 const Scene *scene = CTX_data_scene(C);
478 ViewLayer *view_layer = CTX_data_view_layer(C);
480 *bmain, scene, view_layer, CTX_wm_view3d(C));
481 for (const int ob_index : objects.index_range()) {
482 Object *obedit = objects[ob_index];
483 MetaBall *mb = id_cast<MetaBall *>(obedit->data);
485 continue;
486 }
487 int seed_iter = seed;
488
489 /* This gives a consistent result regardless of object order. */
490 if (ob_index) {
491 seed_iter += BLI_ghashutil_strhash_p(obedit->id.name);
492 }
493
494 RNG *rng = BLI_rng_new_srandom(seed_iter);
495
496 for (MetaElem &ml : *mb->editelems) {
497 if (BLI_rng_get_float(rng) < randfac) {
498 if (select) {
499 ml.flag |= MB_SELECT;
500 }
501 else {
502 ml.flag &= ~MB_SELECT;
503 }
504 }
505 }
506
507 BLI_rng_free(rng);
508
511 }
512 return OPERATOR_FINISHED;
513}
514
516{
517 /* identifiers */
518 ot->name = "Select Random";
519 ot->description = "Randomly select metaball elements";
520 ot->idname = "MBALL_OT_select_random_metaelems";
521
522 /* callback functions */
525
526 /* flags */
528
529 /* properties */
531}
532
534
535/* -------------------------------------------------------------------- */
538
539/* Duplicate selected MetaElements */
541{
542 const Main *bmain = CTX_data_main(C);
543 const Scene *scene = CTX_data_scene(C);
544 ViewLayer *view_layer = CTX_data_view_layer(C);
546 *bmain, scene, view_layer, CTX_wm_view3d(C));
547 for (Object *obedit : objects) {
548 MetaBall *mb = id_cast<MetaBall *>(obedit->data);
549 MetaElem *ml, *newml;
550
551 if (!BKE_mball_is_any_selected(mb)) {
552 continue;
553 }
554
555 ml = mb->editelems->last();
556 if (ml) {
557 while (ml) {
558 if (ml->flag & SELECT) {
559 newml = MEM_dupalloc(ml);
560 BLI_addtail(mb->editelems, newml);
561 mb->lastelem = newml;
562 ml->flag &= ~MB_SELECT;
563 }
564 ml = ml->prev;
565 }
567 DEG_id_tag_update(obedit->data, 0);
568 }
569 }
570 return OPERATOR_FINISHED;
571}
572
574{
575 /* identifiers */
576 ot->name = "Duplicate Metaball Elements";
577 ot->description = "Duplicate selected metaball element(s)";
578 ot->idname = "MBALL_OT_duplicate_metaelems";
579
580 /* callback functions */
583
584 /* flags */
586}
587
589
590/* -------------------------------------------------------------------- */
595
597{
598 const Main *bmain = CTX_data_main(C);
599 const Scene *scene = CTX_data_scene(C);
600 ViewLayer *view_layer = CTX_data_view_layer(C);
602 *bmain, scene, view_layer, CTX_wm_view3d(C));
603 for (Object *obedit : objects) {
604 MetaBall *mb = id_cast<MetaBall *>(obedit->data);
605 MetaElem *ml, *next;
606
607 if (!BKE_mball_is_any_selected(mb)) {
608 continue;
609 }
610
611 ml = mb->editelems->first();
612 if (ml) {
613 while (ml) {
614 next = ml->next;
615 if (ml->flag & SELECT) {
616 if (mb->lastelem == ml) {
617 mb->lastelem = nullptr;
618 }
619 BLI_remlink(mb->editelems, ml);
620 MEM_delete(ml);
621 }
622 ml = next;
623 }
625 DEG_id_tag_update(obedit->data, 0);
626 }
627 }
628 return OPERATOR_FINISHED;
629}
630
632 wmOperator *op,
633 const wmEvent * /*event*/)
634{
635 if (RNA_boolean_get(op->ptr, "confirm")) {
637 op,
638 IFACE_("Delete selected metaball elements?"),
639 nullptr,
640 IFACE_("Delete"),
642 false);
643 }
644 return delete_metaelems_exec(C, op);
645}
646
648{
649 /* identifiers */
650 ot->name = "Delete";
651 ot->description = "Delete selected metaball element(s)";
652 ot->idname = "MBALL_OT_delete_metaelems";
653
654 /* callback functions */
658
659 /* flags */
662}
663
665
666/* -------------------------------------------------------------------- */
669
671{
672 Object *obedit = CTX_data_edit_object(C);
673 MetaBall *mb = id_cast<MetaBall *>(obedit->data);
674 MetaElem *ml;
675 const bool invert = RNA_boolean_get(op->ptr, "unselected") ? SELECT : false;
676
677 ml = mb->editelems->first();
678
679 if (ml) {
680 while (ml) {
681 if ((ml->flag & SELECT) != invert) {
682 ml->flag |= MB_HIDE;
683 }
684 ml = ml->next;
685 }
687 DEG_id_tag_update(obedit->data, 0);
688 }
689
690 return OPERATOR_FINISHED;
691}
692
694{
695 /* identifiers */
696 ot->name = "Hide Selected";
697 ot->description = "Hide (un)selected metaball element(s)";
698 ot->idname = "MBALL_OT_hide_metaelems";
699
700 /* callback functions */
703
704 /* flags */
706
707 /* props */
709 ot->srna, "unselected", false, "Unselected", "Hide unselected rather than selected");
710}
711
713
714/* -------------------------------------------------------------------- */
717
719{
720 Object *obedit = CTX_data_edit_object(C);
721 MetaBall *mb = id_cast<MetaBall *>(obedit->data);
722 const bool select = RNA_boolean_get(op->ptr, "select");
723 bool changed = false;
724
725 for (MetaElem &ml : *mb->editelems) {
726 if (ml.flag & MB_HIDE) {
728 ml.flag &= ~MB_HIDE;
729 changed = true;
730 }
731 }
732 if (changed) {
734 DEG_id_tag_update(obedit->data, 0);
735 }
736
737 return OPERATOR_FINISHED;
738}
739
741{
742 /* identifiers */
743 ot->name = "Reveal Hidden";
744 ot->description = "Reveal all hidden metaball elements";
745 ot->idname = "MBALL_OT_reveal_metaelems";
746
747 /* callback functions */
750
751 /* flags */
753
754 /* props */
755 RNA_def_boolean(ot->srna, "select", true, "Select", "");
756}
757
759
760/* -------------------------------------------------------------------- */
763
765 const uint select_id,
766 MetaElem **r_ml)
767{
768 const uint hit_object = select_id & 0xFFFF;
769 Base *base = nullptr;
770 MetaElem *ml = nullptr;
771 /* TODO(@ideasman42): optimize, eg: sort & binary search. */
772 for (Base *base_iter : bases) {
773 if (base_iter->object->runtime->select_id == hit_object) {
774 base = base_iter;
775 break;
776 }
777 }
778 if (base != nullptr) {
779 const uint hit_elem = (select_id & ~MBALLSEL_ANY) >> 16;
780 MetaBall *mb = id_cast<MetaBall *>(base->object->data);
781 ml = static_cast<MetaElem *>(BLI_findlink(mb->editelems, hit_elem));
782 }
783 *r_ml = ml;
784 return base;
785}
786
788 const int mval[2],
789 bool use_cycle,
790 Base **r_base,
791 MetaElem **r_ml,
792 uint *r_selmask)
793{
794 Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
795 int a, hits;
796 GPUSelectBuffer buffer;
797 rcti rect;
798 bool found = false;
799
801
802 BLI_rcti_init_pt_radius(&rect, mval, 12);
803
804 hits = view3d_gpu_select(&vc,
805 &buffer,
806 &rect,
810
811 if (hits == 0) {
812 return false;
813 }
814
816 *vc.bmain, vc.scene, vc.view_layer, vc.v3d);
817
818 int hit_cycle_offset = 0;
819 if (use_cycle) {
820 /* When cycling, use the hit directly after the current active meta-element (when set). */
821 const int base_index = vc.obact->runtime->select_id;
822 MetaBall *mb = id_cast<MetaBall *>(vc.obact->data);
823 MetaElem *ml = mb->lastelem;
824 if (ml && (ml->flag & SELECT)) {
825 const int ml_index = BLI_findindex(mb->editelems, ml);
826 BLI_assert(ml_index != -1);
827
828 /* Count backwards in case the active meta-element has multiple entries,
829 * ensure this steps onto the next meta-element. */
830 a = hits;
831 while (a--) {
832 const int select_id = buffer.storage[a].id;
833 if (select_id == -1) {
834 continue;
835 }
836
837 if (((select_id & 0xFFFF) == base_index) &&
838 ((select_id & ~MBALLSEL_ANY) >> 16 == ml_index))
839 {
840 hit_cycle_offset = a + 1;
841 break;
842 }
843 }
844 }
845 }
846
847 for (a = 0; a < hits; a++) {
848 const int index = (hit_cycle_offset == 0) ? a : ((a + hit_cycle_offset) % hits);
849 const uint select_id = buffer.storage[index].id;
850 if (select_id == -1) {
851 continue;
852 }
853
854 MetaElem *ml;
855 Base *base = ED_mball_base_and_elem_from_select_buffer(bases, select_id, &ml);
856 if (ml == nullptr) {
857 continue;
858 }
859 *r_base = base;
860 *r_ml = ml;
861 *r_selmask = select_id & MBALLSEL_ANY;
862 found = true;
863 break;
864 }
865
866 return found;
867}
868
869bool ED_mball_select_pick(bContext *C, const int mval[2], const SelectPick_Params &params)
870{
871 Base *base = nullptr;
872 MetaElem *ml = nullptr;
873 uint selmask = 0;
874
875 bool changed = false;
876
877 bool found = ed_mball_findnearest_metaelem(C, mval, true, &base, &ml, &selmask);
878
879 if (params.sel_op == SEL_OP_SET) {
880 if ((found && params.select_passthrough) && (ml->flag & SELECT)) {
881 found = false;
882 }
883 else if (found || params.deselect_all) {
884 /* Deselect everything. */
885 changed |= ED_mball_deselect_all_multi(C);
886 }
887 }
888
889 if (found) {
890 if (selmask & MBALLSEL_RADIUS) {
891 ml->flag |= MB_SCALE_RAD;
892 }
893 else if (selmask & MBALLSEL_STIFF) {
894 ml->flag &= ~MB_SCALE_RAD;
895 }
896
897 switch (params.sel_op) {
898 case SEL_OP_ADD: {
899 ml->flag |= MB_SELECT;
900 break;
901 }
902 case SEL_OP_SUB: {
903 ml->flag &= ~MB_SELECT;
904 break;
905 }
906 case SEL_OP_XOR: {
907 if (ml->flag & SELECT) {
908 ml->flag &= ~MB_SELECT;
909 }
910 else {
911 ml->flag |= MB_SELECT;
912 }
913 break;
914 }
915 case SEL_OP_SET: {
916 /* Deselect has already been performed. */
917 ml->flag |= MB_SELECT;
918 break;
919 }
920 case SEL_OP_AND: {
921 BLI_assert_unreachable(); /* Doesn't make sense for picking. */
922 break;
923 }
924 }
925 const Main *bmain = CTX_data_main(C);
926 const Scene *scene = CTX_data_scene(C);
927 ViewLayer *view_layer = CTX_data_view_layer(C);
928 MetaBall *mb = id_cast<MetaBall *>(base->object->data);
929 mb->lastelem = ml;
930
933
934 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
935 if (BKE_view_layer_active_base_get(view_layer) != base) {
937 }
938
939 changed = true;
940 }
941
942 return changed || found;
943}
944
946
947} // namespace blender
#define SELECT
Definition BKE_mask.hh:19
General operations, lookup, etc. for blender objects.
A KD-tree for nearest neighbor search.
#define M_PI_2
Random number functions.
#define IFACE_(msgid)
Object is a sort of wrapper for general info.
#define MBALLSEL_ANY
Definition ED_mball.hh:66
#define MBALLSEL_STIFF
Definition ED_mball.hh:64
#define MBALLSEL_RADIUS
Definition ED_mball.hh:65
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define NC_GEOM
Definition WM_types.hh:406
#define ND_DATA
Definition WM_types.hh:552
#define ND_SELECT
Definition WM_types.hh:551
#define BLI_assert_unreachable()
#define SET_FLAG_FROM_TEST(value, test, flag)
bool add(const Key &key, const Value &value)
Definition BLI_map.hh:295
int64_t size() const
Definition BLI_map.hh:976
ItemIterator items() const &
Definition BLI_map.hh:902
IndexRange index_range() const
#define FLT_MAX
float2x2 invert(float2x2 mat)
void base_activate(bContext *C, Base *base)
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void MBALL_OT_hide_metaelems(wmOperatorType *ot)
void mul_m3_v3(const float M[3][3], float r[3])
void kdtree_balance(KDTree< CoordT > *tree)
float angle_normalized_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
static void mball_select_similar_type_get(Object *obedit, MetaBall *mb, int type, Map< float, int > &points_1d, Map< float3, int > &points_3d)
void BKE_object_rot_to_mat3(const Object *ob, float r_mat[3][3], bool use_drot)
Definition object.cc:2906
int RNA_enum_get(PointerRNA *ptr, const char *name)
bool BKE_mball_select_all_multi_ex(Span< Base * > bases)
MetaElem * BKE_mball_element_add(MetaBall *mb, int type)
Definition mball.cc:179
void WM_operator_properties_select_random(wmOperatorType *ot)
ViewContext ED_view3d_viewcontext_init(bContext *C, Depsgraph *depsgraph)
void MBALL_OT_select_similar(wmOperatorType *ot)
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
bool ED_mball_deselect_all_multi(bContext *C)
Definition mball_edit.cc:95
void MBALL_OT_select_random_metaelems(wmOperatorType *ot)
bool BKE_mball_deselect_all_multi_ex(Span< Base * > bases)
void ED_mball_editmball_free(Object *obedit)
Definition mball_edit.cc:62
struct RNG * BLI_rng_new_srandom(unsigned int seed)
Definition rand.cc:48
int WM_operator_properties_select_random_seed_increment_get(wmOperator *op)
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 MBALL_OT_select_all(wmOperatorType *ot)
Base * BKE_view_layer_active_base_get(ViewLayer *view_layer)
static wmOperatorStatus select_random_metaelems_exec(bContext *C, wmOperator *op)
void MBALL_OT_reveal_metaelems(wmOperatorType *ot)
static const EnumPropertyItem prop_similar_types[]
ViewLayer * CTX_data_view_layer(const bContext *C)
void WM_operator_properties_select_all(wmOperatorType *ot)
MINLINE void mul_v3_fl(float r[3], float f)
bool ED_mball_select_pick(bContext *C, const int mval[2], const SelectPick_Params &params)
bool BKE_mball_select_swap_multi_ex(Span< Base * > bases)
@ VIEW3D_SELECT_FILTER_OBJECT_MODE_LOCK_SAME_TYPE
Definition ED_view3d.hh:999
void mul_qt_v3(const float q[4], float r[3])
KDTree< CoordT > * kdtree_new(uint nodes_len_capacity)
Definition BLI_kdtree.hh:65
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:541
void WM_operator_properties_confirm_or_exec(wmOperatorType *ot)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:593
bool ED_select_similar_compare_float_tree(const KDTree< float > *tree, float length, float thresh, eSimilarCmp compare)
static wmOperatorStatus duplicate_metaelems_exec(bContext *C, wmOperator *)
void BKE_object_scale_to_mat3(const Object *ob, float r_mat[3][3])
Definition object.cc:2899
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
void DEG_id_tag_update(ID *id, unsigned int flags)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
@ VIEW3D_SELECT_PICK_NEAREST
Definition ED_view3d.hh:987
@ VIEW3D_SELECT_PICK_ALL
Definition ED_view3d.hh:985
Object * CTX_data_edit_object(const bContext *C)
void kdtree_insert(KDTree< CoordT > *tree, int index, const CoordT &co)
Definition BLI_kdtree.hh:96
bool ED_select_similar_compare_float(float delta, float thresh, eSimilarCmp compare)
MetaElem * ED_mball_add_primitive(bContext *C, Object *obedit, bool obedit_is_new, float mat[4][4], float dia, int type)
Base * ED_mball_base_and_elem_from_select_buffer(Span< Base * > bases, const uint select_id, MetaElem **r_ml)
int kdtree_find_nearest(const KDTree< CoordT > *tree, const CoordT &co, KDTreeNearest< CoordT > *r_nearest)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
static bool ed_mball_findnearest_metaelem(bContext *C, const int mval[2], bool use_cycle, Base **r_base, MetaElem **r_ml, uint *r_selmask)
static wmOperatorStatus mball_select_similar_exec(bContext *C, wmOperator *op)
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
Definition rand.cc:55
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
wmOperatorStatus WM_operator_confirm_ex(bContext *C, wmOperator *op, const char *title, const char *message, const char *confirm_text, ui::AlertIcon icon, bool cancel_default)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void MBALL_OT_duplicate_metaelems(wmOperatorType *ot)
static wmOperatorStatus hide_metaelems_exec(bContext *C, wmOperator *op)
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition rand.cc:90
static wmOperatorStatus delete_metaelems_invoke(bContext *C, wmOperator *op, const wmEvent *)
void kdtree_free(KDTree< CoordT > *tree)
Definition BLI_kdtree.hh:84
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
Main * CTX_data_main(const bContext *C)
bool BKE_mball_is_any_unselected(const MetaBall *mb)
Definition mball.cc:321
@ ID_RECALC_SELECT
Definition DNA_ID.h:1101
Vector< Object * > BKE_view_layer_array_from_objects_in_edit_mode_unique_data(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
Vector< Base * > BKE_view_layer_array_from_bases_in_edit_mode_unique_data(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
unsigned int BLI_ghashutil_strhash_p(const void *ptr)
bool BKE_mball_is_any_selected(const MetaBall *mb)
Definition mball.cc:299
@ SIMMBALL_STIFFNESS
@ SIMMBALL_ROTATION
@ SIMMBALL_RADIUS
@ SIMMBALL_TYPE
Scene * CTX_data_scene(const bContext *C)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
Vector< Base * > BKE_view_layer_array_from_bases_in_edit_mode(const Main &bmain, const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size)
Definition rct.cc:480
static wmOperatorStatus mball_select_all_exec(bContext *C, wmOperator *op)
void ED_mball_editmball_load(Object *obedit)
Definition mball_edit.cc:87
bool BKE_mball_is_any_selected_multi(Span< Base * > bases)
bool ED_operator_editmball(bContext *C)
int view3d_gpu_select(const ViewContext *vc, GPUSelectBuffer *buffer, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter, eV3DSelectShape select_shape)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
float RNA_float_get(PointerRNA *ptr, const char *name)
static wmOperatorStatus delete_metaelems_exec(bContext *C, wmOperator *)
void MBALL_OT_delete_metaelems(wmOperatorType *ot)
View3D * CTX_wm_view3d(const bContext *C)
static wmOperatorStatus reveal_metaelems_exec(bContext *C, wmOperator *op)
static bool mball_select_similar_type(Object *obedit, MetaBall *mb, int type, const KDTree< float > *tree_1d, const KDTree< float3 > *tree_3d, const float thresh)
void ED_mball_editmball_make(Object *obedit)
Definition mball_edit.cc:70
#define fabsf
#define cosf
struct Object * object
GPUSelectStorage storage
Definition GPU_select.hh:49
char name[258]
Definition DNA_ID.h:433
ListBaseT< MetaElem > elems
ListBaseT< MetaElem > * editelems
struct MetaElem * prev
eMetaElem_Type type
struct MetaElem * next
eMetaElem_Flag flag
bke::ObjectRuntime * runtime
ViewLayer * view_layer
Definition ED_view3d.hh:80
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141