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#ifdef JPH_DEBUG_RENDERER
12#endif // JPH_DEBUG_RENDERER
13
15
16class PhysicsSystem;
19class WheelSettings;
20class Wheel;
21class StateRecorder;
22
24class JPH_EXPORT VehicleControllerSettings : public SerializableObject, public RefTarget<VehicleControllerSettings>
25{
26public:
28
29
30 virtual void SaveBinaryState(StreamOut &inStream) const = 0;
31
33 virtual void RestoreBinaryState(StreamIn &inStream) = 0;
34
36 virtual VehicleController * ConstructController(VehicleConstraint &inConstraint) const = 0;
37};
38
41{
42public:
44
46 explicit VehicleController(VehicleConstraint &inConstraint) : mConstraint(inConstraint) { }
47 virtual ~VehicleController() = default;
48
49protected:
50 // The functions below are only for the VehicleConstraint
51 friend class VehicleConstraint;
52
53 // Create a new instance of wheel
54 virtual Wheel * ConstructWheel(const WheelSettings &inWheel) const = 0;
55
56 // If the vehicle is allowed to go to sleep
57 virtual bool AllowSleep() const = 0;
58
59 // Called before the wheel probes have been done
60 virtual void PreCollide(float inDeltaTime, PhysicsSystem &inPhysicsSystem) = 0;
61
62 // Called after the wheel probes have been done
63 virtual void PostCollide(float inDeltaTime, PhysicsSystem &inPhysicsSystem) = 0;
64
65 // Solve longitudinal and lateral constraint parts for all of the wheels
66 virtual bool SolveLongitudinalAndLateralConstraints(float inDeltaTime) = 0;
67
68 // Saving state for replay
69 virtual void SaveState(StateRecorder &inStream) const = 0;
70 virtual void RestoreState(StateRecorder &inStream) = 0;
71
72#ifdef JPH_DEBUG_RENDERER
73 // Drawing interface
74 virtual void Draw(DebugRenderer *inRenderer) const = 0;
75#endif // JPH_DEBUG_RENDERER
76
78};
79
#define JPH_EXPORT
Definition: Core.h:227
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition: Memory.h:29
#define JPH_DECLARE_SERIALIZABLE_ABSTRACT(linkage, class_name)
Definition: SerializableObject.h:111
Definition: DebugRenderer.h:47
Class that makes another class non-copyable. Usage: Inherit from NonCopyable.
Definition: NonCopyable.h:11
Definition: PhysicsSystem.h:29
Definition: Reference.h:35
Definition: SerializableObject.h:147
Definition: StateRecorder.h:48
Simple binary input stream.
Definition: StreamIn.h:13
Simple binary output stream.
Definition: StreamOut.h:13
Definition: VehicleConstraint.h:66
Runtime data for interface that controls acceleration / deceleration of the vehicle.
Definition: VehicleController.h:41
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:46
virtual ~VehicleController()=default
virtual void SaveState(StateRecorder &inStream) const =0
VehicleConstraint & mConstraint
The vehicle constraint we belong to.
Definition: VehicleController.h:77
Basic settings object for interface that controls acceleration / deceleration of the vehicle.
Definition: VehicleController.h:25
Base class for runtime data for a wheel, each VehicleController can implement a derived class of this...
Definition: Wheel.h:46
Base class for wheel settings, each VehicleController can implement a derived class of this.
Definition: Wheel.h:19