Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
TwoBodyConstraint.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
9
11
13
16{
17public:
19
20
22 virtual TwoBodyConstraint * Create(Body &inBody1, Body &inBody2) const = 0;
23};
24
27{
28public:
30
32 TwoBodyConstraint(Body &inBody1, Body &inBody2, const TwoBodyConstraintSettings &inSettings) : Constraint(inSettings), mBody1(&inBody1), mBody2(&inBody2) { }
33
35 virtual EConstraintType GetType() const override { return EConstraintType::TwoBodyConstraint; }
36
38 virtual bool IsActive() const override { return Constraint::IsActive() && (mBody1->IsActive() || mBody2->IsActive()) && (mBody2->IsDynamic() || mBody1->IsDynamic()); }
39#ifdef JPH_DEBUG_RENDERER
40 virtual void DrawConstraintReferenceFrame(DebugRenderer *inRenderer) const override;
41#endif // JPH_DEBUG_RENDERER
42
44 Body * GetBody1() const { return mBody1; }
45 Body * GetBody2() const { return mBody2; }
46
48 virtual Mat44 GetConstraintToBody1Matrix() const = 0;
49
51 virtual Mat44 GetConstraintToBody2Matrix() const = 0;
52
54 virtual void BuildIslands(uint32 inConstraintIndex, IslandBuilder &ioBuilder, BodyManager &inBodyManager) override;
55
57 virtual uint BuildIslandSplits(LargeIslandSplitter &ioSplitter) const override;
58
59protected:
63};
64
EConstraintType
Enum to identify constraint type.
Definition: Constraint.h:27
#define JPH_EXPORT
Definition: Core.h:227
unsigned int uint
Definition: Core.h:439
#define JPH_NAMESPACE_END
Definition: Core.h:367
std::uint32_t uint32
Definition: Core.h:442
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition: Memory.h:29
#define JPH_DECLARE_SERIALIZABLE_ABSTRACT(linkage, class_name)
Definition: SerializableObject.h:111
Definition: Body.h:35
Class that contains all bodies.
Definition: BodyManager.h:32
Base class for all physics constraints. A constraint removes one or more degrees of freedom for a rig...
Definition: Constraint.h:103
virtual bool IsActive() const
Definition: Constraint.h:171
Class used to store the configuration of a constraint. Allows run-time creation of constraints.
Definition: Constraint.h:65
Definition: DebugRenderer.h:47
Keeps track of connected bodies and builds islands for multithreaded velocity/position update.
Definition: IslandBuilder.h:19
Definition: LargeIslandSplitter.h:25
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition: Mat44.h:13
Base class for all constraints that involve 2 bodies. Body1 is usually considered the parent,...
Definition: TwoBodyConstraint.h:27
virtual Mat44 GetConstraintToBody2Matrix() const =0
Calculates the transform that transforms from constraint space to body 2 space. The first column of t...
virtual Mat44 GetConstraintToBody1Matrix() const =0
Calculates the transform that transforms from constraint space to body 1 space. The first column of t...
Body * mBody2
Definition: TwoBodyConstraint.h:62
virtual EConstraintType GetType() const override
Get the type of a constraint.
Definition: TwoBodyConstraint.h:35
JPH_OVERRIDE_NEW_DELETE TwoBodyConstraint(Body &inBody1, Body &inBody2, const TwoBodyConstraintSettings &inSettings)
Constructor.
Definition: TwoBodyConstraint.h:32
virtual bool IsActive() const override
Solver interface.
Definition: TwoBodyConstraint.h:38
Body * GetBody2() const
Definition: TwoBodyConstraint.h:45
Body * GetBody1() const
Access to the connected bodies.
Definition: TwoBodyConstraint.h:44
Body * mBody1
The two bodies involved.
Definition: TwoBodyConstraint.h:61
Base class for settings for all constraints that involve 2 bodies.
Definition: TwoBodyConstraint.h:16