* A few fixes to the Linear Motor
parent
b4cb45bb79
commit
68190617b4
|
@ -64,6 +64,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
private Vector3 m_angularMotorDirection = Vector3.Zero;
|
private Vector3 m_angularMotorDirection = Vector3.Zero;
|
||||||
private Vector3 m_linearFrictionTimescale = Vector3.Zero;
|
private Vector3 m_linearFrictionTimescale = Vector3.Zero;
|
||||||
private Vector3 m_linearMotorDirection = Vector3.Zero;
|
private Vector3 m_linearMotorDirection = Vector3.Zero;
|
||||||
|
private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero;
|
||||||
private Vector3 m_linearMotorOffset = Vector3.Zero;
|
private Vector3 m_linearMotorOffset = Vector3.Zero;
|
||||||
private float m_angularDeflectionEfficiency = 0;
|
private float m_angularDeflectionEfficiency = 0;
|
||||||
private float m_angularDeflectionTimescale = 0;
|
private float m_angularDeflectionTimescale = 0;
|
||||||
|
@ -86,7 +87,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
private VehicleFlag m_flags = (VehicleFlag) 0;
|
private VehicleFlag m_flags = (VehicleFlag) 0;
|
||||||
|
|
||||||
private bool m_LinearMotorSetLastFrame = false;
|
private bool m_LinearMotorSetLastFrame = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,7 +174,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
break;
|
break;
|
||||||
case Vehicle.LINEAR_MOTOR_DIRECTION:
|
case Vehicle.LINEAR_MOTOR_DIRECTION:
|
||||||
m_linearMotorDirection = new Vector3(pValue, pValue, pValue);
|
m_linearMotorDirection = new Vector3(pValue, pValue, pValue);
|
||||||
m_LinearMotorSetLastFrame = true;
|
m_linearMotorDirectionLASTSET = new Vector3(pValue, pValue, pValue);
|
||||||
break;
|
break;
|
||||||
case Vehicle.LINEAR_MOTOR_OFFSET:
|
case Vehicle.LINEAR_MOTOR_OFFSET:
|
||||||
m_linearMotorOffset = new Vector3(pValue, pValue, pValue);
|
m_linearMotorOffset = new Vector3(pValue, pValue, pValue);
|
||||||
|
@ -199,6 +200,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
break;
|
break;
|
||||||
case Vehicle.LINEAR_MOTOR_DIRECTION:
|
case Vehicle.LINEAR_MOTOR_DIRECTION:
|
||||||
m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z);
|
m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z);
|
||||||
|
m_linearMotorDirectionLASTSET = new Vector3(pValue.X, pValue.Y, pValue.Z);
|
||||||
break;
|
break;
|
||||||
case Vehicle.LINEAR_MOTOR_OFFSET:
|
case Vehicle.LINEAR_MOTOR_OFFSET:
|
||||||
m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z);
|
m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z);
|
||||||
|
@ -466,27 +468,31 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
if (!m_linearMotorDirection.ApproxEquals(Vector3.Zero, 0.01f))
|
if (!m_linearMotorDirection.ApproxEquals(Vector3.Zero, 0.01f))
|
||||||
{
|
{
|
||||||
|
|
||||||
Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale/pTimestep);
|
Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale/pTimestep);
|
||||||
m_lastLinearVelocityVector += (addAmount*10);
|
m_lastLinearVelocityVector += (addAmount*10);
|
||||||
|
|
||||||
// This will work temporarily, but we really need to compare speed on an axis
|
// This will work temporarily, but we really need to compare speed on an axis
|
||||||
if (Math.Abs(m_lastLinearVelocityVector.X) > Math.Abs(m_linearMotorDirection.X))
|
if (Math.Abs(m_lastLinearVelocityVector.X) > Math.Abs(m_linearMotorDirectionLASTSET.X))
|
||||||
m_lastLinearVelocityVector.X = m_linearMotorDirection.X;
|
m_lastLinearVelocityVector.X = m_linearMotorDirectionLASTSET.X;
|
||||||
if (Math.Abs(m_lastLinearVelocityVector.Y) > Math.Abs(m_linearMotorDirection.Y))
|
if (Math.Abs(m_lastLinearVelocityVector.Y) > Math.Abs(m_linearMotorDirectionLASTSET.Y))
|
||||||
m_lastLinearVelocityVector.Y = m_linearMotorDirection.Y;
|
m_lastLinearVelocityVector.Y = m_linearMotorDirectionLASTSET.Y;
|
||||||
if (Math.Abs(m_lastLinearVelocityVector.Z) > Math.Abs(m_linearMotorDirection.Z))
|
if (Math.Abs(m_lastLinearVelocityVector.Z) > Math.Abs(m_linearMotorDirectionLASTSET.Z))
|
||||||
m_lastLinearVelocityVector.Z = m_linearMotorDirection.Z;
|
m_lastLinearVelocityVector.Z = m_linearMotorDirectionLASTSET.Z;
|
||||||
//System.Console.WriteLine("add: " + addAmount);
|
//Console.WriteLine("add: " + addAmount);
|
||||||
|
|
||||||
m_linearMotorDirection -= (m_linearMotorDirection*new Vector3(1, 1, 1)/
|
Vector3 decayfraction = ((Vector3.One/(m_linearMotorDecayTimescale/pTimestep)));
|
||||||
(m_linearMotorDecayTimescale/pTimestep)) * 0.10f;
|
//Console.WriteLine("decay: " + decayfraction);
|
||||||
|
|
||||||
|
m_linearMotorDirection -= m_linearMotorDirection * decayfraction;
|
||||||
//Console.WriteLine("actual: " + m_linearMotorDirection);
|
//Console.WriteLine("actual: " + m_linearMotorDirection);
|
||||||
}
|
}
|
||||||
|
|
||||||
//System.Console.WriteLine(m_linearMotorDirection + " " + m_lastLinearVelocityVector);
|
//System.Console.WriteLine(m_linearMotorDirection + " " + m_lastLinearVelocityVector);
|
||||||
|
|
||||||
SetMotorProperties();
|
SetMotorProperties();
|
||||||
|
|
||||||
Vector3 decayamount = new Vector3(1,1,1)/(m_linearFrictionTimescale/pTimestep);
|
Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep);
|
||||||
m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount;
|
m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount;
|
||||||
|
|
||||||
//m_linearMotorDirection *= decayamount;
|
//m_linearMotorDirection *= decayamount;
|
||||||
|
@ -507,7 +513,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
{
|
{
|
||||||
|
|
||||||
d.JointSetLMotorAxis(m_lMotor1, 0, 1, dirNorm.X, dirNorm.Y, dirNorm.Z);
|
d.JointSetLMotorAxis(m_lMotor1, 0, 1, dirNorm.X, dirNorm.Y, dirNorm.Z);
|
||||||
d.JointSetLMotorParam(m_lMotor1, (int)dParam.Vel, m_linearMotorDirection.Length());
|
d.JointSetLMotorParam(m_lMotor1, (int)dParam.Vel, m_lastLinearVelocityVector.Length());
|
||||||
|
|
||||||
d.JointSetLMotorParam(m_lMotor1, (int)dParam.FMax, 35f * objMass.mass);
|
d.JointSetLMotorParam(m_lMotor1, (int)dParam.FMax, 35f * objMass.mass);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue