aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorRobert Adams2013-02-08 15:36:10 -0800
committerRobert Adams2013-02-08 16:29:45 -0800
commit222040f1ec0d85b06de8271fd7eabc7dd0a2f7d4 (patch)
treeabe0dc33bb03b3ecb27a5502dce0acfaae6887e5 /OpenSim
parentBulletSim: fix avatar bobbing or jiggling while stationary flying. (diff)
downloadopensim-SC_OLD-222040f1ec0d85b06de8271fd7eabc7dd0a2f7d4.zip
opensim-SC_OLD-222040f1ec0d85b06de8271fd7eabc7dd0a2f7d4.tar.gz
opensim-SC_OLD-222040f1ec0d85b06de8271fd7eabc7dd0a2f7d4.tar.bz2
opensim-SC_OLD-222040f1ec0d85b06de8271fd7eabc7dd0a2f7d4.tar.xz
BulletSim: Change BSCharacter to use new base Density and Friction
variables rather than own local varaibles.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs26
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSParam.cs2
2 files changed, 12 insertions, 16 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 6a995a2..f781aea 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -45,7 +45,6 @@ public sealed class BSCharacter : BSPhysObject
45 private bool _selected; 45 private bool _selected;
46 private OMV.Vector3 _position; 46 private OMV.Vector3 _position;
47 private float _mass; 47 private float _mass;
48 private float _avatarDensity;
49 private float _avatarVolume; 48 private float _avatarVolume;
50 private OMV.Vector3 _force; 49 private OMV.Vector3 _force;
51 private OMV.Vector3 _velocity; 50 private OMV.Vector3 _velocity;
@@ -63,9 +62,6 @@ public sealed class BSCharacter : BSPhysObject
63 private bool _kinematic; 62 private bool _kinematic;
64 private float _buoyancy; 63 private float _buoyancy;
65 64
66 // The friction and velocity of the avatar is modified depending on whether walking or not.
67 private float _currentFriction; // the friction currently being used (changed by setVelocity).
68
69 private BSVMotor _velocityMotor; 65 private BSVMotor _velocityMotor;
70 66
71 private OMV.Vector3 _PIDTarget; 67 private OMV.Vector3 _PIDTarget;
@@ -86,8 +82,8 @@ public sealed class BSCharacter : BSPhysObject
86 _orientation = OMV.Quaternion.Identity; 82 _orientation = OMV.Quaternion.Identity;
87 _velocity = OMV.Vector3.Zero; 83 _velocity = OMV.Vector3.Zero;
88 _buoyancy = ComputeBuoyancyFromFlying(isFlying); 84 _buoyancy = ComputeBuoyancyFromFlying(isFlying);
89 _currentFriction = BSParam.AvatarStandingFriction; 85 Friction = BSParam.AvatarStandingFriction;
90 _avatarDensity = BSParam.AvatarDensity; 86 Density = BSParam.AvatarDensity;
91 87
92 // Old versions of ScenePresence passed only the height. If width and/or depth are zero, 88 // Old versions of ScenePresence passed only the height. If width and/or depth are zero,
93 // replace with the default values. 89 // replace with the default values.
@@ -104,7 +100,7 @@ public sealed class BSCharacter : BSPhysObject
104 SetupMovementMotor(); 100 SetupMovementMotor();
105 101
106 DetailLog("{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5}", 102 DetailLog("{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5}",
107 LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass); 103 LocalID, _size, Scale, Density, _avatarVolume, RawMass);
108 104
109 // do actual creation in taint time 105 // do actual creation in taint time
110 PhysicsScene.TaintedObject("BSCharacter.create", delegate() 106 PhysicsScene.TaintedObject("BSCharacter.create", delegate()
@@ -229,10 +225,10 @@ public sealed class BSCharacter : BSPhysObject
229 } 225 }
230 226
231 // Standing has more friction on the ground 227 // Standing has more friction on the ground
232 if (_currentFriction != BSParam.AvatarStandingFriction) 228 if (Friction != BSParam.AvatarStandingFriction)
233 { 229 {
234 _currentFriction = BSParam.AvatarStandingFriction; 230 Friction = BSParam.AvatarStandingFriction;
235 PhysicsScene.PE.SetFriction(PhysBody, _currentFriction); 231 PhysicsScene.PE.SetFriction(PhysBody, Friction);
236 } 232 }
237 } 233 }
238 DetailLog("{0},BSCharacter.MoveMotor,taint,stopping,target={1},colliding={2}", LocalID, _velocityMotor.TargetValue, IsColliding); 234 DetailLog("{0},BSCharacter.MoveMotor,taint,stopping,target={1},colliding={2}", LocalID, _velocityMotor.TargetValue, IsColliding);
@@ -241,11 +237,11 @@ public sealed class BSCharacter : BSPhysObject
241 { 237 {
242 OMV.Vector3 stepVelocity = _velocityMotor.CurrentValue; 238 OMV.Vector3 stepVelocity = _velocityMotor.CurrentValue;
243 239
244 if (_currentFriction != BSParam.AvatarFriction) 240 if (Friction != BSParam.AvatarFriction)
245 { 241 {
246 // Probably starting up walking. Set friction to moving friction. 242 // Probably starting up walking. Set friction to moving friction.
247 _currentFriction = BSParam.AvatarFriction; 243 Friction = BSParam.AvatarFriction;
248 PhysicsScene.PE.SetFriction(PhysBody, _currentFriction); 244 PhysicsScene.PE.SetFriction(PhysBody, Friction);
249 } 245 }
250 246
251 // If falling, we keep the world's downward vector no matter what the other axis specify. 247 // If falling, we keep the world's downward vector no matter what the other axis specify.
@@ -345,7 +341,7 @@ public sealed class BSCharacter : BSPhysObject
345 Scale = ComputeAvatarScale(_size); 341 Scale = ComputeAvatarScale(_size);
346 ComputeAvatarVolumeAndMass(); 342 ComputeAvatarVolumeAndMass();
347 DetailLog("{0},BSCharacter.setSize,call,size={1},scale={2},density={3},volume={4},mass={5}", 343 DetailLog("{0},BSCharacter.setSize,call,size={1},scale={2},density={3},volume={4},mass={5}",
348 LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass); 344 LocalID, _size, Scale, Density, _avatarVolume, RawMass);
349 345
350 PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() 346 PhysicsScene.TaintedObject("BSCharacter.setSize", delegate()
351 { 347 {
@@ -873,7 +869,7 @@ public sealed class BSCharacter : BSPhysObject
873 * Math.Min(Size.X, Size.Y) / 2 869 * Math.Min(Size.X, Size.Y) / 2
874 * Size.Y / 2f // plus the volume of the capsule end caps 870 * Size.Y / 2f // plus the volume of the capsule end caps
875 ); 871 );
876 _mass = _avatarDensity * _avatarVolume; 872 _mass = Density * _avatarVolume;
877 } 873 }
878 874
879 // The physics engine says that properties have updated. Update same and inform 875 // The physics engine says that properties have updated. Update same and inform
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
index 601c78c..6cb7434 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
@@ -424,7 +424,7 @@ public static class BSParam
424 (s) => { return AvatarFriction; }, 424 (s) => { return AvatarFriction; },
425 (s,p,l,v) => { AvatarFriction = v; } ), 425 (s,p,l,v) => { AvatarFriction = v; } ),
426 new ParameterDefn("AvatarStandingFriction", "Avatar friction when standing. Changed on avatar recreation.", 426 new ParameterDefn("AvatarStandingFriction", "Avatar friction when standing. Changed on avatar recreation.",
427 10.0f, 427 0.95f,
428 (s,cf,p,v) => { AvatarStandingFriction = cf.GetFloat(p, v); }, 428 (s,cf,p,v) => { AvatarStandingFriction = cf.GetFloat(p, v); },
429 (s) => { return AvatarStandingFriction; }, 429 (s) => { return AvatarStandingFriction; },
430 (s,p,l,v) => { AvatarStandingFriction = v; } ), 430 (s,p,l,v) => { AvatarStandingFriction = v; } ),