make ubitODE ignore X and Y rotation components on avatar rotations

avinationmerge
UbitUmarov 2012-12-11 22:53:24 +00:00
parent f35e3c6fe0
commit 71fc9f29f9
1 changed files with 37 additions and 14 deletions

View File

@ -80,6 +80,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private Vector3 m_rotationalVelocity; private Vector3 m_rotationalVelocity;
private Vector3 m_size; private Vector3 m_size;
private Quaternion m_orientation; private Quaternion m_orientation;
private Quaternion m_orientation2D;
private float m_mass = 80f; private float m_mass = 80f;
public float m_density = 60f; public float m_density = 60f;
private bool m_pidControllerActive = true; private bool m_pidControllerActive = true;
@ -207,6 +208,7 @@ namespace OpenSim.Region.Physics.OdePlugin
m_feetOffset = pfeetOffset; m_feetOffset = pfeetOffset;
m_orientation = Quaternion.Identity; m_orientation = Quaternion.Identity;
m_orientation2D = Quaternion.Identity;
m_density = density; m_density = density;
// force lower density for testing // force lower density for testing
@ -649,7 +651,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
// fakeori = value; // fakeori = value;
// givefakeori++; // givefakeori++;
value.Normalize(); value.Normalize();
AddChange(changes.Orientation, value); AddChange(changes.Orientation, value);
} }
@ -977,7 +978,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// force a full inelastic collision // force a full inelastic collision
m_collisionException = true; m_collisionException = true;
offset = m_size * m_orientation; offset = m_size * m_orientation2D;
offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth; offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth;
offset.Y = (float)Math.Abs(offset.Y) * 0.5f + contact.depth; offset.Y = (float)Math.Abs(offset.Y) * 0.5f + contact.depth;
@ -1143,10 +1144,10 @@ namespace OpenSim.Region.Physics.OdePlugin
// so force it back to identity // so force it back to identity
d.Quaternion qtmp; d.Quaternion qtmp;
qtmp.W = m_orientation.W; qtmp.W = m_orientation2D.W;
qtmp.X = m_orientation.X; qtmp.X = m_orientation2D.X;
qtmp.Y = m_orientation.Y; qtmp.Y = m_orientation2D.Y;
qtmp.Z = m_orientation.Z; qtmp.Z = m_orientation2D.Z;
d.BodySetQuaternion(Body, ref qtmp); d.BodySetQuaternion(Body, ref qtmp);
if (m_pidControllerActive == false) if (m_pidControllerActive == false)
@ -1679,14 +1680,36 @@ namespace OpenSim.Region.Physics.OdePlugin
private void changeOrientation(Quaternion newOri) private void changeOrientation(Quaternion newOri)
{ {
d.Quaternion myrot = new d.Quaternion(); if (m_orientation != newOri)
myrot.X = newOri.X; {
myrot.Y = newOri.Y; m_orientation = newOri; // keep a copy for core use
myrot.Z = newOri.Z; // but only use rotations around Z
myrot.W = newOri.W;
float t = d.JointGetAMotorAngle(Amotor, 2); m_orientation2D.W = newOri.W;
d.BodySetQuaternion(Body,ref myrot); m_orientation2D.Z = newOri.Z;
m_orientation = newOri;
float t = m_orientation2D.W * m_orientation2D.W + m_orientation2D.Z * m_orientation2D.Z;
if (t > 0)
{
t = 1.0f / (float)Math.Sqrt(t);
m_orientation2D.W *= t;
m_orientation2D.Z *= t;
}
else
{
m_orientation2D.W = 1.0f;
m_orientation2D.Z = 0f;
}
m_orientation2D.Y = 0f;
m_orientation2D.X = 0f;
d.Quaternion myrot = new d.Quaternion();
myrot.X = m_orientation2D.X;
myrot.Y = m_orientation2D.Y;
myrot.Z = m_orientation2D.Z;
myrot.W = m_orientation2D.W;
d.BodySetQuaternion(Body, ref myrot);
}
} }
private void changeVelocity(Vector3 newVel) private void changeVelocity(Vector3 newVel)