Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
PhysicsScene.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
11
13
14class PhysicsSystem;
15
17class JPH_EXPORT PhysicsScene : public RefTarget<PhysicsScene>
18{
20
21public:
23 void AddBody(const BodyCreationSettings &inBody);
24
26 static constexpr uint32 cFixedToWorld = 0xffffffff;
27
32 void AddConstraint(const TwoBodyConstraintSettings *inConstraint, uint32 inBody1, uint32 inBody2);
33
35 void AddSoftBody(const SoftBodyCreationSettings &inSoftBody);
36
38 size_t GetNumBodies() const { return mBodies.size(); }
39
41 const Array<BodyCreationSettings> & GetBodies() const { return mBodies; }
42 Array<BodyCreationSettings> & GetBodies() { return mBodies; }
43
46 {
48
49 public:
51 ConnectedConstraint(const TwoBodyConstraintSettings *inSettings, uint inBody1, uint inBody2) : mSettings(inSettings), mBody1(inBody1), mBody2(inBody2) { }
52
56 };
57
59 size_t GetNumConstraints() const { return mConstraints.size(); }
60
62 const Array<ConnectedConstraint> & GetConstraints() const { return mConstraints; }
63 Array<ConnectedConstraint> & GetConstraints() { return mConstraints; }
64
66 size_t GetNumSoftBodies() const { return mSoftBodies.size(); }
67
69 const Array<SoftBodyCreationSettings> & GetSoftBodies() const { return mSoftBodies; }
71
73 bool CreateBodies(PhysicsSystem *inSystem) const;
74
77 bool FixInvalidScales();
78
83 void SaveBinaryState(StreamOut &inStream, bool inSaveShapes, bool inSaveGroupFilter) const;
84
86
88 static PhysicsSceneResult sRestoreFromBinaryState(StreamIn &inStream);
89
91 void FromPhysicsSystem(const PhysicsSystem *inSystem);
92
93private:
96
98 Array<ConnectedConstraint> mConstraints;
99
102};
103
#define JPH_EXPORT
Definition Core.h:236
unsigned int uint
Definition Core.h:453
#define JPH_NAMESPACE_END
Definition Core.h:379
std::uint32_t uint32
Definition Core.h:456
#define JPH_NAMESPACE_BEGIN
Definition Core.h:373
#define JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(linkage, class_name)
Definition SerializableObject.h:80
Definition Array.h:36
Settings for constructing a rigid body.
Definition BodyCreationSettings.h:31
A constraint and how it is connected to the bodies in the scene.
Definition PhysicsScene.h:46
uint32 mBody1
Index of first body (in mBodies)
Definition PhysicsScene.h:54
RefConst< TwoBodyConstraintSettings > mSettings
Constraint settings.
Definition PhysicsScene.h:53
ConnectedConstraint(const TwoBodyConstraintSettings *inSettings, uint inBody1, uint inBody2)
Definition PhysicsScene.h:51
uint32 mBody2
Index of second body (in mBodies)
Definition PhysicsScene.h:55
Contains the creation settings of a set of bodies.
Definition PhysicsScene.h:18
Array< BodyCreationSettings > & GetBodies()
Definition PhysicsScene.h:42
size_t GetNumSoftBodies() const
Get number of bodies in this scene.
Definition PhysicsScene.h:66
size_t GetNumConstraints() const
Get number of constraints in this scene.
Definition PhysicsScene.h:59
const Array< ConnectedConstraint > & GetConstraints() const
Access to the constraints for this scene.
Definition PhysicsScene.h:62
Array< SoftBodyCreationSettings > & GetSoftBodies()
Definition PhysicsScene.h:70
size_t GetNumBodies() const
Get number of bodies in this scene.
Definition PhysicsScene.h:38
Array< ConnectedConstraint > & GetConstraints()
Definition PhysicsScene.h:63
const Array< BodyCreationSettings > & GetBodies() const
Access to the body settings for this scene.
Definition PhysicsScene.h:41
const Array< SoftBodyCreationSettings > & GetSoftBodies() const
Access to the soft body settings for this scene.
Definition PhysicsScene.h:69
Definition PhysicsSystem.h:29
Definition Reference.h:163
Definition Reference.h:35
Helper class that either contains a valid result or an error.
Definition Result.h:12
Definition SoftBodyCreationSettings.h:18
Simple binary input stream.
Definition StreamIn.h:13
Simple binary output stream.
Definition StreamOut.h:13
Base class for settings for all constraints that involve 2 bodies.
Definition TwoBodyConstraint.h:16