コード例 #1
0
		protected btSolverBody getOrInitSolverBody( btCollisionObject body, double timeStep )
		{
			btSolverBody solverBodyA = null;

			if( body.getCompanionBody() != null )
			{
				//body has already been converted
				solverBodyA = body.getCompanionBody();
				//Debug.Assert( solverBodyIdA < m_tmpSolverBodyPool.Count );
			}
			else
			{
				btRigidBody rb = btRigidBody.upcast( body );
				//convert both active and kinematic objects (for their velocity)
				if( rb != null && ( rb.getInvMass() != 0 || rb.isKinematicObject() ) )
				{
					//solverBodyA = m_tmpSolverBodyPool.Count;
					//btSolverBody solverBodyA;
					m_tmpSolverBodyPool.Add( solverBodyA = BulletGlobals.SolverBodyPool.Get() );
					initSolverBody( solverBodyA, rb, timeStep );
					body.setCompanionBody( solverBodyA );
				}
				else
				{

					if( m_fixedBody == null )
					{
						//m_fixedBodyId = m_tmpSolverBodyPool.Count;
						//btSolverBody fixedBody;
						m_tmpSolverBodyPool.Add( m_fixedBody = BulletGlobals.SolverBodyPool.Get() );
						initSolverBody( m_fixedBody, null, timeStep );
					}
					return m_fixedBody;
					//			return 0;//assume first one is a fixed solver body
				}
			}

			return solverBodyA;

		}