code review:

1) got rid of evey class having it's own gravity
2) rigidshape inheritance simplifications
3) gravitymod from physicszones taking buoyancy into account natively (we still track raw bouyancy to cancel it out for player)
4) disableMove used throughout
5) items can now also be influenced by the appliedforce from physicszones
This commit is contained in:
AzaezelX 2020-10-02 13:53:46 -05:00
parent 76c5e30869
commit afb39d398f
13 changed files with 191 additions and 487 deletions

View file

@ -54,9 +54,6 @@ static U32 sClientCollisionMask =
StaticShapeObjectType | VehicleObjectType |
VehicleBlockerObjectType;
// Gravity constant
static F32 sWheeledVehicleGravity = -20;
// Misc. sound constants
static F32 sMinSquealVolume = 0.05f;
static F32 sIdleEngineVolume = 0.2f;
@ -857,6 +854,7 @@ void WheeledVehicle::updateForces(F32 dt)
extendWheels();
if (mDisableMove) return;
F32 aMomentum = mMass / mDataBlock->wheelCount;
// Get the current matrix and extact vectors
@ -902,8 +900,7 @@ void WheeledVehicle::updateForces(F32 dt)
// Integrate forces, we'll do this ourselves here instead of
// relying on the rigid class which does it during movement.
Wheel* wend = &mWheel[mDataBlock->wheelCount];
mRigid.force.set(0, 0, 0);
mRigid.torque.set(0, 0, 0);
mRigid.clearForces();
// Calculate vertical load for friction. Divide up the spring
// forces across all the wheels that are in contact with
@ -1095,7 +1092,7 @@ void WheeledVehicle::updateForces(F32 dt)
mRigid.force += mAppliedForce;
// Container drag & buoyancy
mRigid.force += Point3F(0, 0, -mBuoyancy * sWheeledVehicleGravity * mRigid.mass);
mRigid.force += Point3F(0, 0, mRigid.mass * mNetGravity);
mRigid.force -= mRigid.linVelocity * mDrag;
mRigid.torque -= mRigid.angMomentum * mDrag;
@ -1104,17 +1101,13 @@ void WheeledVehicle::updateForces(F32 dt)
if (mRigid.atRest && (mRigid.force.len() || mRigid.torque.len()))
mRigid.atRest = false;
// Gravity
mRigid.force += Point3F(0, 0, sWheeledVehicleGravity * mRigid.mass);
// Integrate and update velocity
mRigid.linMomentum += mRigid.force * dt;
mRigid.angMomentum += mRigid.torque * dt;
mRigid.updateVelocity();
// Since we've already done all the work, just need to clear this out.
mRigid.force.set(0, 0, 0);
mRigid.torque.set(0, 0, 0);
mRigid.clearForces();
// If we're still atRest, make sure we're not accumulating anything
if (mRigid.atRest)