ubOde a few changes to collisions reporting
parent
61ec34b441
commit
17cc238b44
|
@ -1578,6 +1578,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_eventsubscription = 0;
|
m_eventsubscription = 0;
|
||||||
|
_parent_scene.RemoveCollisionEventReporting(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
|
public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
|
||||||
|
@ -1591,8 +1592,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendCollisions()
|
public void SendCollisions(int timestep)
|
||||||
{
|
{
|
||||||
|
if (m_cureventsubscription < 50000)
|
||||||
|
m_cureventsubscription += timestep;
|
||||||
|
|
||||||
if (CollisionEventsThisFrame == null)
|
if (CollisionEventsThisFrame == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1623,13 +1627,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void AddCollisionFrameTime(int t)
|
|
||||||
{
|
|
||||||
// protect it from overflow crashing
|
|
||||||
if (m_cureventsubscription < 50000)
|
|
||||||
m_cureventsubscription += t;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool SubscribedEvents()
|
public override bool SubscribedEvents()
|
||||||
{
|
{
|
||||||
if (m_eventsubscription > 0)
|
if (m_eventsubscription > 0)
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
|
internal bool m_isVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
|
||||||
private bool m_fakeisVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
|
private bool m_fakeisVolumeDetect; // If true, this prim only detects collisions but doesn't collide actively
|
||||||
|
|
||||||
protected bool m_building;
|
internal bool m_building;
|
||||||
protected bool m_forcePosOrRotation;
|
protected bool m_forcePosOrRotation;
|
||||||
private bool m_iscolliding;
|
private bool m_iscolliding;
|
||||||
|
|
||||||
|
@ -1000,14 +1000,36 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
|
|
||||||
public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
|
public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (CollisionEventsThisFrame == null)
|
if (CollisionEventsThisFrame == null)
|
||||||
CollisionEventsThisFrame = new CollisionEventUpdate();
|
CollisionEventsThisFrame = new CollisionEventUpdate();
|
||||||
// if(CollisionEventsThisFrame.Count < 32)
|
CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
|
||||||
CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
|
_parent_scene.AddCollisionEventReporting(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendCollisions()
|
internal void SleeperAddCollisionEvents()
|
||||||
{
|
{
|
||||||
|
if (CollisionEventsThisFrame == null)
|
||||||
|
return;
|
||||||
|
if(CollisionEventsThisFrame.m_objCollisionList.Count == 0)
|
||||||
|
return;
|
||||||
|
foreach(KeyValuePair<uint,ContactPoint> kvp in CollisionEventsThisFrame.m_objCollisionList)
|
||||||
|
{
|
||||||
|
OdePrim other = _parent_scene.getPrim(kvp.Key);
|
||||||
|
if(other == null)
|
||||||
|
continue;
|
||||||
|
ContactPoint cp = kvp.Value;
|
||||||
|
cp.SurfaceNormal = - cp.SurfaceNormal;
|
||||||
|
cp.RelativeSpeed = -cp.RelativeSpeed;
|
||||||
|
other.AddCollisionEvent(ParentActor.LocalID,cp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SendCollisions(int timestep)
|
||||||
|
{
|
||||||
|
if (m_cureventsubscription < 50000)
|
||||||
|
m_cureventsubscription += timestep;
|
||||||
|
|
||||||
if (CollisionEventsThisFrame == null)
|
if (CollisionEventsThisFrame == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1027,7 +1049,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
SentEmptyCollisionsEvent = true;
|
SentEmptyCollisionsEvent = true;
|
||||||
_parent_scene.RemoveCollisionEventReporting(this);
|
_parent_scene.RemoveCollisionEventReporting(this);
|
||||||
}
|
}
|
||||||
else
|
else if(Body == IntPtr.Zero || d.BodyIsEnabled(Body))
|
||||||
{
|
{
|
||||||
SentEmptyCollisionsEvent = false;
|
SentEmptyCollisionsEvent = false;
|
||||||
CollisionEventsThisFrame.Clear();
|
CollisionEventsThisFrame.Clear();
|
||||||
|
@ -1035,12 +1057,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void AddCollisionFrameTime(int t)
|
|
||||||
{
|
|
||||||
if (m_cureventsubscription < 50000)
|
|
||||||
m_cureventsubscription += t;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool SubscribedEvents()
|
public override bool SubscribedEvents()
|
||||||
{
|
{
|
||||||
if (m_eventsubscription > 0)
|
if (m_eventsubscription > 0)
|
||||||
|
|
|
@ -228,8 +228,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
|
|
||||||
private d.NearCallback nearCallback;
|
private d.NearCallback nearCallback;
|
||||||
|
|
||||||
|
private Dictionary<uint,OdePrim> _prims = new Dictionary<uint,OdePrim>();
|
||||||
private HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
|
private HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
|
||||||
private HashSet<OdePrim> _prims = new HashSet<OdePrim>();
|
|
||||||
private HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
|
private HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
|
||||||
private HashSet<OdePrim> _activegroups = new HashSet<OdePrim>();
|
private HashSet<OdePrim> _activegroups = new HashSet<OdePrim>();
|
||||||
|
|
||||||
|
@ -1329,7 +1329,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
|
|
||||||
newPrim = new OdePrim(name, this, position, size, rotation, pbs, isphysical, isPhantom, shapeType, localID);
|
newPrim = new OdePrim(name, this, position, size, rotation, pbs, isphysical, isPhantom, shapeType, localID);
|
||||||
lock (_prims)
|
lock (_prims)
|
||||||
_prims.Add(newPrim);
|
_prims[newPrim.LocalID] = newPrim;
|
||||||
}
|
}
|
||||||
return newPrim;
|
return newPrim;
|
||||||
}
|
}
|
||||||
|
@ -1391,15 +1391,26 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
{
|
{
|
||||||
// RemoveCollisionEventReporting(prim);
|
// RemoveCollisionEventReporting(prim);
|
||||||
lock (_prims)
|
lock (_prims)
|
||||||
_prims.Remove(prim);
|
_prims.Remove(prim.LocalID);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OdePrim getPrim(uint id)
|
||||||
|
{
|
||||||
|
lock (_prims)
|
||||||
|
{
|
||||||
|
if(_prims.ContainsKey(id))
|
||||||
|
return _prims[id];
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool havePrim(OdePrim prm)
|
public bool havePrim(OdePrim prm)
|
||||||
{
|
{
|
||||||
lock (_prims)
|
lock (_prims)
|
||||||
return _prims.Contains(prm);
|
return _prims.ContainsKey(prm.LocalID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool haveActor(PhysicsActor actor)
|
public bool haveActor(PhysicsActor actor)
|
||||||
|
@ -1407,7 +1418,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
if (actor is OdePrim)
|
if (actor is OdePrim)
|
||||||
{
|
{
|
||||||
lock (_prims)
|
lock (_prims)
|
||||||
return _prims.Contains((OdePrim)actor);
|
return _prims.ContainsKey(((OdePrim)actor).LocalID);
|
||||||
}
|
}
|
||||||
else if (actor is OdeCharacter)
|
else if (actor is OdeCharacter)
|
||||||
{
|
{
|
||||||
|
@ -1708,6 +1719,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
m_rayCastManager.ProcessQueuedRequests();
|
m_rayCastManager.ProcessQueuedRequests();
|
||||||
|
|
||||||
collision_optimized();
|
collision_optimized();
|
||||||
|
List<OdePrim> sleepers = new List<OdePrim>();
|
||||||
|
|
||||||
foreach (PhysicsActor obj in _collisionEventPrim)
|
foreach (PhysicsActor obj in _collisionEventPrim)
|
||||||
{
|
{
|
||||||
|
@ -1718,21 +1730,27 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
{
|
{
|
||||||
case ActorTypes.Agent:
|
case ActorTypes.Agent:
|
||||||
OdeCharacter cobj = (OdeCharacter)obj;
|
OdeCharacter cobj = (OdeCharacter)obj;
|
||||||
cobj.AddCollisionFrameTime((int)(odetimestepMS));
|
cobj.SendCollisions((int)(odetimestepMS));
|
||||||
cobj.SendCollisions();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ActorTypes.Prim:
|
case ActorTypes.Prim:
|
||||||
OdePrim pobj = (OdePrim)obj;
|
OdePrim pobj = (OdePrim)obj;
|
||||||
if (!pobj.m_outbounds && (pobj.Body == IntPtr.Zero || d.BodyIsEnabled(pobj.Body)))
|
if (!pobj.m_outbounds)
|
||||||
{
|
{
|
||||||
pobj.AddCollisionFrameTime((int)(odetimestepMS));
|
pobj.SendCollisions((int)(odetimestepMS));
|
||||||
pobj.SendCollisions();
|
if(pobj.Body != IntPtr.Zero && !pobj.m_isSelected &&
|
||||||
|
!pobj.m_disabled && !pobj.m_building &&
|
||||||
|
!d.BodyIsEnabled(pobj.Body))
|
||||||
|
sleepers.Add(pobj);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach(OdePrim prm in sleepers)
|
||||||
|
prm.SleeperAddCollisionEvents();
|
||||||
|
sleepers.Clear();
|
||||||
|
|
||||||
foreach (PhysicsActor obj in _collisionEventPrimRemove)
|
foreach (PhysicsActor obj in _collisionEventPrimRemove)
|
||||||
_collisionEventPrim.Remove(obj);
|
_collisionEventPrim.Remove(obj);
|
||||||
|
|
||||||
|
@ -2481,7 +2499,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
lock (_prims)
|
lock (_prims)
|
||||||
{
|
{
|
||||||
ChangesQueue.Clear();
|
ChangesQueue.Clear();
|
||||||
foreach (OdePrim prm in _prims)
|
foreach (OdePrim prm in _prims.Values)
|
||||||
{
|
{
|
||||||
prm.DoAChange(changes.Remove, null);
|
prm.DoAChange(changes.Remove, null);
|
||||||
_collisionEventPrim.Remove(prm);
|
_collisionEventPrim.Remove(prm);
|
||||||
|
@ -2544,7 +2562,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
lock (_prims)
|
lock (_prims)
|
||||||
{
|
{
|
||||||
foreach (OdePrim prm in _prims)
|
foreach (OdePrim prm in _prims.Values)
|
||||||
{
|
{
|
||||||
if (prm.CollisionScore > 0)
|
if (prm.CollisionScore > 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue