Exemplo n.º 1
0
		public override void addCollisionObject( btCollisionObject collisionObject, btBroadphaseProxy.CollisionFilterGroups collisionFilterGroup = btBroadphaseProxy.CollisionFilterGroups.StaticFilter
			, btBroadphaseProxy.CollisionFilterGroups collisionFilterMask = btBroadphaseProxy.CollisionFilterGroups.StaticFilter )
		{
			base.addCollisionObject( collisionObject, collisionFilterGroup, collisionFilterMask );
		}
Exemplo n.º 2
0
		public abstract void setAabb( btBroadphaseProxy proxy, ref btVector3 aabbMin, ref btVector3 aabbMax, btDispatcher dispatcher );
Exemplo n.º 3
0
			public override bool needsCollision( btBroadphaseProxy proxy0 )
			{
				//don't collide with itself
				if( proxy0.m_clientObject == m_me )
					return false;

				///don't do CCD when the collision filters are not matching
				if( !base.needsCollision( proxy0 ) )
					return false;

				btCollisionObject otherObj = (btCollisionObject)proxy0.m_clientObject;

				//call needsResponse, see http://code.google.com/p/bullet/issues/detail?id=179
				if( m_dispatcher.needsResponse( m_me, otherObj ) )
				{
#if false
			///don't do CCD when there are already contact points (touching contact/penetration)
			List<btPersistentManifold*> manifoldArray;
			btBroadphasePair* collisionPair = m_pairCache.findPair(m_me.getBroadphaseHandle(),proxy0);
			if (collisionPair)
			{
				if (collisionPair.m_algorithm)
				{
					manifoldArray.resize(0);
					collisionPair.m_algorithm.getAllContactManifolds(manifoldArray);
					for (int j=0;j<manifoldArray.Count;j++)
					{
						btPersistentManifold* manifold = manifoldArray[j];
						if (manifold.getNumContacts()>0)
							return false;
					}
				}
			}
#endif
					return true;
				}

				return false;
			}
Exemplo n.º 4
0
		public abstract void destroyProxy( btBroadphaseProxy proxy, btDispatcher dispatcher );
Exemplo n.º 5
0
		public abstract void getAabb( btBroadphaseProxy proxy, ref btVector3 aabbMin, ref btVector3 aabbMax );
Exemplo n.º 6
0
		public void Initialize( btBroadphaseProxy proxy0, btBroadphaseProxy proxy1 )
		{

			//keep them sorted, so the std::set operations work
			m_pProxy0 = proxy0;
			m_pProxy1 = proxy1;

			m_algorithm = null;
			m_internalInfo1 = 0;

		}
Exemplo n.º 7
0
		public abstract btBroadphaseProxy createProxy( ref btVector3 aabbMin, ref btVector3 aabbMax, BroadphaseNativeTypes shapeType, btCollisionObject userPtr, btBroadphaseProxy.CollisionFilterGroups collisionFilterGroup, btBroadphaseProxy.CollisionFilterGroups collisionFilterMask, btDispatcher dispatcher, object multiSapProxy );
Exemplo n.º 8
0
			public override bool process( btBroadphaseProxy proxy )
			{
				///terminate further ray tests, once the closestHitFraction reached zero
				if( m_resultCallback.m_closestHitFraction == (double)( 0f ) )
					return false;

				btCollisionObject collisionObject = (btCollisionObject)proxy.m_clientObject;

				//only perform raycast if filterMask matches
				if( m_resultCallback.needsCollision( collisionObject.getBroadphaseHandle() ) )
				{
					//RigidcollisionObject collisionObject = ctrl.GetRigidcollisionObject();
					//btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
#if false
#if RECALCULATE_AABB
			btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
			collisionObject.getCollisionShape().getAabb(collisionObject.getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax);
#else
					//getBroadphase().getAabb(collisionObject.getBroadphaseHandle(),collisionObjectAabbMin,collisionObjectAabbMax);
					btVector3 collisionObjectAabbMin = collisionObject.getBroadphaseHandle().m_aabbMin;
					btVector3 collisionObjectAabbMax = collisionObject.getBroadphaseHandle().m_aabbMax;
#endif
#endif
					//double hitLambda = m_resultCallback.m_closestHitFraction;
					//culling already done by broadphase
					//if (btRayAabb(m_rayFromWorld,m_rayToWorld,collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,m_hitNormal))
					{
						rayTestSingle( ref m_rayFromTrans, ref m_rayToTrans,
							collisionObject,
							collisionObject.getCollisionShape(),
							ref collisionObject.m_worldTransform,
							m_resultCallback );
					}
				}
				return true;
			}
Exemplo n.º 9
0
			public override bool process( btBroadphaseProxy proxy )
			{
				///terminate further convex sweep tests, once the closestHitFraction reached zero
				if( m_resultCallback.m_closestHitFraction == (double)( 0f ) )
					return false;

				btCollisionObject collisionObject = (btCollisionObject)proxy.m_clientObject;

				//only perform raycast if filterMask matches
				if( m_resultCallback.needsCollision( collisionObject.getBroadphaseHandle() ) )
				{
					//RigidcollisionObject collisionObject = ctrl.GetRigidcollisionObject();
					objectQuerySingle( m_castShape, ref m_convexFromTrans, ref m_convexToTrans,
						collisionObject,
						collisionObject.getCollisionShape(),
						ref collisionObject.m_worldTransform,
						m_resultCallback,
						m_allowedCcdPenetration );
				}

				return true;
			}
