void AddODECollision(d.ContactGeom curContact, PhysicsActor p1, PhysicsActor p2, IntPtr b1, IntPtr b2,
ContactPoint maxDepthContact, ref int NotSkipedCount)
{
IntPtr joint = IntPtr.Zero;
bool p2col = true;
// We only need to test p2 for 'jump crouch purposes'
if (p2 is ODECharacter && p1.PhysicsActorType == (int) ActorTypes.Prim)
{
// Testing if the collision is at the feet of the avatar
if ((p2.Position.Z - maxDepthContact.Position.Z) < (p2.Size.Z*0.5f))
p2col = false;
}
p2.IsTruelyColliding = true;
p2.IsColliding = p2col;
// Logic for collision handling
// Note, that if *all* contacts are skipped (VolumeDetect)
// The prim still detects (and forwards) collision events but
// appears to be phantom for the world
// No collision on volume detect prims
if ((p1 is ODEPrim && p1.VolumeDetect) ||
(p2 is ODEPrim && p2.VolumeDetect))
return;
if (curContact.depth < 0f)
return; //Has to be penetrating
if (m_filterCollisions &&
CheckDupe(curContact, p2.PhysicsActorType))
return;
if (m_filterCollisions)
_perloopContact.Add(curContact);
NotSkipedCount++;
// If we're colliding against terrain
if (p1.PhysicsActorType == (int) ActorTypes.Ground)
{
if (p2.PhysicsActorType == (int) ActorTypes.Prim)
{
((ODEPrim) p2).GetContactParam(p2, ref newGlobalcontact);
joint = CreateContacJoint(curContact);
}
else
{
newGlobalcontact = new d.Contact();
newGlobalcontact.surface.mode |= d.ContactFlags.SoftERP;
newGlobalcontact.surface.mu = 75;
newGlobalcontact.surface.bounce = 0.1f;
newGlobalcontact.surface.soft_erp = 0.05025f;
//GetContactParam(0.0f, AvatarContactBounce, ref newGlobalcontact);
joint = CreateContacJoint(curContact);
}
//Can't collide against anything else, agents do their own ground checks
}
else if ((p1.PhysicsActorType == (int) ActorTypes.Agent) &&
(p2.PhysicsActorType == (int) ActorTypes.Agent))
{
GetContactParam(0.0f, AvatarContactBounce, ref newGlobalcontact);
joint = CreateContacJoint(curContact);
}
else if (p1.PhysicsActorType == (int) ActorTypes.Prim)
{
//Add restitution and friction changes
// was.. greythane-20160602 >> // ((ODEPrim) p1).GetContactParam(p2, ref newGlobalcontact);
((ODEPrim)p1).GetContactParam (p1, ref newGlobalcontact);
joint = CreateContacJoint(curContact);
}
if (ContinueCollisionProcessing && joint != IntPtr.Zero)
{
d.JointAttach(joint, b1, b2);
lock (_contactcountLock)
m_global_contactcount++;
}
}