55 {0,
nullptr, 0,
nullptr,
nullptr},
60 {
SIMVERT_FACE,
"VERT_FACES", 0,
"Amount of Adjacent Faces",
""},
62 {
SIMVERT_EDGE,
"VERT_EDGES", 0,
"Amount of Connecting Edges",
""},
67 {
SIMEDGE_FACE,
"EDGE_FACES", 0,
"Amount of Faces Around an Edge",
""},
88 {0,
nullptr, 0,
nullptr,
nullptr},
141 float normal[3], co[3];
161 const float thresh_radians = thresh *
float(
M_PI);
167 bool any_face_selected =
false;
168 for (
Object *ob : objects) {
173 any_face_selected =
true;
177 if (!any_face_selected) {
195 for (
Object *ob : objects) {
197 Material ***material_array =
nullptr;
198 invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr());
205 copy_m3_m4(ob_m3, ob->object_to_world().ptr());
207 int custom_data_offset = -1;
210 if (ob->totcol == 0) {
219 if (custom_data_offset == -1) {
238 if (material !=
nullptr) {
239 materials_set.
add(material);
245 points_1d.
add(area, tree_index++);
250 points_1d.
add(perimeter, tree_index++);
258 points_3d.
add(normal, tree_index++);
264 points_4d.
add(plane, tree_index++);
269 goto face_select_all;
281 goto face_select_all;
296 for (
const auto &[pos,
index] : points_1d.
items()) {
304 for (
const auto &[pos,
index] : points_3d.
items()) {
312 for (
const auto &[pos,
index] : points_4d.
items()) {
323 for (
Object *ob : objects) {
326 bool changed =
false;
327 Material ***material_array =
nullptr;
330 copy_m3_m4(ob_m3, ob->object_to_world().ptr());
332 int custom_data_offset = -1;
335 if (ob->totcol == 0) {
359 const int num_sides = face->
len;
360 for (
const int num_sides_iter : sides_set) {
361 const int delta_i = num_sides - num_sides_iter;
371 if (material ==
nullptr) {
374 if (materials_set.
contains(material)) {
418 if (nearest.
dist <= thresh) {
419 if ((
fabsf(plane[3] - nearest.
co[3]) <= thresh) &&
437 if (custom_data_offset == -1) {
474 for (
Object *ob : objects) {
516 mul_m4_v3(ob->object_to_world().ptr(), v1);
574 bool any_edge_selected =
false;
575 for (
Object *ob : objects) {
580 any_edge_selected =
true;
584 if (!any_edge_selected) {
598 for (
Object *ob : objects) {
614 points_1d.
add(0.0f, tree_index++);
621 points_1d.
add(0.0f, tree_index++);
628 int custom_data_offset;
644 float ob_m3[3][3], ob_m3_inv[3][3];
645 copy_m3_m4(ob_m3, ob->object_to_world().ptr());
658 float dir[3], dir_flip[3];
660 points_3d.
add(dir, tree_index++);
664 points_3d.
add(dir_flip, tree_index++);
681 goto edge_select_all;
686 goto edge_select_all;
697 goto edge_select_all;
704 points_1d.
add(value, tree_index++);
720 for (
const auto &[pos,
index] : points_1d.
items()) {
728 for (
const auto &[pos,
index] : points_3d.
items()) {
738 for (
Object *ob : objects) {
741 bool changed =
false;
743 bool has_custom_data_layer =
false;
756 if (!has_custom_data_layer) {
769 if (!has_custom_data_layer) {
781 float ob_m3[3][3], ob_m3_inv[3][3];
782 copy_m3_m4(ob_m3, ob->object_to_world().ptr());
785 int custom_data_offset;
809 for (
const int num_faces_iter : face_count_set) {
810 const int delta_i = num_faces - num_faces_iter;
865 if (!has_custom_data_layer) {
879 if (!has_custom_data_layer) {
917 for (
Object *ob : objects) {
967 bool any_vert_selected =
false;
968 for (
Object *ob : objects) {
973 any_vert_selected =
true;
977 if (!any_vert_selected) {
990 int normal_tree_index = 0;
991 int tree_1d_index = 0;
992 for (
Object *ob : objects) {
994 int cd_dvert_offset = -1;
995 int cd_crease_offset = -1;
999 invert_m4_m4(ob->runtime->world_to_object.ptr(), ob->object_to_world().ptr());
1007 if (cd_dvert_offset == -1) {
1011 if (defbase_len == 0) {
1018 points_1d.
add(0.0f, tree_1d_index++);
1042 points_3d.
add(normal, normal_tree_index++);
1050 for (
int i = 0; i < dvert->
totweight; i++, dw++) {
1052 if (dw->
def_nr < defbase_len) [[likely]] {
1061 points_1d.
add(value, tree_1d_index++);
1077 selected_vertex_groups.
add_as(dg.name);
1081 MEM_delete(defbase_selected);
1086 if (selected_vertex_groups.
is_empty()) {
1094 for (
const auto &[pos,
index] : points_3d.
items()) {
1102 for (
const auto &[pos,
index] : points_1d.
items()) {
1115 for (
Object *ob : objects) {
1118 bool changed =
false;
1119 bool has_crease_layer =
false;
1120 int cd_dvert_offset = -1;
1121 int cd_crease_offset = -1;
1123 int defbase_len = 0;
1127 if (cd_dvert_offset == -1) {
1131 defbase_len = defbase->count();
1132 if (defbase_len == 0) {
1140 bool found_any =
false;
1141 for (
const StringRef name : selected_vertex_groups) {
1143 if (vgroup_id != -1) {
1148 if (found_any ==
false) {
1149 MEM_delete(defbase_selected);
1156 if (!has_crease_layer) {
1175 for (
const int num_edges_iter : connected_elems_num_set) {
1176 const int delta_i = num_edges - num_edges_iter;
1186 for (
const int num_faces_iter : connected_elems_num_set) {
1187 const int delta_i = num_faces - num_faces_iter;
1216 for (
int i = 0; i < dvert->
totweight; i++, dw++) {
1218 if (dw->
def_nr < defbase_len) [[likely]] {
1229 if (!has_crease_layer) {
1251 MEM_delete(defbase_selected);
1329#ifdef WITH_FREESTYLE
1356 if (
STREQ(prop_id,
"compare")) {
1362 else if (
STREQ(prop_id,
"threshold")) {
1387 ot->
name =
"Select Similar";
1388 ot->
idname =
"MESH_OT_select_similar";
1389 ot->
description =
"Select similar vertices, edges or faces by property types";
1407 prop =
RNA_def_float(ot->
srna,
"threshold", 0.0f, 0.0f, 100000.0f,
"Threshold",
"", 0.0f, 1.0f);
CustomData interface, see also DNA_customdata_types.h.
General operations, lookup, etc. for materials.
#define BLI_BITMAP_NEW(_num, _alloc_string)
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
A KD-tree for nearest neighbor search.
#define BLT_I18NCONTEXT_ID_MESH
Read Blender memory allocation and freeing.
#define BM_ELEM_CD_GET_BOOL(ele, offset)
#define BM_ELEM_CD_GET_FLOAT(ele, offset)
#define BM_FACE_FIRST_LOOP(p)
#define BM_ELEM_CD_GET_FLOAT_P(ele, offset)
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
#define BM_elem_flag_test(ele, hflag)
#define BM_ITER_MESH(ele, iter, bm, itype)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
bool add(const Key &key, const Value &value)
ItemIterator items() const &
bool add_as(ForwardKey &&key)
bool contains(const Key &key) const
float length(VecOp< float, D >) RET
int CustomData_get_offset(const CustomData *data, eCustomDataType type)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void negate_v3_v3(float r[3], const float a[3])
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
void kdtree_balance(KDTree< CoordT > *tree)
static wmOperatorStatus similar_vert_select_exec(bContext *C, wmOperator *op)
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 *)
int BM_edge_face_count(const BMEdge *e)
static wmOperatorStatus edbm_select_similar_exec(bContext *C, wmOperator *op)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void EDBM_selectmode_flush(BMesh *bm, short selectmode)
const ListBaseT< bDeformGroup > * BKE_object_defgroup_list(const Object *ob)
BMesh * BKE_editmesh_bmesh_get_for_write(Mesh *mesh)
MINLINE void copy_v3_v3(float r[3], const float a[3])
float BM_face_calc_perimeter_with_mat3(const BMFace *f, const float mat3[3][3])
void copy_m3_m4(float m1[3][3], const float m2[4][4])
int BKE_object_defgroup_count(const Object *ob)
Material *** BKE_object_material_array_p(Object *ob)
void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value)
static float edge_length_squared_worldspace_get(Object *ob, BMEdge *edge)
bool invert_m3_m3(float inverse[3][3], const float mat[3][3])
const char * RNA_property_identifier(const PropertyRNA *prop)
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
void EDBM_update(Mesh *mesh, const EDBMUpdate_Params *params)
float angle_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
static const EnumPropertyItem prop_similar_compare_types[]
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
static int mesh_select_similar_compare_int(const int delta, const int compare)
void mul_v3_mat3_m4v3(float r[3], const float mat[4][4], const float vec[3])
int BM_edge_face_count_at_most(const BMEdge *e, const int count_max)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void plane_from_point_normal_v3(float r_plane[4], const float plane_co[3], const float plane_no[3])
int BKE_defgroup_name_index(const ListBaseT< bDeformGroup > *defbase, StringRef name)
static const EnumPropertyItem prop_similar_types[]
ViewLayer * CTX_data_view_layer(const bContext *C)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
KDTree< CoordT > * kdtree_new(uint nodes_len_capacity)
void mul_m4_v3(const float M[4][4], float r[3])
bool ED_operator_editmesh(bContext *C)
static const EnumPropertyItem * select_similar_type_itemf(bContext *C, PointerRNA *, PropertyRNA *, bool *r_free)
static void edge_pos_direction_worldspace_get(Object *ob, BMEdge *edge, float *r_dir)
int BM_vert_face_count(const BMVert *v)
bool ED_select_similar_compare_float_tree(const KDTree< float > *tree, float length, float thresh, eSimilarCmp compare)
void BKE_report(ReportList *reports, eReportType type, const char *message)
static bool edge_data_value_set(BMEdge *edge, const int hflag, int *r_value)
Object * CTX_data_edit_object(const bContext *C)
static bool face_data_value_set(BMFace *face, const int hflag, int *r_value)
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, StringRef name)
void kdtree_insert(KDTree< CoordT > *tree, int index, const CoordT &co)
void BM_face_select_set(BMesh *bm, BMFace *f, const bool select)
Select Face.
int kdtree_find_nearest(const KDTree< CoordT > *tree, const CoordT &co, KDTreeNearest< CoordT > *r_nearest)
static wmOperatorStatus similar_edge_select_exec(bContext *C, wmOperator *op)
void RNA_enum_items_add_value(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item, int value)
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
ToolSettings * CTX_data_tool_settings(const bContext *C)
void MESH_OT_select_similar(wmOperatorType *ot)
void BM_vert_select_set(BMesh *bm, BMVert *v, const bool select)
Select Vert.
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
BMEditMesh * BKE_editmesh_from_object(Object *ob)
Return the BMEditMesh for a given object.
float RNA_property_float_get(PointerRNA *ptr, PropertyRNA *prop)
MINLINE float normalize_v3(float n[3])
void kdtree_free(KDTree< CoordT > *tree)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
Main * CTX_data_main(const bContext *C)
static bool edbm_select_similar_poll_property(const bContext *, wmOperator *op, const PropertyRNA *prop)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
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)
const BMesh * BKE_editmesh_bmesh_get(const Object *ob)
float BM_edge_calc_face_angle_with_imat3(const BMEdge *e, const float imat3[3][3])
bool EDBM_uvselect_clear(BMesh *bm)
static void face_to_plane(const Object *ob, BMFace *face, float r_plane[4])
Scene * CTX_data_scene(const bContext *C)
bool CustomData_has_layer_named(const CustomData *data, eCustomDataType type, StringRef 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)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
View3D * CTX_wm_view3d(const bContext *C)
int BM_vert_edge_count(const BMVert *v)
float BM_face_calc_area_with_mat3(const BMFace *f, const float mat3[3][3])
static wmOperatorStatus similar_face_select_exec(bContext *C, wmOperator *op)
void mul_transposed_mat3_m4_v3(const float M[4][4], float r[3])
void BM_edge_select_set(BMesh *bm, BMEdge *e, const bool select)
Select Edge.
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll_property(const bContext *C, wmOperator *op, const PropertyRNA *prop) 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
struct ReportList * reports