Skip to content
0.2.0-dev Download ZIP
56 lines ·2.0 KB Raw
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7#include <Jolt/ObjectStream/SerializableObject.h>
8#include <Jolt/Core/LinearCurve.h>
9#include <Jolt/Core/StreamIn.h>
10#include <Jolt/Core/StreamOut.h>
11#include <Jolt/Physics/StateRecorder.h>
12
13JPH_NAMESPACE_BEGIN
14
15/// On which side of the vehicle the track is located (for steering)
16enum class ETrackSide : uint
17{
18 Left = 0,
19 Right = 1,
20 Num = 2
21};
22
23/// Generic properties for tank tracks
24class JPH_EXPORT VehicleTrackSettings
25{
26 JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(JPH_EXPORT, VehicleTrackSettings)
27
28public:
29 /// Saves the contents in binary form to inStream.
30 void SaveBinaryState(StreamOut &inStream) const;
31
32 /// Restores the contents in binary form to inStream.
33 void RestoreBinaryState(StreamIn &inStream);
34
35 uint mDrivenWheel; ///< Which wheel on the track is connected to the engine
36 Array<uint> mWheels; ///< Indices of wheels that are inside this track, should include the driven wheel too
37 float mInertia = 10.0f; ///< Moment of inertia (kg m^2) of the track and its wheels as seen on the driven wheel
38 float mAngularDamping = 0.5f; ///< Damping factor of track and its wheels: dw/dt = -c * w as seen on the driven wheel
39 float mMaxBrakeTorque = 15000.0f; ///< How much torque (Nm) the brakes can apply on the driven wheel
40 float mDifferentialRatio = 6.0f; ///< Ratio between rotation speed of gear box and driven wheel of track
41};
42
43/// Runtime data for tank tracks
44class JPH_EXPORT VehicleTrack : public VehicleTrackSettings
45{
46public:
47 /// Saving state for replay
48 void SaveState(StateRecorder &inStream) const;
49 void RestoreState(StateRecorder &inStream);
50
51 float mAngularVelocity = 0.0f; ///< Angular velocity of the driven wheel, will determine the speed of the entire track
52};
53
54using VehicleTracks = VehicleTrack[(int)ETrackSide::Num];
55
56JPH_NAMESPACE_END