116 return changed_multi;
192 for (
uint base_index = 0; base_index < bases_len; base_index++) {
207 ot->
name =
"(De)select All";
208 ot->
description =
"Change selection of all metaball elements";
245 float tree_entry[3] = {0.0f, 0.0f, 0.0f};
252 float radius = ml->
rad;
255 float radius_vec[3] = {radius, radius, radius};
258 radius = (radius_vec[0] + radius_vec[1] + radius_vec[2]) / 3;
259 tree_entry[0] = radius;
263 tree_entry[0] = ml->
s;
267 float dir[3] = {1.0f, 0.0f, 0.0f};
277 BLI_kdtree_1d_insert(tree_1d, tree_index++, tree_entry);
280 BLI_kdtree_3d_insert(tree_3d, tree_index++, tree_entry);
289 const KDTree_1d *tree_1d,
290 const KDTree_3d *tree_3d,
294 bool changed =
false;
299 float radius = ml->
rad;
303 float radius_vec[3] = {radius, radius, radius};
306 radius = (radius_vec[0] + radius_vec[1] + radius_vec[2]) / 3;
321 float dir[3] = {1.0f, 0.0f, 0.0f};
327 float thresh_cos =
cosf(thresh * (
float)
M_PI_2);
329 KDTreeNearest_3d nearest;
330 if (BLI_kdtree_3d_find_nearest(tree_3d, dir, &nearest) != -1) {
333 float delta = thresh_cos -
fabsf(
cosf(orient));
354 int tot_mball_selected_all = 0;
364 KDTree_1d *tree_1d =
NULL;
365 KDTree_3d *tree_3d =
NULL;
370 tree_1d = BLI_kdtree_1d_new(tot_mball_selected_all);
373 tree_3d = BLI_kdtree_3d_new(tot_mball_selected_all);
378 for (
uint base_index = 0; base_index < bases_len; base_index++) {
387 short mball_type = 1 << (ml->
type + 1);
388 type_ref |= mball_type;
404 if (tree_1d !=
NULL) {
405 BLI_kdtree_1d_deduplicate(tree_1d);
406 BLI_kdtree_1d_balance(tree_1d);
408 if (tree_3d !=
NULL) {
409 BLI_kdtree_3d_deduplicate(tree_3d);
410 BLI_kdtree_3d_balance(tree_3d);
413 for (
uint base_index = 0; base_index < bases_len; base_index++) {
416 bool changed =
false;
422 short mball_type = 1 << (ml->
type + 1);
423 if (mball_type & type_ref) {
447 if (tree_1d !=
NULL) {
448 BLI_kdtree_1d_free(tree_1d);
450 if (tree_3d !=
NULL) {
451 BLI_kdtree_3d_free(tree_3d);
459 ot->
name =
"Select Similar";
460 ot->
idname =
"MBALL_OT_select_similar";
466 ot->
description =
"Select similar metaballs by property types";
490 uint objects_len = 0;
493 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
494 Object *obedit = objects[ob_index];
499 int seed_iter =
seed;
531 ot->
name =
"Select Random";
533 ot->
idname =
"MBALL_OT_select_random_metaelems";
556 uint objects_len = 0;
559 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
560 Object *obedit = objects[ob_index];
590 ot->
name =
"Duplicate Metaball Elements";
592 ot->
idname =
"MBALL_OT_duplicate_metaelems";
613 uint objects_len = 0;
616 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
617 Object *obedit = objects[ob_index];
651 ot->
idname =
"MBALL_OT_delete_metaelems";
694 ot->
name =
"Hide Selected";
696 ot->
idname =
"MBALL_OT_hide_metaelems";
707 ot->
srna,
"unselected",
false,
"Unselected",
"Hide unselected rather than selected");
721 bool changed =
false;
741 ot->
name =
"Reveal Hidden";
743 ot->
idname =
"MBALL_OT_reveal_metaelems";
788 if (ml == startelem) {
802 for (
a = 0;
a < hits;
a++) {
803 int hitresult =
buffer[(4 *
a) + 3];
804 if (hitresult == -1) {
808 const uint hit_object = hitresult & 0xFFFF;
813 if (metaelem_id != (hitresult & 0xFFFF0000 & ~
MBALLSEL_ANY)) {
837 if (ml == startelem) {
841 metaelem_id += 0x10000;
846 if (!extend && !deselect && !toggle) {
850 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
851 Object *ob_iter = objects[ob_index];
853 if (ob_iter == base->object) {
871 if (ml_act->flag &
SELECT) {
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 FOREACH_BASE_IN_EDIT_MODE_BEGIN(_view_layer, _v3d, _instance)
#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)
#define FOREACH_BASE_IN_EDIT_MODE_END
bool BKE_mball_deselect_all(struct MetaBall *mb)
int BKE_mball_select_count_multi(struct Base **bases, int bases_len)
bool BKE_mball_is_any_selected(const struct MetaBall *mb)
struct MetaElem * BKE_mball_element_add(struct MetaBall *mb, const int type)
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])
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)
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)
int ED_select_similar_compare_float(const float delta, const float thresh, const int compare)
bool ED_select_similar_compare_float_tree(const struct KDTree_1d *tree, const float length, const float thresh, const int compare)
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc, struct Depsgraph *depsgraph)
void ED_view3d_viewcontext_init_object(struct ViewContext *vc, struct Object *obact)
@ VIEW3D_SELECT_PICK_NEAREST
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
_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.
static unsigned long seed
const Depsgraph * depsgraph
__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)
void *(* MEM_dupallocN)(const void *vmemh)
void MBALL_OT_select_all(wmOperatorType *ot)
void MBALL_OT_hide_metaelems(wmOperatorType *ot)
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)
bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle)
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)
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
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
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))