1
0
Fork 0
blockofighter/src/collision.h

48 lines
1.4 KiB
C
Raw Permalink Normal View History

2014-02-16 14:32:28 +00:00
#ifndef __COLLISION_H_INCLUDED__
#define __COLLISION_H_INCLUDED__
#include "mesh.h"
#include "world.h"
2014-02-16 14:32:28 +00:00
2015-06-03 12:29:34 +00:00
#define COLLISIONGROUP_NONE 0
#define COLLISIONGROUP_ARENA 1
#define COLLISIONGROUP_MAN1 2
#define COLLISIONGROUP_MAN1HAND 3
#define COLLISIONGROUP_MAN2 4
#define COLLISIONGROUP_MAN2HAND 5
#define COLLISIONGROUP_PARTICLE 6
2014-02-16 14:32:28 +00:00
#define COLLISIONFRICTION 0.9
void initCollisions(void);
2015-06-03 12:29:34 +00:00
// void addCollisionObject(Object *object, int group);
2014-02-16 14:32:28 +00:00
void addCollisionLink(int source, int target);
void removeCollisionLink(int source, int target);
bool isCollisionLink(int source, int target);
2015-06-03 12:29:34 +00:00
class Contact {
2014-02-16 14:32:28 +00:00
public:
2015-06-03 12:29:34 +00:00
Object *object1, *object2;
float normal[3];
float position[3];
2014-02-16 14:32:28 +00:00
};
extern Contact *contacts;
extern int contactcount;
2015-06-03 12:29:34 +00:00
// Contact point is world-relative and must be transformed
// into coordinate system of both objects
void addCollision(Object *source, Object *target, float *normal,
float *contactpoint);
2014-02-16 14:32:28 +00:00
bool handleCollision(Contact *contact);
bool handleLink(ObjectLink *link);
2015-06-03 12:29:34 +00:00
bool checkSphereMeshCollision(float *sphereposition, float r, Mesh *mesh,
float *normal, float *contactpoint);
bool checkPointMeshCollision(float *position, Mesh *mesh, float *normal,
float *contactpoint);
bool checkEdgeMeshCollision(float *p1, float *p2, Mesh *mesh, float *normal,
float *contactpoint);
2014-02-16 14:32:28 +00:00
#endif