public override double addSingleResult( ref btCollisionWorld.LocalConvexResult convexResult, bool normalInWorldSpace )
			{
				if( convexResult.m_hitCollisionObject == m_me )
					return 1.0f;

				//ignore result if there is no contact response
				if( !convexResult.m_hitCollisionObject.hasContactResponse() )
					return 1.0f;

				btVector3 linVelA, linVelB;
				m_convexToWorld.Sub( ref m_convexFromWorld, out linVelA );
				linVelB = btVector3.Zero;//toB.getOrigin()-fromB.getOrigin();

				btVector3 relativeVelocity; linVelA.Sub( ref linVelB, out relativeVelocity );
				//don't report time of impact for motion away from the contact normal (or causes minor penetration)
				if( convexResult.m_hitNormalLocal.dot( relativeVelocity ) >= -m_allowedPenetration )
					return 1;

				return base.addSingleResult( ref convexResult, normalInWorldSpace );
			}
Exemple #2
0
		void rayTest( ref btVector3 rayFromWorld, ref btVector3 rayToWorld, btCollisionWorld::RayResultCallback& resultCallback);
Exemple #3
0
			internal void Initialize( ref btVector3 rayFromWorld, ref btVector3 rayToWorld, btCollisionWorld world, RayResultCallback resultCallback )
			{
				m_rayFromWorld = ( rayFromWorld );
				m_rayToWorld = ( rayToWorld );
				m_world = ( world );
				m_resultCallback = ( resultCallback );
				m_rayFromTrans.setIdentity();
				m_rayFromTrans.setOrigin( ref m_rayFromWorld );
				m_rayToTrans.setIdentity();
				m_rayToTrans.setOrigin( ref m_rayToWorld );

				btVector3 rayDir = ( rayToWorld - rayFromWorld );

				rayDir.normalize();
				///what about division by zero? -. just set rayDirection[i] to INF/BT_LARGE_FLOAT
				m_rayDirectionInverse[0] = rayDir[0] == btScalar.BT_ZERO ? (double)( btScalar.BT_LARGE_FLOAT ) : (double)( 1.0 ) / rayDir[0];
				m_rayDirectionInverse[1] = rayDir[1] == btScalar.BT_ZERO ? (double)( btScalar.BT_LARGE_FLOAT ) : (double)( 1.0 ) / rayDir[1];
				m_rayDirectionInverse[2] = rayDir[2] == btScalar.BT_ZERO ? (double)( btScalar.BT_LARGE_FLOAT ) : (double)( 1.0 ) / rayDir[2];
				m_signs[0] = m_rayDirectionInverse[0] < 0.0 ? 1U : 0;
				m_signs[1] = m_rayDirectionInverse[1] < 0.0 ? 1U : 0;
				m_signs[2] = m_rayDirectionInverse[2] < 0.0 ? 1U : 0;
				m_lambda_max = rayDir.dot( m_rayToWorld - m_rayFromWorld );
			}
Exemple #4
0
			internal void Initialize( btConvexShape castShape, ref btTransform convexFromTrans, ref btTransform convexToTrans, btCollisionWorld world, ConvexResultCallback resultCallback, double allowedPenetration )
			{
				m_convexFromTrans = ( convexFromTrans );
				m_convexToTrans = ( convexToTrans );
				m_world = ( world );
				m_resultCallback = ( resultCallback );
				m_allowedCcdPenetration = ( allowedPenetration );
				m_castShape = ( castShape );
				btVector3 unnormalizedRayDir; m_convexToTrans.m_origin.Sub( ref m_convexFromTrans.m_origin, out unnormalizedRayDir );
				btVector3 rayDir; unnormalizedRayDir.normalized( out rayDir );
				///what about division by zero? -. just set rayDirection[i] to INF/BT_LARGE_FLOAT
				m_rayDirectionInverse[0] = rayDir[0] == btScalar.BT_ZERO ? btScalar.BT_LARGE_FLOAT : (double)( 1.0 ) / rayDir[0];
				m_rayDirectionInverse[1] = rayDir[1] == btScalar.BT_ZERO ? btScalar.BT_LARGE_FLOAT : (double)( 1.0 ) / rayDir[1];
				m_rayDirectionInverse[2] = rayDir[2] == btScalar.BT_ZERO ? btScalar.BT_LARGE_FLOAT : (double)( 1.0 ) / rayDir[2];
				m_signs[0] = m_rayDirectionInverse[0] < 0.0 ? 1U : 0;
				m_signs[1] = m_rayDirectionInverse[1] < 0.0 ? 1U : 0;
				m_signs[2] = m_rayDirectionInverse[2] < 0.0 ? 1U : 0;

				m_lambda_max = rayDir.dot( unnormalizedRayDir );

			}
Exemple #5
0
			internal btSingleContactCallback( btCollisionObject collisionObject, btCollisionWorld world, ContactResultCallback resultCallback )
			{
				m_collisionObject = ( collisionObject );
				m_world = ( world );
				m_resultCallback = ( resultCallback );
			}