169 for (
uint base_index = 0; base_index < bases_len; base_index++) {
184 ot->
name =
"(De)select All";
185 ot->
description =
"Change selection of all metaball elements";
222 float tree_entry[3] = {0.0f, 0.0f, 0.0f};
229 float radius = ml->
rad;
232 float radius_vec[3] = {radius, radius, radius};
235 radius = (radius_vec[0] + radius_vec[1] + radius_vec[2]) / 3;
236 tree_entry[0] = radius;
240 tree_entry[0] = ml->
s;
244 float dir[3] = {1.0f, 0.0f, 0.0f};
254 BLI_kdtree_1d_insert(tree_1d, tree_index++, tree_entry);
257 BLI_kdtree_3d_insert(tree_3d, tree_index++, tree_entry);
266 const KDTree_1d *tree_1d,
267 const KDTree_3d *tree_3d,
271 bool changed =
false;
276 float radius = ml->
rad;
280 float radius_vec[3] = {radius, radius, radius};
283 radius = (radius_vec[0] + radius_vec[1] + radius_vec[2]) / 3;
298 float dir[3] = {1.0f, 0.0f, 0.0f};
304 float thresh_cos =
cosf(thresh * (
float)
M_PI_2);
306 KDTreeNearest_3d nearest;
307 if (BLI_kdtree_3d_find_nearest(tree_3d, dir, &nearest) != -1) {
310 float delta = thresh_cos -
fabsf(
cosf(orient));
331 int tot_mball_selected_all = 0;
341 KDTree_1d *tree_1d =
NULL;
342 KDTree_3d *tree_3d =
NULL;
347 tree_1d = BLI_kdtree_1d_new(tot_mball_selected_all);
350 tree_3d = BLI_kdtree_3d_new(tot_mball_selected_all);
355 for (
uint base_index = 0; base_index < bases_len; base_index++) {
364 short mball_type = 1 << (ml->
type + 1);
365 type_ref |= mball_type;
381 if (tree_1d !=
NULL) {
382 BLI_kdtree_1d_deduplicate(tree_1d);
383 BLI_kdtree_1d_balance(tree_1d);
385 if (tree_3d !=
NULL) {
386 BLI_kdtree_3d_deduplicate(tree_3d);
387 BLI_kdtree_3d_balance(tree_3d);
390 for (
uint base_index = 0; base_index < bases_len; base_index++) {
393 bool changed =
false;
399 short mball_type = 1 << (ml->
type + 1);
400 if (mball_type & type_ref) {
424 if (tree_1d !=
NULL) {
425 BLI_kdtree_1d_free(tree_1d);
427 if (tree_3d !=
NULL) {
428 BLI_kdtree_3d_free(tree_3d);
436 ot->
name =
"Select Similar";
437 ot->
idname =
"MBALL_OT_select_similar";
443 ot->
description =
"Select similar metaballs by property types";
467 uint objects_len = 0;
470 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
471 Object *obedit = objects[ob_index];
476 int seed_iter =
seed;
508 ot->
name =
"Select Random";
510 ot->
idname =
"MBALL_OT_select_random_metaelems";
533 uint objects_len = 0;
536 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
537 Object *obedit = objects[ob_index];
567 ot->
name =
"Duplicate Metaball Elements";
569 ot->
idname =
"MBALL_OT_duplicate_metaelems";
590 uint objects_len = 0;
593 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
594 Object *obedit = objects[ob_index];
628 ot->
idname =
"MBALL_OT_delete_metaelems";
671 ot->
name =
"Hide Selected";
673 ot->
idname =
"MBALL_OT_hide_metaelems";
684 ot->
srna,
"unselected",
false,
"Unselected",
"Hide unselected rather than selected");
698 bool changed =
false;
718 ot->
name =
"Reveal Hidden";
720 ot->
idname =
"MBALL_OT_reveal_metaelems";
741 const uint select_id,
744 const uint hit_object = select_id & 0xFFFF;
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];
795 int hit_cycle_offset = 0;
809 const int select_id =
buffer[
a].id;
810 if (select_id == -1) {
814 if (((select_id & 0xFFFF) == base_index) &&
816 hit_cycle_offset =
a + 1;
823 for (
a = 0;
a < hits;
a++) {
824 const int index = (hit_cycle_offset == 0) ?
a : ((
a + hit_cycle_offset) % hits);
826 if (select_id == -1) {
853 bool changed =
false;
861 else if (found ||
params->deselect_all) {
911 if (view_layer->
basact != base) {
918 return changed || found;
struct Object * CTX_data_edit_object(const bContext *C)
struct ViewLayer * CTX_data_view_layer(const bContext *C)
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
struct View3D * CTX_wm_view3d(const bContext *C)
#define BKE_view_layer_array_from_bases_in_edit_mode(view_layer, v3d, r_len)
#define BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, v3d, r_len)
#define BKE_view_layer_array_from_bases_in_edit_mode_unique_data(view_layer, v3d, r_len)
struct MetaElem * BKE_mball_element_add(struct MetaBall *mb, int type)
int BKE_mball_select_count_multi(struct Base **bases, int bases_len)
bool BKE_mball_is_any_selected(const struct MetaBall *mb)
bool BKE_mball_deselect_all_multi_ex(struct Base **bases, int bases_len)
bool BKE_mball_select_swap_multi_ex(struct Base **bases, int bases_len)
bool BKE_mball_is_any_selected_multi(struct Base **bases, int bases_len)
bool BKE_mball_is_any_unselected(const struct MetaBall *mb)
bool BKE_mball_select_all_multi_ex(struct Base **bases, int bases_len)
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])
#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_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 * BLI_findlink(const struct ListBase *listbase, int number) 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)
struct Depsgraph Depsgraph
void DEG_id_tag_update(struct ID *id, int flag)
Object is a sort of wrapper for general info.
void ED_object_base_activate(struct bContext *C, struct Base *base)
bool ED_operator_editmball(struct bContext *C)
bool ED_select_similar_compare_float(float delta, float thresh, eSimilarCmp compare)
bool ED_select_similar_compare_float_tree(const struct KDTree_1d *tree, float length, float thresh, eSimilarCmp compare)
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)
@ VIEW3D_SELECT_PICK_NEAREST
@ VIEW3D_SELECT_FILTER_NOP
_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.
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
static unsigned long seed
const Depsgraph * depsgraph
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
ccl_global float * buffer
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void MBALL_OT_select_all(wmOperatorType *ot)
void MBALL_OT_hide_metaelems(wmOperatorType *ot)
Base * ED_mball_base_and_elem_from_select_buffer(Base **bases, uint bases_len, const uint select_id, MetaElem **r_ml)
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)
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 *UNUSED(op))
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)
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 int delete_metaelems_exec(bContext *C, wmOperator *UNUSED(op))
void MBALL_OT_select_similar(wmOperatorType *ot)
void ED_mball_editmball_load(Object *UNUSED(obedit))
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)
void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot)
MetaElem * ED_mball_add_primitive(bContext *UNUSED(C), Object *obedit, bool obedit_is_new, float mat[4][4], float dia, int type)
static int mball_select_similar_exec(bContext *C, wmOperator *op)
bool ED_mball_select_pick(bContext *C, const int mval[2], const struct SelectPick_Params *params)
void ED_mball_editmball_make(Object *obedit)
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, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
struct ViewLayer * view_layer
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
int(* exec)(struct bContext *, struct wmOperator *) 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_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))