aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
diff options
context:
space:
mode:
authorRobert Adams2011-08-18 14:32:09 -0700
committerMic Bowman2011-08-18 14:32:09 -0700
commitfef73a1a1011126d4df2da2279caae9cef7984d1 (patch)
treeaf54473f37f419648b98c4b8ddc815ff7aea98a3 /OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
parentBulletSim: fix problem with not convex hulling large objects by creating unit... (diff)
downloadopensim-SC-fef73a1a1011126d4df2da2279caae9cef7984d1.zip
opensim-SC-fef73a1a1011126d4df2da2279caae9cef7984d1.tar.gz
opensim-SC-fef73a1a1011126d4df2da2279caae9cef7984d1.tar.bz2
opensim-SC-fef73a1a1011126d4df2da2279caae9cef7984d1.tar.xz
BulletSim: add runtime setting of physics parameters. Update default values.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs31
1 files changed, 24 insertions, 7 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 9f9ebcc..682eb80 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -49,8 +49,9 @@ public class BSCharacter : PhysicsActor
49 private bool _grabbed; 49 private bool _grabbed;
50 private bool _selected; 50 private bool _selected;
51 private Vector3 _position; 51 private Vector3 _position;
52 private float _mass = 80f; 52 private float _mass;
53 public float _density = 60f; 53 public float _density;
54 public float _avatarVolume;
54 private Vector3 _force; 55 private Vector3 _force;
55 private Vector3 _velocity; 56 private Vector3 _velocity;
56 private Vector3 _torque; 57 private Vector3 _torque;
@@ -90,13 +91,13 @@ public class BSCharacter : PhysicsActor
90 _scene = parent_scene; 91 _scene = parent_scene;
91 _position = pos; 92 _position = pos;
92 _size = size; 93 _size = size;
94 _flying = isFlying;
93 _orientation = Quaternion.Identity; 95 _orientation = Quaternion.Identity;
94 _velocity = Vector3.Zero; 96 _velocity = Vector3.Zero;
95 _buoyancy = 0f; // characters return a buoyancy of zero 97 _buoyancy = isFlying ? 1f : 0f;
96 _scale = new Vector3(1f, 1f, 1f); 98 _scale = new Vector3(1f, 1f, 1f);
97 float AVvolume = (float) (Math.PI*Math.Pow(_scene.Params.avatarCapsuleRadius, 2)*_scene.Params.avatarCapsuleHeight);
98 _density = _scene.Params.avatarDensity; 99 _density = _scene.Params.avatarDensity;
99 _mass = _density*AVvolume; 100 ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale
100 101
101 ShapeData shapeData = new ShapeData(); 102 ShapeData shapeData = new ShapeData();
102 shapeData.ID = _localID; 103 shapeData.ID = _localID;
@@ -106,7 +107,7 @@ public class BSCharacter : PhysicsActor
106 shapeData.Velocity = _velocity; 107 shapeData.Velocity = _velocity;
107 shapeData.Scale = _scale; 108 shapeData.Scale = _scale;
108 shapeData.Mass = _mass; 109 shapeData.Mass = _mass;
109 shapeData.Buoyancy = isFlying ? 1f : 0f; 110 shapeData.Buoyancy = _buoyancy;
110 shapeData.Static = ShapeData.numericFalse; 111 shapeData.Static = ShapeData.numericFalse;
111 shapeData.Friction = _scene.Params.avatarFriction; 112 shapeData.Friction = _scene.Params.avatarFriction;
112 shapeData.Restitution = _scene.Params.defaultRestitution; 113 shapeData.Restitution = _scene.Params.defaultRestitution;
@@ -212,6 +213,7 @@ public class BSCharacter : PhysicsActor
212 get { return _velocity; } 213 get { return _velocity; }
213 set { 214 set {
214 _velocity = value; 215 _velocity = value;
216 // m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, _velocity);
215 _scene.TaintedObject(delegate() 217 _scene.TaintedObject(delegate()
216 { 218 {
217 BulletSimAPI.SetObjectVelocity(_scene.WorldID, _localID, _velocity); 219 BulletSimAPI.SetObjectVelocity(_scene.WorldID, _localID, _velocity);
@@ -235,6 +237,7 @@ public class BSCharacter : PhysicsActor
235 get { return _orientation; } 237 get { return _orientation; }
236 set { 238 set {
237 _orientation = value; 239 _orientation = value;
240 // m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation);
238 _scene.TaintedObject(delegate() 241 _scene.TaintedObject(delegate()
239 { 242 {
240 // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); 243 // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
@@ -300,7 +303,6 @@ public class BSCharacter : PhysicsActor
300 set { _buoyancy = value; 303 set { _buoyancy = value;
301 _scene.TaintedObject(delegate() 304 _scene.TaintedObject(delegate()
302 { 305 {
303 // simulate flying by changing the effect of gravity
304 BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy); 306 BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy);
305 }); 307 });
306 } 308 }
@@ -344,6 +346,7 @@ public class BSCharacter : PhysicsActor
344 _force.X += force.X; 346 _force.X += force.X;
345 _force.Y += force.Y; 347 _force.Y += force.Y;
346 _force.Z += force.Z; 348 _force.Z += force.Z;
349 // m_log.DebugFormat("{0}: AddForce. adding={1}, newForce={2}", LogHeader, force, _force);
347 _scene.TaintedObject(delegate() 350 _scene.TaintedObject(delegate()
348 { 351 {
349 BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); 352 BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force);
@@ -370,6 +373,17 @@ public class BSCharacter : PhysicsActor
370 return (_subscribedEventsMs > 0); 373 return (_subscribedEventsMs > 0);
371 } 374 }
372 375
376 // set _avatarVolume and _mass based on capsule size, _density and _scale
377 private void ComputeAvatarVolumeAndMass()
378 {
379 _avatarVolume = (float)(
380 Math.PI
381 * _scene.Params.avatarCapsuleRadius * _scale.X
382 * _scene.Params.avatarCapsuleRadius * _scale.Y
383 * _scene.Params.avatarCapsuleHeight * _scale.Z);
384 _mass = _density * _avatarVolume;
385 }
386
373 // The physics engine says that properties have updated. Update same and inform 387 // The physics engine says that properties have updated. Update same and inform
374 // the world that things have changed. 388 // the world that things have changed.
375 public void UpdateProperties(EntityProperties entprop) 389 public void UpdateProperties(EntityProperties entprop)
@@ -403,6 +417,9 @@ public class BSCharacter : PhysicsActor
403 } 417 }
404 if (changed) 418 if (changed)
405 { 419 {
420 // m_log.DebugFormat("{0}: UpdateProperties: id={1}, c={2}, pos={3}, rot={4}", LogHeader, LocalID, changed, _position, _orientation);
421 // Avatar movement is not done by generating this event. There is a system that
422 // checks for avatar updates each heartbeat loop.
406 // base.RequestPhysicsterseUpdate(); 423 // base.RequestPhysicsterseUpdate();
407 } 424 }
408 } 425 }