Path: blob/master/thirdparty/jolt_physics/Jolt/Physics/Vehicle/VehicleTrack.h
9912 views
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)1// SPDX-FileCopyrightText: 2021 Jorrit Rouwe2// SPDX-License-Identifier: MIT34#pragma once56#include <Jolt/ObjectStream/SerializableObject.h>7#include <Jolt/Core/LinearCurve.h>8#include <Jolt/Core/StreamIn.h>9#include <Jolt/Core/StreamOut.h>10#include <Jolt/Physics/StateRecorder.h>1112JPH_NAMESPACE_BEGIN1314/// On which side of the vehicle the track is located (for steering)15enum class ETrackSide : uint16{17Left = 0,18Right = 1,19Num = 220};2122/// Generic properties for tank tracks23class JPH_EXPORT VehicleTrackSettings24{25JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(JPH_EXPORT, VehicleTrackSettings)2627public:28/// Saves the contents in binary form to inStream.29void SaveBinaryState(StreamOut &inStream) const;3031/// Restores the contents in binary form to inStream.32void RestoreBinaryState(StreamIn &inStream);3334uint mDrivenWheel; ///< Which wheel on the track is connected to the engine35Array<uint> mWheels; ///< Indices of wheels that are inside this track, should include the driven wheel too36float mInertia = 10.0f; ///< Moment of inertia (kg m^2) of the track and its wheels as seen on the driven wheel37float mAngularDamping = 0.5f; ///< Damping factor of track and its wheels: dw/dt = -c * w as seen on the driven wheel38float mMaxBrakeTorque = 15000.0f; ///< How much torque (Nm) the brakes can apply on the driven wheel39float mDifferentialRatio = 6.0f; ///< Ratio between rotation speed of gear box and driven wheel of track40};4142/// Runtime data for tank tracks43class JPH_EXPORT VehicleTrack : public VehicleTrackSettings44{45public:46/// Saving state for replay47void SaveState(StateRecorder &inStream) const;48void RestoreState(StateRecorder &inStream);4950float mAngularVelocity = 0.0f; ///< Angular velocity of the driven wheel, will determine the speed of the entire track51};5253using VehicleTracks = VehicleTrack[(int)ETrackSide::Num];5455JPH_NAMESPACE_END565758