Debian Codegraph @

code/renderergl2/tr_extramath.h

raw symbols SCIP
1 /*
2 ===========================================================================
3 Copyright (C) 2010 James Canete ([email protected])
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake III Arena source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake III Arena source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
21 */
22 // tr_extramath.h
23
24 #ifndef __TR_EXTRAMATH_H__
25 #define __TR_EXTRAMATH_H__
26
27 typedef vec_t mat4_t[16];
28 typedef int ivec2_t[2];
29 typedef int ivec3_t[3];
30 typedef int ivec4_t[4];
31
32 void Mat4Zero( mat4_t out );
33 void Mat4Identity( mat4_t out );
34 void Mat4Copy( const mat4_t in, mat4_t out );
35 void Mat4Multiply( const mat4_t in1, const mat4_t in2, mat4_t out );
36 void Mat4Transform( const mat4_t in1, const vec4_t in2, vec4_t out );
37 qboolean Mat4Compare(const mat4_t a, const mat4_t b);
38 void Mat4Dump( const mat4_t in );
39 void Mat4Translation( vec3_t vec, mat4_t out );
40 void Mat4Ortho( float left, float right, float bottom, float top, float znear, float zfar, mat4_t out );
41 void Mat4View(vec3_t axes[3], vec3_t origin, mat4_t out);
42 void Mat4SimpleInverse( const mat4_t in, mat4_t out);
43
44 #define VectorCopy2(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1])
45 #define VectorSet2(v,x,y) ((v)[0]=(x),(v)[1]=(y));
46
47 #define VectorCopy4(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])
48 #define VectorSet4(v,x,y,z,w) ((v)[0]=(x),(v)[1]=(y),(v)[2]=(z),(v)[3]=(w))
49 #define DotProduct4(a,b) ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2] + (a)[3]*(b)[3])
50 #define VectorScale4(a,b,c) ((c)[0]=(a)[0]*(b),(c)[1]=(a)[1]*(b),(c)[2]=(a)[2]*(b),(c)[3]=(a)[3]*(b))
51
52 #define VectorCopy5(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3],(b)[4]=(a)[4])
53
54 #define OffsetByteToFloat(a) ((float)(a) * 1.0f/127.5f - 1.0f)
55 #define FloatToOffsetByte(a) (byte)((a) * 127.5f + 128.0f)
56 #define ByteToFloat(a) ((float)(a) * 1.0f/255.0f)
57 #define FloatToByte(a) (byte)((a) * 255.0f)
58
59 static ID_INLINE int VectorCompare4(const vec4_t v1, const vec4_t v2)
60 {
61 if(v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2] || v1[3] != v2[3])
62 {
63 return 0;
64 }
65 return 1;
66 }
67
68 static ID_INLINE int VectorCompare5(const vec5_t v1, const vec5_t v2)
69 {
70 if(v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2] || v1[3] != v2[3] || v1[4] != v2[4])
71 {
72 return 0;
73 }
74 return 1;
75 }
76
77 void VectorLerp( vec3_t a, vec3_t b, float lerp, vec3_t c);
78
79
80 qboolean SpheresIntersect(vec3_t origin1, float radius1, vec3_t origin2, float radius2);
81 void BoundingSphereOfSpheres(vec3_t origin1, float radius1, vec3_t origin2, float radius2, vec3_t origin3, float *radius3);
82
83 #ifndef SGN
84 #define SGN(x) (((x) >= 0) ? !!(x) : -1)
85 #endif
86
87 #ifndef MAX
88 #define MAX(a,b) ((a) > (b) ? (a) : (b))
89 #endif
90
91 #ifndef MIN
92 #define MIN(a,b) ((a) < (b) ? (a) : (b))
93 #endif
94
95 #ifndef CLAMP
96 #define CLAMP(a,b,c) MIN(MAX((a),(b)),(c))
97 #endif
98
99 int NextPowerOfTwo(int in);
100 unsigned short FloatToHalf(float in);
101 float HalfToFloat(unsigned short in);
102
103 #endif