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{
17public:
19
20
25 bool DecomposePrincipalMomentsOfInertia(Mat44 &outRotation, Vec3 &outDiagonal) const;
26
28 void SetMassAndInertiaOfSolidBox(Vec3Arg inBoxSize, float inDensity);
29
31 void ScaleToMass(float inMass);
32
34 static Vec3 sGetEquivalentSolidBoxSize(float inMass, Vec3Arg inInertiaDiagonal);
35
37 void Rotate(Mat44Arg inRotation);
38
40 void Translate(Vec3Arg inTranslation);
41
43 void Scale(Vec3Arg inScale);
44
46 void SaveBinaryState(StreamOut &inStream) const;
47
49 void RestoreBinaryState(StreamIn &inStream);
50
52 float mMass = 0.0f;
53
56};
57
#define JPH_NAMESPACE_END
Definition: Core.h:240
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:234
#define JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(class_name)
Definition: SerializableObject.h:71
Describes the mass and inertia properties of a body. Used during body construction only.
Definition: MassProperties.h:16
static Vec3 sGetEquivalentSolidBoxSize(float inMass, Vec3Arg inInertiaDiagonal)
Calculates the size of the solid box that has an inertia tensor diagonal inInertiaDiagonal.
Definition: MassProperties.cpp:94
void Rotate(Mat44Arg inRotation)
Rotate the inertia by 3x3 matrix inRotation.
Definition: MassProperties.cpp:157
void SaveBinaryState(StreamOut &inStream) const
Saves the state of this object in binary form to inStream.
Definition: MassProperties.cpp:173
bool DecomposePrincipalMomentsOfInertia(Mat44 &outRotation, Vec3 &outDiagonal) const
Definition: MassProperties.cpp:24
Mat44 mInertia
Inertia tensor of the shape (kg m^2)
Definition: MassProperties.h:55
void SetMassAndInertiaOfSolidBox(Vec3Arg inBoxSize, float inDensity)
Set the mass and inertia of a box with edge size inBoxSize and density inDensity.
Definition: MassProperties.cpp:62
void Translate(Vec3Arg inTranslation)
Translate the inertia by a vector inTranslation.
Definition: MassProperties.cpp:162
void RestoreBinaryState(StreamIn &inStream)
Restore the state of this object from inStream.
Definition: MassProperties.cpp:179
void Scale(Vec3Arg inScale)
Scale the mass and inertia by inScale, note that elements can be < 0 to flip the shape.
Definition: MassProperties.cpp:103
float mMass
Mass of the shape (kg)
Definition: MassProperties.h:52
void ScaleToMass(float inMass)
Set the mass and scale the inertia tensor to match the mass.
Definition: MassProperties.cpp:73
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:11
Simple binary output stream.
Definition: StreamOut.h:11
Definition: Vec3.h:16