From 1b55a9d81e66972312fdc801d17da697466f9ed4 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 8 Feb 2013 15:25:57 -0800 Subject: BulletSim: fix avatar bobbing or jiggling while stationary flying. Various comments and debugging message mods. --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 29 ++++++++++++---------- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 4 +++ .../Region/Physics/BulletSPlugin/BSPhysObject.cs | 6 ++--- .../Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 2 +- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 2 +- 5 files changed, 25 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 0afc437..6a995a2 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -140,7 +140,7 @@ public sealed class BSCharacter : BSPhysObject ZeroMotion(true); ForcePosition = _position; - // Set the velocity and compute the proper friction + // Set the velocity _velocityMotor.Reset(); _velocityMotor.SetTarget(_velocity); _velocityMotor.SetCurrent(_velocity); @@ -214,25 +214,28 @@ public sealed class BSCharacter : BSPhysObject _velocityMotor.Step(timeStep); // If we're not supposed to be moving, make sure things are zero. - if (_velocityMotor.ErrorIsZero() && _velocityMotor.TargetValue == OMV.Vector3.Zero && IsColliding) + if (_velocityMotor.ErrorIsZero() && _velocityMotor.TargetValue == OMV.Vector3.Zero) { // The avatar shouldn't be moving _velocityMotor.Zero(); - // If we are colliding with a stationary object, presume we're standing and don't move around - if (!ColliderIsMoving) + if (IsColliding) { - DetailLog("{0},BSCharacter.MoveMotor,collidingWithStationary,zeroingMotion", LocalID); - ZeroMotion(true /* inTaintTime */); - } + // If we are colliding with a stationary object, presume we're standing and don't move around + if (!ColliderIsMoving) + { + DetailLog("{0},BSCharacter.MoveMotor,collidingWithStationary,zeroingMotion", LocalID); + ZeroMotion(true /* inTaintTime */); + } - // Standing has more friction on the ground - if (_currentFriction != BSParam.AvatarStandingFriction) - { - _currentFriction = BSParam.AvatarStandingFriction; - PhysicsScene.PE.SetFriction(PhysBody, _currentFriction); + // Standing has more friction on the ground + if (_currentFriction != BSParam.AvatarStandingFriction) + { + _currentFriction = BSParam.AvatarStandingFriction; + PhysicsScene.PE.SetFriction(PhysBody, _currentFriction); + } } - DetailLog("{0},BSCharacter.MoveMotor,taint,stopping,target={1}", LocalID, _velocityMotor.TargetValue); + DetailLog("{0},BSCharacter.MoveMotor,taint,stopping,target={1},colliding={2}", LocalID, _velocityMotor.TargetValue, IsColliding); } else { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 8e69db3..e35311f 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -71,6 +71,10 @@ public abstract class BSLinkset ret = new BSLinksetCompound(physScene, parent); break; } + if (ret == null) + { + physScene.Logger.ErrorFormat("[BULLETSIM LINKSET] Factory could not create linkset. Parent name={1}, ID={2}", parent.Name, parent.LocalID); + } return ret; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index e1d269a..de69fa0 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -290,13 +290,13 @@ public abstract class BSPhysObject : PhysicsActor CollisionAccumulation++; // For movement tests, remember if we are colliding with an object that is moving. - ColliderIsMoving = collidee != null ? collidee.RawVelocity != OMV.Vector3.Zero : false; + ColliderIsMoving = collidee != null ? (collidee.RawVelocity != OMV.Vector3.Zero) : false; // If someone has subscribed for collision events log the collision so it will be reported up if (SubscribedEvents()) { CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); - DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5}", - LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth); + DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5},colliderMoving={6}", + LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth, ColliderIsMoving); ret = true; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index fd66d1c..9898562 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -160,8 +160,8 @@ public class BSPrimLinkable : BSPrimDisplaced // TODO: this will have to change when linksets are articulated. base.UpdateProperties(entprop); } + // The linkset might like to know about changing locations Linkset.UpdateProperties(UpdatedProperties.EntPropUpdates, this); - } public override bool Collide(uint collidingWith, BSPhysObject collidee, diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index e506d22..05722b8 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -463,7 +463,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters if (!m_initialized) return null; - DetailLog("{0},AddPrimShape,call", localID); + DetailLog("{0},BSScene.AddPrimShape,call", localID); BSPhysObject prim = new BSPrimLinkable(localID, primName, this, position, size, rotation, pbs, isPhysical); lock (PhysObjects) PhysObjects.Add(localID, prim); -- cgit v1.1