physics
include
contact.hpp
Go to the documentation of this file.
1
4
#pragma once
5
6
#include "
body.hpp
"
7
#include "
spherical_joint.hpp
"
8
#include "
hinge_joint.hpp
"
9
#include "
mouse_joint.hpp
"
10
#include "
collision.hpp
"
11
12
enum
ContactType
{
FACE
=0,
EDGE
=1};
13
17
class
Contact
{
18
public
:
19
vec3
normal
= vec3(0,0,0);
20
vec3
tangent
= vec3(0,0,0);
21
vec3
bitangent
= vec3(0,0,0);
22
vec3
collision_point
;
23
float
penetration
= 0;
24
float
bias
= 0;
25
float
effective_mass_bitangent
= 0.0f;
26
float
effective_mass_tangent
= 0.0f;
27
float
effective_mass_normal
= 0.0f;
28
float
Pn
= 0;
29
float
Pt
= 0;
30
float
Pbt
= 0;
31
RigidBody
*
body_a
;
32
RigidBody
*
body_b
;
33
34
CollisionBody
*
col_body_a
;
35
CollisionBody
*
col_body_b
;
36
37
ContactType
type
;
38
vector<int>
id
;
39
int
warmStartNo
= 0;
43
Contact
(
CollisionBody
&hullA,
CollisionBody
&hullB);
47
int
applyImpulse
();
51
int
preStep
(
float
dt);
52
53
static
vector<Contact>
allContacts
;
54
static
unsigned
int
iterations
;
55
56
};
57
61
vector<Contact>
getContacts
(
CollisionBody
&body);
65
vector<Face>
getMostParallelFace
(
const
CollisionBody
&hull, vec3
normal
);
69
vector<Face>
getMostAntiparallelFace
(
const
CollisionBody
&hull, vec3
normal
);
73
vector<Face>
getOrthogonalFaces
(
const
CollisionBody
&hull, vec3
normal
);
77
vector<Contact>
sphereSphereContacts
(
CollisionBody
&
body_a
,
CollisionBody
&
body_b
);
81
vector<Contact>
sphereTriContacts
(
CollisionBody
&
body_a
,
CollisionBody
&
body_b
);
85
vector<Contact>
sphereBoxContacts
(
CollisionBody
&
body_a
,
CollisionBody
&
body_b
);
89
vector<Contact>
hullHullContacts
(
CollisionBody
&
body_a
,
CollisionBody
&
body_b
);
93
vector<Contact>
boxCylinderContacts
(
CollisionBody
&
body_a
,
CollisionBody
&
body_b
);
97
vector<Contact>
sphereCylinderContacts
(
CollisionBody
&
body_a
,
CollisionBody
&
body_b
);
101
vector<Contact>
cylinderCylinderContacts
(
CollisionBody
&
body_a
,
CollisionBody
&
body_b
);
105
vector<Contact>
createContacts
(
CollisionBody
&
body_a
,
CollisionBody
&
body_b
);
109
vector<Contact>
createMinimalContacts
(vector<Contact> &contacts);
113
vec3
closestPointOnTri
(vec3 sphereCentre, vec3 p0, vec3 p1, vec3 p2);
117
vector<vec3>
collisionPoints
(
CollisionBody
&
body_a
,
CollisionBody
&
body_b
);
121
int
simulate
(
float
deltaTime);
122
123
vector<Contact>
GJKEPAContacts
(
CollisionBody
&
body_a
,
CollisionBody
&
body_b
);
124
125
126
vector<Contact>
sphereTriContacts
(
CollisionBody
&
body_a
,
CollisionBody
&
body_b
);
boxCylinderContacts
vector< Contact > boxCylinderContacts(CollisionBody &body_a, CollisionBody &body_b)
A data structure to contain the data received from a collision between a box and a box...
spherical_joint.hpp
Contact::warmStartNo
int warmStartNo
Definition:
contact.hpp:39
Contact
A data structure to pass data received from a collision to the solver.
Definition:
contact.hpp:17
collision.hpp
Contact::tangent
vec3 tangent
Definition:
contact.hpp:20
Contact::col_body_b
CollisionBody * col_body_b
Definition:
contact.hpp:35
Contact::Pn
float Pn
Definition:
contact.hpp:28
Contact::normal
vec3 normal
Definition:
contact.hpp:19
Contact::body_a
RigidBody * body_a
Definition:
contact.hpp:31
Contact::preStep
int preStep(float dt)
Apply impulse from previous frame for better coherence.
ContactType
ContactType
Definition:
contact.hpp:12
Contact::col_body_a
CollisionBody * col_body_a
Definition:
contact.hpp:34
sphereTriContacts
vector< Contact > sphereTriContacts(CollisionBody &body_a, CollisionBody &body_b)
A data structure to contain the data received from a collision between a sphere and a tri...
sphereSphereContacts
vector< Contact > sphereSphereContacts(CollisionBody &body_a, CollisionBody &body_b)
A data structure to contain the data received from a collision between a sphere and a sphere...
Contact::allContacts
static vector< Contact > allContacts
Definition:
contact.hpp:53
Contact::bias
float bias
Definition:
contact.hpp:24
Contact::applyImpulse
int applyImpulse()
Impulse-solver function, applies both normal impulse and friction impulses.
cylinderCylinderContacts
vector< Contact > cylinderCylinderContacts(CollisionBody &body_a, CollisionBody &body_b)
A data structure to contain the data received from a collision between a Cylinder and a Cylinder...
getMostAntiparallelFace
vector< Face > getMostAntiparallelFace(const CollisionBody &hull, vec3 normal)
Find the Face on the CollisionBody that is most anti-parallel to the vector, normal.
sphereBoxContacts
vector< Contact > sphereBoxContacts(CollisionBody &body_a, CollisionBody &body_b)
A data structure to contain the data received from a collision between a sphere and a box...
RigidBody
RigidBody structure for organising data to model physics simulations of convex hull collisions...
Definition:
body.hpp:224
closestPointOnTri
vec3 closestPointOnTri(vec3 sphereCentre, vec3 p0, vec3 p1, vec3 p2)
Return the point on a tri that is closest to a point.
hullHullContacts
vector< Contact > hullHullContacts(CollisionBody &body_a, CollisionBody &body_b)
A data structure to contain the data received from a collision between a box and a box...
collisionPoints
vector< vec3 > collisionPoints(CollisionBody &body_a, CollisionBody &body_b)
Return collision points on each CollisionBody.
createMinimalContacts
vector< Contact > createMinimalContacts(vector< Contact > &contacts)
Reduce a vector of Contact's to 4 that are the most stable.
Contact::type
ContactType type
Definition:
contact.hpp:37
Contact::Pbt
float Pbt
Definition:
contact.hpp:30
Contact::effective_mass_normal
float effective_mass_normal
Definition:
contact.hpp:27
Contact::iterations
static unsigned int iterations
Definition:
contact.hpp:54
getOrthogonalFaces
vector< Face > getOrthogonalFaces(const CollisionBody &hull, vec3 normal)
Find the Face's that are orthogonal to the vector, normal, used for clipping to generate contact poin...
Contact::Contact
Contact(CollisionBody &hullA, CollisionBody &hullB)
Constructor, instantiated with the collision query between two CollisionBody objects.
createContacts
vector< Contact > createContacts(CollisionBody &body_a, CollisionBody &body_b)
Generate contacts between two CollisionBody's.
Contact::bitangent
vec3 bitangent
Definition:
contact.hpp:21
getContacts
vector< Contact > getContacts(CollisionBody &body)
Get contacts for a CollisionBody.
sphereCylinderContacts
vector< Contact > sphereCylinderContacts(CollisionBody &body_a, CollisionBody &body_b)
A data structure to contain the data received from a collision between a Sphere and a Cylinder...
Contact::penetration
float penetration
Definition:
contact.hpp:23
Contact::effective_mass_tangent
float effective_mass_tangent
Definition:
contact.hpp:26
CollisionBody
CollisionBody structure for organising data to model physics simulations of convex hull collisions...
Definition:
body.hpp:121
mouse_joint.hpp
Contact::id
vector< int > id
Definition:
contact.hpp:38
getMostParallelFace
vector< Face > getMostParallelFace(const CollisionBody &hull, vec3 normal)
Find the Face on the CollisionBody that is most parallel to the vector, normal.
body.hpp
Contact::Pt
float Pt
Definition:
contact.hpp:29
Contact::body_b
RigidBody * body_b
Definition:
contact.hpp:32
EDGE
Definition:
contact.hpp:12
FACE
Definition:
contact.hpp:12
simulate
int simulate(float deltaTime)
Access function for the physics time step function, called on the client-side manually in the update ...
Contact::collision_point
vec3 collision_point
Definition:
contact.hpp:22
hinge_joint.hpp
GJKEPAContacts
vector< Contact > GJKEPAContacts(CollisionBody &body_a, CollisionBody &body_b)
Contact::effective_mass_bitangent
float effective_mass_bitangent
Definition:
contact.hpp:25
Generated by
1.8.13