2014-01-31 08:23:00 +13:00
|
|
|
|
|
|
|
|
#ifndef COLLISION_H
|
|
|
|
|
#define COLLISION_H
|
|
|
|
|
|
2019-01-18 15:55:06 +01:00
|
|
|
#include "geom.hpp"
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2016-05-04 09:58:44 +02:00
|
|
|
extern const float COLLISION_FLT_EPSILON;
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
struct Collision {
|
|
|
|
|
float time;
|
|
|
|
|
Vector normal;
|
|
|
|
|
void* surface;
|
2014-01-31 08:23:00 +13:00
|
|
|
unsigned short index;
|
|
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
Collision() : time(1), surface(0), index(~0) {}
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
bool update(const Line& line, float time, const Vector& normal);
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
bool sphereCollide(const Line& src_line, float src_radius, const Vector& dest, float dest_radius);
|
|
|
|
|
bool sphereCollide(const Line& line, float radius, const Vector& dest, const Vector& radii);
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
bool triangleCollide(const Line& src_line, float src_radius, const Vector& v0, const Vector& v1, const Vector& v2);
|
2014-01-31 08:23:00 +13:00
|
|
|
|
2019-01-18 17:04:17 +01:00
|
|
|
bool boxCollide(const Line& src_line, float src_radius, const Box& box);
|
2014-01-31 08:23:00 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|