From 38e79b80a87d213748d55d66e8b72021999d3945 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 9 Aug 2012 15:01:05 -0700 Subject: BulletSim: separate out the constraints by type. The linksets use 6dof constraint but eventually others will be exposed so future features can use all the Bullet capabilities. Force children to generate a position update when unlinked. --- .../Region/Physics/BulletSPlugin/BSConstraint.cs | 60 ++++------------------ 1 file changed, 11 insertions(+), 49 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs index ea3093a..a17efea 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs @@ -32,30 +32,19 @@ using OpenMetaverse; namespace OpenSim.Region.Physics.BulletSPlugin { -public class BSConstraint : IDisposable +public abstract class BSConstraint : IDisposable { - private BulletSim m_world; - private BulletBody m_body1; - private BulletBody m_body2; - private BulletConstraint m_constraint; - private bool m_enabled = false; + protected BulletSim m_world; + protected BulletBody m_body1; + protected BulletBody m_body2; + protected BulletConstraint m_constraint; + protected bool m_enabled = false; - public BSConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, - Vector3 frame1, Quaternion frame1rot, - Vector3 frame2, Quaternion frame2rot - ) + public BSConstraint() { - m_world = world; - m_body1 = obj1; - m_body2 = obj2; - m_constraint = new BulletConstraint(BulletSimAPI.CreateConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr, - frame1, frame1rot, - frame2, frame2rot, - true /*useLinearReferenceFrameA*/, true /*disableCollisionsBetweenLinkedBodies*/)); - m_enabled = true; } - public void Dispose() + public virtual void Dispose() { if (m_enabled) { @@ -68,7 +57,7 @@ public class BSConstraint : IDisposable public BulletBody Body1 { get { return m_body1; } } public BulletBody Body2 { get { return m_body2; } } - public bool SetLinearLimits(Vector3 low, Vector3 high) + public virtual bool SetLinearLimits(Vector3 low, Vector3 high) { bool ret = false; if (m_enabled) @@ -76,7 +65,7 @@ public class BSConstraint : IDisposable return ret; } - public bool SetAngularLimits(Vector3 low, Vector3 high) + public virtual bool SetAngularLimits(Vector3 low, Vector3 high) { bool ret = false; if (m_enabled) @@ -84,34 +73,7 @@ public class BSConstraint : IDisposable return ret; } - public bool SetCFMAndERP(float cfm, float erp) - { - bool ret = true; - BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL); - BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL); - BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL); - return ret; - } - - public bool UseFrameOffset(bool useOffset) - { - bool ret = false; - float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; - if (m_enabled) - ret = BulletSimAPI.UseFrameOffset2(m_constraint.Ptr, onOff); - return ret; - } - - public bool TranslationalLimitMotor(bool enable, float targetVelocity, float maxMotorForce) - { - bool ret = false; - float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; - if (m_enabled) - ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.Ptr, onOff, targetVelocity, maxMotorForce); - return ret; - } - - public bool CalculateTransforms() + public virtual bool CalculateTransforms() { bool ret = false; if (m_enabled) -- cgit v1.1