File: stk.patch

package info (click to toggle)
supertuxkart 1.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 845,908 kB
  • sloc: cpp: 416,684; ansic: 320,074; xml: 109,671; sh: 2,786; asm: 1,631; python: 1,162; java: 783; objc: 452; makefile: 386; javascript: 23; awk: 20
file content (201 lines) | stat: -rw-r--r-- 6,942 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# This patch adds some assert statements to catch NANs early
# on, and makes some variables in btRaycastVehicle protected.
# To apply, you might have to use patch -l
Index: src/BulletDynamics/Dynamics/btRigidBody.cpp
===================================================================
--- src/BulletDynamics/Dynamics/btRigidBody.cpp	(revision 10122)
+++ src/BulletDynamics/Dynamics/btRigidBody.cpp	(working copy)
@@ -133,6 +133,9 @@
 
 void btRigidBody::setGravity(const btVector3& acceleration) 
 {
+    btAssert(!isnan(acceleration.getX()));
+    btAssert(!isnan(acceleration.getY()));
+    btAssert(!isnan(acceleration.getZ()));
 	if (m_inverseMass != btScalar(0.0))
 	{
 		m_gravity = acceleration * (btScalar(1.0) / m_inverseMass);
@@ -147,6 +150,8 @@
 
 void btRigidBody::setDamping(btScalar lin_damping, btScalar ang_damping)
 {
+    btAssert(!isnan(lin_damping));
+    btAssert(!isnan(ang_damping));
 	m_linearDamping = btClamped(lin_damping, (btScalar)btScalar(0.0), (btScalar)btScalar(1.0));
 	m_angularDamping = btClamped(ang_damping, (btScalar)btScalar(0.0), (btScalar)btScalar(1.0));
 }
@@ -285,6 +290,13 @@
 	
 void btRigidBody::setCenterOfMassTransform(const btTransform& xform)
 {
+    btAssert(!isnan(xform.getOrigin().getX()));
+    btAssert(!isnan(xform.getOrigin().getY()));
+    btAssert(!isnan(xform.getOrigin().getZ()));
+    btAssert(!isnan(xform.getRotation().getX()));
+    btAssert(!isnan(xform.getRotation().getY()));
+    btAssert(!isnan(xform.getRotation().getZ()));
+    btAssert(!isnan(xform.getRotation().getW()));
 
 	if (isStaticOrKinematicObject())
 	{
Index: src/BulletDynamics/Dynamics/btRigidBody.h
===================================================================
--- src/BulletDynamics/Dynamics/btRigidBody.h	(revision 10122)
+++ src/BulletDynamics/Dynamics/btRigidBody.h	(working copy)
@@ -21,6 +21,11 @@
 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
 #include "BulletCollision/CollisionDispatch/btCollisionObject.h"
 
+#if defined(WIN32) && !defined(__CYGWIN__)
+#  define isnan _isnan
+#endif
+#include <math.h>
+
 class btCollisionShape;
 class btMotionState;
 class btTypedConstraint;
@@ -253,6 +258,9 @@
 	}
 	void setLinearFactor(const btVector3& linearFactor)
 	{
+        btAssert(!isnan(linearFactor.getX()));
+        btAssert(!isnan(linearFactor.getY()));
+        btAssert(!isnan(linearFactor.getZ()));
 		m_linearFactor = linearFactor;
 		m_invMass = m_linearFactor*m_inverseMass;
 	}
@@ -267,6 +275,9 @@
 
 	void			applyCentralForce(const btVector3& force)
 	{
+        btAssert(!isnan(force.getX()));
+        btAssert(!isnan(force.getY()));
+        btAssert(!isnan(force.getZ()));
 		m_totalForce += force*m_linearFactor;
 	}
 
@@ -303,22 +314,40 @@
 	
 	void	applyForce(const btVector3& force, const btVector3& rel_pos) 
 	{
+        btAssert(!isnan(force.getX()));
+        btAssert(!isnan(force.getY()));
+        btAssert(!isnan(force.getZ()));
+        btAssert(!isnan(rel_pos.getX()));
+        btAssert(!isnan(rel_pos.getY()));
+        btAssert(!isnan(rel_pos.getZ()));
 		applyCentralForce(force);
 		applyTorque(rel_pos.cross(force*m_linearFactor));
 	}
 	
 	void applyCentralImpulse(const btVector3& impulse)
 	{
+        btAssert(!isnan(impulse.getX()));
+        btAssert(!isnan(impulse.getY()));
+        btAssert(!isnan(impulse.getZ()));
 		m_linearVelocity += impulse *m_linearFactor * m_inverseMass;
 	}
 	
   	void applyTorqueImpulse(const btVector3& torque)
 	{
+            btAssert(!isnan(torque.getX()));
+            btAssert(!isnan(torque.getY()));
+            btAssert(!isnan(torque.getZ()));
 			m_angularVelocity += m_invInertiaTensorWorld * torque * m_angularFactor;
 	}
 	
 	void applyImpulse(const btVector3& impulse, const btVector3& rel_pos) 
 	{
+        btAssert(!isnan(impulse.getX()));
+        btAssert(!isnan(impulse.getY()));
+        btAssert(!isnan(impulse.getZ()));
+        btAssert(!isnan(rel_pos.getX()));
+        btAssert(!isnan(rel_pos.getY()));
+        btAssert(!isnan(rel_pos.getZ()));
 		if (m_inverseMass != btScalar(0.))
 		{
 			applyCentralImpulse(impulse);
@@ -355,11 +384,17 @@
 
 	inline void setLinearVelocity(const btVector3& lin_vel)
 	{ 
+        btAssert(!isnan(lin_vel.getX()));
+        btAssert(!isnan(lin_vel.getY()));
+        btAssert(!isnan(lin_vel.getZ()));
 		m_linearVelocity = lin_vel; 
 	}
 
 	inline void setAngularVelocity(const btVector3& ang_vel) 
 	{ 
+        btAssert(!isnan(ang_vel.getX()));
+        btAssert(!isnan(ang_vel.getY()));
+        btAssert(!isnan(ang_vel.getZ()));
 		m_angularVelocity = ang_vel; 
 	}
 
Index: src/BulletCollision/CollisionShapes/btCollisionShape.cpp
===================================================================
--- src/BulletCollision/CollisionShapes/btCollisionShape.cpp	(revision 10122)
+++ src/BulletCollision/CollisionShapes/btCollisionShape.cpp	(working copy)
@@ -116,4 +116,4 @@
 	btChunk* chunk = serializer->allocate(len,1);
 	const char* structType = serialize(chunk->m_oldPtr, serializer);
 	serializer->finalizeChunk(chunk,structType,BT_SHAPE_CODE,(void*)this);
-}
\ No newline at end of file
+}
Index: src/BulletCollision/CollisionDispatch/btCollisionObject.h
===================================================================
--- src/BulletCollision/CollisionDispatch/btCollisionObject.h	(revision 10122)
+++ src/BulletCollision/CollisionDispatch/btCollisionObject.h	(working copy)
@@ -16,6 +16,13 @@
 #ifndef BT_COLLISION_OBJECT_H
 #define BT_COLLISION_OBJECT_H
 
+#if defined(WIN32) && !defined(__CYGWIN__)
+#  define isnan _isnan
+#  define isinf(x) (!_finite(x))
+#else
+#  include <math.h>
+#endif
+
 #include "LinearMath/btTransform.h"
 
 //island management, m_activationState1
@@ -294,6 +301,12 @@
 
 	void	setWorldTransform(const btTransform& worldTrans)
 	{
+        btAssert(!isnan(worldTrans.getOrigin().getX()));
+        btAssert(!isnan(worldTrans.getOrigin().getY()));
+        btAssert(!isnan(worldTrans.getOrigin().getZ()));
+        btAssert(!isinf(worldTrans.getOrigin().getX()));
+        btAssert(!isinf(worldTrans.getOrigin().getY()));
+        btAssert(!isinf(worldTrans.getOrigin().getZ()));
 		m_worldTransform = worldTrans;
 	}

Index: src/BulletDynamics/Vehicle/btRaycastVehicle.
===================================================================
--- src/BulletDynamics/Vehicle/btRaycastVehicle.h
+++ src/BulletDynamics/Vehicle/btRaycastVehicle.h 
@@ -24,7 +24,7 @@
 ///rayCast vehicle, very special constraint that turn a rigidbody into a vehicle.
 class btRaycastVehicle : public btActionInterface
 {
-
+protected:
                btAlignedObjectArray<btVector3> m_forwardWS;
                btAlignedObjectArray<btVector3> m_axle;
                btAlignedObjectArray<btScalar>  m_forwardImpulse;
@@ -56,7 +56,7 @@
                        btScalar        m_maxSuspensionForce;
 
                };
-private:
+protected:
 
        btScalar        m_tau;
        btScalar        m_damping;