* Committing some collision stuffs that I'm working on.
* Nothing user facing yet.0.6.0-stable
parent
18362b25bf
commit
07167c9a3f
|
@ -1659,7 +1659,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
Ray NewRay = new Ray(AXOrigin, AXdirection);
|
||||
|
||||
// Ray Trace against target here
|
||||
EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1, 0, 0, 0), frontFacesOnly, CopyCenters);
|
||||
EntityIntersection ei = target.TestIntersectionOBB(NewRay, new Quaternion(1, 0, 0, 0), frontFacesOnly, false);
|
||||
|
||||
// Un-comment out the following line to Get Raytrace results printed to the console.
|
||||
// m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
|
||||
|
@ -1676,16 +1676,17 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
ScaleOffset = Math.Abs(ScaleOffset);
|
||||
LLVector3 intersectionpoint = new LLVector3(ei.ipoint.x, ei.ipoint.y, ei.ipoint.z);
|
||||
LLVector3 normal = new LLVector3(ei.normal.x, ei.normal.y, ei.normal.z);
|
||||
|
||||
LLVector3 offset = (normal * (ScaleOffset / 2f));
|
||||
pos = (intersectionpoint + offset);
|
||||
|
||||
if (CopyCenters)
|
||||
{
|
||||
// now we cast a ray from inside the prim(absolute position) to one of it's faces along the face normal.
|
||||
LLVector3 direction2 = LLVector3.Norm(intersectionpoint - target2.AbsolutePosition);
|
||||
LLVector3 direction2 = LLVector3.Norm(pos - target2.AbsolutePosition);
|
||||
Vector3 AXOrigin2 = new Vector3(target2.AbsolutePosition.X, target2.AbsolutePosition.Y, target2.AbsolutePosition.Z);
|
||||
Vector3 AXdirection2 = ei.AAfaceNormal;
|
||||
Vector3 AXdirection2 = new Vector3(direction2.X, direction2.Y, direction2.Z); //ei.AAfaceNormal;
|
||||
Ray NewRay2 = new Ray(AXOrigin2, AXdirection2);
|
||||
EntityIntersection ei2 = target.TestIntersectionOBB(NewRay2, new Quaternion(1, 0, 0, 0), true, CopyCenters);
|
||||
EntityIntersection ei2 = target.TestIntersectionOBB(NewRay2, new Quaternion(1, 0, 0, 0), false, CopyCenters);
|
||||
if (ei2.HitTF)
|
||||
{
|
||||
//m_log.Info("[RAYTRACERESULTS]: Hit:" + ei2.HitTF.ToString() + " Point: " + ei2.ipoint.ToString() + " Normal: " + ei2.normal.ToString());
|
||||
|
@ -1697,7 +1698,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
}
|
||||
|
||||
// Set the position to the intersection point
|
||||
LLVector3 offset = (normal * (ScaleOffset / 2f));
|
||||
offset = (normal * (ScaleOffset / 2f));
|
||||
pos = (intersectionpoint + offset);
|
||||
|
||||
// stick in offset format from the original prim
|
||||
|
|
|
@ -1329,7 +1329,15 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
AmBa = FaceA[i] - FaceB[i];
|
||||
AmBb = FaceB[i] - FaceC[i];
|
||||
d = normals[i].Dot(FaceB[i]);
|
||||
c = iray.Direction.Dot(normals[i]);
|
||||
|
||||
if (faceCenters)
|
||||
{
|
||||
c = normals[i].Dot(normals[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
c = iray.Direction.Dot(normals[i]);
|
||||
}
|
||||
if (c == 0)
|
||||
continue;
|
||||
|
||||
|
@ -1339,12 +1347,15 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
continue;
|
||||
|
||||
// If the normal is pointing outside the object
|
||||
|
||||
|
||||
|
||||
if (iray.Direction.Dot(normals[i]) < 0 || !frontFacesOnly)
|
||||
{
|
||||
|
||||
if (faceCenters)
|
||||
{
|
||||
q = (FaceA[i] + FaceB[i] + FaceC[1] + FaceD[i]) / 4f; //iray.Origin + a * normals[i];
|
||||
{ //(FaceA[i] + FaceB[i] + FaceC[1] + FaceD[i]) / 4f;
|
||||
q = iray.Origin + a * normals[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1364,8 +1375,9 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
returnresult.distance = distance2;
|
||||
returnresult.HitTF = true;
|
||||
returnresult.ipoint = q;
|
||||
//m_log.Info("[FACE]:" + i.ToString());
|
||||
//m_log.Info("[POINT]: " + q.ToString());
|
||||
m_log.Info("[FACE]:" + i.ToString());
|
||||
m_log.Info("[POINT]: " + q.ToString());
|
||||
m_log.Info("[DIST]: " + distance2.ToString());
|
||||
returnresult.normal = normals[i];
|
||||
returnresult.AAfaceNormal = AAfacenormals[i];
|
||||
|
||||
|
@ -2680,6 +2692,20 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
)
|
||||
{
|
||||
// subscribe to physics updates.
|
||||
if (PhysActor != null)
|
||||
{
|
||||
PhysActor.OnCollisionUpdate += PhysicsCollision;
|
||||
PhysActor.SubscribeEvents(1000);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PhysActor != null)
|
||||
{
|
||||
PhysActor.UnSubscribeEvents();
|
||||
PhysActor.OnCollisionUpdate -= PhysicsCollision;
|
||||
}
|
||||
}
|
||||
|
||||
LocalFlags=(LLObject.ObjectFlags)objectflagupdate;
|
||||
|
@ -2689,5 +2715,24 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
else
|
||||
ScheduleFullUpdate();
|
||||
}
|
||||
public void PhysicsCollision(EventArgs e)
|
||||
{
|
||||
|
||||
return;
|
||||
|
||||
//
|
||||
//if (e == null)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//CollisionEventUpdate a = (CollisionEventUpdate)e;
|
||||
//Dictionary<uint, float> collissionswith = a.m_objCollisionList;
|
||||
//foreach (uint localid in collissionswith.Keys)
|
||||
//{
|
||||
// m_log.Debug("[OBJECT]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -398,5 +398,17 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
|
|||
public override PhysicsVector PIDTarget { set { return; } }
|
||||
public override bool PIDActive { set { return; } }
|
||||
public override float PIDTau { set { return; } }
|
||||
public override void SubscribeEvents(int ms)
|
||||
{
|
||||
|
||||
}
|
||||
public override void UnSubscribeEvents()
|
||||
{
|
||||
|
||||
}
|
||||
public override bool SubscribedEvents()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -996,6 +996,18 @@ namespace OpenSim.Region.Physics.BulletXPlugin
|
|||
public override PhysicsVector PIDTarget { set { return; } }
|
||||
public override bool PIDActive { set { return; } }
|
||||
public override float PIDTau { set { return; } }
|
||||
public override void SubscribeEvents(int ms)
|
||||
{
|
||||
|
||||
}
|
||||
public override void UnSubscribeEvents()
|
||||
{
|
||||
|
||||
}
|
||||
public override bool SubscribedEvents()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -51,9 +51,9 @@ namespace OpenSim.Region.Physics.Manager
|
|||
public int m_colliderType;
|
||||
public int m_GenericStartEnd;
|
||||
//public uint m_LocalID;
|
||||
public List<uint> m_objCollisionList;
|
||||
public Dictionary<uint,float> m_objCollisionList = new Dictionary<uint,float>();
|
||||
|
||||
public CollisionEventUpdate(uint localID, int colliderType, int GenericStartEnd, List<uint> objCollisionList)
|
||||
public CollisionEventUpdate(uint localID, int colliderType, int GenericStartEnd, Dictionary<uint, float> objCollisionList)
|
||||
{
|
||||
m_colliderType = colliderType;
|
||||
m_GenericStartEnd = GenericStartEnd;
|
||||
|
@ -64,7 +64,8 @@ namespace OpenSim.Region.Physics.Manager
|
|||
{
|
||||
m_colliderType = (int) ActorTypes.Unknown;
|
||||
m_GenericStartEnd = 1;
|
||||
m_objCollisionList = null;
|
||||
// m_objCollisionList = null;
|
||||
m_objCollisionList = new Dictionary<uint, float>();
|
||||
}
|
||||
|
||||
public int collidertype
|
||||
|
@ -79,9 +80,17 @@ namespace OpenSim.Region.Physics.Manager
|
|||
set { m_GenericStartEnd = value; }
|
||||
}
|
||||
|
||||
public void addCollider(uint localID)
|
||||
public void addCollider(uint localID, float depth)
|
||||
{
|
||||
m_objCollisionList.Add(localID);
|
||||
if (!m_objCollisionList.ContainsKey(localID))
|
||||
{
|
||||
m_objCollisionList.Add(localID, depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_objCollisionList[localID] < depth)
|
||||
m_objCollisionList[localID] = depth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,6 +198,9 @@ namespace OpenSim.Region.Physics.Manager
|
|||
|
||||
public abstract void AddForce(PhysicsVector force);
|
||||
public abstract void SetMomentum(PhysicsVector momentum);
|
||||
public abstract void SubscribeEvents(int ms);
|
||||
public abstract void UnSubscribeEvents();
|
||||
public abstract bool SubscribedEvents();
|
||||
}
|
||||
|
||||
public class NullPhysicsActor : PhysicsActor
|
||||
|
@ -370,5 +382,18 @@ namespace OpenSim.Region.Physics.Manager
|
|||
public override void SetMomentum(PhysicsVector momentum)
|
||||
{
|
||||
}
|
||||
|
||||
public override void SubscribeEvents(int ms)
|
||||
{
|
||||
|
||||
}
|
||||
public override void UnSubscribeEvents()
|
||||
{
|
||||
|
||||
}
|
||||
public override bool SubscribedEvents()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,6 +112,9 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
public d.Mass ShellMass;
|
||||
public bool collidelock = false;
|
||||
|
||||
public int m_eventsubscription = 0;
|
||||
private CollisionEventUpdate CollisionEventsThisFrame = null;
|
||||
|
||||
public OdeCharacter(String avName, OdeScene parent_scene, PhysicsVector pos, CollisionLocker dode, PhysicsVector size)
|
||||
{
|
||||
ode = dode;
|
||||
|
@ -863,5 +866,33 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
public override PhysicsVector PIDTarget { set { return; } }
|
||||
public override bool PIDActive { set { return; } }
|
||||
public override float PIDTau { set { return; } }
|
||||
public override void SubscribeEvents(int ms)
|
||||
{
|
||||
m_eventsubscription = ms;
|
||||
}
|
||||
public override void UnSubscribeEvents()
|
||||
{
|
||||
m_eventsubscription = 0;
|
||||
}
|
||||
public void AddCollisionEvent(uint CollidedWith, float depth)
|
||||
{
|
||||
if (m_eventsubscription > 0)
|
||||
CollisionEventsThisFrame.addCollider(CollidedWith,depth);
|
||||
}
|
||||
|
||||
public void SendCollisions()
|
||||
{
|
||||
if (m_eventsubscription > 0)
|
||||
{
|
||||
base.SendCollisionUpdate(CollisionEventsThisFrame);
|
||||
CollisionEventsThisFrame = new CollisionEventUpdate();
|
||||
}
|
||||
}
|
||||
public override bool SubscribedEvents()
|
||||
{
|
||||
if (m_eventsubscription > 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,8 +136,12 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
private PhysicsVector _target_velocity;
|
||||
public d.Mass pMass;
|
||||
|
||||
public int m_eventsubscription = 0;
|
||||
private CollisionEventUpdate CollisionEventsThisFrame = null;
|
||||
|
||||
private IntPtr m_linkJoint = (IntPtr)0;
|
||||
|
||||
|
||||
public OdePrim(String primName, OdeScene parent_scene, PhysicsVector pos, PhysicsVector size,
|
||||
Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode)
|
||||
{
|
||||
|
@ -201,12 +205,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Nasty, however without this you get
|
||||
/// 'invalid operation for locked space' when things are really loaded down
|
||||
/// </summary>
|
||||
/// <param name="space"></param>
|
||||
|
||||
public override int PhysicsActorType
|
||||
{
|
||||
get { return (int) ActorTypes.Prim; }
|
||||
|
@ -2229,5 +2227,42 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f);
|
||||
d.JointSetAMotorParam(Amotor, (int)dParam.FMax, m_tensor);
|
||||
}
|
||||
public override void SubscribeEvents(int ms)
|
||||
{
|
||||
m_eventsubscription = ms;
|
||||
_parent_scene.addCollisionEventReporting(this);
|
||||
}
|
||||
public override void UnSubscribeEvents()
|
||||
{
|
||||
_parent_scene.remCollisionEventReporting(this);
|
||||
m_eventsubscription = 0;
|
||||
}
|
||||
public void AddCollisionEvent(uint CollidedWith, float depth)
|
||||
{
|
||||
if (CollisionEventsThisFrame == null)
|
||||
CollisionEventsThisFrame = new CollisionEventUpdate();
|
||||
CollisionEventsThisFrame.addCollider(CollidedWith,depth);
|
||||
}
|
||||
|
||||
public void SendCollisions()
|
||||
{
|
||||
if (CollisionEventsThisFrame == null)
|
||||
return;
|
||||
|
||||
//if (CollisionEventsThisFrame.m_objCollisionList == null)
|
||||
// return;
|
||||
|
||||
if (CollisionEventsThisFrame.m_objCollisionList.Count > 0)
|
||||
{
|
||||
base.SendCollisionUpdate(CollisionEventsThisFrame);
|
||||
CollisionEventsThisFrame = new CollisionEventUpdate();
|
||||
}
|
||||
}
|
||||
public override bool SubscribedEvents()
|
||||
{
|
||||
if (m_eventsubscription > 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
|
||||
private float waterlevel = 0f;
|
||||
private int framecount = 0;
|
||||
private int m_returncollisions = 10;
|
||||
//private int m_returncollisions = 10;
|
||||
|
||||
private IntPtr contactgroup;
|
||||
private IntPtr LandGeom = (IntPtr) 0;
|
||||
|
@ -151,6 +151,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
private List<OdePrim> _prims = new List<OdePrim>();
|
||||
private List<OdePrim> _activeprims = new List<OdePrim>();
|
||||
private List<OdePrim> _taintedPrim = new List<OdePrim>();
|
||||
private List<PhysicsActor> _collisionEventPrim = new List<PhysicsActor>();
|
||||
public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
|
||||
public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>();
|
||||
private d.ContactGeom[] contacts = new d.ContactGeom[80];
|
||||
|
@ -171,16 +172,16 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
//Ckrinke: Comment out until used. We declare it, initialize it, but do not use it
|
||||
//Ckrinke private int ms = 0;
|
||||
public IntPtr world;
|
||||
private bool returncollisions = false;
|
||||
//private bool returncollisions = false;
|
||||
private uint obj1LocalID = 0;
|
||||
private uint obj2LocalID = 0;
|
||||
private int ctype = 0;
|
||||
//private int ctype = 0;
|
||||
private OdeCharacter cc1;
|
||||
private OdePrim cp1;
|
||||
private OdeCharacter cc2;
|
||||
private OdePrim cp2;
|
||||
private int cStartStop = 0;
|
||||
private string cDictKey = "";
|
||||
//private int cStartStop = 0;
|
||||
//private string cDictKey = "";
|
||||
|
||||
public IntPtr space;
|
||||
|
||||
|
@ -413,27 +414,32 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
PhysicsActor p1;
|
||||
PhysicsActor p2;
|
||||
|
||||
if (!actor_name_map.TryGetValue(g1, out p1))
|
||||
{
|
||||
p1 = PANull;
|
||||
}
|
||||
if (!actor_name_map.TryGetValue(g2, out p2))
|
||||
{
|
||||
p2 = PANull;
|
||||
}
|
||||
|
||||
float max_collision_depth = 0f;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
max_collision_depth = (contacts[i].depth > max_collision_depth) ? contacts[i].depth : max_collision_depth;
|
||||
//m_log.Warn("[CCOUNT]: " + count);
|
||||
IntPtr joint;
|
||||
// If we're colliding with terrain, use 'TerrainContact' instead of contact.
|
||||
// allows us to have different settings
|
||||
|
||||
if (!actor_name_map.TryGetValue(g1, out p1))
|
||||
{
|
||||
p1 = PANull;
|
||||
}
|
||||
if (!actor_name_map.TryGetValue(g2, out p2))
|
||||
{
|
||||
p2 = PANull;
|
||||
}
|
||||
|
||||
|
||||
// We only need to test p2 for 'jump crouch purposes'
|
||||
p2.IsColliding = true;
|
||||
|
||||
//if ((framecount % m_returncollisions) == 0)
|
||||
//collision_accounting_events(p1, p2);
|
||||
|
||||
|
||||
|
||||
switch (p1.PhysicsActorType)
|
||||
|
@ -674,7 +680,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
}
|
||||
d.JointAttach(joint, b1, b2);
|
||||
}
|
||||
|
||||
collision_accounting_events(p1, p2, max_collision_depth);
|
||||
if (count > 3)
|
||||
{
|
||||
// If there are more then 3 contact points, it's likely
|
||||
|
@ -690,130 +696,134 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
|
||||
}
|
||||
|
||||
private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2)
|
||||
private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, float collisiondepth)
|
||||
{
|
||||
obj1LocalID = 0;
|
||||
returncollisions = false;
|
||||
//returncollisions = false;
|
||||
obj2LocalID = 0;
|
||||
ctype = 0;
|
||||
cStartStop = 0;
|
||||
//ctype = 0;
|
||||
//cStartStop = 0;
|
||||
if (!p2.SubscribedEvents() && !p1.SubscribedEvents())
|
||||
return;
|
||||
|
||||
switch ((ActorTypes)p2.PhysicsActorType)
|
||||
{
|
||||
case ActorTypes.Agent:
|
||||
cc2 = (OdeCharacter)p2;
|
||||
if (cc2.m_returnCollisions)
|
||||
{
|
||||
|
||||
obj1LocalID = cc2.m_localID;
|
||||
switch ((ActorTypes)p1.PhysicsActorType)
|
||||
{
|
||||
case ActorTypes.Agent:
|
||||
cc1 = (OdeCharacter)p1;
|
||||
obj2LocalID = cc1.m_localID;
|
||||
ctype = (int)CollisionCategories.Character;
|
||||
cc1.AddCollisionEvent(cc2.m_localID, collisiondepth);
|
||||
//ctype = (int)CollisionCategories.Character;
|
||||
|
||||
if (cc1.CollidingObj)
|
||||
cStartStop = (int)StatusIndicators.Generic;
|
||||
else
|
||||
cStartStop = (int)StatusIndicators.Start;
|
||||
//if (cc1.CollidingObj)
|
||||
//cStartStop = (int)StatusIndicators.Generic;
|
||||
//else
|
||||
//cStartStop = (int)StatusIndicators.Start;
|
||||
|
||||
returncollisions = true;
|
||||
//returncollisions = true;
|
||||
break;
|
||||
case ActorTypes.Prim:
|
||||
cp1 = (OdePrim)p1;
|
||||
obj2LocalID = cp1.m_localID;
|
||||
ctype = (int)CollisionCategories.Geom;
|
||||
cp1.AddCollisionEvent(cc2.m_localID, collisiondepth);
|
||||
//ctype = (int)CollisionCategories.Geom;
|
||||
|
||||
if (cp1.CollidingObj)
|
||||
cStartStop = (int)StatusIndicators.Generic;
|
||||
else
|
||||
cStartStop = (int)StatusIndicators.Start;
|
||||
//if (cp1.CollidingObj)
|
||||
//cStartStop = (int)StatusIndicators.Generic;
|
||||
//else
|
||||
//cStartStop = (int)StatusIndicators.Start;
|
||||
|
||||
returncollisions = true;
|
||||
//returncollisions = true;
|
||||
break;
|
||||
|
||||
case ActorTypes.Ground:
|
||||
case ActorTypes.Unknown:
|
||||
obj2LocalID = 0;
|
||||
ctype = (int)CollisionCategories.Land;
|
||||
returncollisions = true;
|
||||
//ctype = (int)CollisionCategories.Land;
|
||||
//returncollisions = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
cc2.AddCollisionEvent(obj2LocalID, collisiondepth);
|
||||
break;
|
||||
case ActorTypes.Prim:
|
||||
cp2 = (OdePrim)p2;
|
||||
if (cp2.m_returnCollisions)
|
||||
{
|
||||
|
||||
obj1LocalID = cp2.m_localID;
|
||||
switch ((ActorTypes)p1.PhysicsActorType)
|
||||
{
|
||||
case ActorTypes.Agent:
|
||||
cc1 = (OdeCharacter)p1;
|
||||
obj2LocalID = cc1.m_localID;
|
||||
ctype = (int)CollisionCategories.Character;
|
||||
cc1.AddCollisionEvent(cp2.m_localID, collisiondepth);
|
||||
//ctype = (int)CollisionCategories.Character;
|
||||
|
||||
if (cc1.CollidingObj)
|
||||
cStartStop = (int)StatusIndicators.Generic;
|
||||
else
|
||||
cStartStop = (int)StatusIndicators.Start;
|
||||
returncollisions = true;
|
||||
//if (cc1.CollidingObj)
|
||||
//cStartStop = (int)StatusIndicators.Generic;
|
||||
//else
|
||||
//cStartStop = (int)StatusIndicators.Start;
|
||||
//returncollisions = true;
|
||||
|
||||
break;
|
||||
case ActorTypes.Prim:
|
||||
cp1 = (OdePrim)p1;
|
||||
obj2LocalID = cp1.m_localID;
|
||||
ctype = (int)CollisionCategories.Geom;
|
||||
cp1.AddCollisionEvent(cp2.m_localID, collisiondepth);
|
||||
//ctype = (int)CollisionCategories.Geom;
|
||||
|
||||
if (cp1.CollidingObj)
|
||||
cStartStop = (int)StatusIndicators.Generic;
|
||||
else
|
||||
cStartStop = (int)StatusIndicators.Start;
|
||||
//if (cp1.CollidingObj)
|
||||
//cStartStop = (int)StatusIndicators.Generic;
|
||||
//else
|
||||
//cStartStop = (int)StatusIndicators.Start;
|
||||
|
||||
returncollisions = true;
|
||||
//returncollisions = true;
|
||||
break;
|
||||
|
||||
case ActorTypes.Ground:
|
||||
case ActorTypes.Unknown:
|
||||
obj2LocalID = 0;
|
||||
ctype = (int)CollisionCategories.Land;
|
||||
//ctype = (int)CollisionCategories.Land;
|
||||
|
||||
returncollisions = true;
|
||||
//returncollisions = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cp2.AddCollisionEvent(obj2LocalID, collisiondepth);
|
||||
break;
|
||||
}
|
||||
if (returncollisions)
|
||||
{
|
||||
//if (returncollisions)
|
||||
//{
|
||||
|
||||
lock (m_storedCollisions)
|
||||
{
|
||||
cDictKey = obj1LocalID.ToString() + obj2LocalID.ToString() + cStartStop.ToString() + ctype.ToString();
|
||||
if (m_storedCollisions.ContainsKey(cDictKey))
|
||||
{
|
||||
sCollisionData objd = m_storedCollisions[cDictKey];
|
||||
objd.NumberOfCollisions += 1;
|
||||
objd.lastframe = framecount;
|
||||
m_storedCollisions[cDictKey] = objd;
|
||||
}
|
||||
else
|
||||
{
|
||||
sCollisionData objd = new sCollisionData();
|
||||
objd.ColliderLocalId = obj1LocalID;
|
||||
objd.CollidedWithLocalId = obj2LocalID;
|
||||
objd.CollisionType = ctype;
|
||||
objd.NumberOfCollisions = 1;
|
||||
objd.lastframe = framecount;
|
||||
objd.StatusIndicator = cStartStop;
|
||||
m_storedCollisions.Add(cDictKey, objd);
|
||||
}
|
||||
}
|
||||
}
|
||||
//lock (m_storedCollisions)
|
||||
//{
|
||||
//cDictKey = obj1LocalID.ToString() + obj2LocalID.ToString() + cStartStop.ToString() + ctype.ToString();
|
||||
//if (m_storedCollisions.ContainsKey(cDictKey))
|
||||
//{
|
||||
//sCollisionData objd = m_storedCollisions[cDictKey];
|
||||
//objd.NumberOfCollisions += 1;
|
||||
//objd.lastframe = framecount;
|
||||
//m_storedCollisions[cDictKey] = objd;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
//sCollisionData objd = new sCollisionData();
|
||||
//objd.ColliderLocalId = obj1LocalID;
|
||||
//objd.CollidedWithLocalId = obj2LocalID;
|
||||
//objd.CollisionType = ctype;
|
||||
//objd.NumberOfCollisions = 1;
|
||||
//objd.lastframe = framecount;
|
||||
//objd.StatusIndicator = cStartStop;
|
||||
//m_storedCollisions.Add(cDictKey, objd);
|
||||
//}
|
||||
//}
|
||||
// }
|
||||
}
|
||||
|
||||
public int TriArrayCallback(IntPtr trimesh, IntPtr refObject, int[] triangleIndex, int triCount)
|
||||
|
@ -940,6 +950,26 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
// return (float)_origheightmap[(int)y * Constants.RegionSize + (int)x];
|
||||
// }
|
||||
|
||||
public void addCollisionEventReporting(PhysicsActor obj)
|
||||
{
|
||||
lock(_collisionEventPrim)
|
||||
{
|
||||
if (!_collisionEventPrim.Contains(obj))
|
||||
_collisionEventPrim.Add(obj);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void remCollisionEventReporting(PhysicsActor obj)
|
||||
{
|
||||
lock (_collisionEventPrim)
|
||||
{
|
||||
if (!_collisionEventPrim.Contains(obj))
|
||||
_collisionEventPrim.Remove(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Add/Remove Entities
|
||||
|
||||
public override PhysicsActor AddAvatar(string avName, PhysicsVector position, PhysicsVector size)
|
||||
|
@ -1068,6 +1098,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
{
|
||||
lock (prim)
|
||||
{
|
||||
remCollisionEventReporting(prim);
|
||||
lock (ode)
|
||||
{
|
||||
if (prim.prim_geom != (IntPtr)0)
|
||||
|
@ -1551,6 +1582,28 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
|
||||
collision_optimized(timeStep);
|
||||
|
||||
lock (_collisionEventPrim)
|
||||
{
|
||||
foreach (PhysicsActor obj in _collisionEventPrim)
|
||||
{
|
||||
if (obj == null)
|
||||
continue;
|
||||
|
||||
switch ((ActorTypes)obj.PhysicsActorType)
|
||||
{
|
||||
case ActorTypes.Agent:
|
||||
OdeCharacter cobj = (OdeCharacter)obj;
|
||||
cobj.SendCollisions();
|
||||
break;
|
||||
case ActorTypes.Prim:
|
||||
OdePrim pobj = (OdePrim)obj;
|
||||
pobj.SendCollisions();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
d.WorldQuickStep(world, ODE_STEPSIZE);
|
||||
|
||||
d.JointGroupEmpty(contactgroup);
|
||||
|
|
|
@ -527,6 +527,18 @@ namespace OpenSim.Region.Physics.POSPlugin
|
|||
public override PhysicsVector PIDTarget { set { return; } }
|
||||
public override bool PIDActive { set { return; } }
|
||||
public override float PIDTau { set { return; } }
|
||||
public override void SubscribeEvents(int ms)
|
||||
{
|
||||
|
||||
}
|
||||
public override void UnSubscribeEvents()
|
||||
{
|
||||
|
||||
}
|
||||
public override bool SubscribedEvents()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class POSPrim : PhysicsActor
|
||||
|
@ -728,5 +740,17 @@ namespace OpenSim.Region.Physics.POSPlugin
|
|||
public override PhysicsVector PIDTarget { set { return; } }
|
||||
public override bool PIDActive { set { return; } }
|
||||
public override float PIDTau { set { return; } }
|
||||
public override void SubscribeEvents(int ms)
|
||||
{
|
||||
|
||||
}
|
||||
public override void UnSubscribeEvents()
|
||||
{
|
||||
|
||||
}
|
||||
public override bool SubscribedEvents()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -441,6 +441,18 @@ namespace OpenSim.Region.Physics.PhysXPlugin
|
|||
public override PhysicsVector PIDTarget { set { return; } }
|
||||
public override bool PIDActive { set { return; } }
|
||||
public override float PIDTau { set { return; } }
|
||||
public override void SubscribeEvents(int ms)
|
||||
{
|
||||
|
||||
}
|
||||
public override void UnSubscribeEvents()
|
||||
{
|
||||
|
||||
}
|
||||
public override bool SubscribedEvents()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -666,5 +678,18 @@ namespace OpenSim.Region.Physics.PhysXPlugin
|
|||
public override PhysicsVector PIDTarget { set { return; } }
|
||||
public override bool PIDActive { set { return; } }
|
||||
public override float PIDTau { set { return; } }
|
||||
|
||||
public override void SubscribeEvents(int ms)
|
||||
{
|
||||
|
||||
}
|
||||
public override void UnSubscribeEvents()
|
||||
{
|
||||
|
||||
}
|
||||
public override bool SubscribedEvents()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue