[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49360] trunk/blender: code cleanup:

Campbell Barton ideasman42 at gmail.com
Sun Jul 29 19:49:14 CEST 2012


Revision: 49360
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49360
Author:   campbellbarton
Date:     2012-07-29 17:49:14 +0000 (Sun, 29 Jul 2012)
Log Message:
-----------
code cleanup:
- building without python works again
- rename maxi/mini to i_max/i_min (so thay are available for function names)
- some minor edits to IK stretch setting (no functional changes).

Modified Paths:
--------------
    trunk/blender/extern/recastnavigation/Recast/Source/RecastContour.cpp
    trunk/blender/extern/recastnavigation/Recast/Source/RecastMesh.cpp
    trunk/blender/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp
    trunk/blender/source/blender/blenkernel/intern/context.c
    trunk/blender/source/blender/bmesh/operators/bmo_utils.c
    trunk/blender/source/blender/editors/uvedit/uvedit_parametrizer.c
    trunk/blender/source/blender/ikplugin/intern/iksolver_plugin.c
    trunk/blender/source/blender/ikplugin/intern/itasc_plugin.cpp
    trunk/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
    trunk/blender/source/gameengine/Ketsji/KX_Light.cpp
    trunk/blender/source/gameengine/Ketsji/KX_RadarSensor.h

Modified: trunk/blender/extern/recastnavigation/Recast/Source/RecastContour.cpp
===================================================================
--- trunk/blender/extern/recastnavigation/Recast/Source/RecastContour.cpp	2012-07-29 16:59:51 UTC (rev 49359)
+++ trunk/blender/extern/recastnavigation/Recast/Source/RecastContour.cpp	2012-07-29 17:49:14 UTC (rev 49360)
@@ -321,7 +321,7 @@
 
 		// Find maximum deviation from the segment.
 		float maxd = 0;
-		int maxi = -1;
+		int i_max = -1;
 		int ci, cinc, endi;
 		
 		// Traverse the segment in lexilogical order so that the
@@ -350,7 +350,7 @@
 				if (d > maxd)
 				{
 					maxd = d;
-					maxi = ci;
+					i_max = ci;
 				}
 				ci = (ci+cinc) % pn;
 			}
@@ -359,7 +359,7 @@
 		
 		// If the max deviation is larger than accepted error,
 		// add new point, else continue to next segment.
-		if (maxi != -1 && maxd > (maxError*maxError))
+		if (i_max != -1 && maxd > (maxError*maxError))
 		{
 			// Add space for the new point.
 			simplified.resize(simplified.size()+4);
@@ -372,10 +372,10 @@
 				simplified[j*4+3] = simplified[(j-1)*4+3];
 			}
 			// Add the point.
-			simplified[(i+1)*4+0] = points[maxi*4+0];
-			simplified[(i+1)*4+1] = points[maxi*4+1];
-			simplified[(i+1)*4+2] = points[maxi*4+2];
-			simplified[(i+1)*4+3] = maxi;
+			simplified[(i+1)*4+0] = points[i_max*4+0];
+			simplified[(i+1)*4+1] = points[i_max*4+1];
+			simplified[(i+1)*4+2] = points[i_max*4+2];
+			simplified[(i+1)*4+3] = i_max;
 		}
 		else
 		{
@@ -399,7 +399,7 @@
 			const int bi = simplified[ii*4+3];
 
 			// Find maximum deviation from the segment.
-			int maxi = -1;
+			int i_max = -1;
 			int ci = (ai+1) % pn;
 
 			// Tessellate only outer edges or edges between areas.
@@ -423,19 +423,19 @@
 					if (bx > ax || (bx == ax && bz > az))
 					{
 						const int n = bi < ai ? (bi+pn - ai) : (bi - ai);
-						maxi = (ai + n/2) % pn;
+						i_max = (ai + n/2) % pn;
 					}
 					else
 					{
 						const int n = bi < ai ? (bi+pn - ai) : (bi - ai);
-						maxi = (ai + (n+1)/2) % pn;
+						i_max = (ai + (n+1)/2) % pn;
 					}
 				}
 			}
 			
 			// If the max deviation is larger than accepted error,
 			// add new point, else continue to next segment.
-			if (maxi != -1)
+			if (i_max != -1)
 			{
 				// Add space for the new point.
 				simplified.resize(simplified.size()+4);
@@ -448,10 +448,10 @@
 					simplified[j*4+3] = simplified[(j-1)*4+3];
 				}
 				// Add the point.
