Exemplo n.º 1
0
		//by default, Bullet will use this near callback
		void defaultNearCallback( btBroadphasePair collisionPair, btCollisionDispatcher dispatcher, btDispatcherInfo dispatchInfo )
		{
			btCollisionObject colObj0 = (btCollisionObject)collisionPair.m_pProxy0.m_clientObject;
			btCollisionObject colObj1 = (btCollisionObject)collisionPair.m_pProxy1.m_clientObject;

			if( dispatcher.needsCollision( colObj0, colObj1 ) )
			{
				btCollisionObjectWrapper obj0Wrap = BulletGlobals.CollisionObjectWrapperPool.Get();
				obj0Wrap.Initialize( null, colObj0.getCollisionShape(), colObj0, -1, -1 );
				btCollisionObjectWrapper obj1Wrap = BulletGlobals.CollisionObjectWrapperPool.Get();
				obj1Wrap.Initialize( null, colObj1.getCollisionShape(), colObj1, -1, -1 );


				//dispatcher will keep algorithms persistent in the collision pair
				if( collisionPair.m_algorithm == null )
				{
					collisionPair.m_algorithm = dispatcher.findAlgorithm( obj0Wrap, obj1Wrap );
				}

				if( collisionPair.m_algorithm != null )
				{
					btManifoldResult contactPointResult = BulletGlobals.ManifoldResultPool.Get();
					contactPointResult.Initialize( obj0Wrap, obj1Wrap );

					if( dispatchInfo.m_dispatchFunc == btDispatcherInfo.DispatchFunc.DISPATCH_DISCRETE )
					{
						//discrete collision detection query

						collisionPair.m_algorithm.processCollision( obj0Wrap
							, ref obj0Wrap.m_collisionObject.m_worldTransform
							, obj1Wrap
							, ref obj1Wrap.m_collisionObject.m_worldTransform
							, dispatchInfo, contactPointResult );
					}
					else
					{
						//continuous collision detection query, time of impact (toi)
						double toi = collisionPair.m_algorithm.calculateTimeOfImpact( colObj0, colObj1, dispatchInfo, contactPointResult );
						if( dispatchInfo.m_timeOfImpact > toi )
							dispatchInfo.m_timeOfImpact = toi;
					}
					BulletGlobals.ManifoldResultPool.Free( contactPointResult );
				}
				BulletGlobals.CollisionObjectWrapperPool.Free( obj0Wrap );
				BulletGlobals.CollisionObjectWrapperPool.Free( obj1Wrap );
			}

		}
Exemplo n.º 2
0
		public btDiscreteDynamicsWorld()
		{
			btDefaultCollisionConfiguration collisionConfiguration = new btDefaultCollisionConfiguration( null );
			btCollisionDispatcher dispatcher = new btCollisionDispatcher( collisionConfiguration );

			btBroadphaseInterface broadphase = new btDbvtBroadphase();
			btSequentialImpulseConstraintSolver solver = new btSequentialImpulseConstraintSolver();
			Initialize( dispatcher, broadphase, solver, collisionConfiguration );
		}
Exemplo n.º 3
0
			internal btCollisionPairCallback( btDispatcherInfo dispatchInfo, btCollisionDispatcher dispatcher )
			{
				m_dispatchInfo = ( dispatchInfo );
				m_dispatcher = ( dispatcher );
			}