|
|
|
@ -592,7 +592,8 @@ void CPhysicsObject::SetMass( float mass )
@@ -592,7 +592,8 @@ void CPhysicsObject::SetMass( float mass )
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Assert( mass > 0 ); |
|
|
|
|
mass = clamp( mass, 0, VPHYSICS_MAX_MASS ); // NOTE: Allow zero procedurally, but not by initialization
|
|
|
|
|
|
|
|
|
|
mass = clamp( mass, 1.f, VPHYSICS_MAX_MASS ); |
|
|
|
|
m_pObject->change_mass( mass ); |
|
|
|
|
SetVolume( m_volume ); |
|
|
|
|
RecomputeDragBases(); |
|
|
|
@ -633,13 +634,17 @@ Vector CPhysicsObject::GetInvInertia( void ) const
@@ -633,13 +634,17 @@ Vector CPhysicsObject::GetInvInertia( void ) const
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CPhysicsObject::SetInertia( const Vector &inertia ) |
|
|
|
|
{ |
|
|
|
|
IVP_U_Float_Point ri; |
|
|
|
|
ConvertDirectionToIVP( inertia, ri ); |
|
|
|
|
IVP_U_Float_Point ri; ConvertDirectionToIVP( inertia, ri ); |
|
|
|
|
ri.k[0] = IVP_Inline_Math::fabsd(ri.k[0]); |
|
|
|
|
ri.k[1] = IVP_Inline_Math::fabsd(ri.k[1]); |
|
|
|
|
ri.k[2] = IVP_Inline_Math::fabsd(ri.k[2]); |
|
|
|
|
|
|
|
|
|
if( ri.k[0] > 1e14f ) ri.k[0] = 1e14f; if( ri.k[1] > 1e14f ) ri.k[1] = 1e14f; if( ri.k[2] > 1e14f ) ri.k[2] = 1e14f; |
|
|
|
|
if( ri.k[0] <= 0 ) ri.k[0] = 1.f; if( ri.k[1] <= 0 ) ri.k[1] = 1.f; if( ri.k[2] <= 0 ) ri.k[2] = 1.f; |
|
|
|
|
|
|
|
|
|
m_pObject->get_core()->set_rotation_inertia( &ri ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1358,6 +1363,7 @@ bool CPhysicsObject::IsFluid() const
@@ -1358,6 +1363,7 @@ bool CPhysicsObject::IsFluid() const
|
|
|
|
|
// sets the object to be hinged. Fixed it place, but able to rotate around one axis.
|
|
|
|
|
void CPhysicsObject::BecomeHinged( int localAxis ) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if ( IsMoveable() ) |
|
|
|
|
{ |
|
|
|
|
float savedMass = GetMass(); |
|
|
|
@ -1370,6 +1376,7 @@ void CPhysicsObject::BecomeHinged( int localAxis )
@@ -1370,6 +1376,7 @@ void CPhysicsObject::BecomeHinged( int localAxis )
|
|
|
|
|
|
|
|
|
|
SetMass( VPHYSICS_MAX_MASS ); |
|
|
|
|
IVP_U_Float_Hesse tmp = *iri; |
|
|
|
|
|
|
|
|
|
#if 0 |
|
|
|
|
for ( i = 0; i < 3; i++ ) |
|
|
|
|
tmp.k[i] = savedRI[i]; |
|
|
|
@ -1394,10 +1401,10 @@ void CPhysicsObject::RemoveHinged()
@@ -1394,10 +1401,10 @@ void CPhysicsObject::RemoveHinged()
|
|
|
|
|
void CPhysicsObject::OutputDebugInfo() const |
|
|
|
|
{ |
|
|
|
|
Msg("-----------------\nObject: %s\n", m_pObject->get_name()); |
|
|
|
|
Msg("Mass: %.1f (inv %.3f)\n", GetMass(), GetInvMass() ); |
|
|
|
|
Msg("Mass: %.3e (inv %.3e)\n", GetMass(), GetInvMass() ); |
|
|
|
|
Vector inertia = GetInertia(); |
|
|
|
|
Vector invInertia = GetInvInertia(); |
|
|
|
|
Msg("Inertia: %.2f, %.2f, %.2f (inv %.3f, %.3f, %.3f)\n", inertia.x, inertia.y, inertia.z, invInertia.x, invInertia.y, invInertia.z ); |
|
|
|
|
Msg("Inertia: %.3e, %.3e, %.3e (inv %.3e, %.3e, %.3e)\n", inertia.x, inertia.y, inertia.z, invInertia.x, invInertia.y, invInertia.z ); |
|
|
|
|
|
|
|
|
|
Vector speed, angSpeed; |
|
|
|
|
GetVelocity( &speed, &angSpeed ); |
|
|
|
@ -1406,7 +1413,7 @@ void CPhysicsObject::OutputDebugInfo() const
@@ -1406,7 +1413,7 @@ void CPhysicsObject::OutputDebugInfo() const
|
|
|
|
|
|
|
|
|
|
float damp, angDamp; |
|
|
|
|
GetDamping( &damp, &angDamp ); |
|
|
|
|
Msg("Damping %.2f linear, %.2f angular\n", damp, angDamp ); |
|
|
|
|
Msg("Damping %.3e linear, %.3e angular\n", damp, angDamp ); |
|
|
|
|
|
|
|
|
|
Msg("Linear Drag: %.2f, %.2f, %.2f (factor %.2f)\n", m_dragBasis.x, m_dragBasis.y, m_dragBasis.z, m_dragCoefficient ); |
|
|
|
|
Msg("Angular Drag: %.2f, %.2f, %.2f (factor %.2f)\n", m_angDragBasis.x, m_angDragBasis.y, m_angDragBasis.z, m_angDragCoefficient ); |
|
|
|
@ -1462,8 +1469,7 @@ bool CPhysicsObject::IsAttachedToConstraint( bool bExternalOnly ) const
@@ -1462,8 +1469,7 @@ bool CPhysicsObject::IsAttachedToConstraint( bool bExternalOnly ) const
|
|
|
|
|
|
|
|
|
|
static void InitObjectTemplate( IVP_Template_Real_Object &objectTemplate, int materialIndex, objectparams_t *pParams, bool isStatic ) |
|
|
|
|
{ |
|
|
|
|
objectTemplate.mass = pParams->mass; |
|
|
|
|
objectTemplate.mass = clamp( objectTemplate.mass, VPHYSICS_MIN_MASS, VPHYSICS_MAX_MASS ); |
|
|
|
|
objectTemplate.mass = clamp( pParams->mass, VPHYSICS_MIN_MASS, VPHYSICS_MAX_MASS ); |
|
|
|
|
|
|
|
|
|
if ( materialIndex >= 0 ) |
|
|
|
|
{ |
|
|
|
@ -1495,8 +1501,8 @@ static void InitObjectTemplate( IVP_Template_Real_Object &objectTemplate, int ma
@@ -1495,8 +1501,8 @@ static void InitObjectTemplate( IVP_Template_Real_Object &objectTemplate, int ma
|
|
|
|
|
if ( inertia <= 0 ) |
|
|
|
|
inertia = 1.0; |
|
|
|
|
|
|
|
|
|
if ( inertia > 1e18f ) |
|
|
|
|
inertia = 1e18f; |
|
|
|
|
if ( inertia > 1e14f ) |
|
|
|
|
inertia = 1e14f; |
|
|
|
|
|
|
|
|
|
objectTemplate.rot_inertia.set(inertia, inertia, inertia); |
|
|
|
|
objectTemplate.rot_speed_damp_factor.set(pParams->rotdamping, pParams->rotdamping, pParams->rotdamping); |
|
|
|
|