aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin
diff options
context:
space:
mode:
authorRobert Adams2012-08-08 13:48:49 -0700
committerRobert Adams2012-08-08 13:48:49 -0700
commit5ab151c2d69277b8c528b8ebe94d2b0d2312a2fc (patch)
tree2cd84dea4822aa671aa04bbfe94d1fde2e1df0d2 /OpenSim/Region/Physics/BulletSPlugin
parentBulletSim: Added avatar capsule scaling for size of avatar. (diff)
downloadopensim-SC_OLD-5ab151c2d69277b8c528b8ebe94d2b0d2312a2fc.zip
opensim-SC_OLD-5ab151c2d69277b8c528b8ebe94d2b0d2312a2fc.tar.gz
opensim-SC_OLD-5ab151c2d69277b8c528b8ebe94d2b0d2312a2fc.tar.bz2
opensim-SC_OLD-5ab151c2d69277b8c528b8ebe94d2b0d2312a2fc.tar.xz
BulletSim: add avatar code to keep avatars from ending up trapped under the terrain
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs56
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs13
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs4
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs26
4 files changed, 46 insertions, 53 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index d4f5c63..8149a53 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -205,6 +205,8 @@ public class BSCharacter : PhysicsActor
205 } 205 }
206 set { 206 set {
207 _position = value; 207 _position = value;
208 PositionSanityCheck();
209
208 _scene.TaintedObject(delegate() 210 _scene.TaintedObject(delegate()
209 { 211 {
210 DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); 212 DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
@@ -212,6 +214,28 @@ public class BSCharacter : PhysicsActor
212 }); 214 });
213 } 215 }
214 } 216 }
217
218 // Check that the current position is sane and, if not, modify the position to make it so.
219 // Check for being below terrain and being out of bounds.
220 // Returns 'true' of the position was made sane by some action.
221 private bool PositionSanityCheck()
222 {
223 bool ret = false;
224
225 // If below the ground, move the avatar up
226 float terrainHeight = Scene.GetTerrainHeightAtXYZ(_position);
227 if (_position.Z < terrainHeight)
228 {
229 DetailLog("{0},PositionAdjustUnderGround,call,pos={1},orient={2}", LocalID, _position, _orientation);
230 _position.Z = terrainHeight + 2.0f;
231 ret = true;
232 }
233
234 // TODO: check for out of bounds
235
236 return ret;
237 }
238
215 public override float Mass { 239 public override float Mass {
216 get { 240 get {
217 return _mass; 241 return _mass;
@@ -456,42 +480,12 @@ public class BSCharacter : PhysicsActor
456 // the world that things have changed. 480 // the world that things have changed.
457 public void UpdateProperties(EntityProperties entprop) 481 public void UpdateProperties(EntityProperties entprop)
458 { 482 {
459 /*
460 bool changed = false;
461 // we assign to the local variables so the normal set action does not happen
462 if (_position != entprop.Position) {
463 _position = entprop.Position;
464 changed = true;
465 }
466 if (_orientation != entprop.Rotation) {
467 _orientation = entprop.Rotation;
468 changed = true;
469 }
470 if (_velocity != entprop.Velocity) {
471 _velocity = entprop.Velocity;
472 changed = true;
473 }
474 if (_acceleration != entprop.Acceleration) {
475 _acceleration = entprop.Acceleration;
476 changed = true;
477 }
478 if (_rotationalVelocity != entprop.RotationalVelocity) {
479 _rotationalVelocity = entprop.RotationalVelocity;
480 changed = true;
481 }
482 if (changed) {
483 // m_log.DebugFormat("{0}: UpdateProperties: id={1}, c={2}, pos={3}, rot={4}", LogHeader, LocalID, changed, _position, _orientation);
484 // Avatar movement is not done by generating this event. There is code in the heartbeat
485 // loop that updates avatars.
486 // base.RequestPhysicsterseUpdate();
487 }
488 */
489 _position = entprop.Position; 483 _position = entprop.Position;
490 _orientation = entprop.Rotation; 484 _orientation = entprop.Rotation;
491 _velocity = entprop.Velocity; 485 _velocity = entprop.Velocity;
492 _acceleration = entprop.Acceleration; 486 _acceleration = entprop.Acceleration;
493 _rotationalVelocity = entprop.RotationalVelocity; 487 _rotationalVelocity = entprop.RotationalVelocity;
494 // Avatars don't report theirr changes the usual way. Changes are checked for in the heartbeat loop. 488 // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop.
495 // base.RequestPhysicsterseUpdate(); 489 // base.RequestPhysicsterseUpdate();
496 } 490 }
497 491
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index 6f8430c..d19c4b8 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -296,13 +296,13 @@ public class BSLinkset
296 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);
297 BSConstraint constrain = m_scene.Constraints.CreateConstraint( 297 BSConstraint constrain = m_scene.Constraints.CreateConstraint(
298 m_scene.World, m_linksetRoot.Body, childPrim.Body, 298 m_scene.World, m_linksetRoot.Body, childPrim.Body,
299 // childRelativePosition, 299 childRelativePosition,
300 // childRelativeRotation, 300 childRelativeRotation,
301 OMV.Vector3.Zero, 301 OMV.Vector3.Zero,
302 OMV.Quaternion.Identity, 302 -childRelativeRotation
303 OMV.Vector3.Zero,
304 OMV.Quaternion.Identity
305 ); 303 );
304
305 // zero linear and angular limits makes the objects unable to move in relation to each other
306 constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); 306 constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero);
307 constrain.SetAngularLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); 307 constrain.SetAngularLimits(OMV.Vector3.Zero, OMV.Vector3.Zero);
308 308
@@ -339,7 +339,8 @@ public class BSLinkset
339 // Invoke the detailed logger and output something if it's enabled. 339 // Invoke the detailed logger and output something if it's enabled.
340 private void DebugLog(string msg, params Object[] args) 340 private void DebugLog(string msg, params Object[] args)
341 { 341 {
342 m_scene.Logger.DebugFormat(msg, args); 342 if (m_scene.ShouldDebugLog)
343 m_scene.Logger.DebugFormat(msg, args);
343 } 344 }
344 345
345 // Invoke the detailed logger and output something if it's enabled. 346 // Invoke the detailed logger and output something if it's enabled.
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 11868bc..98b69b1 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -42,7 +42,7 @@ public sealed class BSPrim : PhysicsActor
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 private static readonly string LogHeader = "[BULLETS PRIM]"; 43 private static readonly string LogHeader = "[BULLETS PRIM]";
44 44
45 private void DebugLog(string mm, params Object[] xx) { if (_scene.shouldDebugLog) m_log.DebugFormat(mm, xx); } 45 private void DebugLog(string mm, params Object[] xx) { if (_scene.ShouldDebugLog) m_log.DebugFormat(mm, xx); }
46 46
47 private IMesh _mesh; 47 private IMesh _mesh;
48 private PrimitiveBaseShape _pbs; 48 private PrimitiveBaseShape _pbs;
@@ -1338,7 +1338,6 @@ public sealed class BSPrim : PhysicsActor
1338 1338
1339 base.RequestPhysicsterseUpdate(); 1339 base.RequestPhysicsterseUpdate();
1340 } 1340 }
1341 /*
1342 else 1341 else
1343 { 1342 {
1344 // For debugging, we also report the movement of children 1343 // For debugging, we also report the movement of children
@@ -1346,7 +1345,6 @@ public sealed class BSPrim : PhysicsActor
1346 LocalID, entprop.Position, entprop.Rotation, entprop.Velocity, 1345 LocalID, entprop.Position, entprop.Rotation, entprop.Velocity,
1347 entprop.Acceleration, entprop.RotationalVelocity); 1346 entprop.Acceleration, entprop.RotationalVelocity);
1348 } 1347 }
1349 */
1350 } 1348 }
1351 1349
1352 // I've collided with something 1350 // I've collided with something
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 0e257b6..117086a 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -73,7 +73,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
73 private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 73 private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
74 private static readonly string LogHeader = "[BULLETS SCENE]"; 74 private static readonly string LogHeader = "[BULLETS SCENE]";
75 75
76 public void DebugLog(string mm, params Object[] xx) { if (shouldDebugLog) m_log.DebugFormat(mm, xx); } 76 public void DebugLog(string mm, params Object[] xx) { if (ShouldDebugLog) m_log.DebugFormat(mm, xx); }
77 77
78 public string BulletSimVersion = "?"; 78 public string BulletSimVersion = "?";
79 79
@@ -169,7 +169,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
169 ConfigurationParameters[] m_params; 169 ConfigurationParameters[] m_params;
170 GCHandle m_paramsHandle; 170 GCHandle m_paramsHandle;
171 171
172 public bool shouldDebugLog { get; private set; } 172 public bool ShouldDebugLog { get; private set; }
173 173
174 private BulletSimAPI.DebugLogCallback m_DebugLogCallbackHandle; 174 private BulletSimAPI.DebugLogCallback m_DebugLogCallbackHandle;
175 175
@@ -812,12 +812,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters
812 812
813 private struct ParameterDefn 813 private struct ParameterDefn
814 { 814 {
815 public string name; 815 public string name; // string name of the parameter
816 public string desc; 816 public string desc; // a short description of what the parameter means
817 public float defaultValue; 817 public float defaultValue; // default value if not specified anywhere else
818 public ParamUser userParam; 818 public ParamUser userParam; // get the value from the configuration file
819 public ParamGet getter; 819 public ParamGet getter; // return the current value stored for this parameter
820 public ParamSet setter; 820 public ParamSet setter; // set the current value for this parameter
821 public ParameterDefn(string n, string d, float v, ParamUser u, ParamGet g, ParamSet s) 821 public ParameterDefn(string n, string d, float v, ParamUser u, ParamGet g, ParamSet s)
822 { 822 {
823 name = n; 823 name = n;
@@ -834,7 +834,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
834 // To add a new externally referencable/settable parameter, add the paramter storage 834 // To add a new externally referencable/settable parameter, add the paramter storage
835 // location somewhere in the program and make an entry in this table with the 835 // location somewhere in the program and make an entry in this table with the
836 // getters and setters. 836 // getters and setters.
837 // To add a new variable, it is easiest to find an existing definition and copy it. 837 // It is easiest to find an existing definition and copy it.
838 // Parameter values are floats. Booleans are converted to a floating value. 838 // Parameter values are floats. Booleans are converted to a floating value.
839 // 839 //
840 // A ParameterDefn() takes the following parameters: 840 // A ParameterDefn() takes the following parameters:
@@ -870,7 +870,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
870 (s) => { return (float)s.m_meshLOD; }, 870 (s) => { return (float)s.m_meshLOD; },
871 (s,p,l,v) => { s.m_meshLOD = (int)v; } ), 871 (s,p,l,v) => { s.m_meshLOD = (int)v; } ),
872 new ParameterDefn("SculptLOD", "Level of detail to render sculpties (32, 16, 8 or 4. 32=most detailed)", 872 new ParameterDefn("SculptLOD", "Level of detail to render sculpties (32, 16, 8 or 4. 32=most detailed)",
873 32, 873 32f,
874 (s,cf,p,v) => { s.m_sculptLOD = cf.GetInt(p, (int)v); }, 874 (s,cf,p,v) => { s.m_sculptLOD = cf.GetInt(p, (int)v); },
875 (s) => { return (float)s.m_sculptLOD; }, 875 (s) => { return (float)s.m_sculptLOD; },
876 (s,p,l,v) => { s.m_sculptLOD = (int)v; } ), 876 (s,p,l,v) => { s.m_sculptLOD = (int)v; } ),
@@ -1106,9 +1106,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
1106 (s,p,l,v) => { s.m_detailedStatsStep = (int)v; } ), 1106 (s,p,l,v) => { s.m_detailedStatsStep = (int)v; } ),
1107 new ParameterDefn("ShouldDebugLog", "Enables detailed DEBUG log statements", 1107 new ParameterDefn("ShouldDebugLog", "Enables detailed DEBUG log statements",
1108 ConfigurationParameters.numericFalse, 1108 ConfigurationParameters.numericFalse,
1109 (s,cf,p,v) => { s.shouldDebugLog = cf.GetBoolean(p, s.BoolNumeric(v)); }, 1109 (s,cf,p,v) => { s.ShouldDebugLog = cf.GetBoolean(p, s.BoolNumeric(v)); },
1110 (s) => { return s.NumericBool(s.shouldDebugLog); }, 1110 (s) => { return s.NumericBool(s.ShouldDebugLog); },
1111 (s,p,l,v) => { s.shouldDebugLog = s.BoolNumeric(v); } ), 1111 (s,p,l,v) => { s.ShouldDebugLog = s.BoolNumeric(v); } ),
1112 1112
1113 }; 1113 };
1114 1114