bzr branch
http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk
27
by Gustav Hartvigsson
* added skeleton for the SBox type. |
1 |
#include "vec.h" |
2 |
||
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
3 |
/* **************************************************************************
|
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
4 |
**************** Vec3_32 (32bit int) ****************************************
|
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
5 |
************************************************************************** */
|
6 |
||
7 |
#define _V_NEW_M_(TYPE) {\
|
|
121.1.3
by Gustav Hartvigsson
* Made the GC switchable at rutime (once) when compiled with S_USE_GC set. |
8 |
TYPE * self = s_malloc (sizeof (TYPE));\
|
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
9 |
self->a = a;\
|
10 |
self->b = b;\
|
|
11 |
self->c = c;\
|
|
12 |
return self;\
|
|
13 |
}
|
|
14 |
||
15 |
#define _V_ADD_M_(TYPE) {\
|
|
121.1.3
by Gustav Hartvigsson
* Made the GC switchable at rutime (once) when compiled with S_USE_GC set. |
16 |
TYPE * new_v = s_malloc (sizeof (TYPE));\
|
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
17 |
new_v->a = a->a + b->a;\
|
18 |
new_v->b = a->b + b->b;\
|
|
19 |
new_v->c = a->c + b->c;\
|
|
20 |
return new_v;\
|
|
21 |
}
|
|
22 |
||
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
23 |
Vec3_32 * |
24 |
vec3_32_new (sint a, |
|
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
25 |
sint b, |
26 |
sint c) { |
|
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
27 |
_V_NEW_M_(Vec3_32); |
28 |
}
|
|
29 |
||
30 |
Vec3_32 * |
|
31 |
vec3_32_add_Vec3_32 (Vec3_32 * a, |
|
32 |
Vec3_32 * b) { |
|
33 |
_V_ADD_M_(Vec3_32); |
|
34 |
}
|
|
35 |
||
36 |
Vec3_32 * |
|
37 |
vec3_32_add_vec3_16 (Vec3_32 * a, |
|
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
38 |
Vec3_16 * b) { |
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
39 |
_V_ADD_M_(Vec3_32); |
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
40 |
}
|
41 |
||
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
42 |
Vec3_32 * |
43 |
vec3_16_add_Vec3_32 (Vec3_16 * a, |
|
44 |
Vec3_32 * b) { |
|
45 |
_V_ADD_M_(Vec3_32); |
|
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
46 |
}
|
47 |
||
48 |
/* **************************************************************************
|
|
49 |
**************** VEC3_16 (16bit int) *************************************
|
|
50 |
************************************************************************** */
|
|
51 |
||
52 |
Vec3_16 * |
|
53 |
vec3_16_new (sshort a, |
|
54 |
sshort b, |
|
55 |
sshort c) { |
|
56 |
_V_NEW_M_(Vec3_16); |
|
57 |
}
|
|
58 |
||
59 |
Vec3_16 * |
|
60 |
vec3_16_add_vec3_16 (Vec3_16 * a, |
|
61 |
Vec3_16 * b) { |
|
62 |
_V_ADD_M_(Vec3_16); |
|
63 |
}
|
|
64 |
||
65 |
||
66 |
/* **************************************************************************
|
|
67 |
**************** VEC3_f (Float) ******************************************
|
|
68 |
************************************************************************** */
|
|
69 |
||
70 |
Vec3_f * |
|
71 |
vec3_f_new (sfloat a, |
|
72 |
sfloat b, |
|
73 |
sfloat c) { |
|
74 |
_V_NEW_M_(Vec3_f); |
|
75 |
}
|
|
76 |
||
77 |
Vec3_f * |
|
78 |
vec3_f_add_vec3_f (Vec3_f * a, |
|
79 |
Vec3_f * b) { |
|
80 |
_V_ADD_M_(Vec3_f); |
|
81 |
}
|
|
82 |
||
83 |
Vec3_f * |
|
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
84 |
vec3_f_add_Vec3_32 (Vec3_f * a, |
85 |
Vec3_32 * b) { |
|
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
86 |
_V_ADD_M_(Vec3_f); |
87 |
}
|
|
88 |
||
89 |
Vec3_f * |
|
90 |
vec3_f_add_vec3_16 (Vec3_f * a, |
|
91 |
Vec3_16 * b) { |
|
92 |
_V_ADD_M_(Vec3_f); |
|
93 |
}
|
|
94 |
||
95 |
Vec3_f * |
|
131.1.1
by Gustav Hatvigsson
* Made a generic vec3_new |
96 |
vec3_add_vec3_f (Vec3_32 * a, |
102
by Gustav Hartvigsson
* Finnished the Vectors... For the moment. |
97 |
Vec3_f * b) { |
98 |
_V_ADD_M_(Vec3_f); |
|
99 |
}
|
|
100 |
||
101 |
Vec3_f * |
|
102 |
vec3_16_add_vec3_f (Vec3_16 * a, |
|
103 |
Vec3_f * b) { |
|
104 |
_V_ADD_M_(Vec3_f); |
|
105 |
}
|
|
106 |