From 820242bc49d9a0ed558a72fda2f7bbb85b716b5f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 27 Oct 2011 02:05:59 +0100 Subject: Fix a bug I introduced yesterday in ODE physics where prim scripts would only receive the very first collision. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 ++ OpenSim/Region/Physics/Manager/PhysicsActor.cs | 2 ++ OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 23 +++++++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 8b68102..c8ecc9b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2082,6 +2082,8 @@ namespace OpenSim.Region.Framework.Scenes public void PhysicsCollision(EventArgs e) { +// m_log.DebugFormat("Invoking PhysicsCollision on {0} {1} {2}", Name, LocalId, UUID); + // single threaded here CollisionEventUpdate a = (CollisionEventUpdate)e; diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 362f997..49f60f8 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -76,6 +76,8 @@ namespace OpenSim.Region.Physics.Manager /// public int Count { get { return m_objCollisionList.Count; } } + public bool CollisionsOnPreviousFrame { get; private set; } + public Dictionary m_objCollisionList; public CollisionEventUpdate(Dictionary objCollisionList) diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 0363885..ea6af3a 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -193,6 +193,15 @@ namespace OpenSim.Region.Physics.OdePlugin private int m_eventsubscription; private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); + /// + /// Signal whether there were collisions on the previous frame, so we know if we need to send the + /// empty CollisionEventsThisFrame to the prim so that it can detect the end of a collision. + /// + /// + /// This is probably a temporary measure, pending storing this information consistently in CollisionEventUpdate itself. + /// + private bool m_collisionsOnPreviousFrame; + private IntPtr m_linkJoint = IntPtr.Zero; internal volatile bool childPrim; @@ -3025,8 +3034,20 @@ Console.WriteLine(" JointCreateFixed"); public void SendCollisions() { - if (CollisionEventsThisFrame.Count > 0) + if (m_collisionsOnPreviousFrame || CollisionEventsThisFrame.Count > 0) + { base.SendCollisionUpdate(CollisionEventsThisFrame); + + if (CollisionEventsThisFrame.Count > 0) + { + m_collisionsOnPreviousFrame = true; + CollisionEventsThisFrame.Clear(); + } + else + { + m_collisionsOnPreviousFrame = false; + } + } } public override bool SubscribedEvents() -- cgit v1.1