[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55121] trunk/blender/source/blender/ editors: code cleanup: use bool's for snapping functions.

Campbell Barton ideasman42 at gmail.com
Fri Mar 8 19:28:26 CET 2013


Revision: 55121
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55121
Author:   campbellbarton
Date:     2013-03-08 18:28:26 +0000 (Fri, 08 Mar 2013)
Log Message:
-----------
code cleanup: use bool's for snapping functions.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/ED_transform.h
    trunk/blender/source/blender/editors/transform/transform_snap.c

Modified: trunk/blender/source/blender/editors/include/ED_transform.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_transform.h	2013-03-08 18:17:12 UTC (rev 55120)
+++ trunk/blender/source/blender/editors/include/ED_transform.h	2013-03-08 18:28:26 UTC (rev 55121)
@@ -177,12 +177,12 @@
 
 #define SNAP_MIN_DISTANCE 30
 
-int peelObjectsTransForm(struct TransInfo *t, struct ListBase *depth_peels, const float mval[2], SnapMode mode);
-int peelObjectsContext(struct bContext *C, struct ListBase *depth_peels, const float mval[2], SnapMode mode);
-int snapObjectsTransform(struct TransInfo *t, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode);
-int snapObjectsContext(struct bContext *C, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode);
-int snapNodesTransform(struct TransInfo *t, const int mval[2], int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode);
-int snapNodesContext(struct bContext *C, const int mval[2], int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode);
+bool peelObjectsTransForm(struct TransInfo *t, struct ListBase *depth_peels, const float mval[2], SnapMode mode);
+bool peelObjectsContext(struct bContext *C, struct ListBase *depth_peels, const float mval[2], SnapMode mode);
+bool snapObjectsTransform(struct TransInfo *t, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode);
+bool snapObjectsContext(struct bContext *C, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode);
+bool snapNodesTransform(struct TransInfo *t, const int mval[2], int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode);
+bool snapNodesContext(struct bContext *C, const int mval[2], int *r_dist, float r_loc[2], char *r_node_border, SnapMode mode);
 
 #endif
 

Modified: trunk/blender/source/blender/editors/transform/transform_snap.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_snap.c	2013-03-08 18:17:12 UTC (rev 55120)
+++ trunk/blender/source/blender/editors/transform/transform_snap.c	2013-03-08 18:28:26 UTC (rev 55121)
@@ -103,7 +103,7 @@
 
 /****************** IMPLEMENTATIONS *********************/
 
-static int snapNodeTest(View2D *v2d, bNode *node, SnapMode mode);
+static bool snapNodeTest(View2D *v2d, bNode *node, SnapMode mode);
 static NodeBorder snapNodeBorder(int snap_node_mode);
 
 #if 0
@@ -818,7 +818,7 @@
 		float loc[3];
 		float no[3];
 		float mval[2];
-		int found = 0;
+		bool found = false;
 		int dist = SNAP_MIN_DISTANCE; // Use a user defined value here
 		
 		mval[0] = t->mval[0];
@@ -901,7 +901,7 @@
 				no[0] = 0.0;
 				no[1] = 0.0;
 				no[2] = 1.0;
-				found = 1;
+				found = true;
 			}
 			
 			BLI_freelistN(&depth_peels);
@@ -910,7 +910,7 @@
 			found = snapObjectsTransform(t, mval, &dist, loc, no, t->tsnap.modeSelect);
 		}
 		
-		if (found == 1) {
+		if (found == true) {
 			float tangent[3];
 			
 			sub_v3_v3v3(tangent, loc, t->tsnap.snapPoint);
@@ -1144,13 +1144,13 @@
 	}
 }
 
-static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], short v2no[3], float obmat[4][4], float timat[3][3],
-                    const float ray_start[3], const float ray_start_local[3], const float ray_normal_local[3], const float mval[2],
-                    float r_loc[3], float r_no[3], int *r_dist, float *r_depth)
+static bool snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], short v2no[3], float obmat[4][4], float timat[3][3],
+                     const float ray_start[3], const float ray_start_local[3], const float ray_normal_local[3], const float mval[2],
+                     float r_loc[3], float r_no[3], int *r_dist, float *r_depth)
 {
 	float intersect[3] = {0, 0, 0}, ray_end[3], dvec[3];
 	int result;
-	int retval = 0;
+	bool retval = false;
 	
 	copy_v3_v3(ray_end, ray_normal_local);
 	mul_v3_fl(ray_end, 2000);
@@ -1206,7 +1206,7 @@
 				float n1[3], n2[3];
 				
 				*r_depth = new_depth;
-				retval = 1;
+				retval = true;
 				
 				sub_v3_v3v3(edge_loc, v1co, v2co);
 				sub_v3_v3v3(vec, intersect, v2co);
@@ -1231,11 +1231,11 @@
 	return retval;
 }
 
