Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void ApplyWheelConstraint(Wheel wheel, float dt)
- {
- Vector offset = ToWorld(wheel.mPosition);
- Vector groundVel = PointVel(offset);
- Vector patchDir = ToWorld(wheel.PatchDir());
- Vector constraintDir = ToWorld(wheel.ConstraintDir());
- Vector deltaV = -groundVel.Project(constraintDir);
- Vector dir = deltaV;
- float mag = 0.0f;
- dir.Normalize(out mag);
- if (mag < 0.1f)
- wheel.mStaticFriction = true;
- else if (wheel.mStaticFriction)
- {
- float acc = wheel.mAcceleration.mValue.Length;
- float maxAcc = cGravity * wheel.Friction();
- if (acc > maxAcc)
- wheel.mStaticFriction = false;
- }
- mag *= wheel.Friction();
- Vector impulse = ChangePointVel( dt, offset, dir, mag );
- wheel.mAngVel = groundVel.Dot(patchDir) / wheel.mRadius;
- //wheel.mAcceleration.mValue = deltaV / dt; //Direct
- wheel.mAcceleration.Add( deltaV / dt, 0.2f ); //Interpolated
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement