PeriDyno 1.0.0
Loading...
Searching...
No Matches
CollisionData.h
Go to the documentation of this file.
1#pragma once
2
3#include "Vector.h"
4#include "Matrix.h"
5#include "Quat.h"
6
7namespace dyno
8{
9#define INVLIDA_ID -1
10
12 {
13 CM_Disabled = 0x00000000,
14 CM_OriginDCD_Tet = 0x00000001, // Origin DCD for local contact point
15 CM_InputSDF_Tet = 0x00000002, // Intergated SDF
16 CM_RigidSurface_Tet = 0x00000004, // Rigid Surface
17 CM_TetMesh_Tet = 0x00000008, // TetMesh for semi-local contact point
18 CM_SurfaceMesh_Tet = 0x00000010, // Surface triangle mesh for semi-local contact point
19 CM_OriginDCD_Sphere = 0x00000020,
20 CM_InputSDF_Sphere = 0x00000040
21 };
22
31
32
34 {
35 CT_AllObjects = 0xFFFFFFFF,
36 CT_BoxExcluded = 0xFFFFFFFE,
37 CT_TetExcluded = 0xFFFFFFFD,
38 CT_CapsuleExcluded = 0xFFFFFFFA,
39 CT_SphereExcluded = 0xFFFFFFF7,
40 CT_BoxOnly = 0x00000001,
41 CT_TetOnly = 0x00000002,
42 CT_CapsuleOnly = 0x00000004,
43 CT_SphereOnly = 0x00000008,
44 CT_Disabled = 0x00000000
45 };
46
58
89
90 struct BoxInfo
91 {
93 {
94 center = Vector<Real, 3>(0.0f, 0.0f, 0.0f);
95 halfLength = Vector<Real, 3>(1.0f, 1.0f, 1.0f);
96 rot = Quat<Real>(0.0f, 0.0f, 0.0f, 1.0f);
97 }
98
101
103 };
104
106 {
108 {
109 center = Vector<Real, 3>(0.0f, 0.0f, 0.0f);
110 radius = 1.0;
111 rot = Quat<Real>(0.0f, 0.0f, 0.0f, 1.0f);
112 }
116 };
117
118 struct TetInfo
119 {
121 {
122 v[0] = Vec3f(0);
123 v[1] = Vec3f(1, 0, 0);
124 v[2] = Vec3f(0, 1, 0);
125 v[3] = Vec3f(0, 0, 1);
126 }
127
129 };
130
132 {
134 {
135 center = Vec3f(0.0f, 0.0f, 0.0f);
136 rot = Quat1f(0.0f, 0.0f, 0.0f, 1.0f);
137 radius = 1.0f;
138 halfLength = 1.0f;
139 }
144 };
145
146 template<typename Real>
148 {
149 public:
150 Vector<Real, 3> position; // World coordinate of contact
151 Real penetration; // Depth of penetration from collision whose value is assumed to be negative when interpenetration occurs
152 };
153
154 template<typename Real>
156 {
157 public:
161
162 DYN_FUNC void pushContact(const Vector<Real, 3>& pos, const Real& dep)
163 {
164 if (contactCount >= 8) return;
165 contacts[contactCount].position = pos;
166 contacts[contactCount].penetration = dep;
167 contactCount++;
168 }
169
170 DYN_FUNC void pushContact(const TContact<Real>& contact)
171 {
172 if (contactCount >= 8) return;
173 contacts[contactCount] = contact;
174 contactCount++;
175 }
176 };
177
178 template<typename Real>
180 {
181 public:
182 DYN_FUNC TContactPair()
183 {
186 };
187
188 DYN_FUNC TContactPair(
189 int a,
190 int b,
191 ContactType type,
192 Vector<Real, 3> p1,
193 Vector<Real, 3> p2,
194 Vector<Real, 3> n1,
196 {
197 bodyId1 = a;
198 bodyId2 = b;
199 contactType = type;
200 pos1 = p1;
201 pos2 = p2;
202 normal1 = n1;
203 normal2 = n2;
204 }
205
208
211//
212// int localTag1;
213// int localTag2;
214
215 Real interpenetration = 0.0f;//inter_dist
216
219
222
224 };
225
226 template<typename Real>
228 {
229 public:
231 {
234 };
235
237 int a,
238 int b,
244 {
245 bodyId1 = a;
246 bodyId2 = b;
247 type = type;
248 pos1 = p1;
249 pos2 = p2;
250 normal1 = n1;
251 normal2 = n2;
252 }
253
256
259
262
269
272
275
277
279
281
283
284 };
285}
#define INVLIDA_ID
Implementation of quaternion.
double Real
Definition Typedef.inl:23
Vector< Real, 3 > axis
Vector< Real, 3 > pos1
Vector< Real, 3 > pos2
DYN_FUNC TConstraintPair(int a, int b, ConstraintType type, Vector< Real, 3 > p1, Vector< Real, 3 > p2, Vector< Real, 3 > n1, Vector< Real, 3 > n2)
Vector< Real, 3 > normal2
Vector< Real, 3 > normal1
Vector< Real, 3 > position
DYN_FUNC TContactPair(int a, int b, ContactType type, Vector< Real, 3 > p1, Vector< Real, 3 > p2, Vector< Real, 3 > n1, Vector< Real, 3 > n2)
Vector< Real, 3 > normal2
Vector< Real, 3 > pos2
ContactType contactType
Vector< Real, 3 > pos1
DYN_FUNC TContactPair()
Vector< Real, 3 > normal1
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
@ CN_NONPENETRATION
@ CN_LOACL_NONPENETRATION
@ CN_BAN_ROT_2
@ CN_ANCHOR_TRANS_2
@ CN_ALLOW_ROT1D_2
@ CN_ANCHOR_TRANS_1
@ CN_FLUID_NONPENETRATION
@ CN_JOINT_HINGE_MOTER
@ CN_ANCHOR_EQUAL_2
@ CN_JOINT_SLIDER_MAX
@ CN_JOINT_NO_MOVE_3
@ CN_FLUID_STICKINESS
@ CN_ANCHOR_EQUAL_3
@ CN_BAN_ROT_1
@ CN_ALLOW_ROT1D_1
@ CN_BAN_ROT_3
@ CN_JOINT_NO_MOVE_1
@ CN_FLUID_SLIPINESS
@ CN_JOINT_HINGE_MIN
@ CN_ANCHOR_EQUAL_1
@ CN_UNKNOWN
@ CN_JOINT_HINGE_MAX
@ CN_FRICTION
@ CN_JOINT_NO_MOVE_2
@ CN_GLOBAL_NONPENETRATION
@ CN_JOINT_SLIDER_MIN
@ CN_JOINT_SLIDER_MOTER
@ CT_SphereExcluded
@ CT_SphereOnly
@ CT_BoxExcluded
@ CT_CapsuleOnly
@ CT_TetExcluded
@ CT_CapsuleExcluded
@ CT_BoxOnly
@ CT_AllObjects
@ CT_Disabled
@ CT_TetOnly
@ CM_InputSDF_Sphere
@ CM_InputSDF_Tet
@ CM_Disabled
@ CM_SurfaceMesh_Tet
@ CM_OriginDCD_Sphere
@ CM_TetMesh_Tet
@ CM_OriginDCD_Tet
@ CM_RigidSurface_Tet
@ CT_EDGE_EDGE
@ CT_BOUDNARY
@ CT_UNKNOWN
@ CT_INTERNAL
@ CT_SURFACE
@ CT_VERTEX_FACE
@ CT_NONPENETRATION
@ CT_VERTEX_SDF
Quat< float > Quat1f
Definition Quat.h:136
@ Kinematic
@ NonGravitative
@ NonRotatable
Vector< float, 3 > Vec3f
Definition Vector3D.h:93
Quat< Real > rot
Vector< Real, 3 > halfLength
Vector< Real, 3 > center
Vector< Real, 3 > center
Quat< Real > rot
Vector< Real, 3 > center
DYN_FUNC void pushContact(const TContact< Real > &contact)
DYN_FUNC void pushContact(const Vector< Real, 3 > &pos, const Real &dep)
Vector< Real, 3 > normal
TContact< Real > contacts[8]
Vector< Real, 3 > v[4]