Exemplo n.º 10
0
		public virtual void addCollisionObject( btCollisionObject collisionObject
			, btBroadphaseProxy.CollisionFilterGroups collisionFilterGroup = btBroadphaseProxy.CollisionFilterGroups.DefaultFilter
			, btBroadphaseProxy.CollisionFilterGroups collisionFilterMask = btBroadphaseProxy.CollisionFilterGroups.AllFilter )
		{
			Debug.Assert( collisionObject != null );

			//check that the object isn't already added
			Debug.Assert( !m_collisionObjects.Contains( collisionObject ) );

			m_collisionObjects.Add( collisionObject );

			//calculate new AABB

			btVector3 minAabb;
			btVector3 maxAabb;
			collisionObject.getCollisionShape().getAabb( ref collisionObject.m_worldTransform, out minAabb, out maxAabb );

			BroadphaseNativeTypes type = collisionObject.getCollisionShape().getShapeType();
			collisionObject.setBroadphaseHandle( getBroadphase().createProxy(
				ref minAabb,
				ref maxAabb,
				type,
				collisionObject,
				collisionFilterGroup,
				collisionFilterMask,
				m_dispatcher1, null
				) );
		}
Exemplo n.º 11
0
			public override bool needsCollision( btBroadphaseProxy p )
			{
				return m_userCallback.needsCollision( p );
			}
Exemplo n.º 12
0
			public bool process( btBroadphaseProxy proxy )
			{
				btCollisionObject collisionObject = (btCollisionObject)proxy.m_clientObject;
				if( collisionObject == m_collisionObject )
					return true;

				//only perform raycast if filterMask matches
				if( m_resultCallback.needsCollision( collisionObject.getBroadphaseHandle() ) )
				{
					btCollisionObjectWrapper ob0 = BulletGlobals.CollisionObjectWrapperPool.Get();
					ob0.Initialize( null, m_collisionObject.getCollisionShape(), m_collisionObject, -1, -1 );
					btCollisionObjectWrapper ob1 = BulletGlobals.CollisionObjectWrapperPool.Get();
					ob1.Initialize( null, collisionObject.getCollisionShape(), collisionObject, -1, -1 );

					btCollisionAlgorithm algorithm = m_world.m_dispatcher1.findAlgorithm( ob0, ob1, null );
					if( algorithm != null )
					{
						btBridgedManifoldResult contactPointResult = BulletGlobals.BridgedManifoldResultPool.Get();

						contactPointResult.Initialize( ob0, ob1, m_resultCallback );
						//discrete collision detection query

						algorithm.processCollision( ob0
							, ref ob0.m_collisionObject.m_worldTransform
							, ob1
							, ref ob1.m_collisionObject.m_worldTransform, m_world.getDispatchInfo(), contactPointResult );

						//algorithm.~btCollisionAlgorithm();
						m_world.m_dispatcher1.freeCollisionAlgorithm( algorithm );
						BulletGlobals.BridgedManifoldResultPool.Free( contactPointResult );
					}
					BulletGlobals.CollisionObjectWrapperPool.Free( ob0 );
					BulletGlobals.CollisionObjectWrapperPool.Free( ob1 );
				}
				return true;
			}
Exemplo n.º 13
0
			public virtual bool needsCollision( btBroadphaseProxy proxy0 )
			{
				bool collides = ( proxy0.m_collisionFilterGroup & m_collisionFilterMask ) != 0;
				collides = collides && ( m_collisionFilterGroup & proxy0.m_collisionFilterMask ) != 0;
				return collides;
			}
Exemplo n.º 14
0
		internal btBroadphasePair( btBroadphaseProxy proxy0, btBroadphaseProxy proxy1 )
		{
			Initialize( proxy0, proxy1 );
		}
Exemplo n.º 15
0
	virtual bool needsCollision( btBroadphaseProxy* proxy0 )
	{
		btCollisionObject otherObj = (btCollisionObject)proxy0.m_clientObject;
		if( !otherObj.isStaticOrKinematicObject() )
			return false;
		return btClosestNotMeConvexResultCallback::needsCollision( proxy0 );
	}
Exemplo n.º 16
0
		public abstract bool process( btBroadphaseProxy proxy );
Exemplo n.º 17
0
		public void addRigidBody( btRigidBody body, btBroadphaseProxy.CollisionFilterGroups group, btBroadphaseProxy.CollisionFilterGroups mask )
		{
			if( !body.isStaticOrKinematicObject() && 0 == ( body.getFlags() & btRigidBodyFlags.BT_DISABLE_WORLD_GRAVITY ) )
			{
				body.setGravity( ref m_gravity );
			}

			if( body.getCollisionShape() != null )
			{
				if( !body.isStaticObject() )
				{
					m_nonStaticRigidBodies.Add( body );
				}
				else
				{
					body.setActivationState( ActivationState.ISLAND_SLEEPING );
				}
				addCollisionObject( body, group, mask );
			}
		}
Exemplo n.º 18
0
        internal btBroadphasePair( ref btBroadphasePair other )
		{
			m_pProxy0 = other.m_pProxy0;
			m_pProxy1 = other.m_pProxy1;
			m_algorithm = other.m_algorithm;
			m_internalInfo1 = other.m_internalInfo1;
		}