-				simplified[(i+1)*4+0] = points[maxi*4+0];
-				simplified[(i+1)*4+1] = points[maxi*4+1];
-				simplified[(i+1)*4+2] = points[maxi*4+2];
-				simplified[(i+1)*4+3] = maxi;
+				simplified[(i+1)*4+0] = points[i_max*4+0];
+				simplified[(i+1)*4+1] = points[i_max*4+1];
+				simplified[(i+1)*4+2] = points[i_max*4+2];
+				simplified[(i+1)*4+3] = i_max;
 			}
 			else
 			{

Modified: trunk/blender/extern/recastnavigation/Recast/Source/RecastMesh.cpp
===================================================================
--- trunk/blender/extern/recastnavigation/Recast/Source/RecastMesh.cpp	2012-07-29 16:59:51 UTC (rev 49359)
+++ trunk/blender/extern/recastnavigation/Recast/Source/RecastMesh.cpp	2012-07-29 17:49:14 UTC (rev 49360)
@@ -305,7 +305,7 @@
 	while (n > 3)
 	{
 		int minLen = -1;
-		int mini = -1;
+		int i_min = -1;
 		for (int i = 0; i < n; i++)
 		{
 			int i1 = next(i, n);
@@ -321,12 +321,12 @@
 				if (minLen < 0 || len < minLen)
 				{
 					minLen = len;
-					mini = i;
+					i_min = i;
 				}
 			}
 		}
 		
-		if (mini == -1)
+		if (i_min == -1)
 		{
 			// Should not happen.
 /*			printf("mini == -1 ntris=%d n=%d\n", ntris, n);
@@ -338,7 +338,7 @@
 			return -ntris;
 		}
 		
-		int i = mini;
+		int i = i_min;
 		int i1 = next(i, n);
 		int i2 = next(i1, n);
 		

Modified: trunk/blender/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp
===================================================================
--- trunk/blender/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp	2012-07-29 16:59:51 UTC (rev 49359)
+++ trunk/blender/extern/recastnavigation/Recast/Source/RecastMeshDetail.cpp	2012-07-29 17:49:14 UTC (rev 49360)
@@ -579,23 +579,23 @@
 				const float* vb = &edge[b*3];
 				// Find maximum deviation along the segment.
 				float maxd = 0;
-				int maxi = -1;
+				int i_max = -1;
 				for (int m = a+1; m < b; ++m)
 				{
 					float d = distancePtSeg(&edge[m*3],va,vb);
 					if (d > maxd)
 					{
 						maxd = d;
-						maxi = m;
+						i_max = m;
 					}
 				}
 				// If the max deviation is larger than accepted error,
 				// add new point, else continue to next segment.
-				if (maxi != -1 && maxd > rcSqr(sampleMaxError))
+				if (i_max != -1 && maxd > rcSqr(sampleMaxError))
 				{
 					for (int m = nidx; m > k; --m)
 						idx[m] = idx[m-1];
-					idx[k+1] = maxi;
+					idx[k+1] = i_max;
 					nidx++;
 				}
 				else

Modified: trunk/blender/source/blender/blenkernel/intern/context.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/context.c	2012-07-29 16:59:51 UTC (rev 49359)
+++ trunk/blender/source/blender/blenkernel/intern/context.c	2012-07-29 17:49:14 UTC (rev 49360)
@@ -242,6 +242,8 @@
 		if (result.ptr.data)
 			return result.ptr.data;
 	}
+#else
+	(void)C, (void)member;
 #endif
 
 	return fall_through;

Modified: trunk/blender/source/blender/bmesh/operators/bmo_utils.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_utils.c	2012-07-29 16:59:51 UTC (rev 49359)
+++ trunk/blender/source/blender/bmesh/operators/bmo_utils.c	2012-07-29 17:49:14 UTC (rev 49360)
@@ -304,7 +304,7 @@
 	BLI_array_declare(fstack);
 	BMLoop *l, *l2;
 	float maxx, maxx_test, cent[3];
-	int i, maxi, flagflip = BMO_slot_bool_get(op, "do_flip");
+	int i, i_max, flagflip = BMO_slot_bool_get(op, "do_flip");
 
 	startf = NULL;
 	maxx = -1.0e10;
@@ -353,7 +353,7 @@
 	BMO_elem_flag_enable(bm, startf, FACE_VIS);
 
 	i = 0;
-	maxi = 1;
+	i_max = 1;
 	while (i >= 0) {
 		f = fstack[i];
 		i--;
@@ -381,9 +381,9 @@
 						}
 					}
 					
-					if (i == maxi) {
+					if (i == i_max) {
 						BLI_array_grow_one(fstack);
-						maxi++;
+						i_max++;
 					}
 
 					fstack[i] = l2->f;

Modified: trunk/blender/source/blender/editors/uvedit/uvedit_parametrizer.c
===================================================================
--- trunk/blender/source/blender/editors/uvedit/uvedit_parametrizer.c	2012-07-29 16:59:51 UTC (rev 49359)
+++ trunk/blender/source/blender/editors/uvedit/uvedit_parametrizer.c	2012-07-29 17:49:14 UTC (rev 49360)
@@ -3469,7 +3469,7 @@
 
 	float rotated, minarea, minangle, area, len;
 	float *angles, miny, maxy, v[2], a[4], mina;
-	int npoints, right, mini, maxi, i, idx[4], nextidx;
+	int npoints, right, i_min, i_max, i, idx[4], nextidx;
 	PVert **points, *p1, *p2, *p3, *p4, *p1n;
 
 	/* compute convex hull */
@@ -3479,7 +3479,7 @@
 	/* find left/top/right/bottom points, and compute angle for each point */
 	angles = MEM_mallocN(sizeof(float) * npoints, "PMinAreaAngles");
 
-	mini = maxi = 0;
+	i_min = i_max = 0;
 	miny = 1e10;
 	maxy = -1e10;
 
@@ -3492,19 +3492,19 @@
 
 		if (points[i]->uv[1] < miny) {
 			miny = points[i]->uv[1];
-			mini = i;
+			i_min = i;
 		}
 		if (points[i]->uv[1] > maxy) {
 			maxy = points[i]->uv[1];
-			maxi = i;
+			i_max = i;
 		}
 	}
 
 	/* left, top, right, bottom */
 	idx[0] = 0;
-	idx[1] = maxi;
+	idx[1] = i_max;
 	idx[2] = right;
-	idx[3] = mini;
+	idx[3] = i_min;
 
 	v[0] = points[idx[0]]->uv[0];
 	v[1] = points[idx[0]]->uv[1] + 1.0f;
@@ -3530,29 +3530,29 @@
 
 	while (rotated <= (float)(M_PI / 2.0)) { /* INVESTIGATE: how far to rotate? */
 		/* rotate with the smallest angle */
-		mini = 0;
+		i_min = 0;
 		mina = 1e10;
 
 		for (i = 0; i < 4; i++)
 			if (a[i] < mina) {
 				mina = a[i];
-				mini = i;
+				i_min = i;
 			}
 
 		rotated += mina;
-		nextidx = (idx[mini] + 1) % npoints;
+		nextidx = (idx[i_min] + 1) % npoints;
 
-		a[mini] = angles[nextidx];
-		a[(mini + 1) % 4] = a[(mini + 1) % 4] - mina;
-		a[(mini + 2) % 4] = a[(mini + 2) % 4] - mina;
-		a[(mini + 3) % 4] = a[(mini + 3) % 4] - mina;
+		a[i_min] = angles[nextidx];
+		a[(i_min + 1) % 4] = a[(i_min + 1) % 4] - mina;
+		a[(i_min + 2) % 4] = a[(i_min + 2) % 4] - mina;
+		a[(i_min + 3) % 4] = a[(i_min + 3) % 4] - mina;
 
 		/* compute area */
-		p1 = points[idx[mini]];
+		p1 = points[idx[i_min]];
 		p1n = points[nextidx];
-		p2 = points[idx[(mini + 1) % 4]];
-		p3 = points[idx[(mini + 2) % 4]];
-		p4 = points[idx[(mini + 3) % 4]];
+		p2 = points[idx[(i_min + 1) % 4]];
+		p3 = points[idx[(i_min + 2) % 4]];
+		p4 = points[idx[(i_min + 3) % 4]];
 
 		len = len_v2v2(p1->uv, p1n->uv);
 
@@ -3570,7 +3570,7 @@
 			}
 		}
 
