Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
SoftBodyManifold.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2024 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
8
10
13{
14public:
16 const Array<SoftBodyVertex> & GetVertices() const { return mVertices; }
17
19 JPH_INLINE bool HasContact(const SoftBodyVertex &inVertex) const
20 {
21 return inVertex.mHasContact;
22 }
23
25 JPH_INLINE Vec3 GetLocalContactPoint(const SoftBodyVertex &inVertex) const
26 {
27 return inVertex.mPosition - inVertex.mCollisionPlane.SignedDistance(inVertex.mPosition) * inVertex.mCollisionPlane.GetNormal();
28 }
29
31 JPH_INLINE Vec3 GetContactNormal(const SoftBodyVertex &inVertex) const
32 {
33 return -inVertex.mCollisionPlane.GetNormal();
34 }
35
37 JPH_INLINE BodyID GetContactBodyID(const SoftBodyVertex &inVertex) const
38 {
39 return inVertex.mHasContact? mCollidingShapes[inVertex.mCollidingShapeIndex].mBodyID : BodyID();
40 }
41
42private:
45
47 explicit SoftBodyManifold(const SoftBodyMotionProperties *inMotionProperties) :
48 mVertices(inMotionProperties->mVertices),
49 mCollidingShapes(inMotionProperties->mCollidingShapes)
50 {
51 }
52
53 using CollidingShape = SoftBodyMotionProperties::CollidingShape;
54
55 const Array<SoftBodyVertex> & mVertices;
56 const Array<CollidingShape> & mCollidingShapes;
57};
58
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
std::vector< T, STLAllocator< T > > Array
Definition: STLAllocator.h:81
ID of a body. This is a way of reasoning about bodies in a multithreaded simulation while avoiding ra...
Definition: BodyID.h:13
Vec3 GetNormal() const
Definition: Plane.h:30
float SignedDistance(Vec3Arg inPoint) const
Distance point to plane.
Definition: Plane.h:46
An interface to query which vertices of a soft body are colliding with other bodies.
Definition: SoftBodyManifold.h:13
JPH_INLINE bool HasContact(const SoftBodyVertex &inVertex) const
Check if a vertex has collided with something in this update.
Definition: SoftBodyManifold.h:19
JPH_INLINE Vec3 GetLocalContactPoint(const SoftBodyVertex &inVertex) const
Get the local space contact point (multiply by GetCenterOfMassTransform() of the soft body to get wor...
Definition: SoftBodyManifold.h:25
JPH_INLINE BodyID GetContactBodyID(const SoftBodyVertex &inVertex) const
Get the body with which the vertex has collided in this update.
Definition: SoftBodyManifold.h:37
const Array< SoftBodyVertex > & GetVertices() const
Get the vertices of the soft body for iterating.
Definition: SoftBodyManifold.h:16
JPH_INLINE Vec3 GetContactNormal(const SoftBodyVertex &inVertex) const
Get the contact normal for the vertex (assumes there is a contact).
Definition: SoftBodyManifold.h:31
This class contains the runtime information of a soft body.
Definition: SoftBodyMotionProperties.h:33
Definition: SoftBodyVertex.h:16
bool mHasContact
True if the vertex has collided with anything in the last update.
Definition: SoftBodyVertex.h:23
int mCollidingShapeIndex
Index in the colliding shapes list of the body we may collide with.
Definition: SoftBodyVertex.h:22
Plane mCollisionPlane
Nearest collision plane, relative to the center of mass of the soft body.
Definition: SoftBodyVertex.h:21
Vec3 mPosition
Position, relative to the center of mass of the soft body.
Definition: SoftBodyVertex.h:19
Definition: Vec3.h:16