aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRobert Adams2012-07-31 09:23:05 -0700
committerRobert Adams2012-07-31 09:23:05 -0700
commit50dbb9ffe480b08f13f7bebb8259193dc00f88dd (patch)
tree20a35e254d4ec9180b75af2e0a02e61dec53e028
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-50dbb9ffe480b08f13f7bebb8259193dc00f88dd.zip
opensim-SC_OLD-50dbb9ffe480b08f13f7bebb8259193dc00f88dd.tar.gz
opensim-SC_OLD-50dbb9ffe480b08f13f7bebb8259193dc00f88dd.tar.bz2
opensim-SC_OLD-50dbb9ffe480b08f13f7bebb8259193dc00f88dd.tar.xz
BulletSim: add parameters and API calls for setting ERP and CFM.
Set ERP and CFM in linkset constraints. Reorder rebuilding of object bodies so they are not rebuilt everytime something is linked and unlinked.
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs12
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs8
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs56
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs38
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs34
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs45
6 files changed, 164 insertions, 29 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
index fbb9e21..07f5a21 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs
@@ -50,7 +50,8 @@ public class BSConstraint : IDisposable
50 m_body2 = obj2; 50 m_body2 = obj2;
51 m_constraint = new BulletConstraint(BulletSimAPI.CreateConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr, 51 m_constraint = new BulletConstraint(BulletSimAPI.CreateConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr,
52 frame1, frame1rot, 52 frame1, frame1rot,
53 frame2, frame2rot)); 53 frame2, frame2rot,
54 true /*useLinearReferenceFrameA*/, true /*disableCollisionsBetweenLinkedBodies*/));
54 m_enabled = true; 55 m_enabled = true;
55 } 56 }
56 57
@@ -83,6 +84,15 @@ public class BSConstraint : IDisposable
83 return ret; 84 return ret;
84 } 85 }
85 86
87 public bool SetCFMAndERP(float cfm, float erp)
88 {
89 bool ret = false;
90 BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL);
91 BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL);
92 BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL);
93 return ret;
94 }
95
86 public bool UseFrameOffset(bool useOffset) 96 public bool UseFrameOffset(bool useOffset)
87 { 97 {
88 bool ret = false; 98 bool ret = false;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs
index a2650fb..c88e645 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs
@@ -83,7 +83,8 @@ public class BSConstraintCollection : IDisposable
83 return true; 83 return true;
84 } 84 }
85 85
86 // Get the constraint between two bodies. There can be only one the way we're using them. 86 // Get the constraint between two bodies. There can be only one.
87 // Return 'true' if a constraint was found.
87 public bool TryGetConstraint(BulletBody body1, BulletBody body2, out BSConstraint returnConstraint) 88 public bool TryGetConstraint(BulletBody body1, BulletBody body2, out BSConstraint returnConstraint)
88 { 89 {
89 bool found = false; 90 bool found = false;
@@ -105,6 +106,9 @@ public class BSConstraintCollection : IDisposable
105 return found; 106 return found;
106 } 107 }
107 108
109 // Remove any constraint between the passed bodies.
110 // Presumed there is only one such constraint possible.
111 // Return 'true' if a constraint was found and destroyed.
108 public bool RemoveAndDestroyConstraint(BulletBody body1, BulletBody body2) 112 public bool RemoveAndDestroyConstraint(BulletBody body1, BulletBody body2)
109 { 113 {
110 // return BulletSimAPI.RemoveConstraint(m_world.ID, obj1.ID, obj2.ID); 114 // return BulletSimAPI.RemoveConstraint(m_world.ID, obj1.ID, obj2.ID);
@@ -125,6 +129,8 @@ public class BSConstraintCollection : IDisposable
125 return ret; 129 return ret;
126 } 130 }
127 131
132 // Remove all constraints that reference the passed body.
133 // Return 'true' if any constraints were destroyed.
128 public bool RemoveAndDestroyConstraint(BulletBody body1) 134 public bool RemoveAndDestroyConstraint(BulletBody body1)
129 { 135 {
130 // return BulletSimAPI.RemoveConstraintByID(m_world.ID, obj.ID); 136 // return BulletSimAPI.RemoveConstraintByID(m_world.ID, obj.ID);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index 3bc2100..6f8430c 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -117,10 +117,50 @@ public class BSLinkset
117 } 117 }
118 118
119 // An existing linkset had one of its members rebuilt or something. 119 // An existing linkset had one of its members rebuilt or something.
120 // Undo all the physical linking and rebuild the physical linkset. 120 // Go through the linkset and rebuild the pointers to the bodies of the linkset members.
121 public bool RefreshLinkset(BSPrim requestor) 121 public BSLinkset RefreshLinkset(BSPrim requestor)
122 { 122 {
123 return true; 123 BSLinkset ret = requestor.Linkset;
124
125 lock (m_linksetActivityLock)
126 {
127 System.IntPtr aPtr = BulletSimAPI.GetBodyHandle2(m_scene.World.Ptr, m_linksetRoot.LocalID);
128 if (aPtr == System.IntPtr.Zero)
129 {
130 // That's odd. We can't find the root of the linkset.
131 // The linkset is somehow dead. The requestor is now a member of a linkset of one.
132 DetailLog("{0},RefreshLinkset.RemoveRoot,child={1}", m_linksetRoot.LocalID, m_linksetRoot.LocalID);
133 ret = RemoveMeFromLinkset(m_linksetRoot);
134 }
135 else
136 {
137 // Reconstruct the pointer to the body of the linkset root.
138 DetailLog("{0},RefreshLinkset.RebuildRoot,rootID={1},ptr={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, aPtr);
139 m_linksetRoot.Body = new BulletBody(m_linksetRoot.LocalID, aPtr);
140
141 List<BSPrim> toRemove = new List<BSPrim>();
142 foreach (BSPrim bsp in m_children)
143 {
144 aPtr = BulletSimAPI.GetBodyHandle2(m_scene.World.Ptr, bsp.LocalID);
145 if (aPtr == System.IntPtr.Zero)
146 {
147 toRemove.Add(bsp);
148 }
149 else
150 {
151 // Reconstruct the pointer to the body of the linkset root.
152 DetailLog("{0},RefreshLinkset.RebuildChild,rootID={1},ptr={2}", bsp.LocalID, m_linksetRoot.LocalID, aPtr);
153 bsp.Body = new BulletBody(bsp.LocalID, aPtr);
154 }
155 }
156 foreach (BSPrim bsp in toRemove)
157 {
158 RemoveChildFromLinkset(bsp);
159 }
160 }
161 }
162
163 return ret;
124 } 164 }
125 165
126 166
@@ -256,10 +296,13 @@ public class BSLinkset
256 DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID); 296 DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID);
257 BSConstraint constrain = m_scene.Constraints.CreateConstraint( 297 BSConstraint constrain = m_scene.Constraints.CreateConstraint(
258 m_scene.World, m_linksetRoot.Body, childPrim.Body, 298 m_scene.World, m_linksetRoot.Body, childPrim.Body,
259 childRelativePosition, 299 // childRelativePosition,
260 childRelativeRotation, 300 // childRelativeRotation,
301 OMV.Vector3.Zero,
302 OMV.Quaternion.Identity,
261 OMV.Vector3.Zero, 303 OMV.Vector3.Zero,
262 OMV.Quaternion.Identity); 304 OMV.Quaternion.Identity
305 );
263 constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); 306 constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero);
264 constrain.SetAngularLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); 307 constrain.SetAngularLimits(OMV.Vector3.Zero, OMV.Vector3.Zero);
265 308
@@ -268,6 +311,7 @@ public class BSLinkset
268 constrain.TranslationalLimitMotor(m_scene.BoolNumeric(m_scene.Params.linkConstraintEnableTransMotor), 311 constrain.TranslationalLimitMotor(m_scene.BoolNumeric(m_scene.Params.linkConstraintEnableTransMotor),
269 m_scene.Params.linkConstraintTransMotorMaxVel, 312 m_scene.Params.linkConstraintTransMotorMaxVel,
270 m_scene.Params.linkConstraintTransMotorMaxForce); 313 m_scene.Params.linkConstraintTransMotorMaxForce);
314 constrain.SetCFMAndERP(m_scene.Params.linkConstraintCFM, m_scene.Params.linkConstraintERP);
271 315
272 } 316 }
273 317
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 7590d93..50d11e6 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -103,7 +103,10 @@ public sealed class BSPrim : PhysicsActor
103 long _collidingGroundStep; 103 long _collidingGroundStep;
104 104
105 private BulletBody m_body; 105 private BulletBody m_body;
106 public BulletBody Body { get { return m_body; } } 106 public BulletBody Body {
107 get { return m_body; }
108 set { m_body = value; }
109 }
107 110
108 private BSDynamics _vehicle; 111 private BSDynamics _vehicle;
109 112
@@ -477,9 +480,11 @@ public sealed class BSPrim : PhysicsActor
477 // Only called at taint time so it is save to call into Bullet. 480 // Only called at taint time so it is save to call into Bullet.
478 private void SetObjectDynamic() 481 private void SetObjectDynamic()
479 { 482 {
480 // m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}", LogHeader, _localID, IsStatic, IsSolid); 483 // RA: remove this for the moment.
481 484 // The problem is that dynamic objects are hulls so if we are becoming physical
482 RecreateGeomAndObject(); 485 // the shape has to be checked and possibly built.
486 // Maybe a VerifyCorrectPhysicalShape() routine?
487 // RecreateGeomAndObject();
483 488
484 float mass = _mass; 489 float mass = _mass;
485 // Bullet wants static objects have a mass of zero 490 // Bullet wants static objects have a mass of zero
@@ -971,21 +976,23 @@ public sealed class BSPrim : PhysicsActor
971 { 976 {
972 DetailLog("{0},CreateGeom,sphere", LocalID); 977 DetailLog("{0},CreateGeom,sphere", LocalID);
973 _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE; 978 _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE;
974 ret = true;
975 // Bullet native objects are scaled by the Bullet engine so pass the size in 979 // Bullet native objects are scaled by the Bullet engine so pass the size in
976 _scale = _size; 980 _scale = _size;
981 // TODO: do we need to check for and destroy a mesh or hull that might have been left from before?
982 ret = true;
977 } 983 }
978 } 984 }
979 } 985 }
980 else 986 else
981 { 987 {
982 // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, size={2}", LogHeader, LocalID, _size); 988 // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, type={2}, size={3}", LogHeader, LocalID, _shapeType, _size);
983 if (_shapeType != ShapeData.PhysicsShapeType.SHAPE_BOX) 989 if (_shapeType != ShapeData.PhysicsShapeType.SHAPE_BOX)
984 { 990 {
985 DetailLog("{0},CreateGeom,box", LocalID); 991 DetailLog("{0},CreateGeom,box", LocalID);
986 _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX; 992 _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX;
987 ret = true;
988 _scale = _size; 993 _scale = _size;
994 // TODO: do we need to check for and destroy a mesh or hull that might have been left from before?
995 ret = true;
989 } 996 }
990 } 997 }
991 } 998 }
@@ -1203,11 +1210,9 @@ public sealed class BSPrim : PhysicsActor
1203 FillShapeInfo(out shape); 1210 FillShapeInfo(out shape);
1204 // m_log.DebugFormat("{0}: CreateObject: lID={1}, shape={2}", LogHeader, _localID, shape.Type); 1211 // m_log.DebugFormat("{0}: CreateObject: lID={1}, shape={2}", LogHeader, _localID, shape.Type);
1205 BulletSimAPI.CreateObject(_scene.WorldID, shape); 1212 BulletSimAPI.CreateObject(_scene.WorldID, shape);
1213
1206 // the CreateObject() may have recreated the rigid body. Make sure we have the latest. 1214 // the CreateObject() may have recreated the rigid body. Make sure we have the latest.
1207 m_body.Ptr = BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID); 1215 m_body.Ptr = BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID);
1208
1209 // The root object could have been recreated. Make sure everything linksety is up to date.
1210 _linkset.RefreshLinkset(this);
1211 } 1216 }
1212 1217
1213 // Copy prim's info into the BulletSim shape description structure 1218 // Copy prim's info into the BulletSim shape description structure
@@ -1236,8 +1241,8 @@ public sealed class BSPrim : PhysicsActor
1236 private void RecreateGeomAndObject() 1241 private void RecreateGeomAndObject()
1237 { 1242 {
1238 // m_log.DebugFormat("{0}: RecreateGeomAndObject. lID={1}", LogHeader, _localID); 1243 // m_log.DebugFormat("{0}: RecreateGeomAndObject. lID={1}", LogHeader, _localID);
1239 CreateGeom(true); 1244 if (CreateGeom(true))
1240 CreateObject(); 1245 CreateObject();
1241 return; 1246 return;
1242 } 1247 }
1243 1248
@@ -1322,6 +1327,15 @@ public sealed class BSPrim : PhysicsActor
1322 1327
1323 base.RequestPhysicsterseUpdate(); 1328 base.RequestPhysicsterseUpdate();
1324 } 1329 }
1330 /*
1331 else
1332 {
1333 // For debugging, we can also report the movement of children
1334 DetailLog("{0},UpdateProperties,child,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
1335 LocalID, entprop.Position, entprop.Rotation, entprop.Velocity,
1336 entprop.Acceleration, entprop.RotationalVelocity);
1337 }
1338 */
1325 } 1339 }
1326 1340
1327 // I've collided with something 1341 // I've collided with something
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index c6d622b..28d5cb5 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -315,6 +315,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
315 public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, bool isFlying) 315 public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, bool isFlying)
316 { 316 {
317 // m_log.DebugFormat("{0}: AddAvatar: {1}", LogHeader, avName); 317 // m_log.DebugFormat("{0}: AddAvatar: {1}", LogHeader, avName);
318
319 if (!m_initialized) return null;
320
318 BSCharacter actor = new BSCharacter(localID, avName, this, position, size, isFlying); 321 BSCharacter actor = new BSCharacter(localID, avName, this, position, size, isFlying);
319 lock (m_avatars) m_avatars.Add(localID, actor); 322 lock (m_avatars) m_avatars.Add(localID, actor);
320 return actor; 323 return actor;
@@ -323,6 +326,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
323 public override void RemoveAvatar(PhysicsActor actor) 326 public override void RemoveAvatar(PhysicsActor actor)
324 { 327 {
325 // m_log.DebugFormat("{0}: RemoveAvatar", LogHeader); 328 // m_log.DebugFormat("{0}: RemoveAvatar", LogHeader);
329
330 if (!m_initialized) return;
331
326 BSCharacter bsactor = actor as BSCharacter; 332 BSCharacter bsactor = actor as BSCharacter;
327 if (bsactor != null) 333 if (bsactor != null)
328 { 334 {
@@ -341,6 +347,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
341 347
342 public override void RemovePrim(PhysicsActor prim) 348 public override void RemovePrim(PhysicsActor prim)
343 { 349 {
350 if (!m_initialized) return;
351
344 BSPrim bsprim = prim as BSPrim; 352 BSPrim bsprim = prim as BSPrim;
345 if (bsprim != null) 353 if (bsprim != null)
346 { 354 {
@@ -366,6 +374,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
366 Vector3 size, Quaternion rotation, bool isPhysical, uint localID) 374 Vector3 size, Quaternion rotation, bool isPhysical, uint localID)
367 { 375 {
368 // m_log.DebugFormat("{0}: AddPrimShape2: {1}", LogHeader, primName); 376 // m_log.DebugFormat("{0}: AddPrimShape2: {1}", LogHeader, primName);
377
378 if (!m_initialized) return null;
379
369 BSPrim prim = new BSPrim(localID, primName, this, position, size, rotation, pbs, isPhysical); 380 BSPrim prim = new BSPrim(localID, primName, this, position, size, rotation, pbs, isPhysical);
370 lock (m_prims) m_prims.Add(localID, prim); 381 lock (m_prims) m_prims.Add(localID, prim);
371 return prim; 382 return prim;
@@ -807,6 +818,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters
807 818
808 // List of all of the externally visible parameters. 819 // List of all of the externally visible parameters.
809 // For each parameter, this table maps a text name to getter and setters. 820 // For each parameter, this table maps a text name to getter and setters.
821 // To add a new externally referencable/settable parameter, add the paramter storage
822 // location somewhere in the program and make an entry in this table with the
823 // getters and setters.
824 // To add a new variable, it is easiest to find an existing definition and copy it.
825 // Parameter values are floats. Booleans are converted to a floating value.
826 //
810 // A ParameterDefn() takes the following parameters: 827 // A ParameterDefn() takes the following parameters:
811 // -- the text name of the parameter. This is used for console input and ini file. 828 // -- the text name of the parameter. This is used for console input and ini file.
812 // -- a short text description of the parameter. This shows up in the console listing. 829 // -- a short text description of the parameter. This shows up in the console listing.
@@ -815,7 +832,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters
815 // -- a delegate for getting the value as a float 832 // -- a delegate for getting the value as a float
816 // -- a delegate for setting the value from a float 833 // -- a delegate for setting the value from a float
817 // 834 //
818 // To add a new variable, it is best to find an existing definition and copy it. 835 // The single letter parameters for the delegates are:
836 // s = BSScene
837 // p = string parameter name
838 // l = localID of referenced object
839 // v = float value
840 // cf = parameter configuration class (for fetching values from ini file)
819 private ParameterDefn[] ParameterDefinitions = 841 private ParameterDefn[] ParameterDefinitions =
820 { 842 {
821 new ParameterDefn("MeshSculptedPrim", "Whether to create meshes for sculpties", 843 new ParameterDefn("MeshSculptedPrim", "Whether to create meshes for sculpties",
@@ -1048,6 +1070,16 @@ public class BSScene : PhysicsScene, IPhysicsParameters
1048 (s,cf,p,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = cf.GetFloat(p, v); }, 1070 (s,cf,p,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = cf.GetFloat(p, v); },
1049 (s) => { return s.m_params[0].linkConstraintTransMotorMaxForce; }, 1071 (s) => { return s.m_params[0].linkConstraintTransMotorMaxForce; },
1050 (s,p,l,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = v; } ), 1072 (s,p,l,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = v; } ),
1073 new ParameterDefn("LinkConstraintCFM", "Amount constraint can be violated. 0=none, 1=all. Default=0",
1074 0.0f,
1075 (s,cf,p,v) => { s.m_params[0].linkConstraintCFM = cf.GetFloat(p, v); },
1076 (s) => { return s.m_params[0].linkConstraintCFM; },
1077 (s,p,l,v) => { s.m_params[0].linkConstraintCFM = v; } ),
1078 new ParameterDefn("LinkConstraintERP", "Amount constraint is corrected each tick. 0=none, 1=all. Default = 0.2",
1079 0.2f,
1080 (s,cf,p,v) => { s.m_params[0].linkConstraintERP = cf.GetFloat(p, v); },
1081 (s) => { return s.m_params[0].linkConstraintERP; },
1082 (s,p,l,v) => { s.m_params[0].linkConstraintERP = v; } ),
1051 1083
1052 new ParameterDefn("DetailedStats", "Frames between outputting detailed phys stats. (0 is off)", 1084 new ParameterDefn("DetailedStats", "Frames between outputting detailed phys stats. (0 is off)",
1053 0f, 1085 0f,
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
index 65e3145..fe705cc 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs
@@ -66,13 +66,14 @@ public struct ShapeData
66{ 66{
67 public enum PhysicsShapeType 67 public enum PhysicsShapeType
68 { 68 {
69 SHAPE_AVATAR = 0, 69 SHAPE_UNKNOWN = 0,
70 SHAPE_BOX = 1, 70 SHAPE_AVATAR = 1,
71 SHAPE_CONE = 2, 71 SHAPE_BOX = 2,
72 SHAPE_CYLINDER = 3, 72 SHAPE_CONE = 3,
73 SHAPE_SPHERE = 4, 73 SHAPE_CYLINDER = 4,
74 SHAPE_MESH = 5, 74 SHAPE_SPHERE = 5,
75 SHAPE_HULL = 6 75 SHAPE_MESH = 6,
76 SHAPE_HULL = 7
76 }; 77 };
77 public uint ID; 78 public uint ID;
78 public PhysicsShapeType Type; 79 public PhysicsShapeType Type;
@@ -168,6 +169,8 @@ public struct ConfigurationParameters
168 public float linkConstraintEnableTransMotor; 169 public float linkConstraintEnableTransMotor;
169 public float linkConstraintTransMotorMaxVel; 170 public float linkConstraintTransMotorMaxVel;
170 public float linkConstraintTransMotorMaxForce; 171 public float linkConstraintTransMotorMaxForce;
172 public float linkConstraintERP;
173 public float linkConstraintCFM;
171 174
172 public const float numericTrue = 1f; 175 public const float numericTrue = 1f;
173 public const float numericFalse = 0f; 176 public const float numericFalse = 0f;
@@ -189,6 +192,28 @@ public enum CollisionFlags : uint
189 PHYSICAL_OBJECT = 1 << 12, 192 PHYSICAL_OBJECT = 1 << 12,
190}; 193};
191 194
195// CFM controls the 'hardness' of the constraint. 0=fixed, 0..1=violatable. Default=0
196// ERP controls amount of correction per tick. Usable range=0.1..0.8. Default=0.2.
197public enum ConstraintParams : int
198{
199 BT_CONSTRAINT_ERP = 1, // this one is not used in Bullet as of 20120730
200 BT_CONSTRAINT_STOP_ERP,
201 BT_CONSTRAINT_CFM,
202 BT_CONSTRAINT_STOP_CFM,
203};
204public enum ConstraintParamAxis : int
205{
206 AXIS_LINEAR_X = 0,
207 AXIS_LINEAR_Y,
208 AXIS_LINEAR_Z,
209 AXIS_ANGULAR_X,
210 AXIS_ANGULAR_Y,
211 AXIS_ANGULAR_Z,
212 AXIS_LINEAR_ALL = 20, // these last three added by BulletSim so we don't have to do zillions of calls
213 AXIS_ANGULAR_ALL,
214 AXIS_ALL
215};
216
192// =============================================================================== 217// ===============================================================================
193static class BulletSimAPI { 218static class BulletSimAPI {
194 219
@@ -380,7 +405,8 @@ public static extern IntPtr CreateObject2(IntPtr sim, ShapeData shapeData);
380[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 405[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
381public static extern IntPtr CreateConstraint2(IntPtr sim, IntPtr obj1, IntPtr obj2, 406public static extern IntPtr CreateConstraint2(IntPtr sim, IntPtr obj1, IntPtr obj2,
382 Vector3 frame1loc, Quaternion frame1rot, 407 Vector3 frame1loc, Quaternion frame1rot,
383 Vector3 frame2loc, Quaternion frame2rot); 408 Vector3 frame2loc, Quaternion frame2rot,
409 bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies);
384 410
385[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 411[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
386public static extern bool SetLinearLimits2(IntPtr constrain, Vector3 low, Vector3 hi); 412public static extern bool SetLinearLimits2(IntPtr constrain, Vector3 low, Vector3 hi);
@@ -398,6 +424,9 @@ public static extern bool TranslationalLimitMotor2(IntPtr constrain, float enabl
398public static extern bool CalculateTransforms2(IntPtr constrain); 424public static extern bool CalculateTransforms2(IntPtr constrain);
399 425
400[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 426[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
427public static extern bool SetConstraintParam2(IntPtr constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis);
428
429[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
401public static extern bool DestroyConstraint2(IntPtr sim, IntPtr constrain); 430public static extern bool DestroyConstraint2(IntPtr sim, IntPtr constrain);
402 431
403[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] 432[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]