From 1dc23b2b9713f4099534ae0d08c2caf5c8b036b4 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 2 Nov 2012 10:35:12 -0700 Subject: [PATCH] BulletSim: parameterize selection of linkset implementation --- .../Region/Physics/BulletSPlugin/BSLinkset.cs | 28 ++++++++++++------- .../Region/Physics/BulletSPlugin/BSScene.cs | 5 ++++ .../Physics/BulletSPlugin/BulletSimAPI.cs | 1 + 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 8f973f4f5d..3a92f9361a 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -36,21 +36,29 @@ public abstract class BSLinkset { // private static string LogHeader = "[BULLETSIM LINKSET]"; + public enum LinksetImplementation + { + Constraint = 0, // linkset tied together with constraints + Compound = 1, // linkset tied together as a compound object + Manual = 2 // linkset tied together manually (code moves all the pieces) + } // Create the correct type of linkset for this child public static BSLinkset Factory(BSScene physScene, BSPhysObject parent) { BSLinkset ret = null; - /* - if (parent.IsPhysical) - ret = new BSLinksetConstraints(physScene, parent); - else - ret = new BSLinksetManual(physScene, parent); - */ - - // at the moment, there is only one - // ret = new BSLinksetConstraints(physScene, parent); - ret = new BSLinksetCompound(physScene, parent); + switch ((int)physScene.Params.linksetImplementation) + { + case (int)LinksetImplementation.Compound: + ret = new BSLinksetCompound(physScene, parent); + break; + case (int)LinksetImplementation.Manual: + // ret = new BSLinksetManual(physScene, parent); + break; + default: + ret = new BSLinksetConstraints(physScene, parent); + break; + } return ret; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index dcfcb8380c..13aa8605d2 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -1214,6 +1214,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters (s) => { return s.m_params[0].numberOfSolverIterations; }, (s,p,l,v) => { s.m_params[0].numberOfSolverIterations = v; } ), + new ParameterDefn("LinksetImplementation", "Type of linkset implementation (0=Constraint, 1=Compound)", + (float)BSLinkset.LinksetImplementation.Constraint, + (s,cf,p,v) => { s.m_params[0].linksetImplementation = cf.GetFloat(p,v); }, + (s) => { return s.m_params[0].linksetImplementation; }, + (s,p,l,v) => { s.m_params[0].linksetImplementation = v; } ), new ParameterDefn("LinkConstraintUseFrameOffset", "For linksets built with constraints, enable frame offsetFor linksets built with constraints, enable frame offset.", ConfigurationParameters.numericFalse, (s,cf,p,v) => { s.m_params[0].linkConstraintUseFrameOffset = s.NumericBool(cf.GetBoolean(p, s.BoolNumeric(v))); }, diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index 143b8beca1..ac6d2b207b 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs @@ -300,6 +300,7 @@ public struct ConfigurationParameters public float shouldEnableFrictionCaching; public float numberOfSolverIterations; + public float linksetImplementation; public float linkConstraintUseFrameOffset; public float linkConstraintEnableTransMotor; public float linkConstraintTransMotorMaxVel;