Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
MotorcycleController.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2023 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
8
10
14{
15public:
17
18 // See: VehicleControllerSettings
19 virtual VehicleController * ConstructController(VehicleConstraint &inConstraint) const override;
20 virtual void SaveBinaryState(StreamOut &inStream) const override;
21 virtual void RestoreBinaryState(StreamIn &inStream) override;
22
25
27 float mLeanSpringConstant = 5000.0f;
28
30 float mLeanSpringDamping = 1000.0f;
31
35};
36
39{
40public:
42
45
47 float GetWheelBase() const;
48
49protected:
50 // See: VehicleController
51 virtual void PreCollide(float inDeltaTime, PhysicsSystem &inPhysicsSystem) override;
52 virtual bool SolveLongitudinalAndLateralConstraints(float inDeltaTime) override;
53 virtual void SaveState(StateRecorder& inStream) const override;
54 virtual void RestoreState(StateRecorder& inStream) override;
55#ifdef JPH_DEBUG_RENDERER
56 virtual void Draw(DebugRenderer *inRenderer) const override;
57#endif // JPH_DEBUG_RENDERER
58
59 // Configuration properties
64
65 // Run-time calculated target lean vector
67
68 // Run-time total angular impulse applied to turn the cycle towards the target lean angle
69 float mAppliedImpulse = 0.0f;
70};
71
#define JPH_NAMESPACE_END
Definition: Core.h:240
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:234
constexpr float DegreesToRadians(float inV)
Convert a value from degrees to radians.
Definition: Math.h:13
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition: Memory.h:29
#define JPH_DECLARE_SERIALIZABLE_VIRTUAL(class_name)
Definition: SerializableObject.h:100
Simple triangle renderer for debugging purposes.
Definition: DebugRenderer.h:25
Runtime controller class.
Definition: MotorcycleController.h:39
virtual bool SolveLongitudinalAndLateralConstraints(float inDeltaTime) override
Definition: MotorcycleController.cpp:157
float mMaxLeanAngle
Definition: MotorcycleController.h:60
virtual void RestoreState(StateRecorder &inStream) override
Definition: MotorcycleController.cpp:228
float mLeanSpringConstant
Definition: MotorcycleController.h:61
float mLeanSmoothingFactor
Definition: MotorcycleController.h:63
virtual void PreCollide(float inDeltaTime, PhysicsSystem &inPhysicsSystem) override
Definition: MotorcycleController.cpp:81
float mLeanSpringDamping
Definition: MotorcycleController.h:62
Vec3 mTargetLean
Definition: MotorcycleController.h:66
virtual void SaveState(StateRecorder &inStream) const override
Definition: MotorcycleController.cpp:221
float GetWheelBase() const
Get the distance between the front and back wheels.
Definition: MotorcycleController.cpp:62
virtual void Draw(DebugRenderer *inRenderer) const override
Definition: MotorcycleController.cpp:237
float mAppliedImpulse
Definition: MotorcycleController.h:69
Definition: MotorcycleController.h:14
float mMaxLeanAngle
How far we're willing to make the bike lean over in turns (in radians)
Definition: MotorcycleController.h:24
virtual VehicleController * ConstructController(VehicleConstraint &inConstraint) const override
Create an instance of the vehicle controller class.
Definition: MotorcycleController.cpp:28
float mLeanSpringDamping
Spring damping constant for the lean spring.
Definition: MotorcycleController.h:30
virtual void SaveBinaryState(StreamOut &inStream) const override
Saves the contents of the controller settings in binary form to inStream.
Definition: MotorcycleController.cpp:33
float mLeanSpringConstant
Spring constant for the lean spring.
Definition: MotorcycleController.h:27
float mLeanSmoothingFactor
Definition: MotorcycleController.h:34
virtual void RestoreBinaryState(StreamIn &inStream) override
Restore the contents of the controller settings in binary form from inStream.
Definition: MotorcycleController.cpp:43
Definition: PhysicsSystem.h:28
Definition: StateRecorder.h:15
Simple binary input stream.
Definition: StreamIn.h:11
Simple binary output stream.
Definition: StreamOut.h:11
Definition: Vec3.h:16
static JPH_INLINE Vec3 sZero()
Vector with all zeros.
Definition: Vec3.inl:107
Definition: VehicleConstraint.h:67
Runtime data for interface that controls acceleration / decelleration of the vehicle.
Definition: VehicleController.h:34
Runtime controller class.
Definition: WheeledVehicleController.h:89
Definition: WheeledVehicleController.h:72