]> icculus.org git repositories - divverent/darkplaces.git/blob - collision.h
split r_shadow_realtime into r_shadow_realtime_world (which requires stencil) and...
[divverent/darkplaces.git] / collision.h
1
2 #ifndef COLLISION_H
3 #define COLLISION_H
4
5 typedef struct
6 {
7         vec3_t  normal;
8         float   dist;
9 } plane_t;
10
11 typedef struct
12 {
13         // if true, the entire trace was in solid
14         int allsolid;
15         // if true, the initial point was in solid
16         int startsolid;
17         // if true, the trace passed through empty somewhere
18         int inopen;
19         // if true, the trace passed through water somewhere
20         int inwater;
21         // fraction of the total distance that was traveled before impact
22         // (1.0 = did not hit anything)
23         double fraction;
24         // final position
25         double endpos[3];
26         // surface normal at impact
27         plane_t plane;
28         // entity the surface is on
29         void *ent;
30         // if not zero, treats this value as empty, and all others as solid (impact
31         // on content change)
32         int startcontents;
33         // the contents that was hit at the end or impact point
34         int endcontents;
35 }
36 trace_t;
37
38 void Collision_RoundUpToHullSize(const model_t *cmodel, const vec3_t inmins, const vec3_t inmaxs, vec3_t outmins, vec3_t outmaxs);
39 void Collision_Init (void);
40 void Collision_ClipTrace (trace_t *trace, const void *cent, const 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);
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 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);
68 float Collision_TraceBrushPolygonFloat(const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, int numpoints, const float *points, float *impactnormal, int *startsolid, int *allsolid);
69 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);
70
71 typedef struct colpointd_s
72 {
73         double v[3];
74 }
75 colpointd_t;
76
77 typedef struct colplaned_s
78 {
79         double normal[3];
80         double dist;
81 }
82 colplaned_t;
83
84 typedef struct colbrushd_s
85 {
86         int numplanes;
87         int numpoints;
88         colplaned_t *planes;
89         colpointd_t *points;
90 }
91 colbrushd_t;
92
93 colbrushd_t *Collision_AllocBrushDouble(mempool_t *mempool, int numpoints, int numplanes);
94 void Collision_CalcPlanesForPolygonBrushDouble(colbrushd_t *brush);
95 colbrushd_t *Collision_AllocBrushFromPermanentPolygonDouble(mempool_t *mempool, int numpoints, double *points);
96 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);
97 double Collision_TraceBrushPolygonDouble(const colbrushd_t *thisbrush_start, const colbrushd_t *thisbrush_end, int numpoints, const double *points, double *impactnormal);
98
99 float Collision_TraceBrushBModel(const colbrushf_t *thisbrush_start, const colbrushf_t *thisbrush_end, model_t *model, float *impactnormal, int *startsolid, int *allsolid);
100 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);
101
102 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);
103
104 #endif