ubitODE: if stopped having collisions do report zero colisions once, so collision_end event can be triggered. Changed reports rate to the requested rate and not full ode rate.

avinationmerge
UbitUmarov 2012-05-15 15:45:01 +01:00
parent 338be76e0a
commit 9d67523235
2 changed files with 43 additions and 9 deletions

View File

@ -194,8 +194,10 @@ namespace OpenSim.Region.Physics.OdePlugin
public int givefakeori = 0; public int givefakeori = 0;
private Quaternion fakeori; private Quaternion fakeori;
public int m_eventsubscription; private int m_eventsubscription;
private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); private int m_cureventsubscription;
private CollisionEventUpdate CollisionEventsThisFrame = null;
private bool SentEmptyCollisionsEvent;
public volatile bool childPrim; public volatile bool childPrim;
@ -931,12 +933,21 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void SubscribeEvents(int ms) public override void SubscribeEvents(int ms)
{ {
m_eventsubscription = ms; m_eventsubscription = ms;
m_cureventsubscription = 0;
if (CollisionEventsThisFrame == null)
CollisionEventsThisFrame = new CollisionEventUpdate();
SentEmptyCollisionsEvent = false;
_parent_scene.AddCollisionEventReporting(this); _parent_scene.AddCollisionEventReporting(this);
} }
public override void UnSubscribeEvents() public override void UnSubscribeEvents()
{ {
_parent_scene.RemoveCollisionEventReporting(this); _parent_scene.RemoveCollisionEventReporting(this);
if (CollisionEventsThisFrame != null)
{
CollisionEventsThisFrame.Clear();
CollisionEventsThisFrame = null;
}
m_eventsubscription = 0; m_eventsubscription = 0;
} }
@ -944,7 +955,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (CollisionEventsThisFrame == null) if (CollisionEventsThisFrame == null)
CollisionEventsThisFrame = new CollisionEventUpdate(); CollisionEventsThisFrame = new CollisionEventUpdate();
CollisionEventsThisFrame.AddCollider(CollidedWith, contact); CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
} }
@ -953,14 +963,34 @@ namespace OpenSim.Region.Physics.OdePlugin
if (CollisionEventsThisFrame == null) if (CollisionEventsThisFrame == null)
return; return;
if (m_cureventsubscription < m_eventsubscription)
return;
m_cureventsubscription = 0;
int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
if (!SentEmptyCollisionsEvent || ncolisions > 0)
{
base.SendCollisionUpdate(CollisionEventsThisFrame); base.SendCollisionUpdate(CollisionEventsThisFrame);
if (CollisionEventsThisFrame.m_objCollisionList.Count == 0) if (ncolisions == 0)
CollisionEventsThisFrame = null; SentEmptyCollisionsEvent = true;
else else
CollisionEventsThisFrame = new CollisionEventUpdate(); {
SentEmptyCollisionsEvent = false;
CollisionEventsThisFrame.Clear();
}
}
} }
internal void AddCollisionFrameTime(int t)
{
// protect it from overflow crashing
if (m_cureventsubscription + t >= int.MaxValue)
m_cureventsubscription = 0;
m_cureventsubscription += t;
}
public override bool SubscribedEvents() public override bool SubscribedEvents()
{ {
if (m_eventsubscription > 0) if (m_eventsubscription > 0)

View File

@ -1898,7 +1898,11 @@ namespace OpenSim.Region.Physics.OdePlugin
case ActorTypes.Prim: case ActorTypes.Prim:
OdePrim pobj = (OdePrim)obj; OdePrim pobj = (OdePrim)obj;
if (pobj.Body == IntPtr.Zero || (d.BodyIsEnabled(pobj.Body) && !pobj.m_outbounds))
{
pobj.AddCollisionFrameTime((int)(ODE_STEPSIZE * 1000.0f));
pobj.SendCollisions(); pobj.SendCollisions();
}
break; break;
} }
} }