BulletSim: Tweeks to vehicle motion.
Pass through old angular velocity making for smoother transitions. Remove some old kludges for angular motion (damping and rotvel suppression).user_profiles
							parent
							
								
									471c477863
								
							
						
					
					
						commit
						80b1e32bfa
					
				| 
						 | 
				
			
			@ -1192,7 +1192,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
 | 
			
		|||
        //     set directly on the vehicle.
 | 
			
		||||
        private void MoveAngular(float pTimestep)
 | 
			
		||||
        {
 | 
			
		||||
            VehicleRotationalVelocity = Vector3.Zero;
 | 
			
		||||
            // VehicleRotationalVelocity = Vector3.Zero;
 | 
			
		||||
 | 
			
		||||
            ComputeAngularTurning(pTimestep);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1202,12 +1202,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
 | 
			
		|||
 | 
			
		||||
            ComputeAngularBanking();
 | 
			
		||||
 | 
			
		||||
            // ==================================================================
 | 
			
		||||
            // All of the above computation are made relative to vehicle coordinates.
 | 
			
		||||
            // Convert to world coordinates.
 | 
			
		||||
            // TODO: Should this be applied as an angular force (torque)?
 | 
			
		||||
            VehicleRotationalVelocity *= VehicleOrientation;
 | 
			
		||||
 | 
			
		||||
            // ==================================================================
 | 
			
		||||
            if (VehicleRotationalVelocity.ApproxEquals(Vector3.Zero, 0.01f))
 | 
			
		||||
            {
 | 
			
		||||
| 
						 | 
				
			
			@ -1256,7 +1250,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
 | 
			
		|||
        private void ComputeAngularTurning(float pTimestep)
 | 
			
		||||
        {
 | 
			
		||||
            // The user wants this many radians per second angular change?
 | 
			
		||||
            Vector3 angularMotorContribution = m_angularMotor.Step(pTimestep);
 | 
			
		||||
            Vector3 currentAngular = VehicleRotationalVelocity * Quaternion.Inverse(VehicleOrientation);
 | 
			
		||||
            Vector3 angularMotorContribution = m_angularMotor.Step(pTimestep, currentAngular);
 | 
			
		||||
 | 
			
		||||
            // ==================================================================
 | 
			
		||||
            // From http://wiki.secondlife.com/wiki/LlSetVehicleFlags :
 | 
			
		||||
| 
						 | 
				
			
			@ -1272,7 +1267,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
 | 
			
		|||
                angularMotorContribution.Y = 0f;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            VehicleRotationalVelocity += angularMotorContribution;
 | 
			
		||||
            VehicleRotationalVelocity += angularMotorContribution * VehicleOrientation;
 | 
			
		||||
            VDetailLog("{0},  MoveAngular,angularTurning,angularMotorContrib={1}", Prim.LocalID, angularMotorContribution);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1312,7 +1307,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
 | 
			
		|||
                if (verticalError.Z < 0f)
 | 
			
		||||
                {
 | 
			
		||||
                    vertContribution.X += PIOverFour;
 | 
			
		||||
                    vertContribution.Y += PIOverFour;
 | 
			
		||||
                    // vertContribution.Y -= PIOverFour;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                // 'vertContrbution' is now the necessary angular correction to correct tilt in one second.
 | 
			
		||||
| 
						 | 
				
			
			@ -1320,7 +1315,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
 | 
			
		|||
                Vector3 unscaledContrib = vertContribution;     // DEBUG DEBUG
 | 
			
		||||
                vertContribution /= m_verticalAttractionTimescale;
 | 
			
		||||
 | 
			
		||||
                VehicleRotationalVelocity += vertContribution;
 | 
			
		||||
                VehicleRotationalVelocity += vertContribution * VehicleOrientation;
 | 
			
		||||
 | 
			
		||||
                VDetailLog("{0},  MoveAngular,verticalAttraction,,verticalError={1},unscaled={2},eff={3},ts={4},vertAttr={5}",
 | 
			
		||||
                                Prim.LocalID, verticalError, unscaledContrib, m_verticalAttractionEfficiency, m_verticalAttractionTimescale, vertContribution);
 | 
			
		||||
| 
						 | 
				
			
			@ -1371,7 +1366,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
 | 
			
		|||
                deflectContribution = (-deflectionError) * m_angularDeflectionEfficiency;
 | 
			
		||||
                deflectContribution /= m_angularDeflectionTimescale;
 | 
			
		||||
 | 
			
		||||
                VehicleRotationalVelocity += deflectContribution;
 | 
			
		||||
                VehicleRotationalVelocity += deflectContribution * VehicleOrientation;
 | 
			
		||||
 | 
			
		||||
                VDetailLog("{0},  MoveAngular,Deflection,movingDir={1},pointingDir={2},deflectError={3},ret={4}",
 | 
			
		||||
                    Prim.LocalID, movingDirection, pointingDirection, deflectionError, deflectContribution);
 | 
			
		||||
| 
						 | 
				
			
			@ -1438,7 +1433,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
 | 
			
		|||
                // Don't do it all at once.
 | 
			
		||||
                bankingContribution /= m_bankingTimescale;
 | 
			
		||||
 | 
			
		||||
                VehicleRotationalVelocity += bankingContribution;
 | 
			
		||||
                VehicleRotationalVelocity += bankingContribution * VehicleOrientation;
 | 
			
		||||
 | 
			
		||||
                VDetailLog("{0},  MoveAngular,Banking,rollComp={1},speed={2},rollComp={3},yAng={4},mYAng={5},ret={6}",
 | 
			
		||||
                            Prim.LocalID, rollComponents, VehicleForwardSpeed, rollComponents, yawAngle, mixedYawAngle, bankingContribution);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -450,7 +450,7 @@ public static class BSParam
 | 
			
		|||
            (s) => { return (float)VehicleMaxAngularVelocity; },
 | 
			
		||||
            (s,p,l,v) => { VehicleMaxAngularVelocity = v; } ),
 | 
			
		||||
        new ParameterDefn("VehicleAngularDamping", "Factor to damp vehicle angular movement per second (0.0 - 1.0)",
 | 
			
		||||
            0.95f,
 | 
			
		||||
            0.0f,
 | 
			
		||||
            (s,cf,p,v) => { VehicleAngularDamping = cf.GetFloat(p, v); },
 | 
			
		||||
            (s) => { return VehicleAngularDamping; },
 | 
			
		||||
            (s,p,l,v) => { VehicleAngularDamping = v; } ),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1009,6 +1009,7 @@ public sealed class BSPrim : BSPhysObject
 | 
			
		|||
            {
 | 
			
		||||
                DetailLog("{0},BSPrim.ForceRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
 | 
			
		||||
                PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity);
 | 
			
		||||
                // PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity);
 | 
			
		||||
                ActivateIfPhysical(false);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -1649,7 +1650,7 @@ public sealed class BSPrim : BSPhysObject
 | 
			
		|||
            // TODO: handle physics introduced by Bullet with computed vehicle physics.
 | 
			
		||||
            if (_vehicle.IsActive)
 | 
			
		||||
            {
 | 
			
		||||
                entprop.RotationalVelocity = OMV.Vector3.Zero;
 | 
			
		||||
                // entprop.RotationalVelocity = OMV.Vector3.Zero;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Assign directly to the local variables so the normal set actions do not happen
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue