changes on the fast speed avatars collider, collisions from above, etc

avinationmerge
UbitUmarov 2012-12-11 19:38:44 +00:00
parent 04baea2d71
commit f35e3c6fe0
1 changed files with 64 additions and 62 deletions

View File

@ -970,78 +970,86 @@ namespace OpenSim.Region.Physics.OdePlugin
if (m_collisionException) if (m_collisionException)
return false; return false;
Vector3 offset;
if (me == bbox) // if moving fast if (me == bbox) // if moving fast
{ {
// force a full inelastic collision // force a full inelastic collision
m_collisionException = true; m_collisionException = true;
Vector3 off = m_size * 0.5f; offset = m_size * m_orientation;
off.X += contact.depth;
off.Y += contact.depth; offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth;
off.Z += contact.depth; offset.Y = (float)Math.Abs(offset.Y) * 0.5f + contact.depth;
offset.Z = (float)Math.Abs(offset.Z) * 0.5f + contact.depth;
if (reverse) if (reverse)
{ {
off.X *= -contact.normal.X; offset.X *= -contact.normal.X;
off.Y *= -contact.normal.Y; offset.Y *= -contact.normal.Y;
off.Z *= -contact.normal.Z; offset.Z *= -contact.normal.Z;
} }
else else
{ {
off.X *= contact.normal.X; offset.X *= contact.normal.X;
off.Y *= contact.normal.Y; offset.Y *= contact.normal.Y;
off.Z *= contact.normal.Z; offset.Z *= contact.normal.Z;
} }
off.X += contact.pos.X; offset.X += contact.pos.X;
off.Y += contact.pos.Y; offset.Y += contact.pos.Y;
off.Z += contact.pos.Z; offset.Z += contact.pos.Z;
_position = off; _position = offset;
return false; return false;
} }
if (me == topbox) // keep a box head offset.X = contact.pos.X - _position.X;
return true; offset.Y = contact.pos.Y - _position.Y;
float t; if (me == topbox)
float offx = contact.pos.X - _position.X; {
float offy = contact.pos.Y - _position.Y; offset.Z = contact.pos.Z - _position.Z;
offset.Normalize();
if (reverse)
{
contact.normal.X = offset.X;
contact.normal.Y = offset.Y;
contact.normal.Z = offset.Z;
}
else
{
contact.normal.X = -offset.X;
contact.normal.Y = -offset.Y;
contact.normal.Z = -offset.Z;
}
return true;
}
if (me == midbox) if (me == midbox)
{ {
if (Math.Abs(contact.normal.Z) > 0.95f) if (Math.Abs(contact.normal.Z) > 0.95f)
{ offset.Z = contact.pos.Z - _position.Z;
float nz = contact.normal.Z; else
if (!reverse) offset.Z = contact.normal.Z;
nz = -nz;
if (nz > 0) offset.Normalize();
return true; // missed head TODO
// missed feet collision?
return true;
}
t = offx * offx + offy * offy;
t = (float)Math.Sqrt(t);
t = 1 / t;
offx *= t;
offy *= t;
if (reverse) if (reverse)
{ {
contact.normal.X = offx; contact.normal.X = offset.X;
contact.normal.Y = offy; contact.normal.Y = offset.Y;
contact.normal.Z = offset.Z;
} }
else else
{ {
contact.normal.X = -offx; contact.normal.X = -offset.X;
contact.normal.Y = -offy; contact.normal.Y = -offset.Y;
contact.normal.Z = -offset.Z;
} }
contact.normal.Z = 0;
return true; return true;
} }
@ -1063,39 +1071,33 @@ namespace OpenSim.Region.Physics.OdePlugin
return true; return true;
} }
offset.Z = h - feetOff; // distance from top of feetbox
float offz = h - feetOff; // distance from top of feetbox if (offset.Z > 0)
if (offz > 0)
return false; return false;
if (offz > -0.01) if (offset.Z > -0.01)
{ {
offx = 0; offset.X = 0;
offy = 0; offset.Y = 0;
offz = -1.0f; offset.Z = -1.0f;
} }
else else
{ {
t = offx * offx + offy * offy + offz * offz; offset.Normalize();
t = (float)Math.Sqrt(t);
t = 1 / t;
offx *= t;
offy *= t;
offz *= t;
} }
if (reverse) if (reverse)
{ {
contact.normal.X = offx; contact.normal.X = offset.X;
contact.normal.Y = offy; contact.normal.Y = offset.Y;
contact.normal.Z = offz; contact.normal.Z = offset.Z;
} }
else else
{ {
contact.normal.X = -offx; contact.normal.X = -offset.X;
contact.normal.Y = -offy; contact.normal.Y = -offset.Y;
contact.normal.Z = -offz; contact.normal.Z = -offset.Z;
} }
feetcollision = true; feetcollision = true;
if (h < boneOff) if (h < boneOff)
@ -1125,7 +1127,7 @@ namespace OpenSim.Region.Physics.OdePlugin
float v = _velocity.Length(); float v = _velocity.Length();
if (v != 0) if (v != 0)
{ {
v = 6.0f / v; v = 5.0f / v;
_velocity = _velocity * v; _velocity = _velocity * v;
d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z);
} }