a few changes to ubOde avatar collisions

0.9.0-post-fixes
UbitUmarov 2017-07-01 01:43:58 +01:00
parent 965d004fbe
commit edc7575f9e
5 changed files with 39 additions and 39 deletions

View File

@ -103,7 +103,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
public float walkDivisor = 1.3f; public float walkDivisor = 1.3f;
public float runDivisor = 0.8f; public float runDivisor = 0.8f;
private bool flying = false; private bool m_flying = false;
private bool m_iscolliding = false; private bool m_iscolliding = false;
private bool m_iscollidingGround = false; private bool m_iscollidingGround = false;
private bool m_iscollidingObj = false; private bool m_iscollidingObj = false;
@ -298,10 +298,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
public override bool Flying public override bool Flying
{ {
get { return flying; } get { return m_flying; }
set set
{ {
flying = value; m_flying = value;
// m_log.DebugFormat("[PHYSICS]: Set OdeCharacter Flying to {0}", flying); // m_log.DebugFormat("[PHYSICS]: Set OdeCharacter Flying to {0}", flying);
} }
} }
@ -900,10 +900,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
} }
public bool Collide(IntPtr me, IntPtr other, bool reverse, ref d.ContactGeom contact, public bool Collide(IntPtr me, IntPtr other, bool reverse, ref d.ContactGeom contact,
ref d.ContactGeom altContact , ref bool useAltcontact, ref bool feetcollision) ref bool feetcollision)
{ {
feetcollision = false; feetcollision = false;
useAltcontact = false;
if (me == capsule) if (me == capsule)
{ {
@ -943,12 +942,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
} }
return true; return true;
} }
/*
d.AABB aabb;
d.GeomGetAABB(other,out aabb);
float othertop = aabb.MaxZ - _position.Z;
*/
// if (offset.Z > 0 || othertop > -feetOff || contact.normal.Z > 0.35f)
if (offset.Z > 0 || contact.normal.Z > 0.35f) if (offset.Z > 0 || contact.normal.Z > 0.35f)
{ {
if (offset.Z <= 0) if (offset.Z <= 0)
@ -965,27 +959,40 @@ namespace OpenSim.Region.PhysicsModule.ubOde
return true; return true;
} }
altContact = contact; if(m_flying)
useAltcontact = true; return true;
offset.Z -= 0.2f; offset.Z -= 0.2f;
offset.Normalize(); offset.Normalize();
if (contact.depth > 0.1f) float tdp = contact.depth;
contact.depth = 0.1f; float t = contact.normal.Z * contact.normal.Z;
t = Math.Abs(t);
if(t > 1e-6)
{
tdp /= t;
tdp *= offset.Z * offset.Z;
}
else
tdp *= 10;
if (tdp > 0.25f)
tdp = 0.25f;
contact.depth = tdp;
if (reverse) if (reverse)
{ {
altContact.normal.X = offset.X; contact.normal.X = offset.X;
altContact.normal.Y = offset.Y; contact.normal.Y = offset.Y;
altContact.normal.Z = offset.Z; contact.normal.Z = offset.Z;
} }
else else
{ {
altContact.normal.X = -offset.X; contact.normal.X = -offset.X;
altContact.normal.Y = -offset.Y; contact.normal.Y = -offset.Y;
altContact.normal.Z = -offset.Z; contact.normal.Z = -offset.Z;
} }
feetcollision = true; feetcollision = true;
@ -1098,7 +1105,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
float ftmp; float ftmp;
if (flying) if (m_flying)
{ {
ftmp = timeStep; ftmp = timeStep;
posch.X += vel.X * ftmp; posch.X += vel.X * ftmp;
@ -1122,7 +1129,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
vec.Z = depth * PID_P * 50; vec.Z = depth * PID_P * 50;
if (!flying) if (!m_flying)
{ {
vec.Z += -vel.Z * PID_D; vec.Z += -vel.Z * PID_D;
if(n.Z < 0.4f) if(n.Z < 0.4f)
@ -1259,7 +1266,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
// movement relative to surface if moving on it // movement relative to surface if moving on it
// dont disturbe vertical movement, ie jumps // dont disturbe vertical movement, ie jumps
if (m_iscolliding && !flying && ctz.Z == 0 && m_collideNormal.Z > 0.2f && m_collideNormal.Z < 0.94f) if (m_iscolliding && !m_flying && ctz.Z == 0 && m_collideNormal.Z > 0.2f && m_collideNormal.Z < 0.94f)
{ {
float p = ctz.X * m_collideNormal.X + ctz.Y * m_collideNormal.Y; float p = ctz.X * m_collideNormal.X + ctz.Y * m_collideNormal.Y;
ctz.X *= (float)Math.Sqrt(1 - m_collideNormal.X * m_collideNormal.X); ctz.X *= (float)Math.Sqrt(1 - m_collideNormal.X * m_collideNormal.X);
@ -1276,7 +1283,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{ {
// if velocity is zero, use position control; otherwise, velocity control // if velocity is zero, use position control; otherwise, velocity control
if (tviszero && m_iscolliding && !flying) if (tviszero && m_iscolliding && !m_flying)
{ {
// keep track of where we stopped. No more slippin' & slidin' // keep track of where we stopped. No more slippin' & slidin'
if (!_zeroFlag) if (!_zeroFlag)
@ -1313,7 +1320,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (m_iscolliding) if (m_iscolliding)
{ {
if (!flying) if (!m_flying)
{ {
// we are on a surface // we are on a surface
if (ctz.Z > 0f) if (ctz.Z > 0f)
@ -1361,7 +1368,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
} }
else // ie not colliding else // ie not colliding
{ {
if (flying || hoverPIDActive) //(!m_iscolliding && flying) if (m_flying || hoverPIDActive) //(!m_iscolliding && flying)
{ {
// we're in mid air suspended // we're in mid air suspended
vec.X += (ctz.X - vel.X) * (PID_D); vec.X += (ctz.X - vel.X) * (PID_D);
@ -1397,13 +1404,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde
breakfactor = m_mass; breakfactor = m_mass;
vec.X -= breakfactor * vel.X; vec.X -= breakfactor * vel.X;
vec.Y -= breakfactor * vel.Y; vec.Y -= breakfactor * vel.Y;
if (flying) if (m_flying)
vec.Z -= 0.5f * breakfactor * vel.Z; vec.Z -= 0.5f * breakfactor * vel.Z;
else else
vec.Z -= .16f* m_mass * vel.Z; vec.Z -= .16f* m_mass * vel.Z;
} }
if (flying || hoverPIDActive) if (m_flying || hoverPIDActive)
{ {
vec.Z -= m_parent_scene.gravityz * m_mass; vec.Z -= m_parent_scene.gravityz * m_mass;

View File

@ -951,8 +951,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
SharedTmpcontact.surface.mu = mu; SharedTmpcontact.surface.mu = mu;
SharedTmpcontact.surface.bounce = bounce; SharedTmpcontact.surface.bounce = bounce;
d.ContactGeom altContact = new d.ContactGeom();
bool useAltcontact = false;
bool noskip = true; bool noskip = true;
if(dop1ava || dop2ava) if(dop1ava || dop2ava)
@ -961,11 +959,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
while (true) while (true)
{ {
noskip = true; noskip = true;
useAltcontact = false;
if (dop1ava) if (dop1ava)
{ {
if ((((OdeCharacter)p1).Collide(g1, g2, false, ref curContact, ref altContact , ref useAltcontact, ref FeetCollision))) if ((((OdeCharacter)p1).Collide(g1, g2, false, ref curContact, ref FeetCollision)))
{ {
if (p2.PhysicsActorType == (int)ActorTypes.Agent) if (p2.PhysicsActorType == (int)ActorTypes.Agent)
{ {
@ -980,7 +977,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
} }
else if (dop2ava) else if (dop2ava)
{ {
if ((((OdeCharacter)p2).Collide(g2, g1, true, ref curContact, ref altContact , ref useAltcontact, ref FeetCollision))) if ((((OdeCharacter)p2).Collide(g2, g1, true, ref curContact, ref FeetCollision)))
{ {
if (p1.PhysicsActorType == (int)ActorTypes.Agent) if (p1.PhysicsActorType == (int)ActorTypes.Agent)
{ {
@ -996,10 +993,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
if (noskip) if (noskip)
{ {
if(useAltcontact) Joint = CreateContacJoint(ref curContact,smoothMesh);
Joint = CreateContacJoint(ref altContact,smoothMesh);
else
Joint = CreateContacJoint(ref curContact,smoothMesh);
if (Joint == IntPtr.Zero) if (Joint == IntPtr.Zero)
break; break;

View File

@ -61,7 +61,6 @@
; osslParcelOG = "PARCEL_GROUP_MEMBER,PARCEL_OWNER," ; osslParcelOG = "PARCEL_GROUP_MEMBER,PARCEL_OWNER,"
; NPC macros ; NPC macros
; There are a block of macros to creating and controlling NPCs.
; These can be mis-used so limit use to those you can trust. ; These can be mis-used so limit use to those you can trust.
osslNPC = ${XEngine|osslParcelOG}ESTATE_MANAGER,ESTATE_OWNER osslNPC = ${XEngine|osslParcelOG}ESTATE_MANAGER,ESTATE_OWNER

Binary file not shown.

Binary file not shown.