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, float inFractionHint) 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
36 Vec3 mPosition;
37 Vec3 mTangent;
38 Vec3 mNormal;
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_EXPORT
Definition: Core.h:227
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
std::vector< T, STLAllocator< T > > Array
Definition: STLAllocator.h:81
#define JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(linkage, class_name)
Definition: SerializableObject.h:71
#define JPH_DECLARE_SERIALIZABLE_VIRTUAL(linkage, class_name)
Definition: SerializableObject.h:100
A path that follows a Hermite spline.
Definition: PathConstraintPathHermite.h:13
void AddPoint(Vec3Arg inPosition, Vec3Arg inTangent, Vec3Arg inNormal)
Adds a point to the path.
Definition: PathConstraintPathHermite.h:27
The path for a path constraint. It allows attaching two bodies to each other while giving the second ...
Definition: PathConstraintPath.h:21
virtual void SaveBinaryState(StreamOut &inStream) const
Saves the contents of the path in binary form to inStream.
Definition: PathConstraintPath.cpp:68
bool IsLooping() const
Definition: PathConstraintPath.h:49
virtual void GetPointOnPath(float inFraction, Vec3 &outPathPosition, Vec3 &outPathTangent, Vec3 &outPathNormal, Vec3 &outPathBinormal) const =0
virtual float GetClosestPoint(Vec3Arg inPosition, float inFractionHint) const =0
Simple binary input stream.
Definition: StreamIn.h:13
Simple binary output stream.
Definition: StreamOut.h:13
Definition: Vec3.h:16
Definition: PathConstraintPathHermite.h:33