예제 #1
0
void BtBody::applyImpulse( const Point3F &origin, const Point3F &force )
{
   AssertFatal( mActor, "BtBody::applyImpulse - The actor is null!" );
   AssertFatal( isDynamic(), "BtBody::applyImpulse - This call is only for dynamics!" );

   // Convert the world position to local
   MatrixF trans = btCast<MatrixF>( mActor->getCenterOfMassTransform() );
   trans.inverse();
   Point3F localOrigin( origin );
   trans.mulP( localOrigin );

   if ( mCenterOfMass )
   {
      Point3F relOrigin( localOrigin );
      mCenterOfMass->mulP( relOrigin );
      Point3F relForce( force );
      mCenterOfMass->mulV( relForce );
      mActor->applyImpulse( btCast<btVector3>( relForce ), btCast<btVector3>( relOrigin ) );
   }
   else
      mActor->applyImpulse( btCast<btVector3>( force ), btCast<btVector3>( localOrigin ) );

   if ( !mActor->isActive() )
      mActor->activate();
}
void btHeightfieldTerrainShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
{
	btVector3 halfExtents = (m_localAabbMax-m_localAabbMin)* m_localScaling * btScalar(0.5);

	btVector3 localOrigin(0, 0, 0);
	localOrigin[m_upAxis] = (m_minHeight + m_maxHeight) * btScalar(0.5);
	localOrigin *= m_localScaling;

	btMatrix3x3 abs_b = t.getBasis().absolute();  
	btVector3 center = t.getOrigin();
    btVector3 extent = halfExtents.dot3(abs_b[0], abs_b[1], abs_b[2]);
	extent += btVector3(getMargin(),getMargin(),getMargin());

	aabbMin = center - extent;
	aabbMax = center + extent;
}
/*
============
hhPhysics_StaticWeapon::Evaluate
============
*/
bool hhPhysics_StaticWeapon::Evaluate( int timeStepMSec, int endTimeMSec ) {
	if( !selfOwner ) {
		return false;
	}

	idMat3 localAxis;
	idVec3 localOrigin( 0.0f, 0.0f, selfOwner->EyeHeight() );
	idAngles pitchAngles( selfOwner->GetUntransformedViewAngles().pitch, 0.0f, 0.0f );

	if( selfOwner->InVehicle() ) {
		localAxis = pitchAngles.ToMat3();
	} else {
		localAxis = ( pitchAngles + selfOwner->GunTurningOffset() ).ToMat3();
		localOrigin += selfOwner->GunAcceleratingOffset();
		if ( castSelf ) {
			castSelf->MuzzleRise( localOrigin, localAxis );
		}
	}

	SetLocalAxis( localAxis );
	SetLocalOrigin( localOrigin );

	return idPhysics_Static::Evaluate( timeStepMSec, endTimeMSec );
}