From 11f582b26da987afe4c9ad76c6ce35b58a8bc6fd Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sun, 20 May 2012 13:18:15 +0100
Subject: minor changes

---
 .../Region/Physics/UbitOdePlugin/ODECharacter.cs   |  7 ++--
 OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs    |  7 ++--
 OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs   | 42 ++++++++++------------
 3 files changed, 24 insertions(+), 32 deletions(-)

(limited to 'OpenSim/Region/Physics')

diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index ca294b8..1084b0e 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -784,8 +784,6 @@ namespace OpenSim.Region.Physics.OdePlugin
 
             // the Amotor still lets avatar rotation to drift during colisions
             // so force it back to identity
-            
-
 
             d.Quaternion qtmp;
             qtmp.W = 1;
@@ -1177,9 +1175,8 @@ namespace OpenSim.Region.Physics.OdePlugin
         internal void AddCollisionFrameTime(int t)
         {
             // protect it from overflow crashing
-            if (m_cureventsubscription + t >= int.MaxValue)
-                m_cureventsubscription = 0;
-            m_cureventsubscription += t;
+            if (m_cureventsubscription < 50000)
+                m_cureventsubscription += t;
         }
 
         public override bool SubscribedEvents()
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index b2af180..62fd279 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -987,11 +987,10 @@ namespace OpenSim.Region.Physics.OdePlugin
 
         internal void AddCollisionFrameTime(int t)
         {
-            // protect it from overflow crashing
-            if (m_cureventsubscription + t >= int.MaxValue)
-                m_cureventsubscription = 0;
-            m_cureventsubscription += t;
+            if (m_cureventsubscription < 50000)
+                m_cureventsubscription += t;
         }
+
         public override bool SubscribedEvents()
         {
             if (m_eventsubscription > 0)
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 0f341b9..bfcfd21 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -190,6 +190,7 @@ namespace OpenSim.Region.Physics.OdePlugin
 
         public float ODE_STEPSIZE = 0.020f;
         public float HalfOdeStep = 0.01f;
+        public int odetimestepMS = 20; // rounded
         private float metersInSpace = 25.6f;
         private float m_timeDilation = 1.0f;
 
@@ -490,6 +491,7 @@ namespace OpenSim.Region.Physics.OdePlugin
             }
 
             HalfOdeStep = ODE_STEPSIZE * 0.5f;
+            odetimestepMS = (int)(1000.0f * ODE_STEPSIZE +0.5f);
 
             ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf);
             GlobalContactsArray = GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf);
@@ -1827,7 +1829,6 @@ namespace OpenSim.Region.Physics.OdePlugin
                         {
                             int ttmpstart = Util.EnvironmentTickCount();
                             int ttmp;
-                            int ttmp2;
 
                             while(ChangesQueue.Dequeue(out item))
                             {
@@ -1849,11 +1850,6 @@ namespace OpenSim.Region.Physics.OdePlugin
                                 if (ttmp > 20)
                                     break;
                             }
-
-                            ttmp2 = Util.EnvironmentTickCountSubtract(ttmpstart);
-                            if (ttmp2 > 50)
-                                ttmp2 = 0;
-
                         }
 
                         // Move characters
