Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
/* Copyright (c) 2017 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software
   and associated documentation files (the "Software"), to deal in the Software
   without restriction,
   including without limitation the rights to use, copy, modify, merge, publish,
   distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
   PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
   IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

#ifndef _CORE_MATH_MATH_VECTORS_H_
#define _CORE_MATH_MATH_VECTORS_H_

namespace Divide {
/*
*  useful vector functions
*/
/// general vec2 cross function
template <typename T>
inline vec2<T> Cross(const vec2<T> &v1, const vec2<T> &v2) {
    return v1.x * v2.y - v1.y * v2.x;
}

template <typename T>
inline vec2<T> Inverse(const vec2<T> &v) {
    return vec2<T>(v.y, v.x);
}

template <typename T>
inline vec2<T> Normalize(vec2<T> &vector) {
    vector.normalize();
    return vector;
}

template <typename T>
inline vec2<T> Normalize(const vec2<T> &vector) {
    vec2<T> result(vector);
    result.normalize();
    return result;
}

/// multiply a vector by a value
template <typename T>
inline vec2<T> operator*(T fl, const vec2<T> &v) {
    return vec2<T>(v.x * fl, v.y * fl);
}

/// general vec2 dot product
template <typename T>
inline T Dot(const vec2<T> &a, const vec2<T> &b) {
    return (a.x * b.x + a.y * b.y);
}

template <typename T>
inline void OrthoNormalize(vec2<T> &v1, vec2<T> &v2) {
    vec2<T>& n(v1); vec2<T>& u(v2);

    n.normalize();
    vec2<T> v(Cross(n, u));
    v.normalize();
    u.set(Cross(v, n));
}

template <typename T>
inline vec3<T> Normalize(vec3<T> &vector) {
    vector.normalize();
    return vector;
}

template <typename T>
inline vec3<T> Normalize(const vec3<T> &vector) {
    vec3<T> result(vector);
    result.normalize();
    return result;
}

/// multiply a vector by a value
template <typename T>
inline vec3<T> operator*(T fl, const vec3<T> &v) {
    return vec3<T>(v.x * fl, v.y * fl, v.z * fl);
}

/// general vec3 dot product
template <typename T>
inline T Dot(const vec3<T> &a, const vec3<T> &b) {
    return (a.x * b.x + a.y * b.y + a.z * b.z);
}

/// general vec3 cross function
template <typename T>
inline vec3<T> Cross(const vec3<T> &v1, const vec3<T> &v2) {
    return vec3<T>(v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z,
                   v1.x * v2.y - v1.y * v2.x);
}

template <typename T>
inline vec3<T> Inverse(const vec3<T> &v) {
    return vec3<T>(v.z, v.y, v.x);
}

template <typename T>
inline void OrthoNormalize(vec3<T> &v1, vec3<T> &v2) {
    vec3<T>& n(v1); vec3<T>& u(v2);

    n.normalize();
    vec3<T> v(Cross(n, u));
    v.normalize();
    u.set(Cross(v, n));
}

/// min/max functions
template <typename T>
inline vec4<T> Min(const vec4<T> &v1, const vec4<T> &v2) {
    return vec4<T>(std::min(v1.x, v2.x), std::min(v1.y, v2.y),
                   std::min(v1.z, v2.z), std::min(v1.w, v2.w));
}

template <typename T>
inline vec4<T> Max(const vec4<T> &v1, const vec4<T> &v2) {
    return vec4<T>(std::max(v1.x, v2.x), std::max(v1.y, v2.y),
                   std::max(v1.z, v2.z), std::max(v1.w, v2.w));
}

template <typename T>
inline vec4<T> Normalize(vec4<T> &vector) {
    vector.normalize();
    return vector;
}

template <typename T>
inline vec4<T> Normalize(const vec4<T> &vector) {
    vec4<T> result(vector);
    result.normalize();
    return result;
}

/// multiply a vector by a value
template <typename T>
inline vec4<T> operator*(T fl, const vec4<T> &v) {
    return v * fl;
}

/*
*  vec2 inline definitions
*/

