66 {
SIMVERT_FACE,
"FACE", 0,
"Amount of Adjacent Faces",
""},
68 {
SIMVERT_EDGE,
"EDGE", 0,
"Amount of Connecting Edges",
""},
72 {
SIMEDGE_FACE,
"FACE", 0,
"Amount of Faces Around an Edge",
""},
165 const float thresh_radians = thresh * (
float)
M_PI;
168 int tot_faces_selected_all = 0;
169 uint objects_len = 0;
173 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
174 Object *ob = objects[ob_index];
179 if (tot_faces_selected_all == 0) {
185 KDTree_1d *tree_1d =
NULL;
186 KDTree_3d *tree_3d =
NULL;
187 KDTree_4d *tree_4d =
NULL;
195 tree_1d = BLI_kdtree_1d_new(tot_faces_selected_all);
198 tree_3d = BLI_kdtree_3d_new(tot_faces_selected_all);
201 tree_4d = BLI_kdtree_4d_new(tot_faces_selected_all);
209 "Select similar face: facemap gset array");
214 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
215 Object *ob = objects[ob_index];
220 int custom_data_offset = 0;
246 if (custom_data_offset == -1) {
249 gset_array[ob_index] =
BLI_gset_ptr_new(
"Select similar face: facemap gset");
271 BLI_kdtree_1d_insert(tree_1d, tree_index++, &
area);
276 BLI_kdtree_1d_insert(tree_1d, tree_index++, &perimeter);
284 BLI_kdtree_3d_insert(tree_3d, tree_index++,
normal);
290 BLI_kdtree_4d_insert(tree_4d, tree_index++, plane);
295 goto face_select_all;
309 goto face_select_all;
326 if (tree_1d !=
NULL) {
327 BLI_kdtree_1d_deduplicate(tree_1d);
328 BLI_kdtree_1d_balance(tree_1d);
330 if (tree_3d !=
NULL) {
331 BLI_kdtree_3d_deduplicate(tree_3d);
332 BLI_kdtree_3d_balance(tree_3d);
334 if (tree_4d !=
NULL) {
335 BLI_kdtree_4d_deduplicate(tree_4d);
336 BLI_kdtree_4d_balance(tree_4d);
339 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
340 Object *ob = objects[ob_index];
343 bool changed =
false;
345 int custom_data_offset;
350 bool has_custom_data_layer =
false;
368 if (custom_data_offset == -1) {
382 const int num_sides = face->
len;
386 const int delta_i = num_sides - num_sides_iter;
432 KDTreeNearest_3d nearest;
433 if (BLI_kdtree_3d_find_nearest(tree_3d,
normal, &nearest) != -1) {
444 KDTreeNearest_4d nearest;
445 if (BLI_kdtree_4d_find_nearest(tree_4d, plane, &nearest) != -1) {
446 if (nearest.dist <= thresh) {
447 if ((
fabsf(plane[3] - nearest.co[3]) <= thresh) &&
448 (
angle_v3v3(plane, nearest.co) <= thresh_radians)) {
464 if (!has_custom_data_layer) {
480 GSET_ITER (gs_iter, gset_array[ob_index]) {
482 if (*face_map == *face_map_iter) {
508 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
509 Object *ob = objects[ob_index];
527 BLI_kdtree_1d_free(tree_1d);
528 BLI_kdtree_3d_free(tree_3d);
529 BLI_kdtree_4d_free(tree_4d);
533 if (gset_array !=
NULL) {
534 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
535 if (gset_array[ob_index] !=
NULL) {
570 if (
fabs(r_dir[2]) < FLT_EPSILON) {
571 if (
fabs(r_dir[1]) < FLT_EPSILON) {
572 if (r_dir[0] < 0.0f) {
576 else if (r_dir[1] < 0.0f) {
580 else if (r_dir[2] < 0.0f) {
628 const float thresh_radians = thresh * (
float)
M_PI + FLT_EPSILON;
630 int custom_data_type = -1;
632 int tot_edges_selected_all = 0;
633 uint objects_len = 0;
637 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
638 Object *ob = objects[ob_index];
643 if (tot_edges_selected_all == 0) {
649 KDTree_1d *tree_1d =
NULL;
650 KDTree_3d *tree_3d =
NULL;
659 tree_1d = BLI_kdtree_1d_new(tot_edges_selected_all);
662 tree_3d = BLI_kdtree_3d_new(tot_edges_selected_all);
679 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
680 Object *ob = objects[ob_index];
699 BLI_kdtree_1d_insert(tree_1d, tree_index++, (
float[1]){0.0f});
706 float ob_m3[3][3], ob_m3_inv[3][3];
722 BLI_kdtree_3d_insert(tree_3d, tree_index++, dir);
727 BLI_kdtree_1d_insert(tree_1d, tree_index++, &
length);
733 BLI_kdtree_1d_insert(tree_1d, tree_index++, &
angle);
739 goto edge_select_all;
744 goto edge_select_all;
757 goto edge_select_all;
765 BLI_kdtree_1d_insert(tree_1d, tree_index++, value);
775 if (tree_1d !=
NULL) {
776 BLI_kdtree_1d_deduplicate(tree_1d);
777 BLI_kdtree_1d_balance(tree_1d);
779 if (tree_3d !=
NULL) {
780 BLI_kdtree_3d_deduplicate(tree_3d);
781 BLI_kdtree_3d_balance(tree_3d);
784 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
785 Object *ob = objects[ob_index];
788 bool changed =
false;
790 bool has_custom_data_layer =
false;
802 if (!has_custom_data_layer) {
813 float ob_m3[3][3], ob_m3_inv[3][3];
829 const int delta_i = num_faces - num_faces_iter;
843 KDTreeNearest_3d nearest;
844 if (BLI_kdtree_3d_find_nearest(tree_3d, dir, &nearest) != -1) {
882 if (!has_custom_data_layer) {
897 if (!has_custom_data_layer) {
928 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
929 Object *ob = objects[ob_index];
947 BLI_kdtree_1d_free(tree_1d);
948 BLI_kdtree_3d_free(tree_3d);
968 const float thresh_radians = thresh * (
float)
M_PI + FLT_EPSILON;
971 int tot_verts_selected_all = 0;
972 uint objects_len = 0;
976 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
977 Object *ob = objects[ob_index];
982 if (tot_verts_selected_all == 0) {
988 KDTree_3d *tree_3d =
NULL;
993 tree_3d = BLI_kdtree_3d_new(tot_verts_selected_all);
1004 int normal_tree_index = 0;
1005 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
1006 Object *ob = objects[ob_index];
1009 int cd_dvert_offset = -1;
1011 int defbase_len = 0;
1021 if (cd_dvert_offset == -1) {
1025 if (defbase_len == 0) {
1049 BLI_kdtree_3d_insert(tree_3d, normal_tree_index++,
normal);
1056 for (
int i = 0; i < dvert->
totweight; i++, dw++) {
1091 if (tree_3d !=
NULL) {
1092 BLI_kdtree_3d_deduplicate(tree_3d);
1093 BLI_kdtree_3d_balance(tree_3d);
1097 for (
uint ob_index = 0; ob_index < objects_len; ob_index++) {
1098 Object *ob = objects[ob_index];
1101 bool changed =
false;
1102 int cd_dvert_offset = -1;
1104 int defbase_len = 0;
1108 if (cd_dvert_offset == -1) {
1112 if (defbase_len == 0) {
1120 bool found_any =
false;
1125 if (vgroup_id != -1) {
1130 if (found_any ==
false) {
1148 const int delta_i = num_edges - num_edges_iter;
1161 const int delta_i = num_faces - num_faces_iter;
1177 KDTreeNearest_3d nearest;
1178 if (BLI_kdtree_3d_find_nearest(tree_3d,
normal, &nearest) != -1) {
1189 for (
int i = 0; i < dvert->
totweight; i++, dw++) {
1221 BLI_kdtree_3d_free(tree_3d);
1286 #ifdef WITH_FREESTYLE
1310 ot->
name =
"Select Similar";
1311 ot->
idname =
"MESH_OT_select_similar";
1312 ot->
description =
"Select similar vertices, edges or faces by property types";
1328 prop =
RNA_def_float(
ot->
srna,
"threshold", 0.0f, 0.0f, 1.0f,
"Threshold",
"", 0.0f, 1.0f);
typedef float(TangentPoint)[2]
struct Object * CTX_data_edit_object(const bContext *C)
struct ViewLayer * CTX_data_view_layer(const bContext *C)
struct View3D * CTX_wm_view3d(const bContext *C)
struct ToolSettings * CTX_data_tool_settings(const bContext *C)
bool CustomData_has_layer(const struct CustomData *data, int type)
void * CustomData_bmesh_get(const struct CustomData *data, void *block, int type)
int CustomData_get_offset(const struct CustomData *data, int type)
BMEditMesh * BKE_editmesh_from_object(struct Object *ob)
Return the BMEditMesh for a given object.
#define BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, v3d, r_len)
General operations, lookup, etc. for materials.
struct Material *** BKE_object_material_array_p(struct Object *ob)
void BKE_report(ReportList *reports, ReportType type, const char *message)
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
#define BLI_BITMAP_NEW(_tot, _alloc_string)
GSet * BLI_gset_str_new(const char *info)
unsigned int BLI_gset_len(GSet *gs) ATTR_WARN_UNUSED_RESULT
GSet * BLI_gset_ptr_new(const char *info)
#define GSET_ITER(gs_iter_, gset_)
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
BLI_INLINE void * BLI_gsetIterator_getKey(GSetIterator *gsi)
bool BLI_gset_add(GSet *gs, void *key)
A kd-tree for nearest neighbor search.
#define LISTBASE_FOREACH(type, var, list)
int BLI_findstringindex(const struct ListBase *listbase, const char *id, const int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
void copy_m3_m4(float m1[3][3], const float m2[4][4])
bool invert_m4_m4(float R[4][4], const float A[4][4])
void mul_m4_v3(const float M[4][4], float r[3])
bool invert_m3_m3(float R[3][3], const float A[3][3])
void mul_transposed_mat3_m4_v3(const float M[4][4], float r[3])
void mul_v3_m4v3(float r[3], const float M[4][4], const float v[3])
void mul_v3_mat3_m4v3(float r[3], const float M[4][4], const float v[3])
float angle_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float normalize_v3(float r[3])
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[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
#define POINTER_FROM_INT(i)
#define POINTER_AS_INT(i)
#define SCE_SELECT_VERTEX
void EDBM_update_generic(struct Mesh *me, const bool do_tessellation, const bool is_destructive)
void EDBM_selectmode_flush(struct BMEditMesh *em)
bool ED_operator_editmesh(struct bContext *C)
bool ED_select_similar_compare_float_tree(const struct KDTree_1d *tree, const float length, const float thresh, const int compare)
_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
_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 const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
Read Guarded memory(de)allocation.
#define BM_FACE_FIRST_LOOP(p)
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
#define BM_elem_flag_test(ele, hflag)
#define BM_ITER_MESH(ele, iter, bm, itype)
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_face_select_set(BMesh *bm, BMFace *f, const bool select)
Select Face.
void BM_vert_select_set(BMesh *bm, BMVert *v, const bool select)
Select Vert.
void BM_edge_select_set(BMesh *bm, BMEdge *e, const bool select)
Select Edge.
float BM_face_calc_area_with_mat3(const BMFace *f, const float mat3[3][3])
float BM_face_calc_perimeter_with_mat3(const BMFace *f, const float mat3[3][3])
int BM_edge_face_count_at_most(const BMEdge *e, const int count_max)
int BM_vert_face_count(const BMVert *v)
int BM_edge_face_count(const BMEdge *e)
int BM_vert_edge_count(const BMVert *v)
float BM_edge_calc_face_angle_with_imat3(const BMEdge *e, const float imat3[3][3])
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE btScalar length(const btQuaternion &q)
Return the length of a quaternion.
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
static int edbm_select_similar_exec(bContext *C, wmOperator *op)
static int mesh_select_similar_compare_int(const int delta, const int compare)
static int similar_edge_select_exec(bContext *C, wmOperator *op)
static int similar_vert_select_exec(bContext *C, wmOperator *op)
static const EnumPropertyItem prop_similar_types[]
static bool edge_data_value_set(BMEdge *edge, const int hflag, int *r_value)
void MESH_OT_select_similar(wmOperatorType *ot)
static float edge_length_squared_worldspace_get(Object *ob, BMEdge *edge)
static int similar_face_select_exec(bContext *C, wmOperator *op)
static void face_to_plane(const Object *ob, BMFace *face, float r_plane[4])
static void edge_pos_direction_worldspace_get(Object *ob, BMEdge *edge, float *r_dir)
static const EnumPropertyItem prop_similar_compare_types[]
static const EnumPropertyItem * select_similar_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
static bool face_data_value_set(BMFace *face, const int hflag, int *r_value)
IconTextureDrawCall normal
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
static void area(int d1, int d2, int e1, int e2, float weights[2])
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
float RNA_float_get(PointerRNA *ptr, const char *name)
void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
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)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
void RNA_enum_items_add_value(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item, int value)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
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
struct ReportList * reports
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
ccl_device_inline float2 fabs(const float2 &a)
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))