bug fix, and make Mesh-Mesh and Mesh-Terrain collisions a lot softer

avinationmerge
UbitUmarov 2015-10-14 02:32:51 +01:00
parent 9ec9eee75f
commit 7deaad7368
1 changed files with 78 additions and 72 deletions

View File

@ -633,18 +633,18 @@ namespace OpenSim.Region.PhysicsModule.ubOde
#region Collision Detection
// sets a global contact for a joint for contactgeom , and base contact description)
private IntPtr CreateContacJoint(ref d.ContactGeom contactGeom)
private IntPtr CreateContacJoint(ref d.ContactGeom contactGeom,bool smooth)
{
if (m_global_contactcount >= maxContactsbeforedeath)
return IntPtr.Zero;
m_global_contactcount++;
if(smooth)
SharedTmpcontact.geom.depth = contactGeom.depth * 0.05f;
else
SharedTmpcontact.geom.depth = contactGeom.depth;
SharedTmpcontact.geom.pos = contactGeom.pos;
SharedTmpcontact.geom.pos = contactGeom.pos;
SharedTmpcontact.geom.normal = contactGeom.normal;
IntPtr contact = new IntPtr(GlobalContactsArray.ToInt64() + (Int64)(m_global_contactcount * d.Contact.unmanagedSizeOf));
@ -836,6 +836,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
bool dop1ava = false;
bool dop2ava = false;
bool ignore = false;
bool smoothMesh = false;
switch (p1.PhysicsActorType)
{
@ -879,6 +880,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (relVlenSQ > 0.01f)
mu *= frictionMovementMult;
if(d.GeomGetClass(g2) == d.GeomClassID.TriMeshClass &&
d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass)
smoothMesh = true;
break;
case (int)ActorTypes.Ground:
@ -889,13 +893,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f)
mu *= frictionMovementMult;
p1.CollidingGround = true;
/*
if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass)
{
if (curContact.side1 > 0)
IgnoreNegSides = true;
}
*/
if(d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass)
smoothMesh = true;
break;
case (int)ActorTypes.Water:
@ -919,6 +919,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f)
mu *= frictionMovementMult;
if(d.GeomGetClass(g2) == d.GeomClassID.TriMeshClass)
smoothMesh = true;
}
else
ignore = true;
@ -951,10 +954,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
bool useAltcontact = false;
bool noskip = true;
if(dop1ava || dop2ava)
smoothMesh = false;
while (true)
{
// if (!(IgnoreNegSides && curContact.side1 < 0))
{
noskip = true;
useAltcontact = false;
@ -992,9 +996,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (noskip)
{
if(useAltcontact)
Joint = CreateContacJoint(ref altContact);
Joint = CreateContacJoint(ref altContact,smoothMesh);
else
Joint = CreateContacJoint(ref curContact);
Joint = CreateContacJoint(ref curContact,smoothMesh);
if (Joint == IntPtr.Zero)
break;
@ -1020,7 +1024,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
minDepthContact.SurfaceNormal.Z = curContact.normal.Z;
}
}
}
if (++i >= count)
break;
@ -1148,12 +1152,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
aprim.CollisionScore = 0;
aprim.IsColliding = false;
}
}
lock (_activeprims)
{
try
{
foreach (OdePrim aprim in _activeprims)
foreach (OdePrim aprim in _activegroups)
{
if(d.BodyIsEnabled(aprim.Body))
if(!aprim.m_outbounds && d.BodyIsEnabled(aprim.Body))
{
d.SpaceCollide2(StaticSpace, aprim.collide_geom, IntPtr.Zero, nearCallback);
d.SpaceCollide2(GroundSpace, aprim.collide_geom, IntPtr.Zero, nearCallback);