/// convert the vector to unit length
template <typename T>
inline T vec2<T>::normalize() {
    T l = this->length();

    if (l < EPSILON_F32) {
        return 0;
    }

    T inv = 1.0f / l;
    this->x *= inv;
    this->y *= inv;
    return l;
}

/// compare 2 vectors
template <typename T>
template <typename U>
inline bool vec2<T>::compare(const vec2<U> &v) const {
    return COMPARE(this->x, v.x) &&
           COMPARE(this->y, v.y);
}

/// compare 2 vectors using the given tolerance
template <typename T>
template <typename U>
inline bool vec2<T>::compare(const vec2<U> &v, T epsi) const {
    return (COMPARE_TOLERANCE(this->x, v.x, epsi) &&
            COMPARE_TOLERANCE(this->y, v.y, epsi));
}

/// return the projection factor from *this to the line determined by points vA
/// and vB
template <typename T>
inline T vec2<T>::projectionOnLine(const vec2 &vA, const vec2 &vB) const {
    vec2 v(vB - vA);
    return v.dot(*this - vA) / v.dot(v);
}

/// get the dot product between this vector and the specified one
template <typename T>
inline T vec2<T>::dot(const vec2 &v) const {
    return ((this->x * v.x) + (this->y * v.y));
}

/// round both values
template <typename T>
inline void vec2<T>::round() {
    set((T)std::roundf(this->x), (T)std::roundf(this->y));
}

/// export the vector's components in the first 2 positions of the specified
/// array
template <typename T>
inline void vec2<T>::get(T *v) const {
    v[0] = (T) this->_v[0];
    v[1] = (T) this->_v[1];
}

/// return the coordinates of the closest point from *this to the line
/// determined by points vA and vB
template <typename T>
inline vec2<T> vec2<T>::closestPointOnLine(const vec2 &vA, const vec2 &vB) {
    return (((vB - vA) * this->projectionOnLine(vA, vB)) + vA);
}

/// return the coordinates of the closest point from *this to the segment
/// determined by points vA and vB
template <typename T>
inline vec2<T> vec2<T>::closestPointOnSegment(const vec2 &vA, const vec2 &vB) {
    T factor = this->projectionOnLine(vA, vB);

    if (factor <= 0) return vA;

    if (factor >= 1) return vB;

    return (((vB - vA) * factor) + vA);
}

/// lerp between this and the specified vector by the specified amount
template <typename T>
inline void vec2<T>::lerp(const vec2 &v, T factor) {
    set((*this * (1 - factor)) + (v * factor));
}

/// lerp between this and the specified vector by the specified amount for each
/// component
template <typename T>
inline void vec2<T>::lerp(const vec2 &v, const vec2 &factor) {
    set((*this * (1 - factor)) + (v * factor));
}

/// linear interpolation between 2 vectors
template <typename T, typename U>
inline vec2<T> Lerp(const vec2<T> &u, const vec2<T> &v, U factor) {
    return ((u * (1 - factor)) + (v * factor));
}

/// linear interpolation between 2 vectors based on separate x and y factors
template <typename T>
inline vec2<T> Lerp(const vec2<T> &u, const vec2<T> &v, const vec2<T> &factor) {
    return (vec2<T>((u.x * (1 - factor.x)) + (v.x * factor.x),
                    (u.y * (1 - factor.y)) + (v.y * factor.y)));
}

/*
*  vec3 inline definitions
*/

/// compare 2 vectors
template <typename T>
template <typename U>
inline bool vec3<T>::compare(const vec3<U> &v) const {
    return COMPARE(this->x, v.x) &&
           COMPARE(this->y, v.y) &&
           COMPARE(this->z, v.z);
}

/// compare 2 vectors within the specified tolerance
template <typename T>
template <typename U>
inline bool vec3<T>::compare(const vec3<U> &v, T epsi) const {
    return COMPARE_TOLERANCE(this->x, v.x, epsi) &&
           COMPARE_TOLERANCE(this->y, v.y, epsi) &&
           COMPARE_TOLERANCE(this->z, v.z, epsi);
}

