void CPhysicsObject::OutputDebugInfo() const { Msg("-----------------\n"); if (m_pName) Msg("Object: %s\n", m_pName); Msg("Mass: %f (inv %f)\n", GetMass(), GetInvMass()); Vector pos; QAngle ang; GetPosition(&pos, &ang); Msg("Position: %f %f %f\nAngle: %f %f %f\n", pos.x, pos.y, pos.z, ang.x, ang.y, ang.z); Vector inertia = GetInertia(); Vector invinertia = GetInvInertia(); Msg("Inertia: %f %f %f (inv %f %f %f)\n", inertia.x, inertia.y, inertia.z, invinertia.x, invinertia.y, invinertia.z); Vector vel; AngularImpulse angvel; GetVelocity(&vel, &angvel); Msg("Velocity: %f, %f, %f\nAng Velocity: %f, %f, %f\n", vel.x, vel.y, vel.z, angvel.x, angvel.y, angvel.z); float dampspeed, damprot; GetDamping(&dampspeed, &damprot); Msg("Damping %f linear, %f angular\n", dampspeed, damprot); Vector dragBasis; Vector angDragBasis; ConvertPosToHL(m_dragBasis, dragBasis); ConvertDirectionToHL(m_angDragBasis, angDragBasis); Msg("Linear Drag: %f, %f, %f (factor %f)\n", dragBasis.x, dragBasis.y, dragBasis.z, m_dragCoefficient); Msg("Angular Drag: %f, %f, %f (factor %f)\n", angDragBasis.x, angDragBasis.y, angDragBasis.z, m_angDragCoefficient); // TODO: Attached to x controllers Msg("State: %s, Collision %s, Motion %s, Drag %s, Flags %04X (game %04x, index %d)\n", IsAsleep() ? "Asleep" : "Awake", IsCollisionEnabled() ? "Enabled" : "Disabled", IsStatic() ? "Static" : IsMotionEnabled() ? "Enabled" : "Disabled", IsDragEnabled() ? "Enabled" : "Disabled", m_pObject->getFlags(), GetGameFlags(), GetGameIndex() ); const char *pMaterialStr = g_SurfaceDatabase.GetPropName(m_materialIndex); surfacedata_t *surfaceData = g_SurfaceDatabase.GetSurfaceData(m_materialIndex); if (surfaceData) { Msg("Material: %s : density(%f), thickness(%f), friction(%f), elasticity(%f)\n", pMaterialStr, surfaceData->physics.density, surfaceData->physics.thickness, surfaceData->physics.friction, surfaceData->physics.elasticity); } Msg("-- COLLISION SHAPE INFO --\n"); g_PhysicsCollision.OutputDebugInfo((CPhysCollide *)m_pObject->getCollisionShape()->getUserPointer()); }
void CPhysicsObject::EnableDrag(bool enable) { if (IsStatic() || enable == IsDragEnabled()) return; if (enable) { m_pEnv->GetDragController()->AddPhysicsObject(this); } else { m_pEnv->GetDragController()->RemovePhysicsObject(this); } }
void CPhysicsObject::EnableDrag( bool enable ) { if ( IsStatic() ) return; bool isEnabled = IsDragEnabled(); if ( enable == isEnabled ) return; IVP_Controller *pDrag = GetVPhysicsEnvironment()->GetDragController(); if ( enable ) { m_pObject->get_core()->add_core_controller( pDrag ); } else { m_pObject->get_core()->rem_core_controller( pDrag ); } }
void CPhysicsObject::WriteToTemplate( vphysics_save_cphysicsobject_t &objectTemplate ) { if ( m_collideType == COLLIDE_BALL ) { objectTemplate.pCollide = NULL; objectTemplate.sphereRadius = GetSphereRadius(); } else { objectTemplate.pCollide = GetCollide(); objectTemplate.sphereRadius = 0; } objectTemplate.isStatic = IsStatic(); objectTemplate.collisionEnabled = IsCollisionEnabled(); objectTemplate.gravityEnabled = IsGravityEnabled(); objectTemplate.dragEnabled = IsDragEnabled(); objectTemplate.motionEnabled = IsMotionEnabled(); objectTemplate.isAsleep = IsAsleep(); objectTemplate.isTrigger = IsTrigger(); objectTemplate.materialIndex = m_materialIndex; objectTemplate.mass = GetMass(); objectTemplate.rotInertia = GetInertia(); GetDamping( &objectTemplate.speedDamping, &objectTemplate.rotSpeedDamping ); objectTemplate.massCenterOverride = m_massCenterOverride; objectTemplate.callbacks = m_callbacks; objectTemplate.gameFlags = m_gameFlags; objectTemplate.volume = GetVolume(); objectTemplate.dragCoefficient = m_dragCoefficient; objectTemplate.angDragCoefficient = m_angDragCoefficient; objectTemplate.pShadow = m_pShadow; objectTemplate.hasShadowController = (m_pShadow != NULL) ? true : false; //bool m_shadowTempGravityDisable; objectTemplate.collideType = m_collideType; objectTemplate.contentsMask = m_contentsMask; GetPosition( &objectTemplate.origin, &objectTemplate.angles ); GetVelocity( &objectTemplate.velocity, &objectTemplate.angVelocity ); }