BulletSim: Modify first and default vehicle vertical attractor to be feature complete with use of the Limit Roll Only Flag.
Signed-off-by: Robert Adams <misterblue@misterblue.com>bullet-2.82
parent
d1b7c2ece3
commit
738c60459c
|
@ -1438,6 +1438,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
// This is only half the distance to the target so it will take 2 seconds to complete the turn.
|
||||
Vector3 torqueVector = Vector3.Cross(predictedUp, Vector3.UnitZ);
|
||||
|
||||
if ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) != 0)
|
||||
{
|
||||
Vector3 vehicleForwardAxis = Vector3.UnitX * VehicleOrientation;
|
||||
torqueVector = ProjectVector(torqueVector, vehicleForwardAxis);
|
||||
}
|
||||
|
||||
// Scale vector by our timescale since it is an acceleration it is r/s^2 or radians a timescale squared
|
||||
Vector3 vertContributionV = torqueVector * verticalAttractionSpeed * verticalAttractionSpeed;
|
||||
|
||||
|
@ -1739,6 +1745,14 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
|
||||
}
|
||||
|
||||
//Given a Vector and a unit vector will return the amount of the vector is on the same axis as the unit.
|
||||
private Vector3 ProjectVector(Vector3 vector, Vector3 onNormal)
|
||||
{
|
||||
float vectorDot = Vector3.Dot(vector, onNormal);
|
||||
return onNormal * vectorDot;
|
||||
|
||||
}
|
||||
|
||||
private float ClampInRange(float low, float val, float high)
|
||||
{
|
||||
return Math.Max(low, Math.Min(val, high));
|
||||
|
|
Loading…
Reference in New Issue