[ODE] Src Patches.

gl gl at ntlworld.com
Sat Aug 23 15:37:01 2003


This is a multi-part message in MIME format.

------=_NextPart_000_2220_01C369CD.A17BC080
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit


Attached two little patches that wrap some floating point values in REAL()
to avoid run-time conversions and build warnings under single float:

Hopefully someone can commit them.  BTW, I'm new to this patching stuff (I
used the excellent TortoiseCVS to do them) - let me know if there are any
problems.
--
gl

------=_NextPart_000_2220_01C369CD.A17BC080
Content-Type: application/octet-stream;
	name="collision_trimesh_sphere.cpp.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="collision_trimesh_sphere.cpp.patch"

Index: ode/src/collision_trimesh_sphere.cpp
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/opende/ode/ode/src/collision_trimesh_sphere.cpp,v
retrieving revision 1.2
diff -u -r1.2 collision_trimesh_sphere.cpp
--- ode/src/collision_trimesh_sphere.cpp	4 Jul 2003 23:15:51 -0000	1.2
+++ ode/src/collision_trimesh_sphere.cpp	23 Aug 2003 22:15:47 -0000
@@ -50,20 +50,20 @@
=20
 	float C =3D dDOT(Diff, Diff);
=20
-	float Det =3D fabs(A00 * A11 - A01 * A01);
+	float Det =3D dFabs(A00 * A11 - A01 * A01);
 	u =3D A01 * B1 - A11 * B0;
 	v =3D A01 * B0 - A00 * B1;
=20
 	float DistSq;
=20
 	if (u + v <=3D Det){
-		if(u < 0.0){
-			if(v < 0.0){  // region 4
-				if(B0 < 0.0){
-					v =3D 0.0;
+		if(u < REAL(0.0)){
+			if(v < REAL(0.0)){  // region 4
+				if(B0 < REAL(0.0)){
+					v =3D REAL(0.0);
 					if (-B0 >=3D A00){
-						u =3D 1.0;
-						DistSq =3D A00 + 2.0 * B0 + C;
+						u =3D REAL(1.0);
+						DistSq =3D A00 + REAL(2.0) * B0 + C;
 					}
 					else{
 						u =3D -B0 / A00;
@@ -71,14 +71,14 @@
 					}
 				}
 				else{
-					u =3D 0.0;
-					if(B1 >=3D 0.0){
-						v =3D 0.0;
+					u =3D REAL(0.0);
+					if(B1 >=3D REAL(0.0)){
+						v =3D REAL(0.0);
 						DistSq =3D C;
 					}
 					else if(-B1 >=3D A11){
-						v =3D 1.0;
-						DistSq =3D A11 + 2.0 * B1 + C;
+						v =3D REAL(1.0);
+						DistSq =3D A11 + REAL(2.0) * B1 + C;
 					}
 					else{
 						v =3D -B1 / A11;
@@ -87,14 +87,14 @@
 				}
 			}
 			else{  // region 3
-				u =3D 0.0;
-				if(B1 >=3D 0.0){
-					v =3D 0.0;
+				u =3D REAL(0.0);
+				if(B1 >=3D REAL(0.0)){
+					v =3D REAL(0.0);
 					DistSq =3D C;
 				}
 				else if(-B1 >=3D A11){
-					v =3D 1.0;
-					DistSq =3D A11 + 2.0 * B1 + C;
+					v =3D REAL(1.0);
+					DistSq =3D A11 + REAL(2.0) * B1 + C;
 				}
 				else{
 					v =3D -B1 / A11;
@@ -102,15 +102,15 @@
 				}
 			}
 		}
-		else if(v < 0.0f){  // region 5
-			v =3D 0.0;
-			if (B0 >=3D 0.0){
-				u =3D 0.0;
+		else if(v < REAL(0.0)){  // region 5
+			v =3D REAL(0.0);
+			if (B0 >=3D REAL(0.0)){
+				u =3D REAL(0.0);
 				DistSq =3D C;
 			}
 			else if (-B0 >=3D A00){
-				u =3D 1.0;
-				DistSq =3D A00 + 2.0 * B0 + C;
+				u =3D REAL(1.0);
+				DistSq =3D A00 + REAL(2.0) * B0 + C;
 			}
 			else{
 				u =3D -B0 / A00;
@@ -119,47 +119,47 @@
 		}
 		else{  // region 0
 			// minimum at interior point
-			if (Det =3D=3D 0.0){
-				u =3D 0.0;
-				v =3D 0.0;
+			if (Det =3D=3D REAL(0.0)){
+				u =3D REAL(0.0);
+				v =3D REAL(0.0);
 				DistSq =3D dInfinity;
 			}
 			else{
-				float InvDet =3D 1.0 / Det;
+				float InvDet =3D REAL(1.0) / Det;
 				u *=3D InvDet;
 				v *=3D InvDet;
-				DistSq =3D u * (A00 * u + A01 * v + 2.0 * B0) + v * (A01 * u + A11 =
* v + 2.0 * B1) + C;
+				DistSq =3D u * (A00 * u + A01 * v + REAL(2.0) * B0) + v * (A01 * u =
+ A11 * v + REAL(2.0) * B1) + C;
 			}
 		}
 	}
 	else{
 		float Tmp0, Tmp1, Numer, Denom;
=20
-		if(u < 0.0){  // region 2
+		if(u < REAL(0.0)){  // region 2
 			Tmp0 =3D A01 + B0;
 			Tmp1 =3D A11 + B1;
 			if (Tmp1 > Tmp0){
 				Numer =3D Tmp1 - Tmp0;
-				Denom =3D A00 - 2.0 * A01 + A11;
+				Denom =3D A00 - REAL(2.0) * A01 + A11;
 				if (Numer >=3D Denom){
-					u =3D 1.0;
-					v =3D 0.0;
-					DistSq =3D A00 + 2.0 * B0 + C;
+					u =3D REAL(1.0);
+					v =3D REAL(0.0);
+					DistSq =3D A00 + REAL(2.0) * B0 + C;
 				}
 				else{
 					u =3D Numer / Denom;
-					v =3D 1.0 - u;
-					DistSq =3D u * (A00 * u + A01 * v + 2.0 * B0) + v * (A01 * u + A11 =
* v + 2.0 * B1) + C;
+					v =3D REAL(1.0) - u;
+					DistSq =3D u * (A00 * u + A01 * v + REAL(2.0) * B0) + v * (A01 * u =
+ A11 * v + REAL(2.0) * B1) + C;
 				}
 			}
 			else{
-				u =3D 0.0;
-				if(Tmp1 <=3D 0.0){
-					v =3D 1.0;
-					DistSq =3D A11 + 2.0 * B1 + C;
+				u =3D REAL(0.0);
+				if(Tmp1 <=3D REAL(0.0)){
+					v =3D REAL(1.0);
+					DistSq =3D A11 + REAL(2.0) * B1 + C;
 				}
-				else if(B1 >=3D 0.0){
-					v =3D 0.0;
+				else if(B1 >=3D REAL(0.0)){
+					v =3D REAL(0.0);
 					DistSq =3D C;
 				}
 				else{
@@ -168,31 +168,31 @@
 				}
 			}
 		}
-		else if(v < 0.0){  // region 6
+		else if(v < REAL(0.0)){  // region 6
 			Tmp0 =3D A01 + B1;
 			Tmp1 =3D A00 + B0;
 			if (Tmp1 > Tmp0){
 				Numer =3D Tmp1 - Tmp0;
-				Denom =3D A00 - 2.0 * A01 + A11;
+				Denom =3D A00 - REAL(2.0) * A01 + A11;
 				if (Numer >=3D Denom){
-					v =3D 1.0;
-					u =3D 0.0;
-					DistSq =3D A11 + 2.0 * B1 + C;
+					v =3D REAL(1.0);
+					u =3D REAL(0.0);
+					DistSq =3D A11 + REAL(2.0) * B1 + C;
 				}
 				else{
 					v =3D Numer / Denom;
-					u =3D 1.0 - v;
-					DistSq =3D  u * (A00 * u + A01 * v + 2.0 * B0) + v * (A01 * u + =
A11 * v + 2.0 * B1) + C;
+					u =3D REAL(1.0) - v;
+					DistSq =3D  u * (A00 * u + A01 * v + REAL(2.0) * B0) + v * (A01 * =
u + A11 * v + REAL(2.0) * B1) + C;
 				}
 			}
 			else{
-				v =3D 0.0;
-				if (Tmp1 <=3D 0.0){
-					u =3D 1.0;
-					DistSq =3D A00 + 2.0 * B0 + C;
+				v =3D REAL(0.0);
+				if (Tmp1 <=3D REAL(0.0)){
+					u =3D REAL(1.0);
+					DistSq =3D A00 + REAL(2.0) * B0 + C;
 				}
-				else if(B0 >=3D 0.0){
-					u =3D 0.0;
+				else if(B0 >=3D REAL(0.0)){
+					u =3D REAL(0.0);
 					DistSq =3D C;
 				}
 				else{
@@ -203,22 +203,22 @@
 		}
 		else{  // region 1
 			Numer =3D A11 + B1 - A01 - B0;
-			if (Numer <=3D 0.0){
-				u =3D 0.0;
-				v =3D 1.0;
-				DistSq =3D A11 + 2.0 * B1 + C;
+			if (Numer <=3D REAL(0.0)){
+				u =3D REAL(0.0);
+				v =3D REAL(1.0);
+				DistSq =3D A11 + REAL(2.0) * B1 + C;
 			}
 			else{
-				Denom =3D A00 - 2.0 * A01 + A11;
+				Denom =3D A00 - REAL(2.0) * A01 + A11;
 				if (Numer >=3D Denom){
-					u =3D 1.0;
-					v =3D 0.0;
-					DistSq =3D A00 + 2.0 * B0 + C;
+					u =3D REAL(1.0);
+					v =3D REAL(0.0);
+					DistSq =3D A00 + REAL(2.0) * B0 + C;
 				}
 				else{
 					u =3D Numer / Denom;
-					v =3D 1.0 - u;
-					DistSq =3D u * (A00 * u + A01 * v + 2.0 * B0) + v * (A01 * u + A11 =
* v + 2.0 * B1) + C;
+					v =3D REAL(1.0) - u;
+					DistSq =3D u * (A00 * u + A01 * v + REAL(2.0) * B0) + v * (A01 * u =
+ A11 * v + REAL(2.0) * B1) + C;
 				}
 			}
 		}
@@ -296,23 +296,23 @@
 			vu[0] =3D v1[0] - v0[0];
 			vu[1] =3D v1[1] - v0[1];
 			vu[2] =3D v1[2] - v0[2];
-			vu[3] =3D 0.0;
+			vu[3] =3D REAL(0.0);
=20
 			dVector3 vv;
 			vv[0] =3D v2[0] - v0[0];
 			vv[1] =3D v2[1] - v0[1];
 			vv[2] =3D v2[2] - v0[2];
-			vv[3] =3D 0.0;
+			vv[3] =3D REAL(0.0);
=20
 			dReal Depth;
 			float u, v;
 			if (!GetContactData(Position, Radius, v0, vu, vv, Depth, u, v)){
 				continue;	// Sphere doesnt hit triangle
 			}
-			dReal w =3D 1.0 - u - v;
+			dReal w =3D REAL(1.0) - u - v;
=20
-			if (Depth < 0.0f){
-				Depth =3D 0.0f;
+			if (Depth < REAL(0.0)){
+				Depth =3D REAL(0.0);
 			}
=20
 			dContactGeom* Contact =3D SAFECONTACT(Flags, Contacts, OutTriCount, =
Stride);

------=_NextPart_000_2220_01C369CD.A17BC080
Content-Type: application/octet-stream;
	name="collision_std.cpp.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="collision_std.cpp.patch"

Index: ode/src/collision_std.cpp
===================================================================
RCS file: /cvsroot/opende/ode/ode/src/collision_std.cpp,v
retrieving revision 1.11
diff -u -r1.11 collision_std.cpp
--- ode/src/collision_std.cpp	11 Aug 2003 05:55:02 -0000	1.11
+++ ode/src/collision_std.cpp	23 Aug 2003 22:16:25 -0000
@@ -201,9 +201,9 @@
   p[1] = y - b->pos[1];
   p[2] = z - b->pos[2];
   dMULTIPLY1_331 (q,b->R,p);
-  dReal dx = b->side[0]*0.5 - dFabs(q[0]);
-  dReal dy = b->side[1]*0.5 - dFabs(q[1]);
-  dReal dz = b->side[2]*0.5 - dFabs(q[2]);
+  dReal dx = b->side[0]*REAL(0.5) - dFabs(q[0]);
+  dReal dy = b->side[1]*REAL(0.5) - dFabs(q[1]);
+  dReal dz = b->side[2]*REAL(0.5) - dFabs(q[2]);
   if (dx < dy) {
     if (dx < dz) return dx; else return dz;
   }
@@ -707,7 +707,7 @@
 	     dVector3 normal, dReal *depth, int *return_code,
 	     int maxc, dContactGeom *contact, int skip)
 {
-  const dReal fudge_factor = 1.05;
+  const dReal fudge_factor = REAL(1.05);
   dVector3 p,pp,normalC;
   const dReal *normalR = 0;
   dReal A[3],B[3],R11,R12,R13,R21,R22,R23,R31,R32,R33,

------=_NextPart_000_2220_01C369CD.A17BC080--