aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin
diff options
context:
space:
mode:
authorMelanie2012-05-13 01:25:03 +0100
committerMelanie2012-05-13 01:25:03 +0100
commitfe029cf4e8fc0940d887329a823e66e0c29bd92e (patch)
tree7c2ae75849307cda30da96b6300ee30295610b42 /OpenSim/Region/Physics/UbitOdePlugin
parentMerge branch 'avination' into careminster (diff)
parentubitODE fix force in case of mlinear motor offset present (diff)
downloadopensim-SC-fe029cf4e8fc0940d887329a823e66e0c29bd92e.zip
opensim-SC-fe029cf4e8fc0940d887329a823e66e0c29bd92e.tar.gz
opensim-SC-fe029cf4e8fc0940d887329a823e66e0c29bd92e.tar.bz2
opensim-SC-fe029cf4e8fc0940d887329a823e66e0c29bd92e.tar.xz
Merge branch 'avination' into careminster
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs4
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs34
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs55
3 files changed, 69 insertions, 24 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..e27be1e 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)
@@ -747,6 +750,9 @@ namespace OpenSim.Region.Physics.OdePlugin
747 { 750 {
748 IntPtr Body = rootPrim.Body; 751 IntPtr Body = rootPrim.Body;
749 752
753 d.Mass dmass;
754 d.BodyGetMass(Body, out dmass);
755
750 d.Quaternion rot = d.BodyGetQuaternion(Body); 756 d.Quaternion rot = d.BodyGetQuaternion(Body);
751 Quaternion objrotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object 757 Quaternion objrotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object
752 Quaternion rotq = objrotq; // rotq = rotation of object 758 Quaternion rotq = objrotq; // rotq = rotation of object
@@ -776,10 +782,10 @@ namespace OpenSim.Region.Physics.OdePlugin
776 float ldampZ = 0; 782 float ldampZ = 0;
777 783
778 // linear motor 784 // linear motor
779 if (m_lmEfect > 0.001 && m_linearMotorTimescale < 1000) 785 if (m_lmEfect > 0.01 && m_linearMotorTimescale < 1000)
780 { 786 {
781 tmpV = m_linearMotorDirection - curLocalVel; // velocity error 787 tmpV = m_linearMotorDirection - curLocalVel; // velocity error
782 tmpV *= m_lmEfect; // error to correct in this timestep 788 tmpV *= m_lmEfect / m_linearMotorTimescale; // error to correct in this timestep
783 tmpV *= rotq; // to world 789 tmpV *= rotq; // to world
784 790
785 if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != 0) 791 if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != 0)
@@ -788,7 +794,7 @@ namespace OpenSim.Region.Physics.OdePlugin
788 if (m_linearMotorOffset.X != 0 || m_linearMotorOffset.Y != 0 || m_linearMotorOffset.Z != 0) 794 if (m_linearMotorOffset.X != 0 || m_linearMotorOffset.Y != 0 || m_linearMotorOffset.Z != 0)
789 { 795 {
790 // have offset, do it now 796 // have offset, do it now
791 tmpV *= rootPrim.Mass; 797 tmpV *= dmass.mass;
792 d.BodyAddForceAtRelPos(Body, tmpV.X, tmpV.Y, tmpV.Z, m_linearMotorOffset.X, m_linearMotorOffset.Y, m_linearMotorOffset.Z); 798 d.BodyAddForceAtRelPos(Body, tmpV.X, tmpV.Y, tmpV.Z, m_linearMotorOffset.X, m_linearMotorOffset.Y, m_linearMotorOffset.Z);
793 } 799 }
794 else 800 else
@@ -799,9 +805,7 @@ namespace OpenSim.Region.Physics.OdePlugin
799 } 805 }
800 806
801 m_lmEfect *= m_lmDecay; 807 m_lmEfect *= m_lmDecay;
802 808 m_ffactor = 0.01f + 1e-4f * curVel.LengthSquared();
803 // m_ffactor = 0.01f + 1e-4f * curVel.LengthSquared();
804 m_ffactor = 0;
805 } 809 }
806 else 810 else
807 { 811 {
@@ -1007,7 +1011,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1007 if (m_amEfect > 0.01 && m_angularMotorTimescale < 1000) 1011 if (m_amEfect > 0.01 && m_angularMotorTimescale < 1000)
1008 { 1012 {
1009 tmpV = m_angularMotorDirection - curLocalAngVel; // velocity error 1013 tmpV = m_angularMotorDirection - curLocalAngVel; // velocity error
1010 tmpV *= m_amEfect; // error to correct in this timestep 1014 tmpV *= m_amEfect / m_angularMotorTimescale; // error to correct in this timestep
1011 torque.X += tmpV.X * m_ampwr; 1015 torque.X += tmpV.X * m_ampwr;
1012 torque.Y += tmpV.Y * m_ampwr; 1016 torque.Y += tmpV.Y * m_ampwr;
1013 torque.Z += tmpV.Z; 1017 torque.Z += tmpV.Z;
@@ -1057,13 +1061,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1057 } 1061 }
1058 1062
1059 1063
1060 d.Mass dmass;
1061 d.BodyGetMass(Body,out dmass);
1062 1064
1063 if (force.X != 0 || force.Y != 0 || force.Z != 0) 1065 if (force.X != 0 || force.Y != 0 || force.Z != 0)
1064 { 1066 {
1065 force *= dmass.mass; 1067 force *= dmass.mass;
1066 d.BodySetForce(Body, force.X, force.Y, force.Z); 1068 d.BodyAddForce(Body, force.X, force.Y, force.Z);
1067 } 1069 }
1068 1070
1069 if (torque.X != 0 || torque.Y != 0 || torque.Z != 0) 1071 if (torque.X != 0 || torque.Y != 0 || torque.Z != 0)
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