@@ -1899,7 +1895,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                             {
                                 case ActorTypes.Agent:
                                     OdeCharacter cobj = (OdeCharacter)obj;
-                                    cobj.AddCollisionFrameTime((int)(ODE_STEPSIZE * 1000.0f));
+                                    cobj.AddCollisionFrameTime((int)(odetimestepMS));
                                     cobj.SendCollisions();
                                     break;
 
@@ -1907,7 +1903,7 @@ namespace OpenSim.Region.Physics.OdePlugin
                                     OdePrim pobj = (OdePrim)obj;
                                     if (pobj.Body == IntPtr.Zero || (d.BodyIsEnabled(pobj.Body) && !pobj.m_outbounds))
                                     {
-                                        pobj.AddCollisionFrameTime((int)(ODE_STEPSIZE * 1000.0f));
+                                        pobj.AddCollisionFrameTime((int)(odetimestepMS));
                                         pobj.SendCollisions();
                                     }
                                     break;
@@ -1924,21 +1920,21 @@ namespace OpenSim.Region.Physics.OdePlugin
                         d.JointGroupEmpty(contactgroup);
 
                         // update managed ideia of physical data and do updates to core
-                        /*
-                                        lock (_characters)
-                                        {
-                                            foreach (OdeCharacter actor in _characters)
-                                            {
-                                                if (actor != null)
-                                                {
-                                                    if (actor.bad)
-                                                        m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid);
-
-                                                    actor.UpdatePositionAndVelocity();
-                                                }
-                                            }
-                                        }
-                        */
+        /*
+                        lock (_characters)
+                        {
+                            foreach (OdeCharacter actor in _characters)
+                            {
+                                if (actor != null)
+                                {
+                                    if (actor.bad)
+                                        m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid);
+
+                                    actor.UpdatePositionAndVelocity();
+                                }
+                            }
+                        }
+        */
 
                         lock (_activegroups)
                         {
-- 
cgit v1.1


From 85f578999320ab4b3b87d99c6901e7dfc86f8cc3 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Mon, 21 May 2012 12:35:17 +0100
Subject:  try to let avas climb higher steps. Will only work in some cases,
 may have bad effects, so needs some more testing

---
 OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs  |  2 +-
 OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 82 +++++++++++++++++++++---
 2 files changed, 75 insertions(+), 9 deletions(-)

(limited to 'OpenSim/Region/Physics')

diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index 62fd279..459cd27 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -2562,10 +2562,10 @@ namespace OpenSim.Region.Physics.OdePlugin
             {
                 d.Quaternion qtmp;
                 d.GeomCopyQuaternion(prim_geom, out qtmp);
-                _orientation.W = qtmp.W;
                 _orientation.X = qtmp.X;
                 _orientation.Y = qtmp.Y;
                 _orientation.Z = qtmp.Z;
+                _orientation.W = qtmp.W;
 
                 d.Vector3 lpos = d.GeomGetPosition(prim_geom);
                 _position.X = lpos.X;
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index bfcfd21..d5968fc 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -1006,16 +1006,82 @@ namespace OpenSim.Region.Physics.OdePlugin
                 else
 
                 {
-                    if (dop1foot && (p1.Position.Z - curContact.pos.Z) > (p1.Size.Z - avCapRadius) * 0.5f)
-                        p1.IsColliding = true;
-                    if (dop2foot && (p2.Position.Z - curContact.pos.Z) > (p2.Size.Z - avCapRadius) * 0.5f)
-                        p2.IsColliding = true;
 
-                    if (AvanormOverride && curContact.depth > 0.3f)
+                    if (AvanormOverride)
                     {
-                        curContact.normal.X = normoverride.X;
-                        curContact.normal.Y = normoverride.Y;
-                        curContact.normal.Z = normoverride.Z;
+                        if (curContact.depth > 0.3f)
+                        {
+                            if (dop1foot && (p1.Position.Z - curContact.pos.Z) > (p1.Size.Z - avCapRadius) * 0.5f)
+                                p1.IsColliding = true;
+                            if (dop2foot && (p2.Position.Z - curContact.pos.Z) > (p2.Size.Z - avCapRadius) * 0.5f)
+                                p2.IsColliding = true;
+                            curContact.normal.X = normoverride.X;
+                            curContact.normal.Y = normoverride.Y;
+                            curContact.normal.Z = normoverride.Z;
+                        }
+
+                        else
+                        {
+                            if (dop1foot)
+                            {
+                                float sz = p1.Size.Z;
+                                Vector3 vtmp = p1.Position;
+                                float ppos = curContact.pos.Z - vtmp.Z + (sz - avCapRadius) * 0.5f;
+                                if (ppos > 0f)
+                                {
+                                    if (!p1.Flying)
+                                    {
+                                        d.AABB aabb;
+                                        d.GeomGetAABB(g2, out aabb);
+                                        float tmp = vtmp.Z - sz * .25f;
+
+                                        if (aabb.MaxZ < tmp)
+                                        {
+                                            vtmp.X = curContact.pos.X - vtmp.X;
+                                            vtmp.Y = curContact.pos.Y - vtmp.Y;
+                                            vtmp.Z = -0.2f;
+                                            vtmp.Normalize();
+                                            curContact.normal.X = vtmp.X;
+                                            curContact.normal.Y = vtmp.Y;
+                                            curContact.normal.Z = vtmp.Z;
+                                        }
+                                    }
+                                }
+                                else
+                                    p1.IsColliding = true;
+
+                            }
+
+                            if (dop2foot)
+                            {
+                                float sz = p2.Size.Z;
+                                Vector3 vtmp = p2.Position;
+                                float ppos = curContact.pos.Z - vtmp.Z + (sz - avCapRadius) * 0.5f;
+                                if (ppos > 0f)
+                                {
+                                    if (!p2.Flying)
+                                    {
+                                        d.AABB aabb;
+                                        d.GeomGetAABB(g1, out aabb);
+                                        float tmp = vtmp.Z - sz * .25f;
+
+                                        if (aabb.MaxZ < tmp)
+                                        {
+                                            vtmp.X = curContact.pos.X - vtmp.X;
+                                            vtmp.Y = curContact.pos.Y - vtmp.Y;
+                                            vtmp.Z = -0.2f;
+                                            vtmp.Normalize();
+                                            curContact.normal.X = vtmp.X;
+                                            curContact.normal.Y = vtmp.Y;
+                                            curContact.normal.Z = vtmp.Z;
+                                        }
+                                    }
+                                }
+                                else
+                                    p2.IsColliding = true;
+
+                            }
+                        }
                     }
 
                     Joint = CreateContacJoint(ref curContact, mu, bounce, cfm, erpscale, dscale);
-- 
cgit v1.1