From 3511f8ef9fe6a2a6491fbae3a44a407f280a19e0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 14 Apr 2009 12:34:39 +0000 Subject: BGE Physics Clamp objects min/max velocity. Accessed with bullet physics from the advanced button with dynamic and rigid body objects. - useful for preventing unstable physics in cases where objects move too fast. - can add linear velocity with the motion actuator to give smooth motion transitions, without moving too fast. - minimum velocity means objects don't stop moving. - python scripts can adjust these values speedup or throttle velocity in the existing direction. Also made copy properties from an object with no properties work (in case you want to clear all props) --- .../Physics/Bullet/CcdPhysicsController.h | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'source/gameengine/Physics/Bullet/CcdPhysicsController.h') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 245cde2baaa..c7638b36728 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -214,6 +214,8 @@ struct CcdConstructionInfo m_gravity(0,0,0), m_scaling(1.f,1.f,1.f), m_mass(0.f), + m_clamp_vel_min(-1.f), + m_clamp_vel_max(-1.f), m_restitution(0.1f), m_friction(0.5f), m_linearDamping(0.1f), @@ -239,6 +241,8 @@ struct CcdConstructionInfo btVector3 m_gravity; btVector3 m_scaling; btScalar m_mass; + btScalar m_clamp_vel_min; + btScalar m_clamp_vel_max; btScalar m_restitution; btScalar m_friction; btScalar m_linearDamping; @@ -479,7 +483,24 @@ class CcdPhysicsController : public PHY_IPhysicsController } m_cci.m_radius = margin; } - + + // velocity clamping + virtual void SetLinVelocityMin(float val) + { + m_cci.m_clamp_vel_min= val; + } + virtual float GetLinVelocityMin() const + { + return m_cci.m_clamp_vel_min; + } + virtual void SetLinVelocityMax(float val) + { + m_cci.m_clamp_vel_max= val; + } + virtual float GetLinVelocityMax() const + { + return m_cci.m_clamp_vel_max; + } bool wantsSleeping(); -- cgit v1.2.3