示例#1
0
		internal override bool needsCollision( btCollisionObject body0, btCollisionObject body1 )
		{
			Debug.Assert( body0 != null );
			Debug.Assert( body1 != null );

			bool needsCollision = true;

#if DEBUG
			if( ( m_dispatcherFlags & DispatcherFlags.CD_STATIC_STATIC_REPORTED ) == 0 )
			{
				//broadphase filtering already deals with this
				if( body0.isStaticOrKinematicObject() && body1.isStaticOrKinematicObject() )
				{
					m_dispatcherFlags |= DispatcherFlags.CD_STATIC_STATIC_REPORTED;
					Console.WriteLine( "warning needsCollision: static-static collision!\n" );
				}
			}
#endif //BT_DEBUG

			if( ( !body0.isActive() ) && ( !body1.isActive() ) )
				needsCollision = false;
			else if( ( !body0.checkCollideWith( body1 ) ) || ( !body1.checkCollideWith( body0 ) ) )
				needsCollision = false;

			return needsCollision;

		}
示例#2
0
		void updateSingleAabb( btCollisionObject colObj )
		{
			btVector3 minAabb, maxAabb;
			colObj.getCollisionShape().getAabb( ref colObj.m_worldTransform, out minAabb, out maxAabb );
			//need to increase the aabb for contact thresholds
			btVector3 contactThreshold = new btVector3( btPersistentManifold.gContactBreakingThreshold, btPersistentManifold.gContactBreakingThreshold, btPersistentManifold.gContactBreakingThreshold );
			minAabb.Sub( ref contactThreshold, out minAabb );
			maxAabb.Add( ref contactThreshold, out maxAabb );
			//minAabb -= contactThreshold;
			//maxAabb += contactThreshold;

			if( getDispatchInfo().m_useContinuous
				&& colObj.getInternalType() == btCollisionObject.CollisionObjectTypes.CO_RIGID_BODY
				&& !colObj.isStaticOrKinematicObject() )
			{
				btVector3 minAabb2, maxAabb2;
				colObj.getCollisionShape().getAabb( ref colObj.m_interpolationWorldTransform, out minAabb2, out maxAabb2 );
				minAabb2.Sub( ref contactThreshold, out minAabb2 );
				maxAabb2.Add( ref contactThreshold, out maxAabb2 );
				minAabb.setMin( ref minAabb2 );
				maxAabb.setMax( ref maxAabb2 );
			}

			btBroadphaseInterface bp = (btBroadphaseInterface)m_broadphasePairCache;

			//moving objects should be moderately sized, probably something wrong if not
			if( colObj.isStaticObject()
				|| ( btVector3.BetweenLength2( ref minAabb, ref maxAabb ) < (double)( 1e12 ) ) )
			{
				bp.setAabb( colObj.getBroadphaseHandle(), ref minAabb, ref maxAabb, m_dispatcher1 );
			}
			else
			{
				//something went wrong, investigate
				//this assert is unwanted in 3D modelers (danger of loosing work)
				colObj.setActivationState( ActivationState.DISABLE_SIMULATION );

				if( reportMe && m_debugDrawer != null )
				{
					reportMe = false;
					m_debugDrawer.reportErrorWarning( "Overflow in AABB, object removed from simulation" );
					m_debugDrawer.reportErrorWarning( "If you can reproduce this, please email [email protected]\n" );
					m_debugDrawer.reportErrorWarning( "Please include above information, your Platform, version of OS.\n" );
					m_debugDrawer.reportErrorWarning( "Thanks.\n" );
				}
			}
		}
示例#3
0
		internal override bool needsResponse( btCollisionObject body0, btCollisionObject body1 )
		{
			//here you can do filtering
			bool hasResponse =
				( body0.hasContactResponse() && body1.hasContactResponse() );
			//no response between two static/kinematic bodies:
			hasResponse = hasResponse &&
				( ( !body0.isStaticOrKinematicObject() ) || ( !body1.isStaticOrKinematicObject() ) );
			return hasResponse;
		}