111 bContext * ,
Object *obedit,
bool obedit_is_new,
float mat[4][4],
float dia,
int type)
174 for (
Base *base : bases) {
175 Object *obedit = base->object;
187 ot->
name =
"(De)select All";
188 ot->
description =
"Change selection of all metaball elements";
219 {0,
nullptr, 0,
nullptr,
nullptr},
223 Object *obedit,
MetaBall *mb,
int type, KDTree_1d *tree_1d, KDTree_3d *tree_3d)
225 float tree_entry[3] = {0.0f, 0.0f, 0.0f};
231 float radius = ml->rad;
234 float radius_vec[3] = {radius, radius, radius};
237 radius = (radius_vec[0] + radius_vec[1] + radius_vec[2]) / 3;
238 tree_entry[0] = radius;
242 tree_entry[0] = ml->s;
246 float dir[3] = {1.0f, 0.0f, 0.0f};
256 BLI_kdtree_1d_insert(tree_1d, tree_index++, tree_entry);
259 BLI_kdtree_3d_insert(tree_3d, tree_index++, tree_entry);
268 const KDTree_1d *tree_1d,
269 const KDTree_3d *tree_3d,
272 bool changed =
false;
277 float radius = ml->rad;
281 float radius_vec[3] = {radius, radius, radius};
284 radius = (radius_vec[0] + radius_vec[1] + radius_vec[2]) / 3;
299 float dir[3] = {1.0f, 0.0f, 0.0f};
305 float thresh_cos =
cosf(thresh *
float(
M_PI_2));
307 KDTreeNearest_3d nearest;
308 if (BLI_kdtree_3d_find_nearest(tree_3d, dir, &nearest) != -1) {
311 float delta = thresh_cos -
fabsf(
cosf(orient));
332 int tot_mball_selected_all = 0;
342 KDTree_1d *tree_1d =
nullptr;
343 KDTree_3d *tree_3d =
nullptr;
348 tree_1d = BLI_kdtree_1d_new(tot_mball_selected_all);
351 tree_3d = BLI_kdtree_3d_new(tot_mball_selected_all);
356 for (
Base *base : bases) {
357 Object *obedit = base->object;
364 short mball_type = 1 << (ml->type + 1);
365 type_ref |= mball_type;
381 if (tree_1d !=
nullptr) {
382 BLI_kdtree_1d_deduplicate(tree_1d);
383 BLI_kdtree_1d_balance(tree_1d);
385 if (tree_3d !=
nullptr) {
386 BLI_kdtree_3d_deduplicate(tree_3d);
387 BLI_kdtree_3d_balance(tree_3d);
390 for (
Base *base : bases) {
391 Object *obedit = base->object;
393 bool changed =
false;
398 short mball_type = 1 << (ml->type + 1);
399 if (mball_type & type_ref) {
422 if (tree_1d !=
nullptr) {
423 BLI_kdtree_1d_free(tree_1d);
425 if (tree_3d !=
nullptr) {
426 BLI_kdtree_3d_free(tree_3d);
434 ot->
name =
"Select Similar";
435 ot->
idname =
"MBALL_OT_select_similar";
441 ot->
description =
"Select similar metaballs by property types";
468 for (
const int ob_index : objects.index_range()) {
469 Object *obedit = objects[ob_index];
474 int seed_iter =
seed;
505 ot->
name =
"Select Random";
507 ot->
idname =
"MBALL_OT_select_random_metaelems";
533 for (
Object *obedit : objects) {
562 ot->
name =
"Duplicate Metaball Elements";
564 ot->
idname =
"MBALL_OT_duplicate_metaelems";
588 for (
Object *obedit : objects) {
621 IFACE_(
"Delete selected metaball elements?"),
635 ot->
idname =
"MBALL_OT_delete_metaelems";
679 ot->
name =
"Hide Selected";
681 ot->
idname =
"MBALL_OT_hide_metaelems";
692 ot->
srna,
"unselected",
false,
"Unselected",
"Hide unselected rather than selected");
706 bool changed =
false;
711 ml->flag &= ~MB_HIDE;
726 ot->
name =
"Reveal Hidden";
728 ot->
idname =
"MBALL_OT_reveal_metaelems";
748 const uint select_id,
751 const uint hit_object = select_id & 0xFFFF;
752 Base *base =
nullptr;
755 for (
Base *base_iter : bases) {
756 if (base_iter->object->runtime->select_id == hit_object) {
761 if (base !=
nullptr) {
762 const uint hit_elem = (select_id & ~MBALLSEL_ANY) >> 16;
800 int hit_cycle_offset = 0;
814 const int select_id = buffer.
storage[a].id;
815 if (select_id == -1) {
819 if (((select_id & 0xFFFF) == base_index) &&
822 hit_cycle_offset = a + 1;
829 for (a = 0; a < hits; a++) {
830 const int index = (hit_cycle_offset == 0) ? a : ((a + hit_cycle_offset) % hits);
832 if (select_id == -1) {
853 Base *base =
nullptr;
857 bool changed =
false;
865 else if (found ||
params->deselect_all) {
876 ml->
flag &= ~MB_SCALE_RAD;
923 return changed || found;
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Object * CTX_data_edit_object(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
blender::Vector< Base * > BKE_view_layer_array_from_bases_in_edit_mode(const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
Base * BKE_view_layer_active_base_get(ViewLayer *view_layer)
blender::Vector< Base * > BKE_view_layer_array_from_bases_in_edit_mode_unique_data(const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
blender::Vector< Object * > BKE_view_layer_array_from_objects_in_edit_mode_unique_data(const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
bool BKE_mball_select_swap_multi_ex(blender::Span< Base * > bases)
MetaElem * BKE_mball_element_add(MetaBall *mb, int type)
bool BKE_mball_is_any_selected_multi(blender::Span< Base * > bases)
int BKE_mball_select_count_multi(blender::Span< Base * > bases)
bool BKE_mball_is_any_unselected(const MetaBall *mb)
bool BKE_mball_select_all_multi_ex(blender::Span< Base * > bases)
bool BKE_mball_is_any_selected(const MetaBall *mb)
bool BKE_mball_deselect_all_multi_ex(blender::Span< Base * > bases)
General operations, lookup, etc. for blender objects.
void BKE_object_rot_to_mat3(const Object *ob, float r_mat[3][3], bool use_drot)
void BKE_object_scale_to_mat3(const Object *ob, float r_mat[3][3])
#define BLI_assert_unreachable()
unsigned int BLI_ghashutil_strhash_p(const void *ptr)
A KD-tree for nearest neighbor search.
#define LISTBASE_FOREACH(type, var, list)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void mul_m3_v3(const float M[3][3], float r[3])
void mul_qt_v3(const float q[4], float r[3])
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
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
struct RNG * BLI_rng_new_srandom(unsigned int seed)
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_rcti_init_pt_radius(struct rcti *rect, const int xy[2], int size)
#define SET_FLAG_FROM_TEST(value, test, flag)
void DEG_id_tag_update(ID *id, unsigned int flags)
Object is a sort of wrapper for general info.
bool ED_operator_editmball(bContext *C)
bool ED_select_similar_compare_float(float delta, float thresh, eSimilarCmp compare)
bool ED_select_similar_compare_float_tree(const KDTree_1d *tree, float length, float thresh, eSimilarCmp compare)
ViewContext ED_view3d_viewcontext_init(bContext *C, Depsgraph *depsgraph)
int view3d_opengl_select(const ViewContext *vc, GPUSelectBuffer *buffer, const rcti *input, eV3DSelectMode select_mode, eV3DSelectObjectFilter select_filter)
@ VIEW3D_SELECT_PICK_NEAREST
@ VIEW3D_SELECT_FILTER_NOP
Read Guarded memory(de)allocation.
static unsigned long seed
const Depsgraph * depsgraph
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
void MEM_freeN(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
ccl_device_inline float4 select(const int4 mask, const float4 a, const float4 b)
void MBALL_OT_select_all(wmOperatorType *ot)
MetaElem * ED_mball_add_primitive(bContext *, Object *obedit, bool obedit_is_new, float mat[4][4], float dia, int type)
void MBALL_OT_hide_metaelems(wmOperatorType *ot)
bool ED_mball_select_pick(bContext *C, const int mval[2], const SelectPick_Params *params)
static int delete_metaelems_invoke(bContext *C, wmOperator *op, const wmEvent *)
bool ED_mball_deselect_all_multi(bContext *C)
static void mball_select_similar_type_get(Object *obedit, MetaBall *mb, int type, KDTree_1d *tree_1d, KDTree_3d *tree_3d)
void ED_mball_editmball_free(Object *obedit)
void ED_mball_editmball_load(Object *)
static const EnumPropertyItem prop_similar_types[]
static int select_random_metaelems_exec(bContext *C, wmOperator *op)
void MBALL_OT_duplicate_metaelems(wmOperatorType *ot)
static int duplicate_metaelems_exec(bContext *C, wmOperator *)
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)
static int mball_select_all_exec(bContext *C, wmOperator *op)
void MBALL_OT_select_random_metaelems(wmOperatorType *ot)
static bool ed_mball_findnearest_metaelem(bContext *C, const int mval[2], bool use_cycle, Base **r_base, MetaElem **r_ml, uint *r_selmask)
void MBALL_OT_select_similar(wmOperatorType *ot)
void MBALL_OT_delete_metaelems(wmOperatorType *ot)
void MBALL_OT_reveal_metaelems(wmOperatorType *ot)
static int reveal_metaelems_exec(bContext *C, wmOperator *op)
static int hide_metaelems_exec(bContext *C, wmOperator *op)
static int delete_metaelems_exec(bContext *C, wmOperator *)
Base * ED_mball_base_and_elem_from_select_buffer(const Span< Base * > bases, const uint select_id, MetaElem **r_ml)
static int mball_select_similar_exec(bContext *C, wmOperator *op)
void ED_mball_editmball_make(Object *obedit)
void base_activate(bContext *C, Base *base)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
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)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
ObjectRuntimeHandle * runtime
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
int WM_operator_properties_select_random_seed_increment_get(wmOperator *op)
void WM_operator_properties_confirm_or_exec(wmOperatorType *ot)
void WM_operator_properties_select_random(wmOperatorType *ot)
void WM_operator_properties_select_all(wmOperatorType *ot)
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
int WM_operator_confirm_ex(bContext *C, wmOperator *op, const char *title, const char *message, const char *confirm_text, int icon, bool cancel_default)