/// uniform vector: x = y = z
template <typename T>
inline bool vec3<T>::isUniform() const {
    return COMPARE(this->x, this->y) && COMPARE(this->y, this->z);
}

/// return the squared distance of the vector
template <typename T>
inline T vec3<T>::lengthSquared() const {
    return this->x * this->x + this->y * this->y + this->z * this->z;
}

/// transform the vector to unit length
template <typename T>
inline T vec3<T>::normalize() {
    T l = this->length();

    if (l < EPSILON_F32) return 0.0f;

    // multiply by the inverse length
    *this *= (1.0f / l);

    return l;
}

/// set this vector to be equal to the cross of the 2 specified vectors
template <typename T>
inline void vec3<T>::cross(const vec3 &v1, const vec3 &v2) {
    this->x = v1.y * v2.z - v1.z * v2.y;
    this->y = v1.z * v2.x - v1.x * v2.z;
    this->z = v1.x * v2.y - v1.y * v2.x;
}

/// set this vector to be equal to the cross between itself and the specified
/// vector
template <typename T>
inline void vec3<T>::cross(const vec3 &v2) {
    this->cross(*this, v2);
}

/// calculate the dot product between this vector and the specified one
template <typename T>
inline T vec3<T>::dot(const vec3 &v) const {
    return Divide::Dot(*this, v);
}

/// compute the vector's distance to another specified vector
template <typename T>
inline T vec3<T>::distance(const vec3 &v) const {
    T distanceSQ = ((v.x - this->x) * (v.x - this->x)) +
                   ((v.y - this->y) * (v.y - this->y)) +
                   ((v.z - this->z) * (v.z - this->z));
    return distanceSQ > EPSILON_F32 ? std::sqrt(distanceSQ) : 0;
}
/// compute the vector's squared distance to another specified vector
template <typename T>
inline T vec3<T>::distanceSquared(const vec3 &v) const {
    return (*this - v).lengthSquared();
}
/// returns the angle in radians between '*this' and 'v'
template <typename T>
inline T vec3<T>::angle(vec3 &v) const {
    T angle =
        (T)std::fabs(std::acos(this->dot(v) / (this->length() * v.length())));

    if (angle < EPSILON_F32) {
        return 0;
    }
    return angle;
}

/// get the direction vector to the specified point
template <typename T>
inline vec3<T> vec3<T>::direction(const vec3 &u) const {
    vec3 vector(u.x - this->x, u.y - this->y, u.z - this->z);
    vector.normalize();
    return vector;
}

/// project this vector on the line defined by the 2 points(A, B)
template <typename T>
inline T vec3<T>::projectionOnLine(const vec3 &vA, const vec3 &vB) const {
    vec3 vector(vB - vA);
    return vector.dot(*this - vA) / vector.dot(vector);
}

/// lerp between this and the specified vector by the specified amount
template <typename T>
inline void vec3<T>::lerp(const vec3 &v, T factor) {
    set((*this * (1 - factor)) + (v * factor));
}

/// lerp between this and the specified vector by the specified amount for each
/// component
template <typename T>
inline void vec3<T>::lerp(const vec3 &v, const vec3 &factor) {
    set((*this * (1 - factor)) + (v * factor));
}

/// rotate this vector on the X axis
template <typename T>
inline void vec3<T>::rotateX(D64 radians) {
    this->y = static_cast<T>(std::cos(radians) * this->y +
                             std::sin(radians) * this->z);
    this->z = static_cast<T>(-std::sin(radians) * this->y +
                             std::cos(radians) * this->z);
}

/// rotate this vector on the Y axis
template <typename T>
inline void vec3<T>::rotateY(D64 radians) {
    this->x = static_cast<T>(std::cos(radians) * this->x -
                             std::sin(radians) * this->z);
    this->z = static_cast<T>(std::sin(radians) * this->x +
                             std::cos(radians) * this->z);
}

/// rotate this vector on the Z axis
template <typename T>
inline void vec3<T>::rotateZ(D64 radians) {
    this->x = static_cast<T>(std::cos(radians) * this->x +
                             std::sin(radians) * this->y);
    this->y = static_cast<T>(-std::sin(radians) * this->x +
                             std::cos(radians) * this->y);
}

