From e9e72fe9079ab011dc43199496fb9a9dc7ea5b3a Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 9 Nov 2007 21:01:55 +0000 Subject: * Added an internal throttle on ODE physics updates * Added a ThrottleUpdates member to PhysicsActor to expose 'throttle' ability to the Scene. * Updated the ode.dll file with a fix to invalid data passed to ODE's heightfield collision calculator. --- .../BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 6 +++- .../Region/Physics/BulletXPlugin/BulletXPlugin.cs | 5 ++++ OpenSim/Region/Physics/Manager/PhysicsActor.cs | 7 +++++ OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 32 ++++++++++++++++++++-- OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 11 +++++++- 5 files changed, 56 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index d5cb99f..6377392 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -201,7 +201,11 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin get { return false; } set { return; } } - + public override bool ThrottleUpdates + { + get { return false; } + set { return; } + } public override bool Flying { get { return flying; } diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index 2e6e40f..c733adb 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs @@ -742,6 +742,11 @@ namespace OpenSim.Region.Physics.BulletXPlugin get { return flying; } set { flying = value; } } + public override bool ThrottleUpdates + { + get { return false; } + set { return; } + } public override bool IsColliding { get { return iscolliding; } diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 049da96..9ce7cf3 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -88,6 +88,8 @@ namespace OpenSim.Region.Physics.Manager public abstract bool Flying { get; set; } + public abstract bool ThrottleUpdates { get; set; } + public abstract bool IsColliding { get; set; } public abstract PhysicsVector RotationalVelocity { get; set; } @@ -148,6 +150,11 @@ namespace OpenSim.Region.Physics.Manager get { return false; } set { return; } } + public override bool ThrottleUpdates + { + get { return false; } + set { return; } + } public override bool IsColliding { diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 79f51a1..decf93f 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -212,6 +212,11 @@ namespace OpenSim.Region.Physics.OdePlugin // We only need to test p2 for 'jump crouch purposes' p2.IsColliding = true; + if (count > 3) + { + p2.ThrottleUpdates = true; + } + //System.Console.WriteLine(count.ToString()); //System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2); } } @@ -667,7 +672,11 @@ namespace OpenSim.Region.Physics.OdePlugin get { return false; } set { return; } } - + public override bool ThrottleUpdates + { + get { return false; } + set { return; } + } public override bool Flying { get { return flying; } @@ -929,6 +938,8 @@ namespace OpenSim.Region.Physics.OdePlugin public IntPtr _triMeshData; private bool iscolliding = false; private bool m_isphysical = false; + private bool m_throttleUpdates = false; + private int throttleCounter = 0; public bool _zeroFlag = false; private bool m_lastUpdateSent = false; @@ -1098,7 +1109,11 @@ namespace OpenSim.Region.Physics.OdePlugin get { return iscolliding; } set { iscolliding = value; } } - + public override bool ThrottleUpdates + { + get { return m_throttleUpdates; } + set { m_throttleUpdates=value; } + } public override PhysicsVector Position { @@ -1347,6 +1362,8 @@ namespace OpenSim.Region.Physics.OdePlugin m_rotationalVelocity.Y = 0; m_rotationalVelocity.Z = 0; base.RequestPhysicsterseUpdate(); + m_throttleUpdates = false; + throttleCounter = 0; _zeroFlag = true; } @@ -1382,6 +1399,8 @@ namespace OpenSim.Region.Physics.OdePlugin m_rotationalVelocity.Z = 0; if (!m_lastUpdateSent) { + m_throttleUpdates = false; + throttleCounter = 0; base.RequestPhysicsterseUpdate(); m_lastUpdateSent = true; } @@ -1406,7 +1425,14 @@ namespace OpenSim.Region.Physics.OdePlugin _orientation.y = ori.Y; _orientation.z = ori.Z; m_lastUpdateSent = false; - base.RequestPhysicsterseUpdate(); + if (!m_throttleUpdates || throttleCounter > 15) + { + base.RequestPhysicsterseUpdate(); + } + else + { + throttleCounter++; + } } m_lastposition = l_position; } diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs index d282e9d..76121ae 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs @@ -204,7 +204,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin get { return false; } set { return; } } - + public override bool ThrottleUpdates + { + get { return false; } + set { return; } + } public override bool Flying { get { return flying; } @@ -335,6 +339,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin get { return false; } set { return; } } + public override bool ThrottleUpdates + { + get { return false; } + set { return; } + } public override PhysicsVector RotationalVelocity { get { return m_rotationalVelocity; } -- cgit v1.1