forked from naev/naev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollision.h
56 lines (50 loc) · 2.16 KB
/
collision.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
/*
* See Licensing and Copyright notice in naev.h
*/
#pragma once
#include "nxml.h"
#include "opengl.h"
#include "physics.h"
/**
* @brief Represents a polygon used for collision detection.
*/
typedef struct CollPoly_ {
float* x; /**< List of X coordinates of the points. */
float* y; /**< List of Y coordinates of the points. */
float xmin; /**< Min of x. */
float xmax; /**< Max of x. */
float ymin; /**< Min of y. */
float ymax; /**< Max of y. */
int npt; /**< Nb of points in the polygon. */
} CollPoly;
/* Loads a polygon data from xml. */
void LoadPolygon( CollPoly* polygon, xmlNodePtr node );
/* Rotates a polygon. */
void RotatePolygon( CollPoly* rpolygon, CollPoly* ipolygon, float theta );
/* Returns 1 if collision is detected */
int CollideSprite( const glTexture* at, const int asx, const int asy, const vec2* ap,
const glTexture* bt, const int bsx, const int bsy, const vec2* bp,
vec2* crash);
int CollideLineLine( double s1x, double s1y, double e1x, double e1y,
double s2x, double s2y, double e2x, double e2y, vec2* crash );
int CollideLineSprite( const vec2* ap, double ad, double al,
const glTexture* bt, const int bsx, const int bsy, const vec2* bp,
vec2 crash[2]);
int CollideCirclePolygon( const vec2* ap, double ar,
const CollPoly* bt, const vec2* bp, vec2 crash[2] );
int CollideCircleSprite( const vec2 *ap, double ar, const glTexture* bt,
const int bsx, const int bsy, const vec2* bp,vec2* crash );
int CollideLinePolygon( const vec2* ap, double ad, double al,
const CollPoly* bt, const vec2* bp, vec2 crash[2] );
int CollideSpritePolygon( const CollPoly* at, const vec2* ap,
const glTexture* bt, const int bsx, const int bsy, const vec2* bp,
vec2* crash );
int CollidePolygon( const CollPoly* at, const vec2* ap,
const CollPoly* bt, const vec2* bp, vec2* crash );
int CollideLineCircle( const vec2* p1, const vec2* p2,
const vec2 *cc, double cr, vec2 crash[2] );
int CollideCircleCircle( const vec2 *p1, double r1,
const vec2 *p2, double r2, vec2 crash[2] );
/* Intersection area. */
double CollideCircleIntersection( const vec2 *p1, double r1,
const vec2 *p2, double r2 );