From 738c60459c0721a2559274f6f6af1f556bda88c2 Mon Sep 17 00:00:00 2001 From: Vegaslon Date: Tue, 24 Jun 2014 10:51:49 -0400 Subject: 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 --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 05374e8..2bf32e7 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)); -- cgit v1.1