From 4ffe936ba837eb47dc235317a54f5fa16af514ce Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Sat, 10 Oct 2009 03:53:53 -0400 Subject: * Make ODECharacter respect the scene's requested collision update time * Set the Scene collision update time to 500 ms --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 15 +++++++++++++-- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index a00ba11..7a86b6e 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -98,6 +98,7 @@ namespace OpenSim.Region.Physics.OdePlugin private bool m_alwaysRun = false; private bool m_hackSentFall = false; private bool m_hackSentFly = false; + private int m_requestedUpdateFrequency = 0; private PhysicsVector m_taintPosition = new PhysicsVector(0, 0, 0); public uint m_localID = 0; public bool m_returnCollisions = false; @@ -1184,26 +1185,31 @@ namespace OpenSim.Region.Physics.OdePlugin public override void SubscribeEvents(int ms) { + m_requestedUpdateFrequency = ms; m_eventsubscription = ms; _parent_scene.addCollisionEventReporting(this); } public override void UnSubscribeEvents() { _parent_scene.remCollisionEventReporting(this); + m_requestedUpdateFrequency = 0; m_eventsubscription = 0; } public void AddCollisionEvent(uint CollidedWith, float depth) { if (m_eventsubscription > 0) - CollisionEventsThisFrame.addCollider(CollidedWith,depth); + { + CollisionEventsThisFrame.addCollider(CollidedWith, depth); + } } public void SendCollisions() { - if (m_eventsubscription > 0) + if (m_eventsubscription > m_requestedUpdateFrequency) { base.SendCollisionUpdate(CollisionEventsThisFrame); CollisionEventsThisFrame = new CollisionEventUpdate(); + m_eventsubscription = 0; } } public override bool SubscribedEvents() @@ -1309,5 +1315,10 @@ namespace OpenSim.Region.Physics.OdePlugin } } + + internal void AddCollisionFrameTime(int p) + { + m_eventsubscription += p; + } } } diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index f5ab1de..083b7db 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -2928,6 +2928,7 @@ namespace OpenSim.Region.Physics.OdePlugin { case ActorTypes.Agent: OdeCharacter cobj = (OdeCharacter)obj; + cobj.AddCollisionFrameTime(100); cobj.SendCollisions(); break; case ActorTypes.Prim: -- cgit v1.1 From 8271528b1fe49d99cf5b64d3644864ba4aa097c1 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Sat, 10 Oct 2009 04:01:36 -0400 Subject: * comment out the velocity test, using updates every 500 ms as set in ScenePresence.AddToPhysicalScene. * This causes time to be counted in ODECharacter and, when a collision occurs, the physics scene will report the collisions only if the the difference of last time it reported the collisions from now was more then the set ms. * This is cool because the time accrues while collisions are not taking place and when they do take place again, you get an immediate update. --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 7a86b6e..bd81d50 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -1318,6 +1318,9 @@ namespace OpenSim.Region.Physics.OdePlugin internal void AddCollisionFrameTime(int p) { + // protect it from overflow crashing + if (m_eventsubscription + p >= int.MaxValue) + m_eventsubscription = 0; m_eventsubscription += p; } } -- cgit v1.1