Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
Skeleton.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
17class JPH_EXPORT Skeleton : public RefTarget<Skeleton>
18{
19public:
21
23
25 class Joint
26 {
27 public:
29
30 Joint() = default;
31 Joint(const string_view &inName, const string_view &inParentName, int inParentJointIndex) : mName(inName), mParentName(inParentName), mParentJointIndex(inParentJointIndex) { }
32
35 int mParentJointIndex = -1;
36 };
37
39
42 const JointVector & GetJoints() const { return mJoints; }
43 JointVector & GetJoints() { return mJoints; }
44 int GetJointCount() const { return (int)mJoints.size(); }
45 const Joint & GetJoint(int inJoint) const { return mJoints[inJoint]; }
46 Joint & GetJoint(int inJoint) { return mJoints[inJoint]; }
47 uint AddJoint(const string_view &inName, const string_view &inParentName = string_view()) { mJoints.emplace_back(inName, inParentName, -1); return (uint)mJoints.size() - 1; }
48 uint AddJoint(const string_view &inName, int inParentIndex) { mJoints.emplace_back(inName, inParentIndex >= 0? mJoints[inParentIndex].mName : String(), inParentIndex); return (uint)mJoints.size() - 1; }
50
52 int GetJointIndex(const string_view &inName) const;
53
55 void CalculateParentJointIndices();
56
59 bool AreJointsCorrectlyOrdered() const;
60
62 void SaveBinaryState(StreamOut &inStream) const;
63
65 static SkeletonResult sRestoreFromBinaryState(StreamIn &inStream);
66
67private:
69 JointVector mJoints;
70};
71
#define JPH_EXPORT
Definition: Core.h:236
unsigned int uint
Definition: Core.h:452
#define JPH_NAMESPACE_END
Definition: Core.h:378
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:372
std::basic_string< char, std::char_traits< char >, STLAllocator< char > > String
Definition: STLAllocator.h:107
#define JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(linkage, class_name)
Definition: SerializableObject.h:80
Definition: Reference.h:101
Definition: Reference.h:35
Helper class that either contains a valid result or an error.
Definition: Result.h:12
Declare internal structure for a joint.
Definition: Skeleton.h:26
String mName
Name of the joint.
Definition: Skeleton.h:33
String mParentName
Name of parent joint.
Definition: Skeleton.h:34
Resource that contains the joint hierarchy for a skeleton.
Definition: Skeleton.h:18
int GetJointCount() const
Definition: Skeleton.h:44
const JointVector & GetJoints() const
Definition: Skeleton.h:42
Joint & GetJoint(int inJoint)
Definition: Skeleton.h:46
JointVector & GetJoints()
Definition: Skeleton.h:43
uint AddJoint(const string_view &inName, const string_view &inParentName=string_view())
Definition: Skeleton.h:47
uint AddJoint(const string_view &inName, int inParentIndex)
Definition: Skeleton.h:48
const Joint & GetJoint(int inJoint) const
Definition: Skeleton.h:45
Simple binary input stream.
Definition: StreamIn.h:13
Simple binary output stream.
Definition: StreamOut.h:13