-
Notifications
You must be signed in to change notification settings - Fork 1
/
collisions.h
79 lines (61 loc) · 2.37 KB
/
collisions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*-----------------------------------------------------------------------------------
File: collisions.h
Authors: Steve Costa
Description: Header file defining collision management class.
-----------------------------------------------------------------------------------*/
#ifndef COLLISIONS_H
#define COLLISIONS_H
#include "world.h"
/*-----------------------------------------------------------------------------------
Constants
-----------------------------------------------------------------------------------*/
#define NO_COLLISION 0
#define BALL_BALL_COLLISION 1
#define BALL_WALL_COLLISION 2
#define BOX_WALL_COLLISION 3
#define BOX_BOX_COLLISION 4
#define BALL_BOX_COLLISION 5
class CCollisions
{
// ATTRIBUTES
public:
// Structure for collision data
struct colldata
{
int collID; // ID of type of collision
int object1;
int object2;
bool edge_collision;
TVector v1, v2, v3;
TVector edge_p1, edge_p2;
};
private:
int num_walls; // Number of walls
int num_balls; // Number of balls
int num_boxes; // Number of boxes
TWall *p_walls; // Declare walls
TBall *p_balls; // Declare balls
TBox *p_boxes; // Declare boxes
int num_sim_collisions; // Number of simultaneous collisions
colldata *p_cdata; // Collision information
float min_time; // Time of earliest collision
float t_left; // Each frame has time slice which decrements to 0 (starts at 1.0)
TVector tri_coords[3]; // Keep track of the coordinates of triangle collided with
// METHODS
public:
CCollisions(CWorld& world);
void Test(float dt); // Test collisions between all objects
~CCollisions();
private:
void TestBallBall(float dt); // Test for collisions between balls
void TestBallWall(float dt); // Test for collisions between balls and walls
void TestBoxWall(float dt); // Test for collisions between boxes and walls
void TestBoxBox(float dt); // Test for collisions between boxes
void TestBoxBall(float dt); // Test for collisions between boxes and balls
void BallBallResponse(int i); // Collision response between balls
void BallWallResponse(int i); // Collision response between balls and walls
void BoxWallResponse(int i); // Collision response between boxes and walls
void BoxBoxResponse(int i); // Collision response between boxes
void BallBoxResponse(int i); // Collision response between balls and boxes
};
#endif