66 operator vec4()
const;
68 operator vec3()
const;
96 this->
vec = _mm_set1_ps(0);
105 this->
vec = _mm_setr_ps(
x,
y,
z, 0);
114 this->
vec = _mm_setr_ps(v, v, v, 0);
150 this->
vec = _mm_insert_ps(rhs,
_id_w, 0b111000);
160 this->
vec = _mm_load_ps(ptr);
171 this->
vec = _mm_loadu_ps(ptr);
182 __m128 v = _mm_permute_ps(this->
vec, _MM_SHUFFLE(2, 2, 2, 2));
183 _mm_storel_epi64(
reinterpret_cast<__m128i*
>(ptr), _mm_castps_si128(this->
vec));
184 _mm_store_ss(&ptr[2], v);
194 __m128 t1 = _mm_permute_ps(this->
vec, _MM_SHUFFLE(1, 1, 1, 1));
195 __m128 t2 = _mm_permute_ps(this->
vec, _MM_SHUFFLE(2, 2, 2, 2));
196 _mm_store_ss(&ptr[0], this->
vec);
197 _mm_store_ss(&ptr[1], t1);
198 _mm_store_ss(&ptr[2], t2);
225 this->
vec = _mm_insert_ps(rhs,
_id_w, 0b111000);
234 this->
vec = _mm_add_ps(this->
vec, rhs.
vec);
243 this->
vec = _mm_sub_ps(this->
vec, rhs.
vec);
252 this->
vec = _mm_mul_ps(this->
vec, _mm_set1_ps(s));
261 return _mm_add_ps(lhs.
vec, rhs.
vec);
270 return _mm_sub_ps(lhs.
vec, rhs.
vec);
279 return _mm_mul_ps(lhs.
vec, _mm_set1_ps(s));
288 return _mm_mul_ps(lhs.
vec, rhs.
vec);
297 __m128 vTemp = _mm_cmpeq_ps(this->
vec, rhs.
vec);
298 return ((_mm_movemask_ps(vTemp) == 0x0f) != 0);
307 __m128 vTemp = _mm_cmpeq_ps(this->
vec, rhs.
vec);
308 return ((_mm_movemask_ps(vTemp) == 0x0f) == 0);
318 return *((&this->
x) + index);
328 return *((&this->
x) + index);
337 return vec4(this->vec);
346 return vec3(this->vec);
355 this->
vec = _mm_setr_ps(
x,
y,
z, 0);
364 if (v ==
vector(0))
return v;
365 __m128 t = _mm_sqrt_ps(_mm_dp_ps(v.
vec, v.
vec, 0xF7));
366 t = _mm_or_ps(t,
_id_w);
367 return _mm_div_ps(v.
vec, t);
376 if (v ==
vector(0))
return v;
377 __m128 t = _mm_rsqrt_ps(_mm_dp_ps(v.
vec, v.
vec, 0xF7));
378 t = _mm_or_ps(t,
_id_w);
379 return _mm_mul_ps(v.
vec, t);
388 return _mm_cvtss_f32(_mm_dp_ps(v0.
vec, v1.
vec, 0x71));
397 __m128 tmp0, tmp1, tmp2, tmp3, result;
398 tmp0 = _mm_shuffle_ps(v0.
vec, v0.
vec, _MM_SHUFFLE(3, 0, 2, 1));
399 tmp1 = _mm_shuffle_ps(v1.
vec, v1.
vec, _MM_SHUFFLE(3, 1, 0, 2));
400 tmp2 = _mm_shuffle_ps(v0.
vec, v0.
vec, _MM_SHUFFLE(3, 1, 0, 2));
401 tmp3 = _mm_shuffle_ps(v1.
vec, v1.
vec, _MM_SHUFFLE(3, 0, 2, 1));
402 result = _mm_mul_ps(tmp0, tmp1);
403 result = _mm_sub_ps(result, _mm_mul_ps(tmp2, tmp3));
413 return _mm_cvtss_f32(_mm_sqrt_ss(_mm_dp_ps(v.
vec, v.
vec, 0x71)));
422 return _mm_cvtss_f32(_mm_dp_ps(v.
vec, v.
vec, 0x71));
#define n_assert(exp)
Definition debug.h:50
Different curves.
Definition angularpfeedbackloop.h:17
__forceinline vec3 cross(const vec3 &v0, const vec3 &v1)
Definition vec3.h:417
static const __m128i _sign
Definition vec3.h:36
__forceinline scalar length(const quat &q)
Definition quat.h:259
__forceinline scalar lengthsq(const quat &q)
Definition quat.h:268
__forceinline scalar dot(const plane &p, const vec4 &v1)
Definition plane.h:246
__forceinline plane normalize(const plane &p)
Definition plane.h:255
half operator-(half one, half two)
Definition half.h:114
static const __m128 _id_w
Definition vec3.h:32
float scalar
Definition scalar.h:45
half operator+(half one, half two)
Definition half.h:105
half operator*(half one, half two)
Definition half.h:123
static const __m128 _mask_xyz
Definition vec3.h:37
__forceinline vec3 normalizeapprox(const vec3 &v)
Definition vec3.h:592
Nebula's scalar datatype.
A 3D vector.
Definition vec3.h:40
__m128 vec
Definition vec3.h:96
A 4D vector.
Definition vec4.h:24
__m128 vec
Definition vec4.h:95
A vector is a 3D direction in space.
Definition vector.h:22
__m128 vec
Definition vector.h:82
bool operator==(const vector &rhs) const
equality operator
Definition vector.h:295
float z
Definition vector.h:85
void store(scalar *ptr) const
write content to 16-byte-aligned memory through the write cache
Definition vector.h:180
void operator=(const vector &rhs)
assignment operator
Definition vector.h:214
float x
Definition vector.h:85
float y
Definition vector.h:85
static vector upvec()
create the up vector
Definition vector.h:447
void storeu(scalar *ptr) const
write content to unaligned memory through the write cache
Definition vector.h:192
void operator*=(scalar s)
inplace scalar multiply
Definition vector.h:250
void loadu(const scalar *ptr)
load content from unaligned memory
Definition vector.h:169
void operator+=(const vector &rhs)
inplace add
Definition vector.h:232
void set(scalar x, scalar y, scalar z)
set content
Definition vector.h:353
static vector onevec()
create a 1,1,1 vector
Definition vector.h:438
void operator-=(const vector &rhs)
inplace sub
Definition vector.h:241
void load(const scalar *ptr)
load content from 16-byte-aligned memory
Definition vector.h:158
bool operator!=(const vector &rhs) const
inequality operator
Definition vector.h:305
vector()
default constructor
Definition vector.h:94
static vector nullvec()
create a null vector
Definition vector.h:429
float operator[](int index) const
Definition vector.h:315