Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
PathConstraintPath.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
8#include <Jolt/Core/Result.h>
10
12
13class StreamIn;
14class StreamOut;
15#ifdef JPH_DEBUG_RENDERER
16class DebugRenderer;
17#endif // JPH_DEBUG_RENDERER
18
20class PathConstraintPath : public SerializableObject, public RefTarget<PathConstraintPath>
21{
22public:
24
26
28 virtual ~PathConstraintPath() override = default;
29
31 virtual float GetPathMaxFraction() const = 0;
32
36 virtual float GetClosestPoint(Vec3Arg inPosition) const = 0;
37
44 virtual void GetPointOnPath(float inFraction, Vec3 &outPathPosition, Vec3 &outPathTangent, Vec3 &outPathNormal, Vec3 &outPathBinormal) const = 0;
45
47 void SetIsLooping(bool inIsLooping) { mIsLooping = inIsLooping; }
48 bool IsLooping() const { return mIsLooping; }
49
50#ifdef JPH_DEBUG_RENDERER
52 void DrawPath(DebugRenderer *inRenderer, RMat44Arg inBaseTransform) const;
53#endif // JPH_DEBUG_RENDERER
54
56 virtual void SaveBinaryState(StreamOut &inStream) const;
57
60
61protected:
63 virtual void RestoreBinaryState(StreamIn &inStream);
64
65private:
67 bool mIsLooping = false;
68};
69
#define JPH_NAMESPACE_END
Definition: Core.h:240
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:234
#define JPH_DECLARE_SERIALIZABLE_ABSTRACT(class_name)
Definition: SerializableObject.h:111
Simple triangle renderer for debugging purposes.
Definition: DebugRenderer.h:25
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition: Mat44.h:13
The path for a path constraint. It allows attaching two bodies to each other while giving the second ...
Definition: PathConstraintPath.h:21
virtual float GetClosestPoint(Vec3Arg inPosition) const =0
virtual void SaveBinaryState(StreamOut &inStream) const
Saves the contents of the path in binary form to inStream.
Definition: PathConstraintPath.cpp:70
void DrawPath(DebugRenderer *inRenderer, RMat44Arg inBaseTransform) const
Draw the path relative to inBaseTransform. Used for debug purposes.
Definition: PathConstraintPath.cpp:39
bool IsLooping() const
Definition: PathConstraintPath.h:48
virtual void RestoreBinaryState(StreamIn &inStream)
This function should not be called directly, it is used by sRestoreFromBinaryState.
Definition: PathConstraintPath.cpp:76
virtual void GetPointOnPath(float inFraction, Vec3 &outPathPosition, Vec3 &outPathTangent, Vec3 &outPathNormal, Vec3 &outPathBinormal) const =0
void SetIsLooping(bool inIsLooping)
If the path is looping or not. If a path is looping, the first and last point are automatically conne...
Definition: PathConstraintPath.h:47
virtual float GetPathMaxFraction() const =0
Gets the max fraction along the path. I.e. sort of the length of the path.
static PathResult sRestoreFromBinaryState(StreamIn &inStream)
Creates a Shape of the correct type and restores its contents from the binary stream inStream.
Definition: PathConstraintPath.cpp:82
Result< Ref< PathConstraintPath > > PathResult
Definition: PathConstraintPath.h:25
Definition: Reference.h:101
Definition: Reference.h:35
Helper class that either contains a valid result or an error.
Definition: Result.h:15
Definition: SerializableObject.h:147
Simple binary input stream.
Definition: StreamIn.h:11
Simple binary output stream.
Definition: StreamOut.h:11
Definition: Vec3.h:16