aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ModifiedBulletX/ModifiedBulletX/Dynamics/Vehicle/WheelInfo.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/ModifiedBulletX/ModifiedBulletX/Dynamics/Vehicle/WheelInfo.cs1058
1 files changed, 529 insertions, 529 deletions
diff --git a/libraries/ModifiedBulletX/ModifiedBulletX/Dynamics/Vehicle/WheelInfo.cs b/libraries/ModifiedBulletX/ModifiedBulletX/Dynamics/Vehicle/WheelInfo.cs
index d4a94f3..516e455 100644
--- a/libraries/ModifiedBulletX/ModifiedBulletX/Dynamics/Vehicle/WheelInfo.cs
+++ b/libraries/ModifiedBulletX/ModifiedBulletX/Dynamics/Vehicle/WheelInfo.cs
@@ -1,529 +1,529 @@
1/* 1/*
2 Bullet for XNA Copyright (c) 2003-2007 Vsevolod Klementjev http://www.codeplex.com/xnadevru 2 Bullet for XNA Copyright (c) 2003-2007 Vsevolod Klementjev http://www.codeplex.com/xnadevru
3 Bullet original C++ version Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com 3 Bullet original C++ version Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com
4 4
5 This software is provided 'as-is', without any express or implied 5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages 6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software. 7 arising from the use of this software.
8 8
9 Permission is granted to anyone to use this software for any purpose, 9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it 10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions: 11 freely, subject to the following restrictions:
12 12
13 1. The origin of this software must not be misrepresented; you must not 13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software 14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be 15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required. 16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be 17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software. 18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution. 19 3. This notice may not be removed or altered from any source distribution.
20*/ 20*/
21 21
22using System; 22using System;
23using System.Collections.Generic; 23using System.Collections.Generic;
24using System.Text; 24using System.Text;
25using MonoXnaCompactMaths; 25using MonoXnaCompactMaths;
26 26
27namespace XnaDevRu.BulletX.Dynamics 27namespace XnaDevRu.BulletX.Dynamics
28{ 28{
29 public struct WheelInfoConstructionInfo 29 public struct WheelInfoConstructionInfo
30 { 30 {
31 private Vector3 _chassicConnectionCS; 31 private Vector3 _chassicConnectionCS;
32 private Vector3 _wheelDirectionCS; 32 private Vector3 _wheelDirectionCS;
33 private Vector3 _wheelAxisCS; 33 private Vector3 _wheelAxisCS;
34 34
35 private Single _suspensionRestLength; 35 private Single _suspensionRestLength;
36 private Single _maxSuspensionTravelCm; 36 private Single _maxSuspensionTravelCm;
37 private Single _wheelRadius; 37 private Single _wheelRadius;
38 private Single _suspensionStiffness; 38 private Single _suspensionStiffness;
39 private Single _wheelsDampingCompression; 39 private Single _wheelsDampingCompression;
40 private Single _wheelsDampingRelaxation; 40 private Single _wheelsDampingRelaxation;
41 private Single _frictionSlip; 41 private Single _frictionSlip;
42 42
43 private Boolean _isFrontWheel; 43 private Boolean _isFrontWheel;
44 44
45 #region Basic Properties 45 #region Basic Properties
46 public Vector3 ChassicConnectionCS 46 public Vector3 ChassicConnectionCS
47 { 47 {
48 get { return _chassicConnectionCS; } 48 get { return _chassicConnectionCS; }
49 set { _chassicConnectionCS = value; } 49 set { _chassicConnectionCS = value; }
50 } 50 }
51 51
52 public Vector3 WheelDirectionCS 52 public Vector3 WheelDirectionCS
53 { 53 {
54 get { return _wheelDirectionCS; } 54 get { return _wheelDirectionCS; }
55 set { _wheelDirectionCS = value; } 55 set { _wheelDirectionCS = value; }
56 } 56 }
57 57
58 public Vector3 WheelAxleCS 58 public Vector3 WheelAxleCS
59 { 59 {
60 get { return _wheelAxisCS; } 60 get { return _wheelAxisCS; }
61 set { _wheelAxisCS = value; } 61 set { _wheelAxisCS = value; }
62 } 62 }
63 63
64 64
65 public Single SuspensionRestLength 65 public Single SuspensionRestLength
66 { 66 {
67 get { return _suspensionRestLength; } 67 get { return _suspensionRestLength; }
68 set { _suspensionRestLength = value; } 68 set { _suspensionRestLength = value; }
69 } 69 }
70 70
71 public Single MaxSuspensionTravelCm 71 public Single MaxSuspensionTravelCm
72 { 72 {
73 get { return _maxSuspensionTravelCm; } 73 get { return _maxSuspensionTravelCm; }
74 set { _maxSuspensionTravelCm = value; } 74 set { _maxSuspensionTravelCm = value; }
75 } 75 }
76 76
77 public Single WheelRadius 77 public Single WheelRadius
78 { 78 {
79 get { return _wheelRadius; } 79 get { return _wheelRadius; }
80 set { _wheelRadius = value; } 80 set { _wheelRadius = value; }
81 } 81 }
82 82
83 83
84 public Single SuspensionStiffness 84 public Single SuspensionStiffness
85 { 85 {
86 get { return _suspensionStiffness; } 86 get { return _suspensionStiffness; }
87 set { _suspensionStiffness = value; } 87 set { _suspensionStiffness = value; }
88 } 88 }
89 89
90 public Single WheelsDampingCompression 90 public Single WheelsDampingCompression
91 { 91 {
92 get { return _wheelsDampingCompression; } 92 get { return _wheelsDampingCompression; }
93 set { _wheelsDampingCompression = value; } 93 set { _wheelsDampingCompression = value; }
94 } 94 }
95 95
96 public Single WheelsDampingRelaxation 96 public Single WheelsDampingRelaxation
97 { 97 {
98 get { return _wheelsDampingRelaxation; } 98 get { return _wheelsDampingRelaxation; }
99 set { _wheelsDampingRelaxation = value; } 99 set { _wheelsDampingRelaxation = value; }
100 } 100 }
101 101
102 public Single FrictionSlip 102 public Single FrictionSlip
103 { 103 {
104 get { return _frictionSlip; } 104 get { return _frictionSlip; }
105 set { _frictionSlip = value; } 105 set { _frictionSlip = value; }
106 } 106 }
107 107
108 108
109 public Boolean IsFrontWheel 109 public Boolean IsFrontWheel
110 { 110 {
111 get { return _isFrontWheel; } 111 get { return _isFrontWheel; }
112 set { _isFrontWheel = value; } 112 set { _isFrontWheel = value; }
113 } 113 }
114 #endregion 114 #endregion
115 } 115 }
116 116
117 public struct RaycastInfo 117 public struct RaycastInfo
118 { 118 {
119 private Vector3 _contractNormalWS; 119 private Vector3 _contractNormalWS;
120 private Vector3 _contractPointWS; 120 private Vector3 _contractPointWS;
121 121
122 private Vector3 _hardPointWS; 122 private Vector3 _hardPointWS;
123 private Vector3 _wheelDirectionWS; 123 private Vector3 _wheelDirectionWS;
124 private Vector3 _wheelAxleWS; 124 private Vector3 _wheelAxleWS;
125 125
126 private Single _suspensionLength; 126 private Single _suspensionLength;
127 private Boolean _isInContract; 127 private Boolean _isInContract;
128 128
129 #region Basic Properties 129 #region Basic Properties
130 public Single SuspensionLength 130 public Single SuspensionLength
131 { 131 {
132 get { return _suspensionLength; } 132 get { return _suspensionLength; }
133 set { _suspensionLength = value; } 133 set { _suspensionLength = value; }
134 } 134 }
135 135
136 public Boolean IsInContact 136 public Boolean IsInContact
137 { 137 {
138 get { return _isInContract; } 138 get { return _isInContract; }
139 set { _isInContract = value; } 139 set { _isInContract = value; }
140 } 140 }
141 141
142 public Vector3 ContactNormalWS 142 public Vector3 ContactNormalWS
143 { 143 {
144 get { return _contractNormalWS; } 144 get { return _contractNormalWS; }
145 set { _contractNormalWS = value; } 145 set { _contractNormalWS = value; }
146 } 146 }
147 147
148 public Vector3 ContactPointWS 148 public Vector3 ContactPointWS
149 { 149 {
150 get { return _contractPointWS; } 150 get { return _contractPointWS; }
151 set { _contractPointWS = value; } 151 set { _contractPointWS = value; }
152 } 152 }
153 153
154 public Vector3 HardPointWS 154 public Vector3 HardPointWS
155 { 155 {
156 get { return _hardPointWS; } 156 get { return _hardPointWS; }
157 set { _hardPointWS = value; } 157 set { _hardPointWS = value; }
158 } 158 }
159 159
160 public Vector3 WheelDirectionWS 160 public Vector3 WheelDirectionWS
161 { 161 {
162 get { return _wheelDirectionWS; } 162 get { return _wheelDirectionWS; }
163 set { _wheelDirectionWS = value; } 163 set { _wheelDirectionWS = value; }
164 } 164 }
165 165
166 public Vector3 WheelAxleWS 166 public Vector3 WheelAxleWS
167 { 167 {
168 get { return _wheelAxleWS; } 168 get { return _wheelAxleWS; }
169 set { _wheelAxleWS = value; } 169 set { _wheelAxleWS = value; }
170 } 170 }
171 #endregion 171 #endregion
172 } 172 }
173 173
174 public struct WheelInfo 174 public struct WheelInfo
175 { 175 {
176 private RaycastInfo _raycastInfo; 176 private RaycastInfo _raycastInfo;
177 177
178 private Matrix _worldTransform; 178 private Matrix _worldTransform;
179 179
180 private Vector3 _chassicConnectionPointCS; 180 private Vector3 _chassicConnectionPointCS;
181 private Vector3 _wheelDirectionCS; 181 private Vector3 _wheelDirectionCS;
182 private Vector3 _wheelAxleCS; 182 private Vector3 _wheelAxleCS;
183 183
184 private Single _suspensionRestLength; 184 private Single _suspensionRestLength;
185 private Single _maxSuspensionTravelCm; 185 private Single _maxSuspensionTravelCm;
186 186
187 private Single _wheelsRadius; 187 private Single _wheelsRadius;
188 private Single _rollInfluence; 188 private Single _rollInfluence;
189 private Single _suspensionStiffness; 189 private Single _suspensionStiffness;
190 private Single _wheelsDampingCompression; 190 private Single _wheelsDampingCompression;
191 private Single _wheelsDampingRelaxation; 191 private Single _wheelsDampingRelaxation;
192 private Single _frictionSlip; 192 private Single _frictionSlip;
193 private Single _steering; 193 private Single _steering;
194 private Single _rotation; 194 private Single _rotation;
195 private Single _deltaRotation; 195 private Single _deltaRotation;
196 196
197 private Single _engineForce; 197 private Single _engineForce;
198 private Single _brake; 198 private Single _brake;
199 private Boolean _isFrontWheel; 199 private Boolean _isFrontWheel;
200 200
201 201
202 private Single _clippedInvContactDotSuspension; 202 private Single _clippedInvContactDotSuspension;
203 private Single _skidInfo; 203 private Single _skidInfo;
204 private Single _wheelsSuspensionForce; 204 private Single _wheelsSuspensionForce;
205 private Single _suspensionRelativeVelocity; 205 private Single _suspensionRelativeVelocity;
206 //can be used to store pointer to sync transforms... 206 //can be used to store pointer to sync transforms...
207 private object _clientInfo; 207 private object _clientInfo;
208 208
209 #region Constructor 209 #region Constructor
210 public WheelInfo(WheelInfoConstructionInfo constructionInfo) 210 public WheelInfo(WheelInfoConstructionInfo constructionInfo)
211 { 211 {
212 _suspensionRestLength = constructionInfo.SuspensionRestLength; 212 _suspensionRestLength = constructionInfo.SuspensionRestLength;
213 _maxSuspensionTravelCm = constructionInfo.MaxSuspensionTravelCm; 213 _maxSuspensionTravelCm = constructionInfo.MaxSuspensionTravelCm;
214 214
215 _wheelsRadius = constructionInfo.WheelRadius; 215 _wheelsRadius = constructionInfo.WheelRadius;
216 _wheelsDampingCompression = constructionInfo.WheelsDampingCompression; 216 _wheelsDampingCompression = constructionInfo.WheelsDampingCompression;
217 _wheelsDampingRelaxation = constructionInfo.WheelsDampingRelaxation; 217 _wheelsDampingRelaxation = constructionInfo.WheelsDampingRelaxation;
218 _wheelDirectionCS = constructionInfo.WheelDirectionCS; 218 _wheelDirectionCS = constructionInfo.WheelDirectionCS;
219 219
220 _suspensionStiffness = constructionInfo.SuspensionStiffness; 220 _suspensionStiffness = constructionInfo.SuspensionStiffness;
221 _chassicConnectionPointCS = constructionInfo.ChassicConnectionCS; 221 _chassicConnectionPointCS = constructionInfo.ChassicConnectionCS;
222 222
223 _wheelAxleCS = constructionInfo.WheelAxleCS; 223 _wheelAxleCS = constructionInfo.WheelAxleCS;
224 _frictionSlip = constructionInfo.FrictionSlip; 224 _frictionSlip = constructionInfo.FrictionSlip;
225 225
226 _clippedInvContactDotSuspension = 0; 226 _clippedInvContactDotSuspension = 0;
227 _suspensionRelativeVelocity = 0; 227 _suspensionRelativeVelocity = 0;
228 _wheelsSuspensionForce = 0; 228 _wheelsSuspensionForce = 0;
229 _skidInfo = 0; 229 _skidInfo = 0;
230 230
231 _steering = 0; 231 _steering = 0;
232 _engineForce = 0; 232 _engineForce = 0;
233 _rotation = 0; 233 _rotation = 0;
234 _rotation = 0; 234 _rotation = 0;
235 _deltaRotation = 0; 235 _deltaRotation = 0;
236 _brake = 0; 236 _brake = 0;
237 _rollInfluence = 0.1f; 237 _rollInfluence = 0.1f;
238 _brake = 0; 238 _brake = 0;
239 _rollInfluence = 0.1f; 239 _rollInfluence = 0.1f;
240 240
241 _isFrontWheel = constructionInfo.IsFrontWheel; 241 _isFrontWheel = constructionInfo.IsFrontWheel;
242 242
243 _raycastInfo = default(RaycastInfo); 243 _raycastInfo = default(RaycastInfo);
244 _worldTransform = default(Matrix); 244 _worldTransform = default(Matrix);
245 _clientInfo = null; 245 _clientInfo = null;
246 } 246 }
247 #endregion 247 #endregion
248 248
249 #region BasicProperties 249 #region BasicProperties
250 public object ClientInfo { get { return _clientInfo; } set { _clientInfo = value; } } 250 public object ClientInfo { get { return _clientInfo; } set { _clientInfo = value; } }
251 251
252 public RaycastInfo RaycastInfo 252 public RaycastInfo RaycastInfo
253 { 253 {
254 get { return _raycastInfo; } 254 get { return _raycastInfo; }
255 set { _raycastInfo = value; } 255 set { _raycastInfo = value; }
256 } 256 }
257 257
258 public Matrix WorldTransform 258 public Matrix WorldTransform
259 { 259 {
260 get { return _worldTransform; } 260 get { return _worldTransform; }
261 set { _worldTransform = value; } 261 set { _worldTransform = value; }
262 } 262 }
263 263
264 public Vector3 ChassicConnectionPointCS 264 public Vector3 ChassicConnectionPointCS
265 { 265 {
266 get { return _chassicConnectionPointCS; } 266 get { return _chassicConnectionPointCS; }
267 set { _chassicConnectionPointCS = value; } 267 set { _chassicConnectionPointCS = value; }
268 } 268 }
269 public Vector3 WheelDirectionCS 269 public Vector3 WheelDirectionCS
270 { 270 {
271 get { return _wheelDirectionCS; } 271 get { return _wheelDirectionCS; }
272 set { _wheelDirectionCS = value; } 272 set { _wheelDirectionCS = value; }
273 } 273 }
274 public Vector3 WheelAxleCS 274 public Vector3 WheelAxleCS
275 { 275 {
276 get { return _wheelAxleCS; } 276 get { return _wheelAxleCS; }
277 set { _wheelAxleCS = value; } 277 set { _wheelAxleCS = value; }
278 } 278 }
279 279
280 public Single SuspensionRestLength 280 public Single SuspensionRestLength
281 { 281 {
282 get { return _suspensionRestLength; } 282 get { return _suspensionRestLength; }
283 set { _suspensionRestLength = value; } 283 set { _suspensionRestLength = value; }
284 } 284 }
285 285
286 286
287 public Single MaxSuspensionTravelCm 287 public Single MaxSuspensionTravelCm
288 { 288 {
289 get { return _maxSuspensionTravelCm; } 289 get { return _maxSuspensionTravelCm; }
290 set { _maxSuspensionTravelCm = value; } 290 set { _maxSuspensionTravelCm = value; }
291 } 291 }
292 292
293 public Single WheelsRadius 293 public Single WheelsRadius
294 { 294 {
295 get { return _wheelsRadius; } 295 get { return _wheelsRadius; }
296 set { _wheelsRadius = value; } 296 set { _wheelsRadius = value; }
297 } 297 }
298 298
299 public Single SuspensionStiffness 299 public Single SuspensionStiffness
300 { 300 {
301 get { return _suspensionStiffness; } 301 get { return _suspensionStiffness; }
302 set { _suspensionStiffness = value; } 302 set { _suspensionStiffness = value; }
303 } 303 }
304 304
305 public Single WheelsDampingCompression 305 public Single WheelsDampingCompression
306 { 306 {
307 get { return _wheelsDampingCompression; } 307 get { return _wheelsDampingCompression; }
308 set { _wheelsDampingCompression = value; } 308 set { _wheelsDampingCompression = value; }
309 } 309 }
310 310
311 public Single WheelsDampingRelaxation 311 public Single WheelsDampingRelaxation
312 { 312 {
313 get { return _wheelsDampingRelaxation; } 313 get { return _wheelsDampingRelaxation; }
314 set { _wheelsDampingRelaxation = value; } 314 set { _wheelsDampingRelaxation = value; }
315 } 315 }
316 316
317 public Single FrictionSlip 317 public Single FrictionSlip
318 { 318 {
319 get { return _frictionSlip; } 319 get { return _frictionSlip; }
320 set { _frictionSlip = value; } 320 set { _frictionSlip = value; }
321 } 321 }
322 322
323 public Single Steering 323 public Single Steering
324 { 324 {
325 get { return _steering; } 325 get { return _steering; }
326 set { _steering = value; } 326 set { _steering = value; }
327 } 327 }
328 328
329 public Single Rotation 329 public Single Rotation
330 { 330 {
331 get { return _rotation; } 331 get { return _rotation; }
332 set { _rotation = value; } 332 set { _rotation = value; }
333 } 333 }
334 334
335 public Single DeltaRotation 335 public Single DeltaRotation
336 { 336 {
337 get { return _deltaRotation; } 337 get { return _deltaRotation; }
338 set { _deltaRotation = value; } 338 set { _deltaRotation = value; }
339 } 339 }
340 340
341 public Single RollInfluence 341 public Single RollInfluence
342 { 342 {
343 get { return _rollInfluence; } 343 get { return _rollInfluence; }
344 set { _rollInfluence = value; } 344 set { _rollInfluence = value; }
345 } 345 }
346 346
347 public Single EngineForce 347 public Single EngineForce
348 { 348 {
349 get { return _engineForce; } 349 get { return _engineForce; }
350 set { _engineForce = value; } 350 set { _engineForce = value; }
351 } 351 }
352 352
353 public Single Brake 353 public Single Brake
354 { 354 {
355 get { return _brake; } 355 get { return _brake; }
356 set { _brake = value; } 356 set { _brake = value; }
357 } 357 }
358 358
359 public Boolean IsFrontWheel 359 public Boolean IsFrontWheel
360 { 360 {
361 get { return _isFrontWheel; } 361 get { return _isFrontWheel; }
362 set { _isFrontWheel = value; } 362 set { _isFrontWheel = value; }
363 } 363 }
364 364
365 public Single ClippedInvContactDotSuspension 365 public Single ClippedInvContactDotSuspension
366 { 366 {
367 get { return _clippedInvContactDotSuspension; } 367 get { return _clippedInvContactDotSuspension; }
368 set { _clippedInvContactDotSuspension = value; } 368 set { _clippedInvContactDotSuspension = value; }
369 } 369 }
370 370
371 public Single SuspensionRelativeVelocity 371 public Single SuspensionRelativeVelocity
372 { 372 {
373 get { return _suspensionRelativeVelocity; } 373 get { return _suspensionRelativeVelocity; }
374 set { _suspensionRelativeVelocity = value; } 374 set { _suspensionRelativeVelocity = value; }
375 } 375 }
376 376
377 public Single WheelsSuspensionForce 377 public Single WheelsSuspensionForce
378 { 378 {
379 get { return _wheelsSuspensionForce; } 379 get { return _wheelsSuspensionForce; }
380 set { _wheelsSuspensionForce = value; } 380 set { _wheelsSuspensionForce = value; }
381 } 381 }
382 382
383 public Single SkidInfo 383 public Single SkidInfo
384 { 384 {
385 get { return _skidInfo; } 385 get { return _skidInfo; }
386 set { _skidInfo = value; } 386 set { _skidInfo = value; }
387 } 387 }
388 #endregion 388 #endregion
389 389
390 /// <summary> 390 /// <summary>
391 /// 391 ///
392 /// </summary> 392 /// </summary>
393 /// <param name="chassis"></param> 393 /// <param name="chassis"></param>
394 /// <param name="paramRaycastInfo">Not used!</param> 394 /// <param name="paramRaycastInfo">Not used!</param>
395 public void UpdateWheel(RigidBody chassis, RaycastInfo paramRaycastInfo) 395 public void UpdateWheel(RigidBody chassis, RaycastInfo paramRaycastInfo)
396 { 396 {
397 if (_raycastInfo.IsInContact) 397 if (_raycastInfo.IsInContact)
398 { 398 {
399 float project = Vector3.Dot(_raycastInfo.ContactNormalWS, _raycastInfo.WheelDirectionWS); 399 float project = Vector3.Dot(_raycastInfo.ContactNormalWS, _raycastInfo.WheelDirectionWS);
400 400
401 Vector3 chassisVelocityAtContactPoint = new Vector3(); 401 Vector3 chassisVelocityAtContactPoint = new Vector3();
402 Vector3 relpos = _raycastInfo.ContactPointWS - chassis.CenterOfMassPosition; 402 Vector3 relpos = _raycastInfo.ContactPointWS - chassis.CenterOfMassPosition;
403 chassisVelocityAtContactPoint = chassis.GetVelocityInLocalPoint(relpos); 403 chassisVelocityAtContactPoint = chassis.GetVelocityInLocalPoint(relpos);
404 float projVel = Vector3.Dot(_raycastInfo.ContactNormalWS, chassisVelocityAtContactPoint); 404 float projVel = Vector3.Dot(_raycastInfo.ContactNormalWS, chassisVelocityAtContactPoint);
405 405
406 if (project >= -0.1f) 406 if (project >= -0.1f)
407 { 407 {
408 _suspensionRelativeVelocity = 0; 408 _suspensionRelativeVelocity = 0;
409 _clippedInvContactDotSuspension = 1.0f / 0.1f; 409 _clippedInvContactDotSuspension = 1.0f / 0.1f;
410 } 410 }
411 else 411 else
412 { 412 {
413 float inv = -1 / project; 413 float inv = -1 / project;
414 _suspensionRelativeVelocity = projVel * inv; 414 _suspensionRelativeVelocity = projVel * inv;
415 _clippedInvContactDotSuspension = inv; 415 _clippedInvContactDotSuspension = inv;
416 } 416 }
417 } 417 }
418 else 418 else
419 { 419 {
420 _raycastInfo.SuspensionLength = _suspensionRestLength; 420 _raycastInfo.SuspensionLength = _suspensionRestLength;
421 _suspensionRelativeVelocity = 0.0f; 421 _suspensionRelativeVelocity = 0.0f;
422 _raycastInfo.ContactNormalWS = -_raycastInfo.WheelDirectionWS; 422 _raycastInfo.ContactNormalWS = -_raycastInfo.WheelDirectionWS;
423 _clippedInvContactDotSuspension = 1.0f; 423 _clippedInvContactDotSuspension = 1.0f;
424 } 424 }
425 } 425 }
426 426
427 // if (m_raycastInfo.m_isInContact) 427 // if (m_raycastInfo.m_isInContact)
428 428
429 //{ 429 //{
430 // btScalar project= m_raycastInfo.m_contactNormalWS.dot( m_raycastInfo.m_wheelDirectionWS ); 430 // btScalar project= m_raycastInfo.m_contactNormalWS.dot( m_raycastInfo.m_wheelDirectionWS );
431 // btVector3 chassis_velocity_at_contactPoint; 431 // btVector3 chassis_velocity_at_contactPoint;
432 // btVector3 relpos = m_raycastInfo.m_contactPointWS - chassis.getCenterOfMassPosition(); 432 // btVector3 relpos = m_raycastInfo.m_contactPointWS - chassis.getCenterOfMassPosition();
433 // chassis_velocity_at_contactPoint = chassis.getVelocityInLocalPoint( relpos ); 433 // chassis_velocity_at_contactPoint = chassis.getVelocityInLocalPoint( relpos );
434 // btScalar projVel = m_raycastInfo.m_contactNormalWS.dot( chassis_velocity_at_contactPoint ); 434 // btScalar projVel = m_raycastInfo.m_contactNormalWS.dot( chassis_velocity_at_contactPoint );
435 // if ( project >= -0.1f) 435 // if ( project >= -0.1f)
436 // { 436 // {
437 // m_suspensionRelativeVelocity = 0.0f; 437 // m_suspensionRelativeVelocity = 0.0f;
438 // m_clippedInvContactDotSuspension = 1.0f / 0.1f; 438 // m_clippedInvContactDotSuspension = 1.0f / 0.1f;
439 // } 439 // }
440 // else 440 // else
441 // { 441 // {
442 // btScalar inv = -1.f / project; 442 // btScalar inv = -1.f / project;
443 // m_suspensionRelativeVelocity = projVel * inv; 443 // m_suspensionRelativeVelocity = projVel * inv;
444 // m_clippedInvContactDotSuspension = inv; 444 // m_clippedInvContactDotSuspension = inv;
445 // } 445 // }
446 446
447 //} 447 //}
448 448
449 //else // Not in contact : position wheel in a nice (rest length) position 449 //else // Not in contact : position wheel in a nice (rest length) position
450 //{ 450 //{
451 // m_raycastInfo.m_suspensionLength = this->getSuspensionRestLength(); 451 // m_raycastInfo.m_suspensionLength = this->getSuspensionRestLength();
452 // m_suspensionRelativeVelocity = 0.0f; 452 // m_suspensionRelativeVelocity = 0.0f;
453 // m_raycastInfo.m_contactNormalWS = -m_raycastInfo.m_wheelDirectionWS; 453 // m_raycastInfo.m_contactNormalWS = -m_raycastInfo.m_wheelDirectionWS;
454 // m_clippedInvContactDotSuspension = 1.0f; 454 // m_clippedInvContactDotSuspension = 1.0f;
455 //} 455 //}
456 }; 456 };
457 457
458 //btScalar m_clippedInvContactDotSuspension; 458 //btScalar m_clippedInvContactDotSuspension;
459 //btScalar m_suspensionRelativeVelocity; 459 //btScalar m_suspensionRelativeVelocity;
460 //btScalar m_wheelsSuspensionForce; 460 //btScalar m_wheelsSuspensionForce;
461 //btScalar m_skidInfo; 461 //btScalar m_skidInfo;
462 462
463 //void* m_clientInfo;//can be used to store pointer to sync transforms... 463 //void* m_clientInfo;//can be used to store pointer to sync transforms...
464 464
465 //btWheelInfo(btWheelInfoConstructionInfo& ci) 465 //btWheelInfo(btWheelInfoConstructionInfo& ci)
466 466
467 //{ 467 //{
468 468
469 // m_suspensionRestLength1 = ci.m_suspensionRestLength; 469 // m_suspensionRestLength1 = ci.m_suspensionRestLength;
470 // m_maxSuspensionTravelCm = ci.m_maxSuspensionTravelCm; 470 // m_maxSuspensionTravelCm = ci.m_maxSuspensionTravelCm;
471 471
472 // m_wheelsRadius = ci.m_wheelRadius; 472 // m_wheelsRadius = ci.m_wheelRadius;
473 // m_suspensionStiffness = ci.m_suspensionStiffness; 473 // m_suspensionStiffness = ci.m_suspensionStiffness;
474 // m_wheelsDampingCompression = ci.m_wheelsDampingCompression; 474 // m_wheelsDampingCompression = ci.m_wheelsDampingCompression;
475 // m_wheelsDampingRelaxation = ci.m_wheelsDampingRelaxation; 475 // m_wheelsDampingRelaxation = ci.m_wheelsDampingRelaxation;
476 // m_chassisConnectionPointCS = ci.m_chassisConnectionCS; 476 // m_chassisConnectionPointCS = ci.m_chassisConnectionCS;
477 // m_wheelDirectionCS = ci.m_wheelDirectionCS; 477 // m_wheelDirectionCS = ci.m_wheelDirectionCS;
478 // m_wheelAxleCS = ci.m_wheelAxleCS; 478 // m_wheelAxleCS = ci.m_wheelAxleCS;
479 // m_frictionSlip = ci.m_frictionSlip; 479 // m_frictionSlip = ci.m_frictionSlip;
480 // m_steering = 0.f; 480 // m_steering = 0.f;
481 // m_engineForce = 0.f; 481 // m_engineForce = 0.f;
482 // m_rotation = 0.f; 482 // m_rotation = 0.f;
483 // m_deltaRotation = 0.f; 483 // m_deltaRotation = 0.f;
484 // m_brake = 0.f; 484 // m_brake = 0.f;
485 // m_rollInfluence = 0.1f; 485 // m_rollInfluence = 0.1f;
486 // m_bIsFrontWheel = ci.m_bIsFrontWheel; 486 // m_bIsFrontWheel = ci.m_bIsFrontWheel;
487 487
488 //} 488 //}
489 489
490 //void updateWheel(const btRigidBody& chassis,RaycastInfo& raycastInfo); 490 //void updateWheel(const btRigidBody& chassis,RaycastInfo& raycastInfo);
491 491
492 //btScalar m_clippedInvContactDotSuspension; 492 //btScalar m_clippedInvContactDotSuspension;
493 //btScalar m_suspensionRelativeVelocity; 493 //btScalar m_suspensionRelativeVelocity;
494 ////calculated by suspension 494 ////calculated by suspension
495 //btScalar m_wheelsSuspensionForce; 495 //btScalar m_wheelsSuspensionForce;
496 //btScalar m_skidInfo; 496 //btScalar m_skidInfo;
497 497
498 //}; 498 //};
499 499
500 //struct RaycastInfo 500 //struct RaycastInfo
501 //{ 501 //{
502 // //set by raycaster 502 // //set by raycaster
503 // btVector3 m_contactNormalWS;//contactnormal 503 // btVector3 m_contactNormalWS;//contactnormal
504 // btVector3 m_contactPointWS;//raycast hitpoint 504 // btVector3 m_contactPointWS;//raycast hitpoint
505 // btScalar m_suspensionLength; 505 // btScalar m_suspensionLength;
506 // btVector3 m_hardPointWS;//raycast starting point 506 // btVector3 m_hardPointWS;//raycast starting point
507 // btVector3 m_wheelDirectionWS; //direction in worldspace 507 // btVector3 m_wheelDirectionWS; //direction in worldspace
508 // btVector3 m_wheelAxleWS; // axle in worldspace 508 // btVector3 m_wheelAxleWS; // axle in worldspace
509 // bool m_isInContact; 509 // bool m_isInContact;
510 // void* m_groundObject; //could be general void* ptr 510 // void* m_groundObject; //could be general void* ptr
511 //}; 511 //};
512 512
513 //struct btWheelInfoConstructionInfo 513 //struct btWheelInfoConstructionInfo
514 //{ 514 //{
515 // btVector3 m_chassisConnectionCS; 515 // btVector3 m_chassisConnectionCS;
516 // btVector3 m_wheelDirectionCS; 516 // btVector3 m_wheelDirectionCS;
517 // btVector3 m_wheelAxleCS; 517 // btVector3 m_wheelAxleCS;
518 // btScalar m_suspensionRestLength; 518 // btScalar m_suspensionRestLength;
519 // btScalar m_maxSuspensionTravelCm; 519 // btScalar m_maxSuspensionTravelCm;
520 // btScalar m_wheelRadius; 520 // btScalar m_wheelRadius;
521 521
522 // float m_suspensionStiffness; 522 // float m_suspensionStiffness;
523 // float m_wheelsDampingCompression; 523 // float m_wheelsDampingCompression;
524 // float m_wheelsDampingRelaxation; 524 // float m_wheelsDampingRelaxation;
525 // float m_frictionSlip; 525 // float m_frictionSlip;
526 // bool m_bIsFrontWheel; 526 // bool m_bIsFrontWheel;
527 527
528 //}; 528 //};
529} 529}