[Bf-blender-cvs] [0f03750f4fb] blender2.8: Cleanup: Remove bmo_similar.c and small renaming

Dalai Felinto noreply at git.blender.org
Fri Sep 28 15:32:19 CEST 2018


Commit: 0f03750f4fb0bee3bdd889b07f37de07243d21f7
Author: Dalai Felinto
Date:   Fri Sep 28 10:32:04 2018 -0300
Branches: blender2.8
https://developer.blender.org/rB0f03750f4fb0bee3bdd889b07f37de07243d21f7

Cleanup: Remove bmo_similar.c and small renaming

===================================================================

M	source/blender/bmesh/CMakeLists.txt
M	source/blender/bmesh/intern/bmesh_opdefines.c
M	source/blender/bmesh/intern/bmesh_operators.h
M	source/blender/bmesh/intern/bmesh_operators_private.h
D	source/blender/bmesh/operators/bmo_similar.c
M	source/blender/editors/mesh/editmesh_select_similar.c

===================================================================

diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt
index bd3eb4cc1ac..e6317762842 100644
--- a/source/blender/bmesh/CMakeLists.txt
+++ b/source/blender/bmesh/CMakeLists.txt
@@ -70,7 +70,6 @@ set(SRC
 	operators/bmo_primitive.c
 	operators/bmo_removedoubles.c
 	operators/bmo_rotate_edges.c
-	operators/bmo_similar.c
 	operators/bmo_smooth_laplacian.c
 	operators/bmo_split_edges.c
 	operators/bmo_subdivide.c
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index d1366d24b5b..778ca89d70c 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -116,13 +116,6 @@ static BMO_FlagSet bmo_enum_falloff_type[] = {
 	{0, NULL},
 };
 
-static BMO_FlagSet bmo_enum_compare_types[] = {
-	{SIM_CMP_EQ, "EQUAL"},
-	{SIM_CMP_GT, "GREATER_THAN"},
-	{SIM_CMP_LT, "LESS_THAN"},
-	{0, NULL},
-};
-
 /*
  * Vertex Smooth.
  *
@@ -1479,110 +1472,6 @@ static BMOpDefine bmo_spin_def = {
 	 BMO_OPTYPE_FLAG_SELECT_FLUSH),
 };
 
-static BMO_FlagSet bmo_enum_similar_faces_types[] = {
-	{SIMFACE_MATERIAL, "MATERIAL"},
-	{SIMFACE_AREA, "AREA"},
-	{SIMFACE_SIDES, "SIDES"},
-	{SIMFACE_PERIMETER, "PERIMETER"},
-	{SIMFACE_NORMAL, "NORMAL"},
-	{SIMFACE_COPLANAR, "COPLANAR"},
-	{SIMFACE_SMOOTH, "SMOOTH"},
-	{SIMFACE_FACEMAP, "FACE_MAP"},
-#ifdef WITH_FREESTYLE
-	{SIMFACE_FREESTYLE, "FREESTYLE"},
-#endif
-	{0, NULL},
-};
-
-/*
- * Similar Faces Search.
- *
- * Find similar faces (area/material/perimeter, ...).
- */
-static BMOpDefine bmo_similar_faces_def = {
-	"similar_faces",
-	/* slots_in */
-	{{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}},    /* input faces */
-	 {"type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_similar_faces_types}, /* type of selection */
-	 {"thresh", BMO_OP_SLOT_FLT},           /* threshold of selection */
-	 {"compare", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_compare_types}, /* comparison method */
-	 {{'\0'}},
-	},
-	/* slots_out */
-	{{"faces.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}},  /* output faces */
-	 {{'\0'}},
-	},
-	bmo_similar_faces_exec,
-	(BMO_OPTYPE_FLAG_SELECT_FLUSH),
-};
-
-static BMO_FlagSet bmo_enum_similar_edges_types[] = {
-	{SIMEDGE_LENGTH, "LENGTH"},
-	{SIMEDGE_DIR, "DIRECTION"},
-	{SIMEDGE_FACE, "FACE"},
-	{SIMEDGE_FACE_ANGLE, "FACE_ANGLE"},
-	{SIMEDGE_CREASE, "CREASE"},
-	{SIMEDGE_BEVEL, "BEVEL"},
-	{SIMEDGE_SEAM, "SEAM"},
-	{SIMEDGE_SHARP, "SHARP"},
-#ifdef WITH_FREESTYLE
-	{SIMEDGE_FREESTYLE, "FREESTYLE"},
-#endif
-	{0, NULL},
-};
-
-/*
- * Similar Edges Search.
- *
- * Find similar edges (length, direction, edge, seam, ...).
- */
-static BMOpDefine bmo_similar_edges_def = {
-	"similar_edges",
-	/* slots_in */
-	{{"edges", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}},    /* input edges */
-	 {"type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_similar_edges_types}, /* type of selection */
-	 {"thresh", BMO_OP_SLOT_FLT},           /* threshold of selection */
-	 {"compare", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_compare_types}, /* comparison method */
-	 {{'\0'}},
-	},
-	/* slots_out */
-	{{"edges.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}},  /* output edges */
-	 {{'\0'}},
-	},
-	bmo_similar_edges_exec,
-	(BMO_OPTYPE_FLAG_SELECT_FLUSH),
-};
-
-static BMO_FlagSet bmo_enum_similar_verts_types[] = {
-	{SIMVERT_NORMAL, "NORMAL"},
-	{SIMVERT_FACE, "FACE"},
-	{SIMVERT_VGROUP, "VERTEX_GROUP"},
-	{SIMVERT_EDGE, "EDGE"},
-	{0, NULL},
-};
-
-/*
- * Similar Verts Search.
- *
- * Find similar vertices (normal, face, vertex group, ...).
- */
-static BMOpDefine bmo_similar_verts_def = {
-	"similar_verts",
-	/* slots_in */
-	{{"verts", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}},    /* input vertices */
-	 {"type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_similar_verts_types}, /* type of selection */
-	 {"thresh", BMO_OP_SLOT_FLT},           /* threshold of selection */
-	 {"compare", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_compare_types}, /* comparison method */
-	 {{'\0'}},
-	},
-	/* slots_out */
-	{{"verts.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}},  /* output vertices */
-	 {{'\0'}},
-	},
-	bmo_similar_verts_exec,
-	(BMO_OPTYPE_FLAG_SELECT_FLUSH),
-};
-
 /*
  * UV Rotation.
  *
@@ -2236,9 +2125,6 @@ const BMOpDefine *bmo_opdefines[] = {
 	&bmo_rotate_edges_def,
 	&bmo_rotate_uvs_def,
 	&bmo_scale_def,
-	&bmo_similar_edges_def,
-	&bmo_similar_faces_def,
-	&bmo_similar_verts_def,
 	&bmo_smooth_vert_def,
 	&bmo_smooth_laplacian_vert_def,
 	&bmo_solidify_def,
diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h
index d8f995b9d3e..3e96d5ff44a 100644
--- a/source/blender/bmesh/intern/bmesh_operators.h
+++ b/source/blender/bmesh/intern/bmesh_operators.h
@@ -56,12 +56,6 @@ enum {
 	SUBDIV_SELECT_LOOPCUT
 };
 
-enum {
-	SIM_CMP_EQ = 0,
-	SIM_CMP_GT,
-	SIM_CMP_LT
-};
-
 /* subdivide_edgering */
 enum {
 	/* just subdiv */
diff --git a/source/blender/bmesh/intern/bmesh_operators_private.h b/source/blender/bmesh/intern/bmesh_operators_private.h
index 5548ee7c361..8e9edfac1f9 100644
--- a/source/blender/bmesh/intern/bmesh_operators_private.h
+++ b/source/blender/bmesh/intern/bmesh_operators_private.h
@@ -94,9 +94,6 @@ void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op);
 void bmo_rotate_exec(BMesh *bm, BMOperator *op);
 void bmo_rotate_uvs_exec(BMesh *bm, BMOperator *op);
 void bmo_scale_exec(BMesh *bm, BMOperator *op);
-void bmo_similar_edges_exec(BMesh *bm, BMOperator *op);
-void bmo_similar_faces_exec(BMesh *bm, BMOperator *op);
-void bmo_similar_verts_exec(BMesh *bm, BMOperator *op);
 void bmo_smooth_vert_exec(BMesh *bm, BMOperator *op);
 void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op);
 void bmo_solidify_face_region_exec(BMesh *bm, BMOperator *op);
diff --git a/source/blender/bmesh/operators/bmo_similar.c b/source/blender/bmesh/operators/bmo_similar.c
deleted file mode 100644
index 0cd17258834..00000000000
--- a/source/blender/bmesh/operators/bmo_similar.c
+++ /dev/null
@@ -1,667 +0,0 @@
-/*
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributor(s): Joseph Eagar, Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/bmesh/operators/bmo_similar.c
- *  \ingroup bmesh
- *
- * bmesh operators to select based on
- * comparisons with the existing selection.
- */
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_object_types.h"
-#include "DNA_meshdata_types.h"
-
-#include "BLI_math.h"
-
-#include "BKE_customdata.h"
-#include "BKE_deform.h"
-
-#include "bmesh.h"
-
-#include "intern/bmesh_operators_private.h"  /* own include */
-
-/* in fact these could all be the same */
-
-/*
- * extra face data (computed data)
- */
-typedef struct SimSel_FaceExt {
-	BMFace  *f;             /* the face */
-	float    c[3];          /* center */
-	union {
-		float   area;       /* area */
-		float   perim;      /* perimeter */
-		float   d;          /* 4th component of plane (the first three being the normal) */
-		struct Image *t;    /* image pointer */
-	};
-} SimSel_FaceExt;
-
-static int bm_sel_similar_cmp_fl(const float delta, const float thresh, const int compare)
-{
-	switch (compare) {
-		case SIM_CMP_EQ:
-			return (fabsf(delta) <= thresh);
-		case SIM_CMP_GT:
-			return ((delta + thresh) >= 0.0f);
-		case SIM_CMP_LT:
-			return ((delta - thresh) <= 0.0f);
-		default:
-			BLI_assert(0);
-			return 0;
-	}
-}
-
-static int bm_sel_similar_cmp_i(const int delta, const int compare)
-{
-	switch (compare) {
-		case SIM_CMP_EQ:
-			return (delta == 0);
-		case SIM_CMP_GT:
-			return (delta > 0);
-		case SIM_CMP_LT:
-			return (delta < 0);
-		default:
-			BLI_assert(0);
-			return 0;
-	}
-}
-
-/*
- * Select similar faces, the choices are in the enum in source/blender/bmesh/bmesh_operators.h
- * We select either similar faces based on material, image, area, perimeter, normal, or the coplanar faces
- */
-void bmo_similar_faces_exec(BMesh *bm, BMOperator *op)
-{
-#define FACE_MARK	1
-
-	BMIter fm_iter;
-	BMFace *fs, *fm;
-	BMOIter fs_iter;
-	int num_sels = 0, num_total = 0, i = 0, idx = 0;
-	float angle = 0.0f;
-	SimSel_FaceExt *f_ext = NULL;
-	int *indices = NULL;
-	const int type = BMO_slot_int_get(op->slots_in, "type");
-	const float thresh = BMO_slot_float_get(op->slots_in, "thresh");
-	const float thresh_radians = thresh * (float)M_PI;
-	const int compare = BMO_slot_int_get(op->slots_in, "compare");
-	/* for comparison types that use custom-data */
-	int cd_offset = -1;
-
-	/* initial_elem - other_elem */
-	float delta_fl;
-	int   delta_i;
-
-	if (type == SIMFACE_FACEMAP) {
-		cd_offset = CustomData_get_offset(&bm->pdata, CD_FACEMAP);
-		if (cd_offset == -1) {
-			return;
-		}
-	}
-#ifdef WITH_FREESTYLE
-	else if (type == SIMFACE_FREESTYLE) {
-		cd_offset = CustomData_get_offset(&bm->pdata, CD_FREESTYLE_FACE);
-		if (cd_offset == -1) {
-			return;
-		}
-	}
-#endif
-
-	num_total = BM_mesh_elem_count(bm, BM_FACE);
-
-	/*
-	 * The first thing to do is to iterate through all the selected items and mark them since
-	 * they will be in the selection anyway.
-	 * This will increase performance, (especially when the number of originally selected faces is high)
-	 * so the overall complexity will be less than $O(mn)$ where is the total number of selected faces,
-	 * and n is the total number of faces
-	 */
-	BMO_ITER (fs, &fs_iter, op->slots_in, "faces", BM_FACE) {
-		if (!BMO_face_flag_test(bm, fs, FAC

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list