/// round all three values
template <typename T>
inline void vec3<T>::round() {
    set(static_cast<T>(std::roundf(this->x)),
        static_cast<T>(std::roundf(this->y)),
        static_cast<T>(std::roundf(this->z)));
}

/// swap the components  of this vector with that of the specified one
template <typename T>
inline void vec3<T>::swap(vec3 &iv) {
    std::swap(this->x, iv.x);
    std::swap(this->y, iv.y);
    std::swap(this->z, iv.z);
}

/// swap the components  of this vector with that of the specified one
template <typename T>
inline void vec3<T>::swap(vec3 *iv) {
    std::swap(this->x, iv->x);
    std::swap(this->y, iv->y);
    std::swap(this->z, iv->z);
}

/// export the vector's components in the first 3 positions of the specified
/// array
template <typename T>
inline void vec3<T>::get(T *v) const {
    v[0] = static_cast<T>(this->_v[0]);
    v[1] = static_cast<T>(this->_v[1]);
    v[2] = static_cast<T>(this->_v[2]);
}

/// this calculates a vector between the two specified points and returns the
/// result
template <typename T>
inline vec3<T> vec3<T>::vector(const vec3 &vp1, const vec3 &vp2) const {
    return vec3(vp1.x - vp2.x, vp1.y - vp2.y, vp1.z - vp2.z);
}

/// return the closest point on the line defined by the 2 points (A, B) and this
/// vector
template <typename T>
inline vec3<T> vec3<T>::closestPointOnLine(const vec3 &vA, const vec3 &vB) {
    return (((vB - vA) * this->projectionOnLine(vA, vB)) + vA);
}

/// return the closest point on the line segment created between the 2 points
/// (A, B) and this vector
template <typename T>
inline vec3<T> vec3<T>::closestPointOnSegment(const vec3 &vA, const vec3 &vB) {
    T factor = this->projectionOnLine(vA, vB);

    if (factor <= 0.0f) return vA;

    if (factor >= 1.0f) return vB;

    return (((vB - vA) * factor) + vA);
}

/// lerp between the 2 specified vectors by the specified amount
template <typename T, typename U>
inline vec3<T> Lerp(const vec3<T> &u, const vec3<T> &v, U factor) {
    return ((u * (1 - factor)) + (v * factor));
}

/// lerp between the 2 specified vectors by the specified amount for each
/// component
template <typename T>
inline vec3<T> Lerp(const vec3<T> &u, const vec3<T> &v, const vec3<T> &factor) {
    return (vec3<T>((u.x * (1 - factor.x)) + (v.x * factor.x),
                    (u.y * (1 - factor.y)) + (v.y * factor.y),
                    (u.z * (1 - factor.z)) + (v.z * factor.z)));
}
/*
*  vec4 inline definitions
*/

/// compare 2 vectors
template <typename T>
template <typename U>
inline bool vec4<T>::compare(const vec4<U> &v) const {
    return COMPARE(this->x, v.x) &&
           COMPARE(this->y, v.y) &&
           COMPARE(this->z, v.z) &&
           COMPARE(this->w, v.w);
}

/// compare this vector with the one specified and see if they match within the
/// specified amount
template <typename T>
template <typename U>
inline bool vec4<T>::compare(const vec4<U> &v, T epsi) const {
    return (COMPARE_TOLERANCE(this->x, v.x, epsi) &&
            COMPARE_TOLERANCE(this->y, v.y, epsi) &&
            COMPARE_TOLERANCE(this->z, v.z, epsi) &&
            COMPARE_TOLERANCE(this->w, v.w, epsi));
}

/// round all four values
template <typename T>
inline void vec4<T>::round() {
    set((T)std::roundf(this->x), (T)std::roundf(this->y),
        (T)std::roundf(this->z), (T)std::roundf(this->w));
}

