aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorUbitUmarov2012-12-11 22:53:24 +0000
committerUbitUmarov2012-12-11 22:53:24 +0000
commit71fc9f29f92edf2956ecb25dcbcdb97d262c8a14 (patch)
tree734244164dfde9ff60fad2c0a4e7f5c7bca963b8 /OpenSim
parent changes on the fast speed avatars collider, collisions from above, etc (diff)
downloadopensim-SC-71fc9f29f92edf2956ecb25dcbcdb97d262c8a14.zip
opensim-SC-71fc9f29f92edf2956ecb25dcbcdb97d262c8a14.tar.gz
opensim-SC-71fc9f29f92edf2956ecb25dcbcdb97d262c8a14.tar.bz2
opensim-SC-71fc9f29f92edf2956ecb25dcbcdb97d262c8a14.tar.xz
make ubitODE ignore X and Y rotation components on avatar rotations
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs51
1 files changed, 37 insertions, 14 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 27a9f1c..bb04ea7 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -80,6 +80,7 @@ namespace OpenSim.Region.Physics.OdePlugin
80 private Vector3 m_rotationalVelocity; 80 private Vector3 m_rotationalVelocity;
81 private Vector3 m_size; 81 private Vector3 m_size;
82 private Quaternion m_orientation; 82 private Quaternion m_orientation;
83 private Quaternion m_orientation2D;
83 private float m_mass = 80f; 84 private float m_mass = 80f;
84 public float m_density = 60f; 85 public float m_density = 60f;
85 private bool m_pidControllerActive = true; 86 private bool m_pidControllerActive = true;
@@ -207,6 +208,7 @@ namespace OpenSim.Region.Physics.OdePlugin
207 208
208 m_feetOffset = pfeetOffset; 209 m_feetOffset = pfeetOffset;
209 m_orientation = Quaternion.Identity; 210 m_orientation = Quaternion.Identity;
211 m_orientation2D = Quaternion.Identity;
210 m_density = density; 212 m_density = density;
211 213
212 // force lower density for testing 214 // force lower density for testing
@@ -649,7 +651,6 @@ namespace OpenSim.Region.Physics.OdePlugin
649 { 651 {
650// fakeori = value; 652// fakeori = value;
651// givefakeori++; 653// givefakeori++;
652
653 value.Normalize(); 654 value.Normalize();
654 AddChange(changes.Orientation, value); 655 AddChange(changes.Orientation, value);
655 } 656 }
@@ -977,7 +978,7 @@ namespace OpenSim.Region.Physics.OdePlugin
977 // force a full inelastic collision 978 // force a full inelastic collision
978 m_collisionException = true; 979 m_collisionException = true;
979 980
980 offset = m_size * m_orientation; 981 offset = m_size * m_orientation2D;
981 982
982 offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth; 983 offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth;
983 offset.Y = (float)Math.Abs(offset.Y) * 0.5f + contact.depth; 984 offset.Y = (float)Math.Abs(offset.Y) * 0.5f + contact.depth;
@@ -1143,10 +1144,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1143 // so force it back to identity 1144 // so force it back to identity
1144 1145
1145 d.Quaternion qtmp; 1146 d.Quaternion qtmp;
1146 qtmp.W = m_orientation.W; 1147 qtmp.W = m_orientation2D.W;
1147 qtmp.X = m_orientation.X; 1148 qtmp.X = m_orientation2D.X;
1148 qtmp.Y = m_orientation.Y; 1149 qtmp.Y = m_orientation2D.Y;
1149 qtmp.Z = m_orientation.Z; 1150 qtmp.Z = m_orientation2D.Z;
1150 d.BodySetQuaternion(Body, ref qtmp); 1151 d.BodySetQuaternion(Body, ref qtmp);
1151 1152
1152 if (m_pidControllerActive == false) 1153 if (m_pidControllerActive == false)
@@ -1679,14 +1680,36 @@ namespace OpenSim.Region.Physics.OdePlugin
1679 1680
1680 private void changeOrientation(Quaternion newOri) 1681 private void changeOrientation(Quaternion newOri)
1681 { 1682 {
1682 d.Quaternion myrot = new d.Quaternion(); 1683 if (m_orientation != newOri)
1683 myrot.X = newOri.X; 1684 {
1684 myrot.Y = newOri.Y; 1685 m_orientation = newOri; // keep a copy for core use
1685 myrot.Z = newOri.Z; 1686 // but only use rotations around Z
1686 myrot.W = newOri.W; 1687
1687 float t = d.JointGetAMotorAngle(Amotor, 2); 1688 m_orientation2D.W = newOri.W;
1688 d.BodySetQuaternion(Body,ref myrot); 1689 m_orientation2D.Z = newOri.Z;
1689 m_orientation = newOri; 1690
1691 float t = m_orientation2D.W * m_orientation2D.W + m_orientation2D.Z * m_orientation2D.Z;
1692 if (t > 0)
1693 {
1694 t = 1.0f / (float)Math.Sqrt(t);
1695 m_orientation2D.W *= t;
1696 m_orientation2D.Z *= t;
1697 }
1698 else
1699 {
1700 m_orientation2D.W = 1.0f;
1701 m_orientation2D.Z = 0f;
1702 }
1703 m_orientation2D.Y = 0f;
1704 m_orientation2D.X = 0f;
1705
1706 d.Quaternion myrot = new d.Quaternion();
1707 myrot.X = m_orientation2D.X;
1708 myrot.Y = m_orientation2D.Y;
1709 myrot.Z = m_orientation2D.Z;
1710 myrot.W = m_orientation2D.W;
1711 d.BodySetQuaternion(Body, ref myrot);
1712 }
1690 } 1713 }
1691 1714
1692 private void changeVelocity(Vector3 newVel) 1715 private void changeVelocity(Vector3 newVel)