diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 05374e8807..2bf32e765c 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -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));