aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs41
1 files changed, 34 insertions, 7 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index ee485b4..d4f5c63 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -102,7 +102,9 @@ public class BSCharacter : PhysicsActor
102 _orientation = Quaternion.Identity; 102 _orientation = Quaternion.Identity;
103 _velocity = Vector3.Zero; 103 _velocity = Vector3.Zero;
104 _buoyancy = ComputeBuoyancyFromFlying(isFlying); 104 _buoyancy = ComputeBuoyancyFromFlying(isFlying);
105 _scale = new Vector3(1f, 1f, 1f); 105 // The dimensions of the avatar capsule are kept in the scale.
106 // Physics creates a unit capsule which is scaled by the physics engine.
107 _scale = new Vector3(_scene.Params.avatarCapsuleRadius, _scene.Params.avatarCapsuleRadius, size.Z);
106 _density = _scene.Params.avatarDensity; 108 _density = _scene.Params.avatarDensity;
107 ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale 109 ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale
108 110
@@ -150,9 +152,28 @@ public class BSCharacter : PhysicsActor
150 public override bool Stopped { 152 public override bool Stopped {
151 get { return false; } 153 get { return false; }
152 } 154 }
153 public override Vector3 Size { 155 public override Vector3 Size {
154 get { return _size; } 156 get
155 set { _size = value; 157 {
158 // Avatar capsule size is kept in the scale parameter.
159 return new Vector3(_scale.X * 2, _scale.Y * 2, _scale.Z);
160 }
161
162 set {
163 // When an avatar's size is set, only the height is changed
164 // and that really only depends on the radius.
165 _size = value;
166 _scale.Z = (_size.Z * 1.15f) - (_scale.X + _scale.Y);
167
168 // TODO: something has to be done with the avatar's vertical position
169
170 ComputeAvatarVolumeAndMass();
171
172 _scene.TaintedObject(delegate()
173 {
174 BulletSimAPI.SetObjectScaleMass(_scene.WorldID, LocalID, _scale, _mass, true);
175 });
176
156 } 177 }
157 } 178 }
158 public override PrimitiveBaseShape Shape { 179 public override PrimitiveBaseShape Shape {
@@ -419,9 +440,15 @@ public class BSCharacter : PhysicsActor
419 { 440 {
420 _avatarVolume = (float)( 441 _avatarVolume = (float)(
421 Math.PI 442 Math.PI
422 * _scene.Params.avatarCapsuleRadius * _scale.X 443 * _scale.X
423 * _scene.Params.avatarCapsuleRadius * _scale.Y 444 * _scale.Y // the area of capsule cylinder
424 * _scene.Params.avatarCapsuleHeight * _scale.Z); 445 * _scale.Z // times height of capsule cylinder
446 + 1.33333333f
447 * Math.PI
448 * _scale.X
449 * Math.Min(_scale.X, _scale.Y)
450 * _scale.Y // plus the volume of the capsule end caps
451 );
425 _mass = _density * _avatarVolume; 452 _mass = _density * _avatarVolume;
426 } 453 }
427 454