From bfac09849ff4b14f5df4bab4fffdbaea0d3b6a9e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 26 Jan 2013 06:12:26 +0000 Subject: bug fix: crash when too many collisions on a ode step --- OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 76 +++++++++++++----------- 1 file changed, 40 insertions(+), 36 deletions(-) (limited to 'OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs') diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 510cbe9..754bc86 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -995,63 +995,67 @@ namespace OpenSim.Region.Physics.OdePlugin d.ContactGeom maxContact = curContact; -// if (IgnoreNegSides && curContact.side1 < 0) -// maxContact.depth = float.MinValue; + // if (IgnoreNegSides && curContact.side1 < 0) + // maxContact.depth = float.MinValue; d.ContactGeom minContact = curContact; -// if (IgnoreNegSides && curContact.side1 < 0) -// minContact.depth = float.MaxValue; + // if (IgnoreNegSides && curContact.side1 < 0) + // minContact.depth = float.MaxValue; IntPtr Joint; bool FeetCollision = false; int ncontacts = 0; - int i = 0; + int i = 0; - while (true) - { - if (m_global_contactcount >= maxContactsbeforedeath) - break; + while (true) + { // if (!(IgnoreNegSides && curContact.side1 < 0)) + { + bool noskip = true; + if (dop1ava) { - bool noskip = true; - if (dop1ava) - { - if (!(((OdeCharacter)p1).Collide(g1,false, ref curContact, ref FeetCollision))) + if (!(((OdeCharacter)p1).Collide(g1, false, ref curContact, ref FeetCollision))) - noskip = false; - } - else if (dop2ava) - { - if (!(((OdeCharacter)p2).Collide(g2,true, ref curContact, ref FeetCollision))) - noskip = false; - } + noskip = false; + } + else if (dop2ava) + { + if (!(((OdeCharacter)p2).Collide(g2, true, ref curContact, ref FeetCollision))) + noskip = false; + } - if (noskip) - { - m_global_contactcount++; - ncontacts++; + if (noskip) + { + m_global_contactcount++; + if (m_global_contactcount >= maxContactsbeforedeath) + break; - Joint = CreateContacJoint(ref curContact, mu, bounce, cfm, erpscale, dscale); - d.JointAttach(Joint, b1, b2); + ncontacts++; - if (curContact.depth > maxContact.depth) - maxContact = curContact; + Joint = CreateContacJoint(ref curContact, mu, bounce, cfm, erpscale, dscale); + if (Joint == IntPtr.Zero) + break; - if (curContact.depth < minContact.depth) - minContact = curContact; - } - } + d.JointAttach(Joint, b1, b2); - if (++i >= count) - break; + if (curContact.depth > maxContact.depth) + maxContact = curContact; - if (!GetCurContactGeom(i, ref curContact)) - break; + if (curContact.depth < minContact.depth) + minContact = curContact; + } } + if (++i >= count) + break; + + if (!GetCurContactGeom(i, ref curContact)) + break; + } + if (ncontacts > 0) { ContactPoint maxDepthContact = new ContactPoint( -- cgit v1.1