public CompoundCollisionAlgorithm(
            CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo,
            CollisionObject bodyA,
            CollisionObject bodyB, bool isSwapped)
            : base(collisionAlgorithmConstructionInfo)
        {
            //Begin
            _isSwapped = isSwapped;

            CollisionObject collisionObject = isSwapped ? bodyB : bodyA;
            CollisionObject otherObject     = isSwapped ? bodyA : bodyB;

            BulletDebug.Assert(collisionObject.CollisionShape.IsCompound);

            CompoundShape compoundShape  = collisionObject.CollisionShape as CompoundShape;
            int           childrenNumber = compoundShape.ChildShapeCount;
            int           index          = 0;

            _childCollisionAlgorithms = new List <CollisionAlgorithm>(childrenNumber);

            for (index = 0; index < childrenNumber; index++)
            {
                CollisionShape childShape = compoundShape.GetChildShape(index);
                CollisionShape orgShape   = collisionObject.CollisionShape;

                collisionObject.CollisionShape   = childShape;
                _childCollisionAlgorithms[index] = collisionAlgorithmConstructionInfo.Dispatcher.FindAlgorithm(collisionObject, otherObject);
                collisionObject.CollisionShape   = orgShape;
            }
        }
		public CompoundCollisionAlgorithm(
			CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo,
			CollisionObject bodyA,
			CollisionObject bodyB, bool isSwapped)
			: base(collisionAlgorithmConstructionInfo)
		{
			//Begin
			_isSwapped = isSwapped;

			CollisionObject collisionObject = isSwapped ? bodyB : bodyA;
			CollisionObject otherObject = isSwapped ? bodyA : bodyB;

			BulletDebug.Assert(collisionObject.CollisionShape.IsCompound);

			CompoundShape compoundShape = collisionObject.CollisionShape as CompoundShape;
			int childrenNumber = compoundShape.ChildShapeCount;
			int index = 0;

			_childCollisionAlgorithms = new List<CollisionAlgorithm>(childrenNumber);

			for (index = 0; index < childrenNumber; index++)
			{
				CollisionShape childShape = compoundShape.GetChildShape(index);
				CollisionShape orgShape = collisionObject.CollisionShape;

				collisionObject.CollisionShape = childShape;
				_childCollisionAlgorithms[index] = collisionAlgorithmConstructionInfo.Dispatcher.FindAlgorithm(collisionObject, otherObject);
				collisionObject.CollisionShape = orgShape;
			}
		}
        public void ProcessTriangle(Vector3[] triangle, int partID, int triangleIndex)
        {
            //aabb filter is already applied!
            CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo = new CollisionAlgorithmConstructionInfo();

            collisionAlgorithmConstructionInfo.Dispatcher = _dispatcher;

            CollisionObject collisionObject = _triBody;

            //debug drawing of the overlapping triangles

            /*if (m_dispatchInfoPtr && m_dispatchInfoPtr.m_debugDraw && m_dispatchInfoPtr->m_debugDraw->getDebugMode() > 0)
             * {
             *      Vector3 color = new Vector3(255, 255, 0);
             *      btTransform & tr = ob->WorldTransform;
             *      m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]), tr(triangle[1]), color);
             *      m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]), tr(triangle[2]), color);
             *      m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]), tr(triangle[0]), color);
             * }*/

            if (_convexBody.CollisionShape.IsConvex)
            {
                TriangleShape triangleShape = new TriangleShape(triangle[0], triangle[1], triangle[2]);
                triangleShape.Margin = _collisionMarginTriangle;

                CollisionShape tempShape = collisionObject.CollisionShape;
                collisionObject.CollisionShape = triangleShape;

                CollisionAlgorithm collisionAlgorithm = collisionAlgorithmConstructionInfo.Dispatcher.FindAlgorithm(_convexBody, _triBody, _manifold);

                _resultOut.SetShapeIdentifiers(-1, -1, partID, triangleIndex);
                collisionAlgorithm.ProcessCollision(_convexBody, _triBody, _dispatchInfo, _resultOut);
                collisionObject.CollisionShape = tempShape;
            }
        }
Example #4
0
 public ConvexConvexAlgorithm(PersistentManifold manifold, CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB, ISimplexSolver simplexSolver, IConvexPenetrationDepthSolver penetrationDepthSolver)
     : base(collisionAlgorithmConstructionInfo)
 {
     _gjkPairDetector  = new GjkPairDetector(null, null, simplexSolver, penetrationDepthSolver);
     _ownManifold      = false;
     _manifold         = manifold;
     _lowLevelOfDetail = false;
 }
Example #5
0
 public ConvexConvexAlgorithm(PersistentManifold manifold, CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB, ISimplexSolver simplexSolver, IConvexPenetrationDepthSolver penetrationDepthSolver)
     : base(collisionAlgorithmConstructionInfo)
 {
     _gjkPairDetector = new GjkPairDetector(null, null, simplexSolver, penetrationDepthSolver);
     _ownManifold = false;
     _manifold = manifold;
     _lowLevelOfDetail = false;
 }
