In collisions report linksets root parts to parts, and not all parts.

Temporary suspend collision checks on full stopped bodies, until a better
away is found wake them, avoiding spurius collision end and start events.
Until a nice way is found to avoid them, this may cause some higher cpu load. plus some clean up
avinationmerge
UbitUmarov 2012-07-13 23:57:45 +01:00
parent 39262f6232
commit 72e2b94094
4 changed files with 45 additions and 41 deletions

View File

@ -95,7 +95,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private bool m_iscollidingObj = false; private bool m_iscollidingObj = false;
private bool m_alwaysRun = false; private bool m_alwaysRun = false;
private int m_requestedUpdateFrequency = 0; private int m_requestedUpdateFrequency = 0;
public uint m_localID = 0; private uint m_localID = 0;
public bool m_returnCollisions = false; public bool m_returnCollisions = false;
// taints and their non-tainted counterparts // taints and their non-tainted counterparts
public bool m_isPhysical = false; // the current physical status public bool m_isPhysical = false; // the current physical status
@ -214,6 +214,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public override uint LocalID public override uint LocalID
{ {
get { return m_localID; }
set { m_localID = value; } set { m_localID = value; }
} }

View File

@ -101,7 +101,6 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_invTimeStep = 50.0f; private float m_invTimeStep = 50.0f;
private float m_timeStep = .02f; private float m_timeStep = .02f;
private Vector3 m_PIDTarget; private Vector3 m_PIDTarget;
private float m_PIDTau; private float m_PIDTau;
private bool m_usePID; private bool m_usePID;
@ -119,7 +118,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_buoyancy; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle. private float m_buoyancy; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle.
private int body_autodisable_frames = 5; private int body_autodisable_frames = 5;
private int bodydisablecontrol = 0; public int bodydisablecontrol = 0;
// Default we're a Geometry // Default we're a Geometry
@ -144,7 +143,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public bool m_disabled; public bool m_disabled;
public uint m_localID; private uint m_localID;
private IMesh m_mesh; private IMesh m_mesh;
private object m_meshlock = new object(); private object m_meshlock = new object();
@ -167,7 +166,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// private bool m_throttleUpdates; // private bool m_throttleUpdates;
// private int throttleCounter; // private int throttleCounter;
public float m_collisionscore; public float m_collisionscore;
int m_colliderfilter = 0; private int m_colliderfilter = 0;
public IntPtr collide_geom; // for objects: geom if single prim space it linkset public IntPtr collide_geom; // for objects: geom if single prim space it linkset
@ -235,7 +234,6 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
public override bool Phantom // this is not reliable for internal use public override bool Phantom // this is not reliable for internal use
{ {
get { return m_fakeisphantom; } get { return m_fakeisphantom; }
@ -292,15 +290,19 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
public override uint LocalID public override uint LocalID
{
get { return m_localID; }
set { m_localID = value; }
}
public OdePrim Parent
{ {
get get
{ {
return m_localID; if (childPrim)
} return (OdePrim)_parent;
set else
{ return this;
//m_log.Info("[PHYSICS]: Setting TrackerID: " + value);
m_localID = value;
} }
} }
@ -945,8 +947,7 @@ namespace OpenSim.Region.Physics.OdePlugin
CollisionEventsThisFrame = null; CollisionEventsThisFrame = null;
} }
m_eventsubscription = 0; m_eventsubscription = 0;
// for now still done on odescene _parent_scene.RemoveCollisionEventReporting(this);
// _parent_scene.RemoveCollisionEventReporting(this);
} }
public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) public void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
@ -980,10 +981,6 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
else else
{ {
if (ncolisions > 10)
{
}
SentEmptyCollisionsEvent = false; SentEmptyCollisionsEvent = false;
CollisionEventsThisFrame.Clear(); CollisionEventsThisFrame.Clear();
} }
@ -1833,7 +1830,6 @@ namespace OpenSim.Region.Physics.OdePlugin
d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z); d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z);
d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z);
} }
_parent_scene.addActiveGroups(this); _parent_scene.addActiveGroups(this);
} }
@ -3700,6 +3696,8 @@ namespace OpenSim.Region.Physics.OdePlugin
d.BodySetAngularVel(Body, 0, 0, 0); d.BodySetAngularVel(Body, 0, 0, 0);
d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
disableBodySoft(); // stop collisions disableBodySoft(); // stop collisions
UnSubscribeEvents();
base.RequestPhysicsterseUpdate(); base.RequestPhysicsterseUpdate();
return; return;
} }
@ -3871,7 +3869,6 @@ namespace OpenSim.Region.Physics.OdePlugin
m_vehicle = null; m_vehicle = null;
RemoveGeom(); RemoveGeom();
m_targetSpace = IntPtr.Zero; m_targetSpace = IntPtr.Zero;
if (m_eventsubscription > 0)
UnSubscribeEvents(); UnSubscribeEvents();
return true; return true;

