From 482c7b5368faa034b73b3434fd90ce3702644cb8 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 18 Jan 2013 11:37:36 -0800 Subject: BulletSim: add logic to turn off pre-step actions when object goes non-active. This turns off 'setForce', 'setTorque' and 'moveToTarget' when the object is selected or made non-physical. --- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 7aa2d92..aaa6fe5 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -502,6 +502,12 @@ public sealed class BSPrim : BSPhysObject RegisterPreStepAction("BSPrim.setForce", LocalID, delegate(float timeStep) { + if (!IsPhysicallyActive) + { + UnRegisterPreStepAction("BSPrim.setForce", LocalID); + return; + } + DetailLog("{0},BSPrim.setForce,preStep,force={1}", LocalID, _force); if (PhysBody.HasPhysicalBody) { @@ -627,6 +633,12 @@ public sealed class BSPrim : BSPhysObject RegisterPreStepAction("BSPrim.setTorque", LocalID, delegate(float timeStep) { + if (!IsPhysicallyActive) + { + UnRegisterPreStepAction("BSPrim.setTorque", LocalID); + return; + } + if (PhysBody.HasPhysicalBody) AddAngularForce(_torque, false, true); } @@ -1061,6 +1073,12 @@ public sealed class BSPrim : BSPhysObject RegisterPreStepAction("BSPrim.PIDTarget", LocalID, delegate(float timeStep) { + if (!IsPhysicallyActive) + { + UnRegisterPreStepAction("BSPrim.PIDTarget", LocalID); + return; + } + OMV.Vector3 origPosition = RawPosition; // DEBUG DEBUG (for printout below) // 'movePosition' is where we'd like the prim to be at this moment. @@ -1108,6 +1126,9 @@ public sealed class BSPrim : BSPhysObject RegisterPreStepAction("BSPrim.Hover", LocalID, delegate(float timeStep) { + if (!IsPhysicallyActive) + return; + _hoverMotor.SetCurrent(RawPosition.Z); _hoverMotor.SetTarget(ComputeCurrentPIDHoverHeight()); float targetHeight = _hoverMotor.Step(timeStep); -- cgit v1.1 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') 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