Example #6
0
        public CollisionAlgorithm FindAlgorithm(CollisionObject bodyA, CollisionObject bodyB, PersistentManifold sharedManifold)
        {
            CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo = new CollisionAlgorithmConstructionInfo();

            collisionAlgorithmConstructionInfo.Dispatcher = this;
            collisionAlgorithmConstructionInfo.Manifold   = sharedManifold;
            CollisionAlgorithm collisionAlgorithm = _doubleDispatch[(int)bodyA.CollisionShape.ShapeType, (int)bodyB.CollisionShape.ShapeType].CreateCollisionAlgorithm(collisionAlgorithmConstructionInfo, bodyA, bodyB);

            return(collisionAlgorithm);
        }
Example #7
0
 public override CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB)
 {
     if (!IsSwapped)
     {
         return(new SphereBoxCollisionAlgorithm(null, collisionAlgorithmConstructionInfo, bodyA, bodyB, false));
     }
     else
     {
         return(new SphereBoxCollisionAlgorithm(null, collisionAlgorithmConstructionInfo, bodyA, bodyB, true));
     }
 }
Example #8
0
        public SphereSphereCollisionAlgorithm(PersistentManifold manifold, CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB)
            : base(collisionAlgorithmConstructionInfo)
        {
            _ownManifold = false;
            _manifold    = manifold;

            if (_manifold == null)
            {
                _manifold    = Dispatcher.GetNewManifold(bodyA, bodyB);
                _ownManifold = true;
            }
        }
		public SphereSphereCollisionAlgorithm(PersistentManifold manifold, CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB)
			: base(collisionAlgorithmConstructionInfo)
		{
			_ownManifold = false;
			_manifold = manifold;

			if (_manifold == null)
			{
				_manifold = Dispatcher.GetNewManifold(bodyA, bodyB);
				_ownManifold = true;
			}
		}
Example #10
0
        public SphereBoxCollisionAlgorithm(PersistentManifold manifold, CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject collisionObjectA, CollisionObject collisionObjectB, bool isSwapped)
            : base(collisionAlgorithmConstructionInfo)
        {
            _ownManifold = false;
            _manifold    = manifold;
            _isSwapped   = isSwapped;

            CollisionObject sphereObject = _isSwapped ? collisionObjectB : collisionObjectA;
            CollisionObject boxObject    = _isSwapped ? collisionObjectA : collisionObjectB;

            if (_manifold == null && Dispatcher.NeedsCollision(sphereObject, boxObject))
            {
                _manifold    = Dispatcher.GetNewManifold(sphereObject, boxObject);
                _ownManifold = true;
            }
        }
		public SphereBoxCollisionAlgorithm(PersistentManifold manifold, CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject collisionObjectA, CollisionObject collisionObjectB, bool isSwapped)
			: base(collisionAlgorithmConstructionInfo)
		{
			_ownManifold = false;
			_manifold = manifold;
			_isSwapped = isSwapped;

			CollisionObject sphereObject = _isSwapped ? collisionObjectB : collisionObjectA;
			CollisionObject boxObject = _isSwapped ? collisionObjectA : collisionObjectB;

			if (_manifold == null && Dispatcher.NeedsCollision(sphereObject, boxObject))
			{
				_manifold = Dispatcher.GetNewManifold(sphereObject, boxObject);
				_ownManifold = true;
			}
		}
Example #12
0
 public override CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB)
 {
     return new ConvexConvexAlgorithm(collisionAlgorithmConstructionInfo.Manifold, collisionAlgorithmConstructionInfo, bodyA, bodyB, _simplexSolver, _penetrationDepthSolver);
 }
		public void ProcessTriangle(Vector3[] triangle, int partID, int triangleIndex)
		{
			//aabb filter is already applied!	
			CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo = new CollisionAlgorithmConstructionInfo();
			collisionAlgorithmConstructionInfo.Dispatcher = _dispatcher;

			CollisionObject collisionObject = _triBody;

			//debug drawing of the overlapping triangles
			/*if (m_dispatchInfoPtr && m_dispatchInfoPtr.m_debugDraw && m_dispatchInfoPtr->m_debugDraw->getDebugMode() > 0)
			{
				Vector3 color = new Vector3(255, 255, 0);
				btTransform & tr = ob->WorldTransform;
				m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]), tr(triangle[1]), color);
				m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]), tr(triangle[2]), color);
				m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]), tr(triangle[0]), color);
			}*/

			if (_convexBody.CollisionShape.IsConvex)
			{
				TriangleShape triangleShape = new TriangleShape(triangle[0], triangle[1], triangle[2]);
				triangleShape.Margin=_collisionMarginTriangle;

				CollisionShape tempShape = collisionObject.CollisionShape;
				collisionObject.CollisionShape = triangleShape;

				CollisionAlgorithm collisionAlgorithm = collisionAlgorithmConstructionInfo.Dispatcher.FindAlgorithm(_convexBody, _triBody, _manifold);

				_resultOut.SetShapeIdentifiers(-1, -1, partID, triangleIndex);
				collisionAlgorithm.ProcessCollision(_convexBody, _triBody, _dispatchInfo, _resultOut);
				collisionObject.CollisionShape = tempShape;
			}
		}
