Exemplo n.º 1
0
		internal override void getClosestPoints( ClosestPointInput input, Result output, btIDebugDraw debugDraw, bool swapResults = false )
		{

			//(void)debugDraw;
			//btTransform transformA = input.m_transformA;
			//btTransform transformB = input.m_transformB;

			btVector3 point, normal;
			double timeOfImpact = btScalar.BT_ONE;
			double depth = btScalar.BT_ZERO;
			//	output.m_distance = (double)(BT_LARGE_FLOAT);
			//move sphere into triangle space
			btTransform sphereInTr; input.m_transformB.inverseTimes( ref input.m_transformA, out sphereInTr );

			if( collide( ref sphereInTr.m_origin, out point, out normal, out depth, timeOfImpact, m_contactBreakingThreshold ) )
			{
				if( swapResults )
				{

					btVector3 normalOnB; input.m_transformB.m_basis.Apply( ref normal, out normalOnB );
					btVector3 normalOnA; normalOnB.Invert( out normalOnA ); 
					btVector3 tmp;
					input.m_transformB.Apply( ref point, out tmp );

					btVector3 pointOnA; tmp.AddScale( ref normalOnB, depth, out pointOnA );
					output.addContactPoint( ref normalOnA, ref pointOnA, depth );
				}
				else
				{
					btVector3 tmp, tmp2;
					input.m_transformB.m_basis.Apply( ref normal, out tmp );
					input.m_transformB.Apply( ref point, out tmp2 );
					output.addContactPoint( ref tmp, ref tmp2, depth );
				}
			}

		}