Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
PathConstraintPathHermite.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
10
13{
14public:
16
17 // See PathConstraintPath::GetPathMaxFraction
18 virtual float GetPathMaxFraction() const override { return float(IsLooping()? mPoints.size() : mPoints.size() - 1); }
19
20 // See PathConstraintPath::GetClosestPoint
21 virtual float GetClosestPoint(Vec3Arg inPosition) const override;
22
23 // See PathConstraintPath::GetPointOnPath
24 virtual void GetPointOnPath(float inFraction, Vec3 &outPathPosition, Vec3 &outPathTangent, Vec3 &outPathNormal, Vec3 &outPathBinormal) const override;
25
27 void AddPoint(Vec3Arg inPosition, Vec3Arg inTangent, Vec3Arg inNormal) { mPoints.push_back({ inPosition, inTangent, inNormal}); }
28
29 // See: PathConstraintPath::SaveBinaryState
30 virtual void SaveBinaryState(StreamOut &inStream) const override;
31
32 struct Point
33 {
35
39 };
40
41protected:
42 // See: PathConstraintPath::RestoreBinaryState
43 virtual void RestoreBinaryState(StreamIn &inStream) override;
44
45private:
47 inline void GetIndexAndT(float inFraction, int &outIndex, float &outT) const;
48
49 using Points = Array<Point>;
50
51 Points mPoints;
52};
53
#define JPH_NAMESPACE_END
Definition: Core.h:240
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:234
std::vector< T, STLAllocator< T > > Array
Definition: STLAllocator.h:81
#define JPH_DECLARE_SERIALIZABLE_VIRTUAL(class_name)
Definition: SerializableObject.h:100
#define JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(class_name)
Definition: SerializableObject.h:71
A path that follows a Hermite spline.
Definition: PathConstraintPathHermite.h:13
virtual void RestoreBinaryState(StreamIn &inStream) override
This function should not be called directly, it is used by sRestoreFromBinaryState.
Definition: PathConstraintPathHermite.cpp:301
virtual void GetPointOnPath(float inFraction, Vec3 &outPathPosition, Vec3 &outPathTangent, Vec3 &outPathNormal, Vec3 &outPathBinormal) const override
Definition: PathConstraintPathHermite.cpp:265
virtual void SaveBinaryState(StreamOut &inStream) const override
Saves the contents of the path in binary form to inStream.
Definition: PathConstraintPathHermite.cpp:294
void AddPoint(Vec3Arg inPosition, Vec3Arg inTangent, Vec3Arg inNormal)
Adds a point to the path.
Definition: PathConstraintPathHermite.h:27
virtual float GetPathMaxFraction() const override
Gets the max fraction along the path. I.e. sort of the length of the path.
Definition: PathConstraintPathHermite.h:18
virtual float GetClosestPoint(Vec3Arg inPosition) const override
Definition: PathConstraintPathHermite.cpp:206
The path for a path constraint. It allows attaching two bodies to each other while giving the second ...
Definition: PathConstraintPath.h:21
bool IsLooping() const
Definition: PathConstraintPath.h:48
Simple binary input stream.
Definition: StreamIn.h:11
Simple binary output stream.
Definition: StreamOut.h:11
Definition: Vec3.h:16
Definition: PathConstraintPathHermite.h:33
Vec3 mTangent
Tangent of the path, does not need to be normalized (in the direction of the path)
Definition: PathConstraintPathHermite.h:37
Vec3 mNormal
Normal of the path (together with the tangent along the curve this forms a basis for the constraint)
Definition: PathConstraintPathHermite.h:38
Vec3 mPosition
Position on the path.
Definition: PathConstraintPathHermite.h:36