~gimaker/peekabot/og3d-caching

« back to all changes in this revision

Viewing changes to src/Types.hh

  • Committer: Staffan Gimåker
  • Date: 2010-06-28 14:28:08 UTC
  • mfrom: (806.1.5 trunk)
  • Revision ID: staffan@gimaker.se-20100628142808-su4ekzxhs53hl7ul
Merged changes from trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 * signify the number <em>value and data bits</em> in the type.
23
23
 */
24
24
 
 
25
#include <cassert>
25
26
#include <ostream>
26
27
#include <string>
27
28
#include <boost/cstdint.hpp>
242
243
 
243
244
        Vector3(float x_, float y_, float z_) : x(x_), y(y_), z(z_) {}
244
245
 
 
246
        float &operator()(int idx)
 
247
        {
 
248
            if( idx == 0 )
 
249
                return x;
 
250
            else if( idx == 1 )
 
251
                return y;
 
252
            else if( idx == 2 )
 
253
                return z;
 
254
            else
 
255
                assert( false );
 
256
        }
 
257
 
 
258
        float operator()(int idx) const
 
259
        {
 
260
            if( idx == 0 )
 
261
                return x;
 
262
            else if( idx == 1 )
 
263
                return y;
 
264
            else if( idx == 2 )
 
265
                return z;
 
266
            else
 
267
                assert( false );
 
268
        }
 
269
 
245
270
        float x, y, z;
246
271
    };
247
272
 
248
273
 
249
274
    struct Transformation
250
275
    {
 
276
        Vector3 &operator()(int idx)
 
277
        {
 
278
            if( idx == 0 )
 
279
                return x;
 
280
            else if( idx == 1 )
 
281
                return y;
 
282
            else if( idx == 2 )
 
283
                return z;
 
284
            else if( idx == 3 )
 
285
                return pos;
 
286
            else
 
287
                assert( false );
 
288
        }
 
289
 
 
290
        const Vector3 &operator()(int idx) const
 
291
        {
 
292
            if( idx == 0 )
 
293
                return x;
 
294
            else if( idx == 1 )
 
295
                return y;
 
296
            else if( idx == 2 )
 
297
                return z;
 
298
            else if( idx == 3 )
 
299
                return pos;
 
300
            else
 
301
                assert( false );
 
302
        }
 
303
 
 
304
        inline float &operator()(int row, int col)
 
305
        {
 
306
            return (*this)(col)(row);
 
307
        }
 
308
 
 
309
        inline float operator()(int row, int col) const
 
310
        {
 
311
            return (*this)(col)(row);
 
312
        }
 
313
 
251
314
        Vector3 x, y, z;
252
315
        Vector3 pos;
253
316
    };