Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
CollideSoftBodyVertexIterator.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
9
11
15{
16public:
20
22 CollideSoftBodyVertexIterator(const StridedPtr<const Vec3> &inPosition, const StridedPtr<const float> &inInvMass, const StridedPtr<Plane> &inCollisionPlane, const StridedPtr<float> &inLargestPenetration, const StridedPtr<int> &inCollidingShapeIndex) :
23 mPosition(inPosition),
24 mInvMass(inInvMass),
25 mCollisionPlane(inCollisionPlane),
26 mLargestPenetration(inLargestPenetration),
27 mCollidingShapeIndex(inCollidingShapeIndex)
28 {
29 }
30
33 mPosition(&inVertices->mPosition, sizeof(SoftBodyVertex)),
34 mInvMass(&inVertices->mInvMass, sizeof(SoftBodyVertex)),
35 mCollisionPlane(&inVertices->mCollisionPlane, sizeof(SoftBodyVertex)),
36 mLargestPenetration(&inVertices->mLargestPenetration, sizeof(SoftBodyVertex)),
37 mCollidingShapeIndex(&inVertices->mCollidingShapeIndex, sizeof(SoftBodyVertex))
38 {
39 }
40
43
47 {
48 return mPosition != inRHS.mPosition;
49 }
50
53 {
54 ++mPosition;
55 ++mInvMass;
56 ++mCollisionPlane;
57 ++mLargestPenetration;
58 ++mCollidingShapeIndex;
59 return *this;
60 }
61
68
71 {
72 return *mPosition;
73 }
74
76 float GetInvMass() const
77 {
78 return *mInvMass;
79 }
80
83 bool UpdatePenetration(float inLargestPenetration) const
84 {
85 float &penetration = *mLargestPenetration;
86 if (penetration >= inLargestPenetration)
87 return false;
88 penetration = inLargestPenetration;
89 return true;
90 }
91
93 void SetCollision(const Plane &inCollisionPlane, int inCollidingShapeIndex) const
94 {
95 *mCollisionPlane = inCollisionPlane;
96 *mCollidingShapeIndex = inCollidingShapeIndex;
97 }
98
99private:
101 StridedPtr<const Vec3> mPosition;
103
105 StridedPtr<Plane> mCollisionPlane;
106 StridedPtr<float> mLargestPenetration;
107 StridedPtr<int> mCollidingShapeIndex;
108};
109
#define JPH_NAMESPACE_END
Definition Core.h:414
#define JPH_NAMESPACE_BEGIN
Definition Core.h:408
Definition CollideSoftBodyVertexIterator.h:15
CollideSoftBodyVertexIterator(const CollideSoftBodyVertexIterator &)=default
CollideSoftBodyVertexIterator & operator=(const CollideSoftBodyVertexIterator &)=default
Default assignment.
CollideSoftBodyVertexIterator(SoftBodyVertex *inVertices)
Construct using a soft body vertex.
Definition CollideSoftBodyVertexIterator.h:32
float GetInvMass() const
Get the inverse mass of the current vertex.
Definition CollideSoftBodyVertexIterator.h:76
CollideSoftBodyVertexIterator operator+(int inOffset) const
Definition CollideSoftBodyVertexIterator.h:64
void SetCollision(const Plane &inCollisionPlane, int inCollidingShapeIndex) const
Update the collision of the current vertex.
Definition CollideSoftBodyVertexIterator.h:93
Vec3 GetPosition() const
Get the position of the current vertex.
Definition CollideSoftBodyVertexIterator.h:70
bool operator!=(const CollideSoftBodyVertexIterator &inRHS) const
Definition CollideSoftBodyVertexIterator.h:46
CollideSoftBodyVertexIterator()=default
Default constructor.
CollideSoftBodyVertexIterator(const StridedPtr< const Vec3 > &inPosition, const StridedPtr< const float > &inInvMass, const StridedPtr< Plane > &inCollisionPlane, const StridedPtr< float > &inLargestPenetration, const StridedPtr< int > &inCollidingShapeIndex)
Construct using (strided) pointers.
Definition CollideSoftBodyVertexIterator.h:22
CollideSoftBodyVertexIterator & operator++()
Next vertex.
Definition CollideSoftBodyVertexIterator.h:52
bool UpdatePenetration(float inLargestPenetration) const
Definition CollideSoftBodyVertexIterator.h:83
An infinite plane described by the formula X . Normal + Constant = 0.
Definition Plane.h:11
Definition SoftBodyVertex.h:16
Definition StridedPtr.h:14
Definition Vec3.h:17