/// swap this vector's values with that of the specified vector
template <typename T>
inline void vec4<T>::swap(vec4 *iv) {
    std::swap(this->x, iv->x);
    std::swap(this->y, iv->y);
    std::swap(this->z, iv->z);
    std::swap(this->w, iv->w);
}

/// swap this vector's values with that of the specified vector
template <typename T>
inline void vec4<T>::swap(vec4 &iv) {
    std::swap(this->x, iv.x);
    std::swap(this->y, iv.y);
    std::swap(this->z, iv.z);
    std::swap(this->w, iv.w);
}

/// general vec4 dot product
template <typename T>
inline T Dot(const vec4<T> &a, const vec4<T> &b) {
    return (a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w);
}

/// calculate the dot product between this vector and the specified one
template <typename T>
inline T vec4<T>::dot(const vec4 &v) const {
    return Divide::Dot(*this, v);
}

/// return the squared distance of the vector
template <typename T>
inline T vec4<T>::lengthSquared() const {
    return this->x * this->x + this->y * this->y + this->z * this->z +
           this->w * this->w;
}
/// transform the vector to unit length
template <typename T>
inline T vec4<T>::normalize() {
    T l = this->length();

    if (l < EPSILON_F32) return 0;

    // multiply by the inverse length
    *this *= (1.0f / l);

    return l;
}
/// lerp between this and the specified vector by the specified amount
template <typename T>
inline void vec4<T>::lerp(const vec4 &v, T factor) {
    set((*this * (1 - factor)) + (v * factor));
}

/// lerp between this and the specified vector by the specified amount for each
/// component
template <typename T>
inline void vec4<T>::lerp(const vec4 &v, const vec4 &factor) {
    set((*this * (1 - factor)) + (v * factor));
}
/// lerp between the 2 vectors by the specified amount
template <typename T>
inline vec4<T> Lerp(const vec4<T> &u, const vec4<T> &v, T factor) {
    return ((u * (1 - factor)) + (v * factor));
}

/// lerp between the 2 specified vectors by the specified amount for each
/// component
template <typename T>
inline vec4<T> Lerp(const vec4<T> &u, const vec4<T> &v, const vec4<T> &factor) {
    return (vec4<T>((u.x * (1 - factor.x)) + (v.x * factor.x),
                    (u.y * (1 - factor.y)) + (v.y * factor.y),
                    (u.z * (1 - factor.z)) + (v.z * factor.z),
                    (u.w * (1 - factor.w)) + (v.w * factor.w)));
}

template <typename Type>
inline vec2<Type> Random(const vec2<Type>& min, const vec2<Type>& max) {
    return vec2<Type>(Random(min.x, max.x), Random(min.y, max.y));
}

template <typename Type>
inline vec3<Type> Random(const vec3<Type>& min, const vec3<Type>& max) {
    return vec3<Type>(Random(min.x, max.x), Random(min.y, max.y),
                      Random(min.z, max.z));
}

