diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index d694a6a..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() |
@@ -140,7 +136,7 @@ public sealed class BSCharacter : BSPhysObject | |||
140 | ZeroMotion(true); | 136 | ZeroMotion(true); |
141 | ForcePosition = _position; | 137 | ForcePosition = _position; |
142 | 138 | ||
143 | // Set the velocity and compute the proper friction | 139 | // Set the velocity |
144 | _velocityMotor.Reset(); | 140 | _velocityMotor.Reset(); |
145 | _velocityMotor.SetTarget(_velocity); | 141 | _velocityMotor.SetTarget(_velocity); |
146 | _velocityMotor.SetCurrent(_velocity); | 142 | _velocityMotor.SetCurrent(_velocity); |
@@ -214,35 +210,38 @@ public sealed class BSCharacter : BSPhysObject | |||
214 | _velocityMotor.Step(timeStep); | 210 | _velocityMotor.Step(timeStep); |
215 | 211 | ||
216 | // If we're not supposed to be moving, make sure things are zero. | 212 | // If we're not supposed to be moving, make sure things are zero. |
217 | if (_velocityMotor.ErrorIsZero() && _velocityMotor.TargetValue == OMV.Vector3.Zero && IsColliding) | 213 | if (_velocityMotor.ErrorIsZero() && _velocityMotor.TargetValue == OMV.Vector3.Zero) |
218 | { | 214 | { |
219 | // The avatar shouldn't be moving | 215 | // The avatar shouldn't be moving |
220 | _velocityMotor.Zero(); | 216 | _velocityMotor.Zero(); |
221 | 217 | ||
222 | // If we are colliding with a stationary object, presume we're standing and don't move around | 218 | if (IsColliding) |
223 | if (!ColliderIsMoving) | ||
224 | { | 219 | { |
225 | DetailLog("{0},BSCharacter.MoveMotor,collidingWithStationary,zeroingMotion", LocalID); | 220 | // If we are colliding with a stationary object, presume we're standing and don't move around |
226 | ZeroMotion(true /* inTaintTime */); | 221 | if (!ColliderIsMoving) |
227 | } | 222 | { |
223 | DetailLog("{0},BSCharacter.MoveMotor,collidingWithStationary,zeroingMotion", LocalID); | ||
224 | ZeroMotion(true /* inTaintTime */); | ||
225 | } | ||
228 | 226 | ||
229 | // Standing has more friction on the ground | 227 | // Standing has more friction on the ground |
230 | if (_currentFriction != BSParam.AvatarStandingFriction) | 228 | if (Friction != BSParam.AvatarStandingFriction) |
231 | { | 229 | { |
232 | _currentFriction = BSParam.AvatarStandingFriction; | 230 | Friction = BSParam.AvatarStandingFriction; |
233 | PhysicsScene.PE.SetFriction(PhysBody, _currentFriction); | 231 | PhysicsScene.PE.SetFriction(PhysBody, Friction); |
232 | } | ||
234 | } | 233 | } |
235 | DetailLog("{0},BSCharacter.MoveMotor,taint,stopping,target={1}", LocalID, _velocityMotor.TargetValue); | 234 | DetailLog("{0},BSCharacter.MoveMotor,taint,stopping,target={1},colliding={2}", LocalID, _velocityMotor.TargetValue, IsColliding); |
236 | } | 235 | } |
237 | else | 236 | else |
238 | { | 237 | { |
239 | OMV.Vector3 stepVelocity = _velocityMotor.CurrentValue; | 238 | OMV.Vector3 stepVelocity = _velocityMotor.CurrentValue; |
240 | 239 | ||
241 | if (_currentFriction != BSParam.AvatarFriction) | 240 | if (Friction != BSParam.AvatarFriction) |
242 | { | 241 | { |
243 | // Probably starting up walking. Set friction to moving friction. | 242 | // Probably starting up walking. Set friction to moving friction. |
244 | _currentFriction = BSParam.AvatarFriction; | 243 | Friction = BSParam.AvatarFriction; |
245 | PhysicsScene.PE.SetFriction(PhysBody, _currentFriction); | 244 | PhysicsScene.PE.SetFriction(PhysBody, Friction); |
246 | } | 245 | } |
247 | 246 | ||
248 | // 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. |
@@ -342,7 +341,7 @@ public sealed class BSCharacter : BSPhysObject | |||
342 | Scale = ComputeAvatarScale(_size); | 341 | Scale = ComputeAvatarScale(_size); |
343 | ComputeAvatarVolumeAndMass(); | 342 | ComputeAvatarVolumeAndMass(); |
344 | 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}", |
345 | LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass); | 344 | LocalID, _size, Scale, Density, _avatarVolume, RawMass); |
346 | 345 | ||
347 | PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() | 346 | PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() |
348 | { | 347 | { |
@@ -870,7 +869,7 @@ public sealed class BSCharacter : BSPhysObject | |||
870 | * Math.Min(Size.X, Size.Y) / 2 | 869 | * Math.Min(Size.X, Size.Y) / 2 |
871 | * Size.Y / 2f // plus the volume of the capsule end caps | 870 | * Size.Y / 2f // plus the volume of the capsule end caps |
872 | ); | 871 | ); |
873 | _mass = _avatarDensity * _avatarVolume; | 872 | _mass = Density * _avatarVolume; |
874 | } | 873 | } |
875 | 874 | ||
876 | // 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 |
@@ -901,7 +900,7 @@ public sealed class BSCharacter : BSPhysObject | |||
901 | CurrentEntityProperties = entprop; | 900 | CurrentEntityProperties = entprop; |
902 | 901 | ||
903 | // Tell the linkset about value changes | 902 | // Tell the linkset about value changes |
904 | Linkset.UpdateProperties(UpdatedProperties.EntPropUpdates, this); | 903 | // Linkset.UpdateProperties(UpdatedProperties.EntPropUpdates, this); |
905 | 904 | ||
906 | // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop. | 905 | // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop. |
907 | // base.RequestPhysicsterseUpdate(); | 906 | // base.RequestPhysicsterseUpdate(); |