Example #14
0
 public CollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo)
 {
     _comparisonID = _globalCount++;
     _dispatcher   = collisionAlgorithmConstructionInfo.Dispatcher;
 }
Example #15
0
 public override CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB)
 {
     return(new ConvexConcaveCollisionAlgorithm(collisionAlgorithmConstructionInfo, bodyA, bodyB, false));
 }
 public override CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB)
 {
     return(new CompoundCollisionAlgorithm(collisionAlgorithmConstructionInfo, bodyA, bodyB, true));
 }
			public override CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB)
			{
				return new SphereSphereCollisionAlgorithm(null, collisionAlgorithmConstructionInfo, bodyA, bodyB);
			}
			public override CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB)
			{
				return new ConvexConcaveCollisionAlgorithm(collisionAlgorithmConstructionInfo, bodyA, bodyB, true);
			}
Example #19
0
		public CollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo)
		{
			_comparisonID = _globalCount++;
			_dispatcher = collisionAlgorithmConstructionInfo.Dispatcher;
		}
Example #20
0
		public CollisionAlgorithm FindAlgorithm(CollisionObject bodyA, CollisionObject bodyB, PersistentManifold sharedManifold)
		{
			CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo = new CollisionAlgorithmConstructionInfo();
			collisionAlgorithmConstructionInfo.Dispatcher = this;
			collisionAlgorithmConstructionInfo.Manifold = sharedManifold;
			CollisionAlgorithm collisionAlgorithm = _doubleDispatch[(int)bodyA.CollisionShape.ShapeType, (int)bodyB.CollisionShape.ShapeType].CreateCollisionAlgorithm(collisionAlgorithmConstructionInfo, bodyA, bodyB);
			return collisionAlgorithm;
		}
Example #21
0
		public EmptyAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo)
			: base(collisionAlgorithmConstructionInfo) { }
			public override CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB)
			{
				return new SphereTriangleCollisionAlgorithm(collisionAlgorithmConstructionInfo.Manifold, collisionAlgorithmConstructionInfo, bodyA, bodyB, IsSwapped);
			}
Example #23
0
 public override CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB)
 {
     return(new SphereSphereCollisionAlgorithm(null, collisionAlgorithmConstructionInfo, bodyA, bodyB));
 }
		public ConvexConcaveCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB, bool isSwapped)
			: base(collisionAlgorithmConstructionInfo)
		{
			_isSwapped = isSwapped;
			_convexTriangleCallback = new ConvexTriangleCallback(collisionAlgorithmConstructionInfo.Dispatcher, bodyA, bodyB, isSwapped);
		}
Example #25
0
 public virtual CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo ci, CollisionObject body0, CollisionObject body1)
 {
     return(null);
 }
Example #26
0
 public ConvexConcaveCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB, bool isSwapped)
     : base(collisionAlgorithmConstructionInfo)
 {
     _isSwapped = isSwapped;
     _convexTriangleCallback = new ConvexTriangleCallback(collisionAlgorithmConstructionInfo.Dispatcher, bodyA, bodyB, isSwapped);
 }
		public SphereTriangleCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo)
			: base(collisionAlgorithmConstructionInfo) { }
			public override CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB)
			{
				return new CompoundCollisionAlgorithm(collisionAlgorithmConstructionInfo, bodyA, bodyB, false);
			}
			public override CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB)
			{
				if (!IsSwapped)
					return new SphereBoxCollisionAlgorithm(null, collisionAlgorithmConstructionInfo, bodyA, bodyB, false);
				else
					return new SphereBoxCollisionAlgorithm(null, collisionAlgorithmConstructionInfo, bodyA, bodyB, true);
			}
 public SphereTriangleCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo)
     : base(collisionAlgorithmConstructionInfo)
 {
 }
 public override CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB)
 {
     return(new SphereTriangleCollisionAlgorithm(collisionAlgorithmConstructionInfo.Manifold, collisionAlgorithmConstructionInfo, bodyA, bodyB, IsSwapped));
 }
Example #32
0
 public EmptyAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo)
     : base(collisionAlgorithmConstructionInfo)
 {
 }
Example #33
0
			public override CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB)
			{
				return new EmptyAlgorithm(collisionAlgorithmConstructionInfo);
			}
Example #34
0
 public override CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB)
 {
     return(new EmptyAlgorithm(collisionAlgorithmConstructionInfo));
 }
Example #35
0
 public virtual CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo ci, CollisionObject body0, CollisionObject body1)
 {
     return null;
 }
Example #36
0
 public override CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB)
 {
     return(new ConvexConvexAlgorithm(collisionAlgorithmConstructionInfo.Manifold, collisionAlgorithmConstructionInfo, bodyA, bodyB, _simplexSolver, _penetrationDepthSolver));
 }