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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/*
Copyright (C) 1997-2001 Id Software, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MATH_H
#define MATH_H
#define NUMVERTEXNORMALS 162
void vectoangles2(const vec3_t value1, vec3_t angles);
void MakeNormalVectors(const vec3_t forward, vec3_t right, vec3_t up);
extern const vec3_t bytedirs[NUMVERTEXNORMALS];
int DirToByte(const vec3_t dir);
//void ByteToDir(int index, vec3_t dir);
void SetPlaneType(cplane_t *plane);
void SetPlaneSignbits(cplane_t *plane);
#define BOX_INFRONT 1
#define BOX_BEHIND 2
#define BOX_INTERSECTS 3
int BoxOnPlaneSide(vec3_t emins, vec3_t emaxs, cplane_t *p);
static inline int BoxOnPlaneSideFast(vec3_t emins, vec3_t emaxs, cplane_t *p)
{
// fast axial cases
if (p->type < 3) {
if (p->dist <= emins[p->type])
return BOX_INFRONT;
if (p->dist >= emaxs[p->type])
return BOX_BEHIND;
return BOX_INTERSECTS;
}
// slow generic case
return BoxOnPlaneSide(emins, emaxs, p);
}
static inline vec_t PlaneDiffFast(vec3_t v, cplane_t *p)
{
// fast axial cases
if (p->type < 3) {
return v[p->type] - p->dist;
}
// slow generic case
return PlaneDiff(v, p);
}
void SetupRotationMatrix(vec3_t matrix[3], const vec3_t dir, float degrees);
void RotatePointAroundVector(vec3_t dst, const vec3_t dir, const vec3_t point, float degrees);
void ProjectPointOnPlane(vec3_t dst, const vec3_t p, const vec3_t normal);
void PerpendicularVector(vec3_t dst, const vec3_t src);
#endif // MATH_H
|