aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
diff options
context:
space:
mode:
authorRobert Adams2013-01-20 22:35:42 -0800
committerRobert Adams2013-01-20 23:09:54 -0800
commit52b341e2e24384395fddc7d32fd66358f5062468 (patch)
treea0b28ec5b79004b1a556db78d835e486b8040632 /OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
parentBulletSim: fix problem of avatar sliding very slowly occasionally after stopp... (diff)
downloadopensim-SC-52b341e2e24384395fddc7d32fd66358f5062468.zip
opensim-SC-52b341e2e24384395fddc7d32fd66358f5062468.tar.gz
opensim-SC-52b341e2e24384395fddc7d32fd66358f5062468.tar.bz2
opensim-SC-52b341e2e24384395fddc7d32fd66358f5062468.tar.xz
BulletSim: More aggressive as setting character velocity to zero
when should be standing. Modify angular force routines to be the same pattern as linear force routines. BulletSim vehicle turning is scaled like SL and is DIFFERENT THAN ODE!! Fix some bugs in BSMotor dealing with the motor going to zero. Add a bunch of parameters: MaxLinearVelocity, MaxAngularVelocity, MaxAddForceMagnitude, VehicleMaxLinearVelocity, VehicleMaxAngularVelocity, and most of the values are defaulted to values that are larger than in SL. Use the new parameters in BSPrim, BSCharacter and BSDynamic.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs30
1 files changed, 23 insertions, 7 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index cd279e3..a9e16e6 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -200,20 +200,36 @@ public sealed class BSCharacter : BSPhysObject
200 // TODO: Decide if the step parameters should be changed depending on the avatar's 200 // TODO: Decide if the step parameters should be changed depending on the avatar's
201 // state (flying, colliding, ...). There is code in ODE to do this. 201 // state (flying, colliding, ...). There is code in ODE to do this.
202 202
203 // COMMENTARY: when the user is making the avatar walk, except for falling, the velocity
204 // specified for the avatar is the one that should be used. For falling, if the avatar
205 // is not flying and is not colliding then it is presumed to be falling and the Z
206 // component is not fooled with (thus allowing gravity to do its thing).
207 // When the avatar is standing, though, the user has specified a velocity of zero and
208 // the avatar should be standing. But if the avatar is pushed by something in the world
209 // (raising elevator platform, moving vehicle, ...) the avatar should be allowed to
210 // move. Thus, the velocity cannot be forced to zero. The problem is that small velocity
211 // errors can creap in and the avatar will slowly float off in some direction.
212 // So, the problem is that, when an avatar is standing, we cannot tell creaping error
213 // from real pushing.OMV.Vector3.Zero;
214 // The code below keeps setting the velocity to zero hoping the world will keep pushing.
215
203 _velocityMotor.Step(timeStep); 216 _velocityMotor.Step(timeStep);
204 217
205 // If we're not supposed to be moving, make sure things are zero. 218 // If we're not supposed to be moving, make sure things are zero.
206 if (_velocityMotor.ErrorIsZero() && _velocityMotor.TargetValue.ApproxEquals(OMV.Vector3.Zero, 0.01f)) 219 if (_velocityMotor.ErrorIsZero() && _velocityMotor.TargetValue == OMV.Vector3.Zero && IsColliding)
207 { 220 {
208 if (_wasWalking) 221 // The avatar shouldn't be moving
222 _velocityMotor.Zero();
223 ZeroMotion(true /* inTaintTime */);
224
225 // Standing has more friction on the ground
226 if (_currentFriction != BSParam.AvatarStandingFriction)
209 { 227 {
210 _velocityMotor.Zero();
211 _velocity = OMV.Vector3.Zero;
212 PhysicsScene.PE.SetLinearVelocity(PhysBody, OMV.Vector3.Zero);
213 _currentFriction = BSParam.AvatarStandingFriction; 228 _currentFriction = BSParam.AvatarStandingFriction;
214 PhysicsScene.PE.SetFriction(PhysBody, _currentFriction); 229 PhysicsScene.PE.SetFriction(PhysBody, _currentFriction);
215 // DetailLog("{0},BSCharacter.MoveMotor,taint,stopping,target={1}", LocalID, _velocityMotor.TargetValue);
216 } 230 }
231 DetailLog("{0},BSCharacter.MoveMotor,taint,stopping,target={1}", LocalID, _velocityMotor.TargetValue);
232
217 _wasWalking = false; 233 _wasWalking = false;
218 } 234 }
219 else 235 else
@@ -242,7 +258,7 @@ public sealed class BSCharacter : BSPhysObject
242 // Add special movement force to allow avatars to walk up stepped surfaces. 258 // Add special movement force to allow avatars to walk up stepped surfaces.
243 moveForce += WalkUpStairs(); 259 moveForce += WalkUpStairs();
244 260
245 // DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", LocalID, stepVelocity, _velocity, Mass, moveForce); 261 DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", LocalID, stepVelocity, _velocity, Mass, moveForce);
246 PhysicsScene.PE.ApplyCentralImpulse(PhysBody, moveForce); 262 PhysicsScene.PE.ApplyCentralImpulse(PhysBody, moveForce);
247 _wasWalking = true; 263 _wasWalking = true;
248 } 264 }