Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
MassProperties.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
11class StreamIn;
12class StreamOut;
13
16{
18
19public:
21 bool operator == (const MassProperties &inRHS) const
22 {
23 return mMass == inRHS.mMass && mInertia == inRHS.mInertia;
24 }
25
26 bool operator != (const MassProperties &inRHS) const
27 {
28 return !(*this == inRHS);
29 }
30
36 bool DecomposePrincipalMomentsOfInertia(Mat44 &outRotation, Vec3 &outDiagonal) const;
37
39 void SetMassAndInertiaOfSolidBox(Vec3Arg inBoxSize, float inDensity);
40
42 void ScaleToMass(float inMass);
43
45 static Vec3 sGetEquivalentSolidBoxSize(float inMass, Vec3Arg inInertiaDiagonal);
46
48 void Rotate(Mat44Arg inRotation);
49
51 void Translate(Vec3Arg inTranslation);
52
54 void Scale(Vec3Arg inScale);
55
57 void SaveBinaryState(StreamOut &inStream) const;
58
60 void RestoreBinaryState(StreamIn &inStream);
61
63 float mMass = 0.0f;
64
66 Mat44 mInertia = Mat44::sZero();
67};
68
#define JPH_EXPORT
Definition Core.h:283
#define JPH_NAMESPACE_END
Definition Core.h:433
#define JPH_NAMESPACE_BEGIN
Definition Core.h:427
#define JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(linkage, class_name)
Definition SerializableObject.h:80
Describes the mass and inertia properties of a body. Used during body construction only.
Definition MassProperties.h:16
Mat44 mInertia
Inertia tensor of the shape (kg m^2)
Definition MassProperties.h:66
float mMass
Mass of the shape (kg)
Definition MassProperties.h:63
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition Mat44.h:13
static JPH_INLINE Mat44 sZero()
Zero matrix.
Definition Mat44.inl:30
Simple binary input stream.
Definition StreamIn.h:13
Simple binary output stream.
Definition StreamOut.h:13
Definition Vec3.h:17