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.
parent
338be76e0a
commit
9d67523235
|
@ -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;
|
||||||
|
|
||||||
base.SendCollisionUpdate(CollisionEventsThisFrame);
|
if (m_cureventsubscription < m_eventsubscription)
|
||||||
|
return;
|
||||||
|
|
||||||
if (CollisionEventsThisFrame.m_objCollisionList.Count == 0)
|
m_cureventsubscription = 0;
|
||||||
CollisionEventsThisFrame = null;
|
|
||||||
else
|
int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
|
||||||
CollisionEventsThisFrame = new CollisionEventUpdate();
|
|
||||||
|
if (!SentEmptyCollisionsEvent || ncolisions > 0)
|
||||||
|
{
|
||||||
|
base.SendCollisionUpdate(CollisionEventsThisFrame);
|
||||||
|
|
||||||
|
if (ncolisions == 0)
|
||||||
|
SentEmptyCollisionsEvent = true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
|
|
@ -1898,7 +1898,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
case ActorTypes.Prim:
|
case ActorTypes.Prim:
|
||||||
OdePrim pobj = (OdePrim)obj;
|
OdePrim pobj = (OdePrim)obj;
|
||||||
pobj.SendCollisions();
|
if (pobj.Body == IntPtr.Zero || (d.BodyIsEnabled(pobj.Body) && !pobj.m_outbounds))
|
||||||
|
{
|
||||||
|
pobj.AddCollisionFrameTime((int)(ODE_STEPSIZE * 1000.0f));
|
||||||
|
pobj.SendCollisions();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue