chenynCV / bullet

Automatically exported from code.google.com/p/bullet
Other
0 stars 0 forks source link

[Patch] fix for btWheelInfo::AddWheel() initializing wheel position to garbage #701

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.
btRaycastVehicle::AddWheel() calls updateWheelTransform(), which references 
wheel.m_raycastInfo.m_suspensionLength to set the wheel position in this code:
    wheel.m_worldTransform.setOrigin(
        wheel.m_raycastInfo.m_hardPointWS + wheel.m_raycastInfo.m_wheelDirectionWS * wheel.m_raycastInfo.m_suspensionLength
    );

but wheel.m_raycastInfo is completely uninitialized when a btWheelInfo is 
created, so the position is garbage (only 0 if you are lucky)

This is bullet 2.81
Patch is this:
------------------------------
+++ btWheelInfo.h       2013-03-05 15:51:32.579795000 -0800
@@ -40,6 +40,19 @@
 {
        struct RaycastInfo
        {
+               RaycastInfo() :
+                       m_contactNormalWS(0.0f,0.0f,0.0f),
+                       m_contactPointWS(0.0f,0.0f,0.0f),
+                       m_hardPointWS(0.0f,0.0f,0.0f),
+                       m_wheelDirectionWS(0.0f,0.0f,0.0f),
+                       m_wheelAxleWS(0.0f,0.0f,0.0f),
+                       m_suspensionLength(0.0f),
+                       m_isInContact(false),
+                       m_groundObject(NULL),
+                       m_contactMaterial(NULL)
+               {
+               }
+
                //set by raycaster
                btVector3       m_contactNormalWS;//contactnormal
                btVector3       m_contactPointWS;//raycast hitpoint

Original issue reported on code.google.com by chris.ge...@gmail.com on 6 Mar 2013 at 12:19

GoogleCodeExporter commented 9 years ago
See https://github.com/bulletphysics/bullet3/issues/96

Original comment by erwin.coumans on 30 Mar 2014 at 6:10