View File

@ -509,14 +509,14 @@ namespace OpenSim.Region.Physics.OdePlugin
if ((thisFlags & CurrentRayFilter) == 0) if ((thisFlags & CurrentRayFilter) == 0)
return; return;
ID = ((OdePrim)p2).m_localID; ID = ((OdePrim)p2).LocalID;
} }
else if (p2 is OdeCharacter) else if (p2 is OdeCharacter)
{ {
if ((CurrentRayFilter & RayFilterFlags.agent) == 0) if ((CurrentRayFilter & RayFilterFlags.agent) == 0)
return; return;
else else
ID = ((OdeCharacter)p2).m_localID; ID = ((OdeCharacter)p2).LocalID;
} }
else //?? else //??
return; return;

View File

@ -1171,6 +1171,8 @@ namespace OpenSim.Region.Physics.OdePlugin
OdePrim cp1; OdePrim cp1;
OdeCharacter cc2; OdeCharacter cc2;
OdePrim cp2; OdePrim cp2;
OdePrim cp1Parent;
OdePrim cp2Parent;
uint obj2LocalID = 0; uint obj2LocalID = 0;
bool p1events = p1.SubscribedEvents(); bool p1events = p1.SubscribedEvents();
@ -1207,18 +1209,19 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
case ActorTypes.Agent: case ActorTypes.Agent:
cc2 = (OdeCharacter)p2; cc2 = (OdeCharacter)p2;
obj2LocalID = cc2.m_localID; obj2LocalID = cc2.LocalID;
if (p2events) if (p2events)
cc2.AddCollisionEvent(cc1.m_localID, contact); cc2.AddCollisionEvent(cc1.LocalID, contact);
break; break;
case ActorTypes.Prim: case ActorTypes.Prim:
if (p2 is OdePrim) if (p2 is OdePrim)
{ {
cp2 = (OdePrim)p2; cp2 = (OdePrim)p2;
obj2LocalID = cp2.m_localID;
if (p2events) if (p2events)
cp2.AddCollisionEvent(cc1.m_localID, contact); cp2.AddCollisionEvent(cc1.LocalID, contact);
cp2 = cp2.Parent;
obj2LocalID = cp2.LocalID;
} }
break; break;
@ -1240,17 +1243,16 @@ namespace OpenSim.Region.Physics.OdePlugin
if (p1 is OdePrim) if (p1 is OdePrim)
{ {
cp1 = (OdePrim)p1; cp1 = (OdePrim)p1;
cp1Parent = cp1.Parent;
// obj1LocalID = cp2.m_localID;
switch ((ActorTypes)p2.PhysicsActorType) switch ((ActorTypes)p2.PhysicsActorType)
{ {
case ActorTypes.Agent: case ActorTypes.Agent:
if (p2 is OdeCharacter) if (p2 is OdeCharacter)
{ {
cc2 = (OdeCharacter)p2; cc2 = (OdeCharacter)p2;
obj2LocalID = cc2.m_localID; obj2LocalID = cc2.LocalID;
if (p2events) if (p2events)
cc2.AddCollisionEvent(cp1.m_localID, contact); cc2.AddCollisionEvent(cp1Parent.LocalID, contact);
} }
break; break;
case ActorTypes.Prim: case ActorTypes.Prim:
@ -1258,9 +1260,10 @@ namespace OpenSim.Region.Physics.OdePlugin
if (p2 is OdePrim) if (p2 is OdePrim)
{ {
cp2 = (OdePrim)p2; cp2 = (OdePrim)p2;
obj2LocalID = cp2.m_localID;
if (p2events) if (p2events)
cp2.AddCollisionEvent(cp1.m_localID, contact); cp2.AddCollisionEvent(cp1Parent.LocalID, contact);
cp2 = cp2.Parent;
obj2LocalID = cp2.LocalID;
} }
break; break;
@ -1286,7 +1289,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (p2 is OdeCharacter) if (p2 is OdeCharacter)
{ {
cc2 = (OdeCharacter)p2; cc2 = (OdeCharacter)p2;
obj2LocalID = cc2.m_localID; obj2LocalID = cc2.LocalID;
if (p2events) if (p2events)
cc2.AddCollisionEvent(0, contact); cc2.AddCollisionEvent(0, contact);
} }
@ -1295,7 +1298,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (p2 is OdePrim) if (p2 is OdePrim)
{ {
cp2 = (OdePrim)p2; cp2 = (OdePrim)p2;
obj2LocalID = cp2.m_localID; obj2LocalID = cp2.LocalID;
if (p2events) if (p2events)
cp2.AddCollisionEvent(0, contact); cp2.AddCollisionEvent(0, contact);
} }
@ -1350,10 +1353,13 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
foreach (OdePrim prm in _activegroups) foreach (OdePrim prm in _activegroups)
{ {
if (d.BodyIsEnabled(prm.Body) && !prm.m_outbounds) if (!prm.m_outbounds)
{
// if (d.BodyIsEnabled(prm.Body))
d.SpaceCollide2(StaticSpace, prm.collide_geom, IntPtr.Zero, nearCallback); d.SpaceCollide2(StaticSpace, prm.collide_geom, IntPtr.Zero, nearCallback);
} }
} }
}
catch (AccessViolationException) catch (AccessViolationException)
{ {
m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space"); m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space");
@ -1604,7 +1610,7 @@ namespace OpenSim.Region.Physics.OdePlugin
//Console.WriteLine("RemovePrimThreadLocked " + prim.m_primName); //Console.WriteLine("RemovePrimThreadLocked " + prim.m_primName);
lock (prim) lock (prim)
{ {
RemoveCollisionEventReporting(prim); // RemoveCollisionEventReporting(prim);
lock (_prims) lock (_prims)
_prims.Remove(prim); _prims.Remove(prim);
} }
@ -2012,6 +2018,7 @@ 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)) if (pobj.Body == IntPtr.Zero || (d.BodyIsEnabled(pobj.Body) && !pobj.m_outbounds))
if (!pobj.m_outbounds)
{ {
pobj.AddCollisionFrameTime((int)(odetimestepMS)); pobj.AddCollisionFrameTime((int)(odetimestepMS));
pobj.SendCollisions(); pobj.SendCollisions();
@ -2728,7 +2735,6 @@ namespace OpenSim.Region.Physics.OdePlugin
WaterMapHandler.Free(); WaterMapHandler.Free();
} }
if (ContactgeomsArray != IntPtr.Zero) if (ContactgeomsArray != IntPtr.Zero)
Marshal.FreeHGlobal(ContactgeomsArray); Marshal.FreeHGlobal(ContactgeomsArray);
if (GlobalContactsArray != IntPtr.Zero) if (GlobalContactsArray != IntPtr.Zero)
@ -2751,7 +2757,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (prm.CollisionScore > 0) if (prm.CollisionScore > 0)
{ {
returncolliders.Add(prm.m_localID, prm.CollisionScore); returncolliders.Add(prm.LocalID, prm.CollisionScore);
cnt++; cnt++;
prm.CollisionScore = 0f; prm.CollisionScore = 0f;
if (cnt > 25) if (cnt > 25)