* Added smoother handling of interpenetrating physical objects.

* Fixes:
* -- duplicating Active physical object causes objects to explode in opposite directions
* -- Rezzing objects too close to you avatar causes avatar to shoot around in odd directions
* Vanity
afrisby
Teravus Ovares 2007-12-22 05:43:34 +00:00
parent a5c641e92d
commit de32006f9a
4 changed files with 76 additions and 27 deletions

View File

@ -17,6 +17,7 @@ OpenSim Developers
* Babblefrog
* Tedd
* justincc (International Business Machines Corp.)
* Teravus (w3z)
Patches

View File

@ -332,6 +332,7 @@ namespace OpenSim.Region.Environment.Scenes
// If agent is a root agent.
if (!agent.IsChildAgent)
{
//agent.ControllingClient.new
//this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo());
InformClientOfNeighbor(agent, otherRegion);

View File

@ -174,7 +174,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
if (m_wascolliding != m_iscolliding)
{
base.SendCollisionUpdate(new CollisionEventUpdate());
//base.SendCollisionUpdate(new CollisionEventUpdate());
}
m_wascolliding = m_iscolliding;
@ -527,7 +527,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (_velocity.Z < -6 && !m_hackSentFall)
{
m_hackSentFall = true;
base.SendCollisionUpdate(new CollisionEventUpdate());
//base.SendCollisionUpdate(new CollisionEventUpdate());
m_pidControllerActive = false;
}
else if (flying && !m_hackSentFly)

View File

@ -281,12 +281,61 @@ namespace OpenSim.Region.Physics.OdePlugin
break;
}
// we don't want prim or avatar to explode
#region InterPenetration Handling - Unintended physics explosions
if (contacts[i].depth >= 0.08f)
{
if (contacts[i].depth >= 1.00f)
{
//MainLog.Instance.Debug("PHYSICS",contacts[i].depth.ToString());
}
// If you interpenetrate a prim with an agent
if ((p2.PhysicsActorType == (int)ActorTypes.Agent && p1.PhysicsActorType == (int)ActorTypes.Prim) || (p1.PhysicsActorType == (int)ActorTypes.Agent && p2.PhysicsActorType == (int)ActorTypes.Prim))
{
if (p2.PhysicsActorType == (int)ActorTypes.Agent)
{
p2.CollidingObj = true;
contacts[i].depth = 0.003f;
p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f);
contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2));
}
else
{
contacts[i].depth = 0.0000000f;
}
if (p1.PhysicsActorType == (int)ActorTypes.Agent)
{
p1.CollidingObj = true;
contacts[i].depth = 0.003f;
p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f);
contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p2.Size.X / 2), contacts[i].pos.Y + (p2.Size.Y / 2), contacts[i].pos.Z + (p2.Size.Z / 2));
}
else
{
contacts[i].depth = 0.0000000f;
}
}
// If you interpenetrate a prim with another prim
if (p1.PhysicsActorType == (int)ActorTypes.Prim && p2.PhysicsActorType == (int)ActorTypes.Prim)
{
// Don't collide, one or both prim will explode.
contacts[i].depth = 0.0f;
}
}
#endregion
if (contacts[i].depth > 0f)
{
if (name1 == "Terrain" || name2 == "Terrain")
{
if ((p2.PhysicsActorType == (int)ActorTypes.Agent) && (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f))
{
AvatarMovementTerrainContact.geom = contacts[i];
joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact);
}
else
{
@ -300,6 +349,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
AvatarMovementprimContact.geom = contacts[i];
joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact);
}
else
{
@ -307,11 +357,8 @@ namespace OpenSim.Region.Physics.OdePlugin
joint = d.JointCreateContact(world, contactgroup, ref contact);
}
}
d.JointAttach(joint, b1, b2);
}
if (count > 3)
{
@ -334,7 +381,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
// If the sim is running slow this frame,
// don't process collision for prim!
if (timeStep < (m_SkipFramesAtms / 2))
if (timeStep < (m_SkipFramesAtms / 3))
{
foreach (OdePrim chr in _activeprims)
{