template <typename Type>
inline vec4<Type> Random(const vec4<Type>& min, const vec4<Type>& max) {
    return vec4<Type>(Random(min.x, max.x), Random(min.y, max.y),
                      Random(min.z, max.z), Random(min.w, max.w));
}
/*
template<>
const vec4<F32> vec4<F32>::operator-(F32 _f) const {
    return vec4<F32>(simd_vector<F32>(_mm_sub_ps(this->_reg._reg, _mm_set1_ps(_f))));
}

template<>
const vec4<F32> vec4<F32>::operator+(F32 _f) const {
    return vec4<F32>(simd_vector<F32>(_mm_add_ps(this->_reg._reg, _mm_set1_ps(_f))));
}

template<>
const vec4<F32> vec4<F32>::operator*(F32 _f) const {
    return vec4<F32>(simd_vector<F32>(_mm_mul_ps(this->_reg._reg, _mm_set1_ps(_f))));
}

template<>
const vec4<F32> vec4<F32>::operator/(F32 _f) const {
    if (IS_ZERO(_f)) {
        return *this;
    }

    return vec4<F32>(simd_vector<F32>(_mm_div_ps(this->_reg._reg, _mm_set1_ps(_f))));
}

template<>
const vec4<F32> vec4<F32>::operator+(const vec4<F32> &v) const {
    return vec4<F32>(simd_vector<F32>(_mm_add_ps(this->_reg._reg, v._reg._reg)));
}

template<>
const vec4<F32> vec4<F32>::operator-(const vec4<F32> &v) const {
    return vec4<F32>(simd_vector<F32>(_mm_sub_ps(this->_reg._reg, v._reg._reg)));
}

template<>
const vec4<F32> vec4<F32>::operator/(const vec4<F32> &v) const {
    return vec4<F32>(simd_vector<F32>(_mm_div_ps(this->_reg._reg, v._reg._reg)));
}

template<>
const vec4<F32> vec4<F32>::operator*(const vec4<F32> &v) const {
    return vec4<F32>(simd_vector<F32>(_mm_mul_ps(this->_reg._reg, v._reg._reg)));
}

template<>
vec4<F32>& vec4<F32>::operator*=(const vec4<F32> &v) {
    this->_reg._reg = _mm_mul_ps(this->_reg._reg, v._reg._reg);
    return *this;
}

template<>
vec4<F32>& vec4<F32>::operator/=(const vec4<F32> &v) {
    this->_reg._reg = _mm_div_ps(this->_reg._reg, v._reg._reg);
    return *this;
}

template<>
vec4<F32>& vec4<F32>::operator+=(const vec4<F32> &v) {
    this->_reg._reg = _mm_add_ps(this->_reg._reg, v._reg._reg);
    return *this;
}

template<>
vec4<F32>& vec4<F32>::operator-=(const vec4<F32> &v) {
    this->_reg._reg = _mm_sub_ps(this->_reg._reg, v._reg._reg);
    return *this;
}

template<>
inline void vec4<F32>::setV(const F32 *v) {
    this->_reg._reg = _mm_load_ps(v);
}
*/
};  // namespace Divide
#endif

Commits for Divide-Framework/trunk/Source Code/Core/Math/Headers/MathVectors.inl

Diff revisions: vs.
Revision Author Commited Message
853 Diff Diff IonutCava picture IonutCava Tue 07 Feb, 2017 21:43:58 +0000

[IonutCava]
- More work on water rendering.

836 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice

828 Diff Diff IonutCava picture IonutCava Mon 23 Jan, 2017 17:19:22 +0000

[Ionut]
- XML loading/saving cleanup PART I

687 Diff Diff IonutCava picture IonutCava Thu 21 Apr, 2016 20:44:41 +0000

[IonutCava]
- Fix stack overflow issue with SGN relationship cache invalidation
- Code cleanup

680 Diff Diff IonutCava picture IonutCava Thu 14 Apr, 2016 16:15:38 +0000

[IonutCava]
- Added a mat2 class (untested)
- Added static asserts to matrices, vectors and quaternions to allow only arithmetic (sans bool) data types
- Added more vector unit tests
- Added unit tests for matrices
- D32 finally renamed to D64 as the VC++ compiler is considered as the reference compiler

648 Diff Diff IonutCava picture IonutCava Sun 21 Feb, 2016 16:32:52 +0000

[IonutCava]
- Update copyright notice
- Move BoundingBox and BoundingSphere to a new BoundsComponent
— Add a temp hack in SceneGraphNode to update these

565 Diff Diff IonutCava picture IonutCava Fri 13 Nov, 2015 16:39:03 +0000

[IonutCava]
- Implemented SSE functionality to the float specializations of vec4 and mat4 (some scalar operations are still used for now)
- Cleaned up some redundant static casts

548 Diff Diff IonutCava picture IonutCava Wed 04 Nov, 2015 17:23:15 +0000

[IonutCava]
- More work on improving cascaded shadow maps

502 Diff Diff IonutCava picture IonutCava Sun 23 Aug, 2015 18:03:16 +0000

[IonutCava]
- Micro-optimise the rendering path (faster compares, less stack allocation, etc)

469 IonutCava picture IonutCava Tue 09 Jun, 2015 15:19:29 +0000

[Ionut]
- Particle system updates