| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#pragma once |
| 6 |
|
| 7 |
#include <Jolt/Physics/Constraints/PathConstraintPath.h> |
| 8 |
|
| 9 |
JPH_NAMESPACE_BEGIN |
| 10 |
|
| 11 |
|
| 12 |
class JPH_EXPORT PathConstraintPathHermite final : public PathConstraintPath |
| 13 |
{ |
| 14 |
JPH_DECLARE_SERIALIZABLE_VIRTUAL(JPH_EXPORT, PathConstraintPathHermite) |
| 15 |
|
| 16 |
public: |
| 17 |
|
| 18 |
virtual float GetPathMaxFraction() const override { return float(IsLooping()? mPoints.size() : mPoints.size() - 1); } |
| 19 |
|
| 20 |
|
| 21 |
virtual float GetClosestPoint(Vec3Arg inPosition, float inFractionHint) const override; |
| 22 |
|
| 23 |
|
| 24 |
virtual void GetPointOnPath(float inFraction, Vec3 &outPathPosition, Vec3 &outPathTangent, Vec3 &outPathNormal, Vec3 &outPathBinormal) const override; |
| 25 |
|
| 26 |
|
| 27 |
void AddPoint(Vec3Arg inPosition, Vec3Arg inTangent, Vec3Arg inNormal) { mPoints.push_back({ inPosition, inTangent, inNormal}); } |
| 28 |
|
| 29 |
|
| 30 |
virtual void SaveBinaryState(StreamOut &inStream) const override; |
| 31 |
|
| 32 |
struct Point |
| 33 |
{ |
| 34 |
JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(JPH_EXPORT, Point) |
| 35 |
|
| 36 |
Vec3 mPosition; |
| 37 |
Vec3 mTangent; |
| 38 |
Vec3 mNormal; |
| 39 |
}; |
| 40 |
|
| 41 |
protected: |
| 42 |
|
| 43 |
virtual void RestoreBinaryState(StreamIn &inStream) override; |
| 44 |
|
| 45 |
private: |
| 46 |
|
| 47 |
inline void GetIndexAndT(float inFraction, int &outIndex, float &outT) const; |
| 48 |
|
| 49 |
using Points = Array<Point>; |
| 50 |
|
| 51 |
Points mPoints; |
| 52 |
}; |
| 53 |
|
| 54 |
JPH_NAMESPACE_END |