Fix a bug I introduced yesterday in ODE physics where prim scripts would only receive the very first collision.

0.7.2-post-fixes
Justin Clark-Casey (justincc) 2011-10-27 02:05:59 +01:00
parent 05dff4987b
commit 88ef35cb23
3 changed files with 26 additions and 1 deletions

View File

@ -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;

View File

@ -76,6 +76,8 @@ namespace OpenSim.Region.Physics.Manager
/// </summary>
public int Count { get { return m_objCollisionList.Count; } }
public bool CollisionsOnPreviousFrame { get; private set; }
public Dictionary<uint, ContactPoint> m_objCollisionList;
public CollisionEventUpdate(Dictionary<uint, ContactPoint> objCollisionList)

View File

@ -193,6 +193,15 @@ namespace OpenSim.Region.Physics.OdePlugin
private int m_eventsubscription;
private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate();
/// <summary>
/// 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.
/// </summary>
/// <remarks>
/// This is probably a temporary measure, pending storing this information consistently in CollisionEventUpdate itself.
/// </remarks>
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()