-static int snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[4][4], float timat[3][3],
-                      const float ray_start[3], const float ray_start_local[3], const float ray_normal_local[3], const float mval[2],
-                      float r_loc[3], float r_no[3], int *r_dist, float *r_depth)
+static bool snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[4][4], float timat[3][3],
+                       const float ray_start[3], const float ray_start_local[3], const float ray_normal_local[3], const float mval[2],
+                       float r_loc[3], float r_no[3], int *r_dist, float *r_depth)
 {
-	int retval = 0;
+	bool retval = false;
 	float dvec[3];
 	
 	sub_v3_v3v3(dvec, vco, ray_start_local);
@@ -1262,7 +1262,7 @@
 		
 		if (new_dist <= *r_dist && new_depth < *r_depth) {
 			*r_depth = new_depth;
-			retval = 1;
+			retval = true;
 			
 			copy_v3_v3(r_loc, location);
 			
@@ -1279,13 +1279,13 @@
 	return retval;
 }
 
-static int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm, float obmat[4][4],
-                        const float ray_start[3], const float ray_normal[3], const float mval[2],
-                        float r_loc[3], float *UNUSED(r_no), int *r_dist, float *r_depth)
+static bool snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm, float obmat[4][4],
+                         const float ray_start[3], const float ray_normal[3], const float mval[2],
+                         float r_loc[3], float *UNUSED(r_no), int *r_dist, float *r_depth)
 {
 	float imat[4][4];
 	float ray_start_local[3], ray_normal_local[3];
-	int retval = 0;
+	bool retval = false;
 
 	invert_m4_m4(imat, obmat);
 
@@ -1342,11 +1342,11 @@
 	return retval;
 }
 
-static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, BMEditMesh *em, float obmat[4][4],
-                           const float ray_start[3], const float ray_normal[3], const float mval[2],
-                           float r_loc[3], float r_no[3], int *r_dist, float *r_depth)
+static bool snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh *dm, BMEditMesh *em, float obmat[4][4],
+                            const float ray_start[3], const float ray_normal[3], const float mval[2],
+                            float r_loc[3], float r_no[3], int *r_dist, float *r_depth)
 {
-	int retval = 0;
+	bool retval = false;
 	int totvert = dm->getNumVerts(dm);
 	int totface = dm->getNumTessFaces(dm);
 
@@ -1514,12 +1514,12 @@
 	return retval;
 } 
 
-static int snapObject(Scene *scene, ARegion *ar, Object *ob, int editobject, float obmat[4][4],
-                      const float ray_start[3], const float ray_normal[3], const float mval[2],
-                      float r_loc[3], float r_no[3], int *r_dist, float *r_depth)
+static bool snapObject(Scene *scene, ARegion *ar, Object *ob, int editobject, float obmat[4][4],
+                       const float ray_start[3], const float ray_normal[3], const float mval[2],
+                       float r_loc[3], float r_no[3], int *r_dist, float *r_depth)
 {
 	ToolSettings *ts = scene->toolsettings;
-	int retval = 0;
+	bool retval = false;
 	
 	if (ob->type == OB_MESH) {
 		BMEditMesh *em;
@@ -1546,12 +1546,12 @@
 	return retval;
 }
 
-static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, const float mval[2],
-                       int *r_dist, float r_loc[3], float r_no[3], SnapMode mode)
+static bool snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, const float mval[2],
+                        int *r_dist, float r_loc[3], float r_no[3], SnapMode mode)
 {
 	Base *base;
 	float depth = (FLT_MAX / 2.0f);  /* use half of flt-max so we can scale up without an exception */
-	int retval = 0;
+	bool retval = false;
 	float ray_start[3], ray_normal[3];
 	
 	ED_view3d_win_to_ray(ar, v3d, mval, ray_start, ray_normal);
@@ -1602,12 +1602,12 @@
 	return retval;
 }
 
-int snapObjectsTransform(TransInfo *t, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode)
+bool snapObjectsTransform(TransInfo *t, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode)
 {
 	return snapObjects(t->scene, t->view, t->ar, t->obedit, mval, r_dist, r_loc, r_no, mode);
 }
 
-int snapObjectsContext(bContext *C, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode)
+bool snapObjectsContext(bContext *C, const float mval[2], int *r_dist, float r_loc[3], float r_no[3], SnapMode mode)
 {
 	ScrArea *sa = CTX_wm_area(C);
 	View3D *v3d = sa->spacedata.first;
@@ -1667,11 +1667,11 @@
 	peel->flag = 0;
 }
 
-static int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[4][4],
-                           const float ray_start[3], const float ray_normal[3], const float UNUSED(mval[2]),
-                           ListBase *depth_peels)
+static bool peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[4][4],
+                            const float ray_start[3], const float ray_normal[3], const float UNUSED(mval[2]),
+                            ListBase *depth_peels)
 {
-	int retval = 0;
+	bool retval = false;
 	int totvert = dm->getNumVerts(dm);
 	int totface = dm->getNumTessFaces(dm);
 	
@@ -1776,10 +1776,11 @@
 	return retval;
 } 
 
-static int peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, ListBase *depth_peels, const float mval[2], SnapMode mode)
+static bool peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit,
+                        ListBase *depth_peels, const float mval[2], SnapMode mode)
 {
 	Base *base;
-	int retval = 0;
+	bool retval = false;
 	float ray_start[3], ray_normal[3];
 	
 	ED_view3d_win_to_ray(ar, v3d, mval, ray_start, ray_normal);
@@ -1798,7 +1799,7 @@
 					if (dob->type == OB_MESH) {
 						BMEditMesh *em;
 						DerivedMesh *dm = NULL;
-						int val;
+						bool val;
 
 						if (dob != obedit) {
 							dm = mesh_get_derived_final(scene, dob, CD_MASK_BAREMESH);
@@ -1822,7 +1823,7 @@
 			}
 			
 			if (ob->type == OB_MESH) {
-				int val = 0;
+				bool val = false;
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list