Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
VehicleController.h
Go to the documentation of this file.
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
10#include <Jolt/Core/StreamOut.h>
11
13
15
17class VehicleControllerSettings : public SerializableObject, public RefTarget<VehicleControllerSettings>
18{
19public:
21
22
23 virtual void SaveBinaryState(StreamOut &inStream) const = 0;
24
26 virtual void RestoreBinaryState(StreamIn &inStream) = 0;
27
29 virtual VehicleController * ConstructController(VehicleConstraint &inConstraint) const = 0;
30};
31
34{
35public:
37
39 explicit VehicleController(VehicleConstraint &inConstraint) : mConstraint(inConstraint) { }
40 virtual ~VehicleController() = default;
41
42protected:
43 // The functions below are only for the VehicleConstraint
44 friend class VehicleConstraint;
45
46 // Create a new instance of wheel
47 virtual Wheel * ConstructWheel(const WheelSettings &inWheel) const = 0;
48
49 // If the vehicle is allowed to go to sleep
50 virtual bool AllowSleep() const = 0;
51
52 // Called before the wheel probes have been done
53 virtual void PreCollide(float inDeltaTime, PhysicsSystem &inPhysicsSystem) = 0;
54
55 // Called after the wheel probes have been done
56 virtual void PostCollide(float inDeltaTime, PhysicsSystem &inPhysicsSystem) = 0;
57
58 // Solve longitudinal and lateral constraint parts for all of the wheels
59 virtual bool SolveLongitudinalAndLateralConstraints(float inDeltaTime) = 0;
60
61 // Saving state for replay
62 virtual void SaveState(StateRecorder &inStream) const = 0;
63 virtual void RestoreState(StateRecorder &inStream) = 0;
64
65#ifdef JPH_DEBUG_RENDERER
66 // Drawing interface
67 virtual void Draw(DebugRenderer *inRenderer) const = 0;
68#endif // JPH_DEBUG_RENDERER
69
71};
72
#define JPH_NAMESPACE_END
Definition: Core.h:240
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:234
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition: Memory.h:29
#define JPH_DECLARE_SERIALIZABLE_ABSTRACT(class_name)
Definition: SerializableObject.h:111
Simple triangle renderer for debugging purposes.
Definition: DebugRenderer.h:25
Definition: PhysicsSystem.h:28
Definition: Reference.h:35
Definition: SerializableObject.h:147
Definition: StateRecorder.h:15
Simple binary input stream.
Definition: StreamIn.h:11
Simple binary output stream.
Definition: StreamOut.h:11
Definition: VehicleConstraint.h:67
Runtime data for interface that controls acceleration / decelleration of the vehicle.
Definition: VehicleController.h:34
virtual bool AllowSleep() const =0
virtual void PostCollide(float inDeltaTime, PhysicsSystem &inPhysicsSystem)=0
virtual void Draw(DebugRenderer *inRenderer) const =0
virtual void PreCollide(float inDeltaTime, PhysicsSystem &inPhysicsSystem)=0
virtual void RestoreState(StateRecorder &inStream)=0
virtual Wheel * ConstructWheel(const WheelSettings &inWheel) const =0
virtual bool SolveLongitudinalAndLateralConstraints(float inDeltaTime)=0
JPH_OVERRIDE_NEW_DELETE VehicleController(VehicleConstraint &inConstraint)
Constructor / destructor.
Definition: VehicleController.h:39
virtual ~VehicleController()=default
virtual void SaveState(StateRecorder &inStream) const =0
VehicleConstraint & mConstraint
The vehicle constraint we belong to.
Definition: VehicleController.h:70
Basic settings object for interface that controls acceleration / decelleration of the vehicle.
Definition: VehicleController.h:18
virtual VehicleController * ConstructController(VehicleConstraint &inConstraint) const =0
Create an instance of the vehicle controller class.
virtual void RestoreBinaryState(StreamIn &inStream)=0
Restore the contents of the controller settings in binary form from inStream.
virtual void SaveBinaryState(StreamOut &inStream) const =0
Saves the contents of the controller settings in binary form to inStream.
Base class for runtime data for a wheel, each VehicleController can implement a derived class of this...
Definition: Wheel.h:45
Base class for wheel settings, each VehicleController can implement a derived class of this.
Definition: Wheel.h:19