From c6b6c94ccbbbd5226a377a510a988bedec7a418c Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 18 Jan 2013 11:39:24 -0800 Subject: BulletSim: reduce jitter in avatar velocity when walking or flying. OpenSimulator is VERY sensitive to changes in avatar velocity and will send an avatar update message when velocity changes more than 0.001m/s. This significantly reduces the number of avatar update messages by smoothing the avatar velocity returned by Bullet. --- OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 9 ++++++++- OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 6d5e23f..478aeab 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -853,7 +853,14 @@ public sealed class BSCharacter : BSPhysObject { _position = entprop.Position; _orientation = entprop.Rotation; - _velocity = entprop.Velocity; + + // Smooth velocity. OpenSimulator is very sensitive to changes in velocity of the avatar + // and will send agent updates to the clients if velocity changes by more than + // 0.001m/s. Bullet introduces a lot of jitter in the velocity which causes many + // extra updates. + if (!entprop.Velocity.ApproxEquals(_velocity, 0.1f)) + _velocity = entprop.Velocity; + _acceleration = entprop.Acceleration; _rotationalVelocity = entprop.RotationalVelocity; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index bac0427..5353c75 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -141,7 +141,7 @@ public abstract class BSPhysObject : PhysicsActor // It can be confusing for an actor to know if it should move or update an object // depeneding on the setting of 'selected', 'physical, ... - // This flag is the true test -- if true, the object is being acted on in the physical world + // This flag is the true test -- if true, the object is being acted on in the physical world public abstract bool IsPhysicallyActive { get; } // Materialness -- cgit v1.1