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
43 JPH_INLINE uint GetNumSensorContacts() const
44 {
45 return (uint)mCollidingSensors.size();
46 }
47
49 JPH_INLINE BodyID GetSensorContactBodyID(uint inIndex) const
50 {
51 return mCollidingSensors[inIndex].mBodyID;
52 }
53
54private:
57
59 explicit SoftBodyManifold(const SoftBodyMotionProperties *inMotionProperties) :
60 mVertices(inMotionProperties->mVertices),
61 mCollidingShapes(inMotionProperties->mCollidingShapes),
62 mCollidingSensors(inMotionProperties->mCollidingSensors)
63 {
64 }
65
66 using CollidingShape = SoftBodyMotionProperties::CollidingShape;
67 using CollidingSensor = SoftBodyMotionProperties::CollidingSensor;
68
69 const Array<SoftBodyVertex> & mVertices;
70 const Array<CollidingShape> & mCollidingShapes;
71 const Array<CollidingSensor> & mCollidingSensors;
72};
73
unsigned int uint
Definition Core.h:453
#define JPH_NAMESPACE_END
Definition Core.h:379
#define JPH_NAMESPACE_BEGIN
Definition Core.h:373
Definition Array.h:36
size_type size() const
Returns amount of elements in the array.
Definition Array.h:320
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:54
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 BodyID GetSensorContactBodyID(uint inIndex) const
Get the i-th sensor that is in contact with the soft body.
Definition SoftBodyManifold.h:49
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
JPH_INLINE uint GetNumSensorContacts() const
Get the number of sensors that are in contact with the soft body.
Definition SoftBodyManifold.h:43
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:34
Definition SoftBodyVertex.h:16
bool mHasContact
True if the vertex has collided with anything in the last update.
Definition SoftBodyVertex.h:31
int mCollidingShapeIndex
Internal use only. Index in the colliding shapes list of the body we may collide with.
Definition SoftBodyVertex.h:30
Plane mCollisionPlane
Internal use only. Nearest collision plane, relative to the center of mass of the soft body.
Definition SoftBodyVertex.h:29
Vec3 mPosition
Position, relative to the center of mass of the soft body.
Definition SoftBodyVertex.h:27
Definition Vec3.h:17