-		idx[mini] = nextidx;
+		idx[i_min] = nextidx;
 	}
 
 	/* try keeping rotation as small as possible */

Modified: trunk/blender/source/blender/ikplugin/intern/iksolver_plugin.c
===================================================================
--- trunk/blender/source/blender/ikplugin/intern/iksolver_plugin.c	2012-07-29 16:59:51 UTC (rev 49359)
+++ trunk/blender/source/blender/ikplugin/intern/iksolver_plugin.c	2012-07-29 17:49:14 UTC (rev 49360)
@@ -334,7 +334,8 @@
 		IK_SetStiffness(seg, IK_Z, pchan->stiffness[2]);
 
 		if (tree->stretch && (pchan->ikstretch > 0.0f)) {
-			double ikstretch = (double)pchan->ikstretch * (double)pchan->ikstretch;
+			const float ikstretch = pchan->ikstretch * pchan->ikstretch;
+			/* this function does its own clamping */
 			IK_SetStiffness(seg, IK_TRANS_Y, 1.0f - ikstretch);
 			IK_SetLimit(seg, IK_TRANS_Y, IK_STRETCH_STIFF_MIN, IK_STRETCH_STIFF_MAX);
 		}

Modified: trunk/blender/source/blender/ikplugin/intern/itasc_plugin.cpp
===================================================================
--- trunk/blender/source/blender/ikplugin/intern/itasc_plugin.cpp	2012-07-29 16:59:51 UTC (rev 49359)
+++ trunk/blender/source/blender/ikplugin/intern/itasc_plugin.cpp	2012-07-29 17:49:14 UTC (rev 49360)
@@ -1254,8 +1254,9 @@
 			joint = bone->name;
 			joint += ":TY";
 			ret = arm->addSegment(joint, parent, KDL::Joint::TransY, rot[ikchan->ndof - 1]);
-			float ikstretch = pchan->ikstretch * pchan->ikstretch;
-			weight[1] = (1.0 - minf(1.0 - ikstretch, 0.99));
+			const float ikstretch = pchan->ikstretch * pchan->ikstretch;
+			/* why invert twice here? */
+			weight[1] = (1.0 - minf(1.0 - ikstretch, 1.0f - IK_STRETCH_STIFF_EPS));
 			weights.push_back(weight[1]);
 		}
 		if (!ret)

Modified: trunk/blender/source/gameengine/Converter/KX_BlenderSceneConverter.cpp

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list