]> icculus.org git repositories - divverent/darkplaces.git/blob - collision.h
no time to explain, more changes on the path to q3bsp support
[divverent/darkplaces.git] / collision.h
1
2 #ifndef COLLISION_H
3 #define COLLISION_H
4
5 typedef struct plane_s
6 {
7         vec3_t  normal;
8         float   dist;
9 }
10 plane_t;
11
12 typedef struct trace_s
13 {
14         // if true, the entire trace was in solid
15         int allsolid;
16         // if true, the initial point was in solid
17         int startsolid;
18         // if true, the trace passed through empty somewhere
19         int inopen;
20         // if true, the trace passed through water somewhere
21         int inwater;
22         // fraction of the total distance that was traveled before impact
23         // (1.0 = did not hit anything)
24         double fraction;
25         // final position
26         double endpos[3];
27         // surface normal at impact
28         plane_t plane;
29         // entity the surface is on
30         void *ent;
31         // if not zero, treats this value as empty, and all others as solid (impact
32         // on content change)
33         int thiscontents;
34         // the contents at the impact or end point
35         int endcontents;
36 }
37 trace_t;
38
39 void Collision_Init(void);
40 void Collision_ClipTrace_Box(trace_t *trace, const vec3_t cmins, const vec3_t cmaxs, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end);
41
42 typedef struct colpointf_s
43 {
44         float v[3];
45 }
46 colpointf_t;
47
48 typedef struct colplanef_s
49 {
50         float normal[3];
51         float dist;
52 }
53 colplanef_t;
54
55 typedef struct colbrushf_s
56 {
57         int numplanes;
58         int numpoints;
59         colplanef_t *planes;
60         colpointf_t *points;
61 }
62 colbrushf_t;
63
64 colbrushf_t *Collision_AllocBrushFloat(mempool_t *mempool, int numpoints, int numplanes);
65 void Collision_CalcPlanesForPolygonBrushFloat(colbrushf_t *brush);
66 colbrushf_t *Collision_AllocBrushFromPermanentPolygonFloat(mempool_t *mempool, int numpoints, float *points);
67 void Collision_TraceBrushBrushFloat(trace_t *trace, const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, const colbrushf_t *thatbrush_start, const colbrushf_t *thatbrush_end);
68 void Collision_TraceBrushPolygonFloat(trace_t *trace, const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, int numpoints, const float *points);
69 void Collision_TraceBrushPolygonTransformFloat(trace_t *trace, const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, int numpoints, const float *points, const matrix4x4_t *polygonmatrixstart, const matrix4x4_t *polygonmatrixend);
70
71 colbrushf_t *Collision_BrushForBox(const matrix4x4_t *matrix, const vec3_t mins, const vec3_t maxs);
72
73 #endif