From 9f194054909bff0c042d664fa548736f7862c32c Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 25 Oct 2011 22:28:40 +0100 Subject: [PATCH] When sending object collision updates, don't null out and recreate the CollisionEventUpdate() if the number of collisions falls to zero. Reuse the existing one instead. --- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 5 +++++ OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 16 +++------------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 1659ebd6ef..44af636df9 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -70,6 +70,11 @@ namespace OpenSim.Region.Physics.Manager { // Raising the event on the object, so don't need to provide location.. further up the tree knows that info. + /// + /// Number of collision events in this update. + /// + public int Count { get { return m_objCollisionList.Count; } } + public int m_colliderType; public int m_GenericStartEnd; //public uint m_LocalID; diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 3087f8d84e..4ef731d5d0 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -191,7 +191,7 @@ namespace OpenSim.Region.Physics.OdePlugin private d.Mass pMass; private int m_eventsubscription; - private CollisionEventUpdate CollisionEventsThisFrame; + private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); private IntPtr m_linkJoint = IntPtr.Zero; @@ -3020,23 +3020,13 @@ Console.WriteLine(" JointCreateFixed"); public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { - if (CollisionEventsThisFrame == null) - CollisionEventsThisFrame = new CollisionEventUpdate(); - CollisionEventsThisFrame.addCollider(CollidedWith, contact); } public void SendCollisions() { - if (CollisionEventsThisFrame == null) - return; - - base.SendCollisionUpdate(CollisionEventsThisFrame); - - if (CollisionEventsThisFrame.m_objCollisionList.Count == 0) - CollisionEventsThisFrame = null; - else - CollisionEventsThisFrame = new CollisionEventUpdate(); + if (CollisionEventsThisFrame.Count > 0) + base.SendCollisionUpdate(CollisionEventsThisFrame); } public override bool SubscribedEvents()