Path: blob/master/thirdparty/jolt_physics/Jolt/Physics/Vehicle/VehicleController.h
9912 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; }5152protected:53// The functions below are only for the VehicleConstraint54friend class VehicleConstraint;5556// Create a new instance of wheel57virtual Wheel * ConstructWheel(const WheelSettings &inWheel) const = 0;5859// If the vehicle is allowed to go to sleep60virtual bool AllowSleep() const = 0;6162// Called before the wheel probes have been done63virtual void PreCollide(float inDeltaTime, PhysicsSystem &inPhysicsSystem) = 0;6465// Called after the wheel probes have been done66virtual void PostCollide(float inDeltaTime, PhysicsSystem &inPhysicsSystem) = 0;6768// Solve longitudinal and lateral constraint parts for all of the wheels69virtual bool SolveLongitudinalAndLateralConstraints(float inDeltaTime) = 0;7071// Saving state for replay72virtual void SaveState(StateRecorder &inStream) const = 0;73virtual void RestoreState(StateRecorder &inStream) = 0;7475#ifdef JPH_DEBUG_RENDERER76// Drawing interface77virtual void Draw(DebugRenderer *inRenderer) const = 0;78#endif // JPH_DEBUG_RENDERER7980VehicleConstraint & mConstraint; ///< The vehicle constraint we belong to81};8283JPH_NAMESPACE_END848586