Path: blob/master/thirdparty/jolt_physics/Jolt/Physics/Vehicle/VehicleController.h
21928 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/StreamIn.h>8#include <Jolt/Core/StreamOut.h>9#ifdef JPH_DEBUG_RENDERER10#include <Jolt/Renderer/DebugRenderer.h>11#endif // JPH_DEBUG_RENDERER1213JPH_NAMESPACE_BEGIN1415class PhysicsSystem;16class VehicleController;17class VehicleConstraint;18class WheelSettings;19class Wheel;20class StateRecorder;2122/// Basic settings object for interface that controls acceleration / deceleration of the vehicle23class JPH_EXPORT VehicleControllerSettings : public SerializableObject, public RefTarget<VehicleControllerSettings>24{25JPH_DECLARE_SERIALIZABLE_ABSTRACT(JPH_EXPORT, VehicleControllerSettings)2627public:28/// Saves the contents of the controller settings in binary form to inStream.29virtual void SaveBinaryState(StreamOut &inStream) const = 0;3031/// Restore the contents of the controller settings in binary form from inStream.32virtual void RestoreBinaryState(StreamIn &inStream) = 0;3334/// Create an instance of the vehicle controller class35virtual VehicleController * ConstructController(VehicleConstraint &inConstraint) const = 0;36};3738/// Runtime data for interface that controls acceleration / deceleration of the vehicle39class JPH_EXPORT VehicleController : public NonCopyable40{41public:42JPH_OVERRIDE_NEW_DELETE4344/// Constructor / destructor45explicit VehicleController(VehicleConstraint &inConstraint) : mConstraint(inConstraint) { }46virtual ~VehicleController() = default;4748/// Access the vehicle constraint that this controller is part of49VehicleConstraint & GetConstraint() { return mConstraint; }50const VehicleConstraint & GetConstraint() const { return mConstraint; }5152/// Recreate the settings for this controller53virtual Ref<VehicleControllerSettings> GetSettings() const = 0;5455protected:56// The functions below are only for the VehicleConstraint57friend class VehicleConstraint;5859// Create a new instance of wheel60virtual Wheel * ConstructWheel(const WheelSettings &inWheel) const = 0;6162// If the vehicle is allowed to go to sleep63virtual bool AllowSleep() const = 0;6465// Called before the wheel probes have been done66virtual void PreCollide(float inDeltaTime, PhysicsSystem &inPhysicsSystem) = 0;6768// Called after the wheel probes have been done69virtual void PostCollide(float inDeltaTime, PhysicsSystem &inPhysicsSystem) = 0;7071// Solve longitudinal and lateral constraint parts for all of the wheels72virtual bool SolveLongitudinalAndLateralConstraints(float inDeltaTime) = 0;7374// Saving state for replay75virtual void SaveState(StateRecorder &inStream) const = 0;76virtual void RestoreState(StateRecorder &inStream) = 0;7778#ifdef JPH_DEBUG_RENDERER79// Drawing interface80virtual void Draw(DebugRenderer *inRenderer) const = 0;81#endif // JPH_DEBUG_RENDERER8283VehicleConstraint & mConstraint; ///< The vehicle constraint we belong to84};8586JPH_NAMESPACE_END878889