ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/util.C
(Generate patch)

Comparing libgender/util.C (file contents):
Revision 1.6 by root, Mon Oct 4 07:04:58 2004 UTC vs.
Revision 1.7 by root, Mon Oct 4 10:18:13 2004 UTC

19 19
20 p.x = modff (p.x, &i); s.x += (int)i; 20 p.x = modff (p.x, &i); s.x += (int)i;
21 p.y = modff (p.y, &i); s.y += (int)i; 21 p.y = modff (p.y, &i); s.y += (int)i;
22 p.z = modff (p.z, &i); s.z += (int)i; 22 p.z = modff (p.z, &i); s.z += (int)i;
23} 23}
24
25/////////////////////////////////////////////////////////////////////////////
24 26
25const vec3 normalize (const vec3 &v) 27const vec3 normalize (const vec3 &v)
26{ 28{
27 GLfloat s = abs (v); 29 GLfloat s = abs (v);
28 30
39 a.y * b.z - a.z * b.y, 41 a.y * b.z - a.z * b.y,
40 a.z * b.x - a.x * b.z, 42 a.z * b.x - a.x * b.z,
41 a.x * b.y - a.y * b.x 43 a.x * b.y - a.y * b.x
42 ); 44 );
43} 45}
46
47/////////////////////////////////////////////////////////////////////////////
44 48
45void gl_matrix::diagonal (GLfloat v) 49void gl_matrix::diagonal (GLfloat v)
46{ 50{
47 for (int i = 4; i--; ) 51 for (int i = 4; i--; )
48 for (int j = 4; j--; ) 52 for (int j = 4; j--; )
197 m(3,3) = 1; 201 m(3,3) = 1;
198 202
199 (*this) = (*this) * m; 203 (*this) = (*this) * m;
200} 204}
201 205
206/////////////////////////////////////////////////////////////////////////////
207
208plane::plane (GLfloat a, GLfloat b, GLfloat c, GLfloat d)
209: n (vec3 (a,b,c)), d(d)
210{
211 GLfloat s = 1. / abs (n);
212
213 n = n * s;
214 d = d * s;
215}
216
217/////////////////////////////////////////////////////////////////////////////
218
202void box::add (const box &o) 219void box::add (const box &o)
203{ 220{
204 a.x = min (a.x, o.a.x); 221 a.x = min (a.x, o.a.x);
205 a.y = min (a.y, o.a.y); 222 a.y = min (a.y, o.a.y);
206 a.z = min (a.z, o.a.z); 223 a.z = min (a.z, o.a.z);
227 b.x = max (b.x, (soffs)ceilf (p.x)); 244 b.x = max (b.x, (soffs)ceilf (p.x));
228 b.y = max (b.y, (soffs)ceilf (p.y)); 245 b.y = max (b.y, (soffs)ceilf (p.y));
229 b.z = max (b.z, (soffs)ceilf (p.z)); 246 b.z = max (b.z, (soffs)ceilf (p.z));
230} 247}
231 248
249/////////////////////////////////////////////////////////////////////////////
250
232struct timer timer; 251struct timer timer;
233static double base; 252static double base;
234double timer::now = 0.; 253double timer::now = 0.;
235double timer::diff; 254double timer::diff;
236 255

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines