75 ml = mb->
elems.first();
111 bContext * ,
Object *obedit,
bool obedit_is_new,
float mat[4][4],
float dia,
int type)
175 for (
Base *base : bases) {
176 Object *obedit = base->object;
188 ot->
name =
"(De)select All";
189 ot->
description =
"Change selection of all metaball elements";
190 ot->
idname =
"MBALL_OT_select_all";
220 {0,
nullptr, 0,
nullptr,
nullptr},
229 float tree_entry[3] = {0.0f, 0.0f, 0.0f};
235 float radius = ml.
rad;
238 float radius_vec[3] = {radius, radius, radius};
241 radius = (radius_vec[0] + radius_vec[1] + radius_vec[2]) / 3;
242 tree_entry[0] = radius;
246 tree_entry[0] = ml.
s;
250 float dir[3] = {1.0f, 0.0f, 0.0f};
263 points_1d.
add(tree_entry[0], tree_index++);
266 points_3d.
add(tree_entry, tree_index++);
280 bool changed =
false;
285 float radius = ml.
rad;
289 float radius_vec[3] = {radius, radius, radius};
292 radius = (radius_vec[0] + radius_vec[1] + radius_vec[2]) / 3;
307 float dir[3] = {1.0f, 0.0f, 0.0f};
313 float thresh_cos =
cosf(thresh *
float(
M_PI_2));
319 float delta = thresh_cos -
fabsf(
cosf(orient));
353 for (
Base *base : bases) {
354 Object *obedit = base->object;
361 short mball_type = 1 << (ml.
type + 1);
362 type_ref |= mball_type;
385 for (
const auto &[pos,
index] : points_1d.
items()) {
393 for (
const auto &[pos,
index] : points_3d.
items()) {
402 for (
Base *base : bases) {
403 Object *obedit = base->object;
405 bool changed =
false;
410 short mball_type = 1 << (ml.
type + 1);
411 if (mball_type & type_ref) {
434 if (tree_1d !=
nullptr) {
437 if (tree_3d !=
nullptr) {
446 ot->
name =
"Select Similar";
447 ot->
idname =
"MBALL_OT_select_similar";
453 ot->
description =
"Select similar metaballs by property types";
482 Object *obedit = objects[ob_index];
487 int seed_iter = seed;
518 ot->
name =
"Select Random";
519 ot->
description =
"Randomly select metaball elements";
520 ot->
idname =
"MBALL_OT_select_random_metaelems";
547 for (
Object *obedit : objects) {
548 MetaBall *mb = id_cast<MetaBall *>(obedit->data);
559 newml = MEM_dupalloc(ml);
576 ot->
name =
"Duplicate Metaball Elements";
577 ot->
description =
"Duplicate selected metaball element(s)";
578 ot->
idname =
"MBALL_OT_duplicate_metaelems";
603 for (
Object *obedit : objects) {
604 MetaBall *mb = id_cast<MetaBall *>(obedit->data);
638 IFACE_(
"Delete selected metaball elements?"),
651 ot->
description =
"Delete selected metaball element(s)";
652 ot->
idname =
"MBALL_OT_delete_metaelems";
696 ot->
name =
"Hide Selected";
697 ot->
description =
"Hide (un)selected metaball element(s)";
698 ot->
idname =
"MBALL_OT_hide_metaelems";
709 ot->
srna,
"unselected",
false,
"Unselected",
"Hide unselected rather than selected");
723 bool changed =
false;
743 ot->
name =
"Reveal Hidden";
744 ot->
description =
"Reveal all hidden metaball elements";
745 ot->
idname =
"MBALL_OT_reveal_metaelems";
765 const uint select_id,
768 const uint hit_object = select_id & 0xFFFF;
769 Base *base =
nullptr;
772 for (
Base *base_iter : bases) {
773 if (base_iter->object->runtime->select_id == hit_object) {
778 if (base !=
nullptr) {
818 int hit_cycle_offset = 0;
832 const int select_id = buffer.
storage[a].id;
833 if (select_id == -1) {
837 if (((select_id & 0xFFFF) == base_index) &&
840 hit_cycle_offset = a + 1;
847 for (a = 0; a < hits; a++) {
848 const int index = (hit_cycle_offset == 0) ? a : ((a + hit_cycle_offset) % hits);
850 if (select_id == -1) {
871 Base *base =
nullptr;
875 bool changed =
false;
942 return changed || found;
General operations, lookup, etc. for blender objects.
A KD-tree for nearest neighbor search.
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
#define SET_FLAG_FROM_TEST(value, test, flag)
bool add(const Key &key, const Value &value)
ItemIterator items() const &
IndexRange index_range() const
float2x2 invert(float2x2 mat)
void base_activate(bContext *C, Base *base)
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)
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)
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])
bool ED_mball_deselect_all_multi(bContext *C)
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)
struct RNG * BLI_rng_new_srandom(unsigned int seed)
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 ¶ms)
bool BKE_mball_select_swap_multi_ex(Span< Base * > bases)
@ VIEW3D_SELECT_FILTER_OBJECT_MODE_LOCK_SAME_TYPE
void mul_qt_v3(const float q[4], float r[3])
KDTree< CoordT > * kdtree_new(uint nodes_len_capacity)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
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)
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])
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
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
Object * CTX_data_edit_object(const bContext *C)
void kdtree_insert(KDTree< CoordT > *tree, int index, const CoordT &co)
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)
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)
static wmOperatorStatus delete_metaelems_invoke(bContext *C, wmOperator *op, const wmEvent *)
void kdtree_free(KDTree< CoordT > *tree)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Main * CTX_data_main(const bContext *C)
bool BKE_mball_is_any_unselected(const MetaBall *mb)
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)
Scene * CTX_data_scene(const bContext *C)
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)
static wmOperatorStatus mball_select_all_exec(bContext *C, wmOperator *op)
void ED_mball_editmball_load(Object *obedit)
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)
bke::ObjectRuntime * runtime
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT