Advertisement
Ember

Vectorr

Apr 7th, 2014
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. Align(16) class Vector
  2. {
  3. private:
  4.     m128 v;
  5.  
  6. public:
  7.     // Constructors
  8.     Vector() : v(_mm_setzero_ps()) {};
  9.     Vector(const m128 vector) : v(vector) {};
  10.     Vector(const Float4 &vector) : v(_mm_loadu_ps(&vector.x)) {};
  11.     Vector(const Float x, const Float y, const Float z, const Float w) : v(_mm_set_ps(x, y, z, w)) {};
  12.  
  13.     // Register compatibility
  14.     Vector operator=(const m128 &vector) { v = vector; return *this; }
  15.     operator m128() const { return v; }
  16.  
  17.     // Float4 compatibility
  18.     Vector operator=(const Float4 &vector) { v = _mm_loadu_ps(&vector.x); return *this; }
  19.     operator Float4() const { Float4 a; _mm_storeu_ps(&a.x, v); return a; }
  20. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement