From d7add2940a38437e748ca74163bbf37acecfa04c Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 25 Jul 2012 14:52:17 -0700 Subject: BulletSim: add parameters for setting linkset constraint factors --- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 24 +++++++++--------------- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 25 +++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 17 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 6c8ae2e..3be28e3 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -1295,10 +1295,9 @@ public sealed class BSPrim : PhysicsActor // relative to each other. void CreateLinkset() { - DebugLog("{0}: CreateLinkset. Root prim={1}, prims={2}", LogHeader, LocalID, _childrenPrims.Count+1); + // DebugLog("{0}: CreateLinkset. Root prim={1}, prims={2}", LogHeader, LocalID, _childrenPrims.Count+1); // remove any constraints that might be in place - DebugLog("{0}: CreateLinkset: RemoveConstraints between me and any children", LogHeader, LocalID); UnlinkAllChildren(); // create constraints between the root prim and each of the children @@ -1324,18 +1323,8 @@ public sealed class BSPrim : PhysicsActor // create a constraint that allows no freedom of movement between the two objects // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 - DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, childPrim.LocalID); + // DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, childPrim.LocalID); DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", LocalID, LocalID, childPrim.LocalID); - /* - BulletSimAPI.AddConstraint(_scene.WorldID, LocalID, childPrim.LocalID, - childRelativePosition, - childRelativeRotation, - OMV.Vector3.Zero, - OMV.Quaternion.Identity, - OMV.Vector3.Zero, OMV.Vector3.Zero, - OMV.Vector3.Zero, OMV.Vector3.Zero); - */ - // BSConstraint constrain = new BSConstraint(_scene.World, this.Body, childPrim.Body, BSConstraint constrain = _scene.Constraints.CreateConstraint( _scene.World, this.Body, childPrim.Body, childRelativePosition, @@ -1346,8 +1335,13 @@ public sealed class BSPrim : PhysicsActor constrain.SetAngularLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); // tweek the constraint to increase stability - constrain.UseFrameOffset(true); - constrain.TranslationalLimitMotor(true, 5f, 0.1f); + constrain.UseFrameOffset(_scene.BoolNumeric(_scene.Params.linkConstraintUseFrameOffset)); + if (_scene.BoolNumeric(_scene.Params.linkConstraintEnableTransMotor)) + { + constrain.TranslationalLimitMotor(true, + _scene.Params.linkConstraintTransMotorMaxVel, + _scene.Params.linkConstraintTransMotorMaxForce); + } } // Remove linkage between myself and a particular child diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 07a377b..a1587a8 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -1025,6 +1025,27 @@ public class BSScene : PhysicsScene, IPhysicsParameters (s) => { return s.m_params[0].numberOfSolverIterations; }, (s,p,l,v) => { s.m_params[0].numberOfSolverIterations = v; } ), + new ParameterDefn("LinkConstraintUseFrameOffset", "For linksets built with constraints, enable frame offsetFor linksets built with constraints, enable frame offset.", + ConfigurationParameters.numericTrue, + (s,cf,p,v) => { s.m_params[0].linkConstraintUseFrameOffset = s.NumericBool(cf.GetBoolean(p, s.BoolNumeric(v))); }, + (s) => { return s.m_params[0].linkConstraintUseFrameOffset; }, + (s,p,l,v) => { s.m_params[0].linkConstraintUseFrameOffset = v; } ), + new ParameterDefn("LinkConstraintEnableTransMotor", "Whether to enable translational motor on linkset constraints", + ConfigurationParameters.numericTrue, + (s,cf,p,v) => { s.m_params[0].linkConstraintEnableTransMotor = s.NumericBool(cf.GetBoolean(p, s.BoolNumeric(v))); }, + (s) => { return s.m_params[0].linkConstraintEnableTransMotor; }, + (s,p,l,v) => { s.m_params[0].linkConstraintEnableTransMotor = v; } ), + new ParameterDefn("LinkConstraintTransMotorMaxVel", "Maximum velocity to be applied by translational motor in linkset constraints", + 5.0f, + (s,cf,p,v) => { s.m_params[0].linkConstraintTransMotorMaxVel = cf.GetFloat(p, v); }, + (s) => { return s.m_params[0].linkConstraintTransMotorMaxVel; }, + (s,p,l,v) => { s.m_params[0].linkConstraintTransMotorMaxVel = v; } ), + new ParameterDefn("LinkConstraintTransMotorMaxForce", "Maximum force to be applied by translational motor in linkset constraints", + 0.1f, + (s,cf,p,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = cf.GetFloat(p, v); }, + (s) => { return s.m_params[0].linkConstraintTransMotorMaxForce; }, + (s,p,l,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = v; } ), + new ParameterDefn("DetailedStats", "Frames between outputting detailed phys stats. (0 is off)", 0f, (s,cf,p,v) => { s.m_detailedStatsStep = cf.GetInt(p, (int)v); }, @@ -1039,13 +1060,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters }; // Convert a boolean to our numeric true and false values - protected float NumericBool(bool b) + public float NumericBool(bool b) { return (b ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse); } // Convert numeric true and false values to a boolean - protected bool BoolNumeric(float b) + public bool BoolNumeric(float b) { return (b == ConfigurationParameters.numericTrue ? true : false); } -- cgit v1.1