feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -28,4 +28,6 @@ public:
|
|||
float mStiffness = 1000.0f; ///< Stiffness (spring constant in N/m) of anti rollbar, can be 0 to disable the anti-rollbar
|
||||
};
|
||||
|
||||
using VehicleAntiRollBars = Array<VehicleAntiRollBar>;
|
||||
|
||||
JPH_NAMESPACE_END
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ bool VehicleCollisionTesterCastSphere::Collide(PhysicsSystem &inPhysicsSystem, c
|
|||
const WheelSettings *wheel_settings = inVehicleConstraint.GetWheel(inWheelIndex)->GetSettings();
|
||||
float wheel_radius = wheel_settings->mRadius;
|
||||
float shape_cast_length = wheel_settings->mSuspensionMaxLength + wheel_radius - mRadius;
|
||||
RShapeCast shape_cast(&sphere, Vec3::sReplicate(1.0f), RMat44::sTranslation(inOrigin), inDirection * shape_cast_length);
|
||||
RShapeCast shape_cast(&sphere, Vec3::sOne(), RMat44::sTranslation(inOrigin), inDirection * shape_cast_length);
|
||||
|
||||
ShapeCastSettings settings;
|
||||
settings.mUseShrunkenShapeAndConvexRadius = true;
|
||||
|
|
@ -261,7 +261,7 @@ bool VehicleCollisionTesterCastCylinder::Collide(PhysicsSystem &inPhysicsSystem,
|
|||
CylinderShape cylinder(wheel_half_width, wheel_settings->mRadius, min(wheel_half_width, wheel_settings->mRadius) * mConvexRadiusFraction);
|
||||
cylinder.SetEmbedded();
|
||||
|
||||
RShapeCast shape_cast(&cylinder, Vec3::sReplicate(1.0f), shape_cast_start, inDirection * max_suspension_length);
|
||||
RShapeCast shape_cast(&cylinder, Vec3::sOne(), shape_cast_start, inDirection * max_suspension_length);
|
||||
|
||||
ShapeCastSettings settings;
|
||||
settings.mUseShrunkenShapeAndConvexRadius = true;
|
||||
|
|
|
|||
|
|
@ -80,7 +80,8 @@ VehicleConstraint::VehicleConstraint(Body &inVehicleBody, const VehicleConstrain
|
|||
mBody(&inVehicleBody),
|
||||
mForward(inSettings.mForward),
|
||||
mUp(inSettings.mUp),
|
||||
mWorldUp(inSettings.mUp)
|
||||
mWorldUp(inSettings.mUp),
|
||||
mAntiRollBars(inSettings.mAntiRollBars)
|
||||
{
|
||||
// Check sanity of incoming settings
|
||||
JPH_ASSERT(inSettings.mUp.IsNormalized());
|
||||
|
|
@ -90,15 +91,6 @@ VehicleConstraint::VehicleConstraint(Body &inVehicleBody, const VehicleConstrain
|
|||
// Store max pitch/roll angle
|
||||
SetMaxPitchRollAngle(inSettings.mMaxPitchRollAngle);
|
||||
|
||||
// Copy anti-rollbar settings
|
||||
mAntiRollBars.resize(inSettings.mAntiRollBars.size());
|
||||
for (uint i = 0; i < mAntiRollBars.size(); ++i)
|
||||
{
|
||||
const VehicleAntiRollBar &r = inSettings.mAntiRollBars[i];
|
||||
mAntiRollBars[i] = r;
|
||||
JPH_ASSERT(r.mStiffness >= 0.0f);
|
||||
}
|
||||
|
||||
// Construct our controller class
|
||||
mController = inSettings.mController->ConstructController(*this);
|
||||
|
||||
|
|
@ -283,6 +275,8 @@ void VehicleConstraint::OnStep(const PhysicsStepListenerContext &inContext)
|
|||
// Calculate anti-rollbar impulses
|
||||
for (const VehicleAntiRollBar &r : mAntiRollBars)
|
||||
{
|
||||
JPH_ASSERT(r.mStiffness >= 0.0f);
|
||||
|
||||
Wheel *lw = mWheels[r.mLeftWheel];
|
||||
Wheel *rw = mWheels[r.mRightWheel];
|
||||
|
||||
|
|
@ -309,16 +303,19 @@ void VehicleConstraint::OnStep(const PhysicsStepListenerContext &inContext)
|
|||
mPostStepCallback(*this, inContext);
|
||||
|
||||
// If the wheels are rotating, we don't want to go to sleep yet
|
||||
bool allow_sleep = mController->AllowSleep();
|
||||
if (allow_sleep)
|
||||
for (const Wheel *w : mWheels)
|
||||
if (abs(w->mAngularVelocity) > DegreesToRadians(10.0f))
|
||||
{
|
||||
allow_sleep = false;
|
||||
break;
|
||||
}
|
||||
if (mBody->GetAllowSleeping() != allow_sleep)
|
||||
mBody->SetAllowSleeping(allow_sleep);
|
||||
if (mBody->GetAllowSleeping())
|
||||
{
|
||||
bool allow_sleep = mController->AllowSleep();
|
||||
if (allow_sleep)
|
||||
for (const Wheel *w : mWheels)
|
||||
if (abs(w->mAngularVelocity) > DegreesToRadians(10.0f))
|
||||
{
|
||||
allow_sleep = false;
|
||||
break;
|
||||
}
|
||||
if (!allow_sleep)
|
||||
mBody->ResetSleepTimer();
|
||||
}
|
||||
|
||||
// Increment step counter
|
||||
++mCurrentStep;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public:
|
|||
Vec3 mForward { 0, 0, 1 }; ///< Vector indicating forward direction of the vehicle (in local space to the body)
|
||||
float mMaxPitchRollAngle = JPH_PI; ///< Defines the maximum pitch/roll angle (rad), can be used to avoid the car from getting upside down. The vehicle up direction will stay within a cone centered around the up axis with half top angle mMaxPitchRollAngle, set to pi to turn off.
|
||||
Array<Ref<WheelSettings>> mWheels; ///< List of wheels and their properties
|
||||
Array<VehicleAntiRollBar> mAntiRollBars; ///< List of anti rollbars and their properties
|
||||
VehicleAntiRollBars mAntiRollBars; ///< List of anti rollbars and their properties
|
||||
Ref<VehicleControllerSettings> mController; ///< Defines how the vehicle can accelerate / decelerate
|
||||
|
||||
protected:
|
||||
|
|
@ -161,6 +161,10 @@ public:
|
|||
/// @param inWheelUp Unit vector that indicates up in model space of the wheel
|
||||
RMat44 GetWheelWorldTransform(uint inWheelIndex, Vec3Arg inWheelRight, Vec3Arg inWheelUp) const;
|
||||
|
||||
/// Access to the vehicle's anti roll bars
|
||||
const VehicleAntiRollBars & GetAntiRollBars() const { return mAntiRollBars; }
|
||||
VehicleAntiRollBars & GetAntiRollBars() { return mAntiRollBars; }
|
||||
|
||||
/// Number of simulation steps between wheel collision tests when the vehicle is active. Default is 1. 0 = never, 1 = every step, 2 = every other step, etc.
|
||||
/// Note that if a vehicle has multiple wheels and the number of steps > 1, the wheels will be tested in a round robin fashion.
|
||||
/// If there are multiple vehicles, the tests will be spread out based on the BodyID of the vehicle.
|
||||
|
|
@ -214,7 +218,7 @@ private:
|
|||
Vec3 mUp; ///< Local space up vector for the vehicle
|
||||
Vec3 mWorldUp; ///< Vector indicating the world space up direction (used to limit vehicle pitch/roll)
|
||||
Wheels mWheels; ///< Wheel states of the vehicle
|
||||
Array<VehicleAntiRollBar> mAntiRollBars; ///< Anti rollbars of the vehicle
|
||||
VehicleAntiRollBars mAntiRollBars; ///< Anti rollbars of the vehicle
|
||||
VehicleController * mController; ///< Controls the acceleration / deceleration of the vehicle
|
||||
bool mIsActive = false; ///< If this constraint is active
|
||||
uint mNumStepsBetweenCollisionTestActive = 1; ///< Number of simulation steps between wheel collision tests when the vehicle is active
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public:
|
|||
};
|
||||
|
||||
/// Runtime data for interface that controls acceleration / deceleration of the vehicle
|
||||
class JPH_EXPORT VehicleController : public RefTarget<VehicleController>, public NonCopyable
|
||||
class JPH_EXPORT VehicleController : public NonCopyable
|
||||
{
|
||||
public:
|
||||
JPH_OVERRIDE_NEW_DELETE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue