Exemplo n.º 1
0
		public void addRigidBody( btRigidBody body )
		{
			if( !body.isStaticOrKinematicObject() && ( body.getFlags() & btRigidBodyFlags.BT_DISABLE_WORLD_GRAVITY ) == 0 )
			{
				body.setGravity( ref m_gravity );
			}

			if( body.getCollisionShape() != null )
			{
				if( !body.isStaticObject() )
				{
					m_nonStaticRigidBodies.Add( body );
				}
				else
				{
					body.setActivationState( ActivationState.ISLAND_SLEEPING );
				}

				bool isDynamic = !( body.isStaticObject() || body.isKinematicObject() );
				btBroadphaseProxy.CollisionFilterGroups collisionFilterGroup = ( isDynamic ? btBroadphaseProxy.CollisionFilterGroups.DefaultFilter : btBroadphaseProxy.CollisionFilterGroups.StaticFilter );
				btBroadphaseProxy.CollisionFilterGroups collisionFilterMask = ( isDynamic ? btBroadphaseProxy.CollisionFilterGroups.AllFilter : ( btBroadphaseProxy.CollisionFilterGroups.AllFilter ^ btBroadphaseProxy.CollisionFilterGroups.StaticFilter ) );

				addCollisionObject( body, collisionFilterGroup, collisionFilterMask );
			}
		}
Exemplo n.º 2
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.º 3
0
		internal void synchronizeSingleMotionState( btRigidBody body )
		{
			Debug.Assert( body != null );

			if( body.getMotionState() != null && !body.isStaticOrKinematicObject() )
			{
				//we need to call the update at least once, even for sleeping objects
				//otherwise the 'graphics' transform never updates properly
				///@todo: add 'dirty' flag
				//if (body.getActivationState() != ISLAND_SLEEPING)
				{
					btTransform interpolatedTransform;
					btTransformUtil.integrateTransform( ref body.m_interpolationWorldTransform,
						ref body.m_interpolationLinearVelocity,ref  body.m_interpolationAngularVelocity,
						( m_latencyMotionStateInterpolation && m_fixedTimeStep != 0 ) ? m_localTime - m_fixedTimeStep : m_localTime * body.getHitFraction(),
						out interpolatedTransform );
					btScalar.Dbg( DbgFlag.PredictedTransform, body.m_interpolationWorldTransform.ToString( "old int orn\t", "\t\t", "old int org\t" ) );
					btScalar.Dbg( DbgFlag.PredictedTransform, "Sync transform state " + body.m_interpolationAngularVelocity );
					btScalar.Dbg( DbgFlag.PredictedTransform, interpolatedTransform.ToString( "inter orient\t", "\t\t", "inter origin\t" ) );
                    body.getMotionState().setWorldTransform( ref interpolatedTransform );
				}
			}
		}