]> icculus.org git repositories - divverent/darkplaces.git/blob - collision.h
disable -Werror because it makes a mess of releases if anyone has warnings (like...
[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_RoundUpToHullSize(const model_t *cmodel, const vec3_t inmins, const vec3_t inmaxs, vec3_t outmins, vec3_t outmaxs);
40 void Collision_Init(void);
41 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);
42
43 typedef struct colpointf_s
44 {
45         float v[3];
46 }
47 colpointf_t;
48
49 typedef struct colplanef_s
50 {
51         float normal[3];
52         float dist;
53 }
54 colplanef_t;
55
56 typedef struct colbrushf_s
57 {
58         int numplanes;
59         int numpoints;
60         colplanef_t *planes;
61         colpointf_t *points;
62 }
63 colbrushf_t;
64
65 colbrushf_t *Collision_AllocBrushFloat(mempool_t *mempool, int numpoints, int numplanes);
66 void Collision_CalcPlanesForPolygonBrushFloat(colbrushf_t *brush);
67 colbrushf_t *Collision_AllocBrushFromPermanentPolygonFloat(mempool_t *mempool, int numpoints, float *points);
68 float Collision_TraceBrushBrushFloat(const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, const colbrushf_t *thatbrush_start, const colbrushf_t *thatbrush_end, float *impactnormal, int *startsolid, int *allsolid);
69 float Collision_TraceBrushPolygonFloat(const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, int numpoints, const float *points, float *impactnormal, int *startsolid, int *allsolid);
70 float Collision_TraceBrushPolygonTransformFloat(const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, int numpoints, const float *points, float *impactnormal, const matrix4x4_t *polygonmatrixstart, const matrix4x4_t *polygonmatrixend, int *startsolid, int *allsolid);
71
72 typedef struct colpointd_s
73 {
74         double v[3];
75 }
76 colpointd_t;
77
78 typedef struct colplaned_s
79 {
80         double normal[3];
81         double dist;
82 }
83 colplaned_t;
84
85 typedef struct colbrushd_s
86 {
87         int numplanes;
88         int numpoints;
89         colplaned_t *planes;
90         colpointd_t *points;
91 }
92 colbrushd_t;
93
94 colbrushd_t *Collision_AllocBrushDouble(mempool_t *mempool, int numpoints, int numplanes);
95 void Collision_CalcPlanesForPolygonBrushDouble(colbrushd_t *brush);
96 colbrushd_t *Collision_AllocBrushFromPermanentPolygonDouble(mempool_t *mempool, int numpoints, double *points);
97 double Collision_TraceBrushBrushDouble(const colbrushd_t *thisbrush_start, const colbrushd_t *thisbrush_end, const colbrushd_t *thatbrush_start, const colbrushd_t *thatbrush_end, double *impactnormal);
98 double Collision_TraceBrushPolygonDouble(const colbrushd_t *thisbrush_start, const colbrushd_t *thisbrush_end, int numpoints, const double *points, double *impactnormal);
99
100 float Collision_TraceBrushBModel(const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, model_t *model, float *impactnormal, int *startsolid, int *allsolid);
101 float Collision_TraceBrushBModelTransform(const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, model_t *model, float *impactnormal, const matrix4x4_t *modelmatrixstart, const matrix4x4_t *modelmatrixend, int *startsolid, int *allsolid);
102
103 void Collision_PolygonClipTrace(trace_t *trace, const void *cent, model_t *cmodel, const vec3_t corigin, const vec3_t cangles, const vec3_t cmins, const vec3_t cmaxs, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end);
104
105 #endif