Пример #1
0
 public void UpdateWheel(RigidBody chassis, ref WheelRaycastInfo raycastInfo)
 {
     if (m_raycastInfo.m_isInContact)
     {
         float          project = IndexedVector3.Dot(m_raycastInfo.m_contactNormalWS, m_raycastInfo.m_wheelDirectionWS);
         IndexedVector3 chassis_velocity_at_contactPoint;
         IndexedVector3 relpos = m_raycastInfo.m_contactPointWS - chassis.GetCenterOfMassPosition();
         chassis_velocity_at_contactPoint = chassis.GetVelocityInLocalPoint(ref relpos);
         float projVel = IndexedVector3.Dot(m_raycastInfo.m_contactNormalWS, chassis_velocity_at_contactPoint);
         if (project >= -0.1f)
         {
             m_suspensionRelativeVelocity     = 0f;
             m_clippedInvContactDotSuspension = 1.0f / 0.1f;
         }
         else
         {
             float inv = -1f / project;
             m_suspensionRelativeVelocity     = projVel * inv;
             m_clippedInvContactDotSuspension = inv;
         }
     }
     else        // Not in contact : position wheel in a nice (rest length) position
     {
         m_raycastInfo.m_suspensionLength = this.GetSuspensionRestLength();
         m_suspensionRelativeVelocity     = 0f;
         m_raycastInfo.m_contactNormalWS  = -m_raycastInfo.m_wheelDirectionWS;
         m_clippedInvContactDotSuspension = 1f;
     }
 }
Пример #2
0
        public void UpdateWheel(RigidBody chassis, ref WheelRaycastInfo raycastInfo)
        {
	        if (m_raycastInfo.m_isInContact)
	        {
		        float project= IndexedVector3.Dot(m_raycastInfo.m_contactNormalWS,m_raycastInfo.m_wheelDirectionWS );
		        IndexedVector3	chassis_velocity_at_contactPoint;
		        IndexedVector3 relpos = m_raycastInfo.m_contactPointWS - chassis.GetCenterOfMassPosition();
		        chassis_velocity_at_contactPoint = chassis.GetVelocityInLocalPoint( ref relpos );
		        float projVel = IndexedVector3.Dot(m_raycastInfo.m_contactNormalWS,chassis_velocity_at_contactPoint );
		        if ( project >= -0.1f)
		        {
			        m_suspensionRelativeVelocity = 0f;
			        m_clippedInvContactDotSuspension = 1.0f / 0.1f;
		        }
		        else
		        {
			        float inv = -1f / project;
			        m_suspensionRelativeVelocity = projVel * inv;
			        m_clippedInvContactDotSuspension = inv;
		        }
	        }
	        else	// Not in contact : position wheel in a nice (rest length) position
	        {
		        m_raycastInfo.m_suspensionLength = this.GetSuspensionRestLength();
		        m_suspensionRelativeVelocity = 0f;
		        m_raycastInfo.m_contactNormalWS = -m_raycastInfo.m_wheelDirectionWS;
		        m_clippedInvContactDotSuspension = 1f;
	        }
        }