aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs4
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs25
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs55
3 files changed, 64 insertions, 20 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 43b4581..b0711d7 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -1006,9 +1006,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1006 } 1006 }
1007 } 1007 }
1008 1008
1009 if (velLengthSquared > 625.0f) // 25m/s apply breaks 1009 if (velLengthSquared > 2500.0f) // 50m/s apply breaks
1010 { 1010 {
1011 breakfactor = 0.31f * m_mass; 1011 breakfactor = 0.16f * m_mass;
1012 vec.X -= breakfactor * vel.X; 1012 vec.X -= breakfactor * vel.X;
1013 vec.Y -= breakfactor * vel.Y; 1013 vec.Y -= breakfactor * vel.Y;
1014 vec.Z -= breakfactor * vel.Z; 1014 vec.Z -= breakfactor * vel.Z;
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
index e88e559..56d0f1a 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
@@ -63,6 +63,9 @@ namespace OpenSim.Region.Physics.OdePlugin
63 private OdeScene _pParentScene; 63 private OdeScene _pParentScene;
64 64
65 // Vehicle properties 65 // Vehicle properties
66 // WARNING this are working copies for internel use
67 // their values may not be the corresponding parameter
68
66 private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier 69 private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier
67 private Quaternion m_RollreferenceFrame = Quaternion.Identity; // what hell is this ? 70 private Quaternion m_RollreferenceFrame = Quaternion.Identity; // what hell is this ?
68 71
@@ -244,6 +247,7 @@ namespace OpenSim.Region.Physics.OdePlugin
244 if (pValue < m_timestep) pValue = m_timestep; 247 if (pValue < m_timestep) pValue = m_timestep;
245 else if (pValue > 120) pValue = 120; 248 else if (pValue > 120) pValue = 120;
246 m_angularMotorDecayTimescale = pValue * m_invtimestep; 249 m_angularMotorDecayTimescale = pValue * m_invtimestep;
250 m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale;
247 break; 251 break;
248 case Vehicle.ANGULAR_MOTOR_TIMESCALE: 252 case Vehicle.ANGULAR_MOTOR_TIMESCALE:
249 if (pValue < m_timestep) pValue = m_timestep; 253 if (pValue < m_timestep) pValue = m_timestep;
@@ -293,6 +297,7 @@ namespace OpenSim.Region.Physics.OdePlugin
293 if (pValue < m_timestep) pValue = m_timestep; 297 if (pValue < m_timestep) pValue = m_timestep;
294 else if (pValue > 120) pValue = 120; 298 else if (pValue > 120) pValue = 120;
295 m_linearMotorDecayTimescale = (0.2f +pValue) * m_invtimestep; 299 m_linearMotorDecayTimescale = (0.2f +pValue) * m_invtimestep;
300 m_lmDecay = (1.0f - 1.0f / m_linearMotorDecayTimescale);
296 break; 301 break;
297 case Vehicle.LINEAR_MOTOR_TIMESCALE: 302 case Vehicle.LINEAR_MOTOR_TIMESCALE:
298 if (pValue < m_timestep) pValue = m_timestep; 303 if (pValue < m_timestep) pValue = m_timestep;
@@ -320,7 +325,7 @@ namespace OpenSim.Region.Physics.OdePlugin
320 if (len > 12.566f) 325 if (len > 12.566f)
321 m_angularMotorDirection *= (12.566f / len); 326 m_angularMotorDirection *= (12.566f / len);
322 327
323 m_amEfect = 1.0f / m_angularMotorTimescale; // turn it on 328 m_amEfect = 1.0f ; // turn it on
324 m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale; 329 m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale;
325 330
326 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) 331 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
@@ -338,7 +343,7 @@ namespace OpenSim.Region.Physics.OdePlugin
338 m_linearMotorDirection *= (100.0f / len); 343 m_linearMotorDirection *= (100.0f / len);
339 344
340 m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale; 345 m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale;
341 m_lmEfect = 1.0f / m_linearMotorTimescale; // turn it on 346 m_lmEfect = 1.0f; // turn it on
342 347
343 m_ffactor = 0.01f; 348 m_ffactor = 0.01f;
344 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) 349 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
@@ -374,7 +379,7 @@ namespace OpenSim.Region.Physics.OdePlugin
374 if (len > 12.566f) 379 if (len > 12.566f)
375 m_angularMotorDirection *= (12.566f / len); 380 m_angularMotorDirection *= (12.566f / len);
376 381
377 m_amEfect = 1.0f / m_angularMotorTimescale; // turn it on 382 m_amEfect = 1.0f; // turn it on
378 m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale; 383 m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale;
379 384
380 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) 385 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
@@ -393,11 +398,9 @@ namespace OpenSim.Region.Physics.OdePlugin
393 if (len > 100.0f) 398 if (len > 100.0f)
394 m_linearMotorDirection *= (100.0f / len); 399 m_linearMotorDirection *= (100.0f / len);
395 400
396 m_lmEfect = 1.0f / m_linearMotorTimescale; // turn it on 401 m_lmEfect = 1.0f; // turn it on
397 m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale; 402 m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale;
398 403
399
400
401 m_ffactor = 0.01f; 404 m_ffactor = 0.01f;
402 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) 405 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
403 && !rootPrim.m_isSelected && !rootPrim.m_disabled) 406 && !rootPrim.m_isSelected && !rootPrim.m_disabled)
@@ -776,10 +779,10 @@ namespace OpenSim.Region.Physics.OdePlugin
776 float ldampZ = 0; 779 float ldampZ = 0;
777 780
778 // linear motor 781 // linear motor
779 if (m_lmEfect > 0.001 && m_linearMotorTimescale < 1000) 782 if (m_lmEfect > 0.01 && m_linearMotorTimescale < 1000)
780 { 783 {
781 tmpV = m_linearMotorDirection - curLocalVel; // velocity error 784 tmpV = m_linearMotorDirection - curLocalVel; // velocity error
782 tmpV *= m_lmEfect; // error to correct in this timestep 785 tmpV *= m_lmEfect / m_linearMotorTimescale; // error to correct in this timestep
783 tmpV *= rotq; // to world 786 tmpV *= rotq; // to world
784 787
785 if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != 0) 788 if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != 0)
@@ -799,9 +802,7 @@ namespace OpenSim.Region.Physics.OdePlugin
799 } 802 }
800 803
801 m_lmEfect *= m_lmDecay; 804 m_lmEfect *= m_lmDecay;
802 805 m_ffactor = 0.01f + 1e-4f * curVel.LengthSquared();
803 // m_ffactor = 0.01f + 1e-4f * curVel.LengthSquared();
804 m_ffactor = 0;
805 } 806 }
806 else 807 else
807 { 808 {
@@ -1007,7 +1008,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1007 if (m_amEfect > 0.01 && m_angularMotorTimescale < 1000) 1008 if (m_amEfect > 0.01 && m_angularMotorTimescale < 1000)
1008 { 1009 {
1009 tmpV = m_angularMotorDirection - curLocalAngVel; // velocity error 1010 tmpV = m_angularMotorDirection - curLocalAngVel; // velocity error
1010 tmpV *= m_amEfect; // error to correct in this timestep 1011 tmpV *= m_amEfect / m_angularMotorTimescale; // error to correct in this timestep
1011 torque.X += tmpV.X * m_ampwr; 1012 torque.X += tmpV.X * m_ampwr;
1012 torque.Y += tmpV.Y * m_ampwr; 1013 torque.Y += tmpV.Y * m_ampwr;
1013 torque.Z += tmpV.Z; 1014 torque.Z += tmpV.Z;
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index e0de6cc..7367719 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -537,7 +537,7 @@ namespace OpenSim.Region.Physics.OdePlugin
537 // Essentially Steps * m_physicsiterations 537 // Essentially Steps * m_physicsiterations
538 d.WorldSetQuickStepNumIterations(world, m_physicsiterations); 538 d.WorldSetQuickStepNumIterations(world, m_physicsiterations);
539 539
540 d.WorldSetContactMaxCorrectingVel(world, 50.0f); 540 d.WorldSetContactMaxCorrectingVel(world, 60.0f);
541 541
542 spacesPerMeter = 1 / metersInSpace; 542 spacesPerMeter = 1 / metersInSpace;
543 spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeter); 543 spaceGridMaxX = (int)(WorldExtents.X * spacesPerMeter);
@@ -754,14 +754,15 @@ namespace OpenSim.Region.Physics.OdePlugin
754 } 754 }
755 755
756 // big messy collision analises 756 // big messy collision analises
757
758 Vector3 normoverride = Vector3.Zero; //damm c#
759
757 float mu = 0; 760 float mu = 0;
758 float bounce = 0; 761 float bounce = 0;
759 float cfm = 0.0001f; 762 float cfm = 0.0001f;
760 float erp = 0.1f;
761 float erpscale = 1.0f; 763 float erpscale = 1.0f;
762 float dscale = 1.0f; 764 float dscale = 1.0f;
763 bool IgnoreNegSides = false; 765 bool IgnoreNegSides = false;
764
765 766
766 ContactData contactdata1 = new ContactData(0, 0, false); 767 ContactData contactdata1 = new ContactData(0, 0, false);
767 ContactData contactdata2 = new ContactData(0, 0, false); 768 ContactData contactdata2 = new ContactData(0, 0, false);
@@ -770,14 +771,30 @@ namespace OpenSim.Region.Physics.OdePlugin
770 bool dop1foot = false; 771 bool dop1foot = false;
771 bool dop2foot = false; 772 bool dop2foot = false;
772 bool ignore = false; 773 bool ignore = false;
774 bool AvanormOverride = false;
773 775
774 switch (p1.PhysicsActorType) 776 switch (p1.PhysicsActorType)
775 { 777 {
776 case (int)ActorTypes.Agent: 778 case (int)ActorTypes.Agent:
777 { 779 {
778 bounce = 0; 780 AvanormOverride = true;
779 mu = 0; 781 Vector3 tmp = p2.Position - p1.Position;
780 cfm = 0.0001f; 782 normoverride = p2.Velocity - p1.Velocity;
783 mu = normoverride.LengthSquared();
784
785 if (mu > 1e-6)
786 {
787 mu = 1.0f / (float)Math.Sqrt(mu);
788 normoverride *= mu;
789 mu = Vector3.Dot(tmp, normoverride);
790 if (mu > 0)
791 normoverride *= -1;
792 }
793 else
794 {
795 tmp.Normalize();
796 normoverride = -tmp;
797 }
781 798
782 switch (p2.PhysicsActorType) 799 switch (p2.PhysicsActorType)
783 { 800 {
@@ -824,6 +841,25 @@ namespace OpenSim.Region.Physics.OdePlugin
824 // p1.getContactData(ref contactdata1); 841 // p1.getContactData(ref contactdata1);
825 // p2.getContactData(ref contactdata2); 842 // p2.getContactData(ref contactdata2);
826 843
844 AvanormOverride = true;
845
846 Vector3 tmp = p2.Position - p1.Position;
847 normoverride = p2.Velocity - p1.Velocity;
848 mu = normoverride.LengthSquared();
849 if (mu > 1e-6)
850 {
851 mu = 1.0f / (float)Math.Sqrt(mu);
852 normoverride *= mu;
853 mu = Vector3.Dot(tmp, normoverride);
854 if (mu > 0)
855 normoverride *= -1;
856 }
857 else
858 {
859 tmp.Normalize();
860 normoverride = -tmp;
861 }
862
827 bounce = 0; 863 bounce = 0;
828 mu = 0; 864 mu = 0;
829 cfm = 0.0001f; 865 cfm = 0.0001f;
@@ -974,6 +1010,13 @@ namespace OpenSim.Region.Physics.OdePlugin
974 if (dop2foot && (p2.Position.Z - curContact.pos.Z) > (p2.Size.Z - avCapRadius) * 0.5f) 1010 if (dop2foot && (p2.Position.Z - curContact.pos.Z) > (p2.Size.Z - avCapRadius) * 0.5f)
975 p2.IsColliding = true; 1011 p2.IsColliding = true;
976 1012
1013 if (AvanormOverride && curContact.depth > 0.3f)
1014 {
1015 curContact.normal.X = normoverride.X;
1016 curContact.normal.Y = normoverride.Y;
1017 curContact.normal.Z = normoverride.Z;
1018 }
1019
977 Joint = CreateContacJoint(ref curContact, mu, bounce, cfm, erpscale, dscale); 1020 Joint = CreateContacJoint(ref curContact, mu, bounce, cfm, erpscale, dscale);
978 d.JointAttach(Joint, b1, b2); 1021 d.JointAttach(Joint, b1, b2);
979 1022