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
694
695
696
697
/***************************************************************************
 * Mathlib
 *
 * Copyright (C) 2003-2004, Alexander Zaprjagaev <frustum@frustum.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 ***************************************************************************
 * Update 2004/08/19
 *
 * added ivec2, ivec3 & ivec4 methods
 * vec2, vec3 & vec4 data : added texture coords (s,t,p,q) and colour enums
 *(r,g,b,a)
 * mat3 & mat4 : added multiple float constructor ad modified methods returning
 *mat3 or mat4
 * optimisations like "x / 2.0f" replaced by faster "x * 0.5f"
 * defines of multiples usefull maths values and radian/degree conversions
 * vec2 : added methods : set, reset, compare, dot, closestPointOnLine,
 *closestPointOnSegment,
 *                        projectionOnLine, lerp, angle
 * vec3 : added methods : set, reset, compare, dot, cross, closestPointOnLine,
 *closestPointOnSegment,
 *                        projectionOnLine, lerp, angle
 * vec4 : added methods : set, reset, compare
 ***************************************************************************
 */
 /*
 *
 * MathLibrary
 * Copyright (c) 2011 NoLimitsDesigns
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the copyright holders nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.

 * If there are any concerns or questions about the code, please e-mail
smasherprog@gmail.com or visit www.nolimitsdesigns.com
 */

/*
 * Author: Scott Lee
 */

/*
   Copyright (c) 2018 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 _MATH_MATRICES_H_
#define _MATH_MATRICES_H_

#include "Plane.h"

namespace Divide {

/*********************************
* mat2
*********************************/
template <typename T>
class mat2 {
    // m0  m1
    // m2  m3
    static_assert(std::is_arithmetic<T>::value &&
        !std::is_same<T, bool>::value,
        "non-arithmetic matrix type");
public:
    mat2() noexcept;
    template<typename U>
    mat2(U m) noexcept;
    template<typename U>
    mat2(U m0, U m1,
         U m2, U m3) noexcept;
    template<typename U>
    mat2(const U *m) noexcept;
    mat2(const mat2 &B) noexcept;
    template<typename U>
    mat2(const mat2<U> &B) noexcept;
    template<typename U>
    mat2(const mat3<U> &B) noexcept;
    template<typename U>
    mat2(const mat4<U> &B) noexcept;

    mat2 &operator=(const mat2& other) noexcept;
    template<typename U>
    mat2 &operator=(const mat2<U>& other) noexcept;

    template<typename U>
    vec2<T> operator*(const vec2<U> &v) const;
    template<typename U>
    vec3<T> operator*(const vec3<U> &v) const;
    template<typename U>
    vec4<T> operator*(const vec4<U> &v) const;

    template<typename U>
    mat2 operator*(const mat2<U> &B) const;
    template<typename U>
    mat2 operator/(const mat2<U> &B) const;
    template<typename U>
    mat2 operator+(const mat2<U> &B) const;
    template<typename U>
    mat2 operator-(const mat2<U> &B) const;

    template<typename U>
    mat2 &operator*=(const mat2<U> &B);
    template<typename U>
    mat2 &operator/=(const mat2<U> &B);
    template<typename U>
    mat2 &operator+=(const mat2<U> &B);
    template<typename U>
    mat2 &operator-=(const mat2<U> &B);

    template<typename U>
    mat2 operator*(U f) const;
    template<typename U>
    mat2 operator/(U f) const;
    template<typename U>
    mat2 operator+(U f) const;
    template<typename U>
    mat2 operator-(U f) const;

    template<typename U>
    mat2 &operator*=(U f);
    template<typename U>
    mat2 &operator/=(U f);
    template<typename U>
    mat2 &operator+=(U f);
    template<typename U>
    mat2 &operator-=(U f);

    bool operator==(const mat2 &B) const;
    bool operator!=(const mat2 &B) const;
    template<typename U>
    bool operator==(const mat2<U> &B) const;
    template<typename U>
    bool operator!=(const mat2<U> &B) const;

    bool compare(const mat2 &B, F32 epsilon) const;
    template<typename U>
    bool compare(const mat2<U> &B, F32 epsilon) const;

    operator T *();
    operator const T *() const;

    T &operator[](I32 i);
    const T operator[](I32 i) const;

    T &element(I8 row, I8 column);
    const T &element(I8 row, I8 column) const;

    template<typename U>
    void set(U m0, U m1, U m2, U m3);
    template<typename U>
    void set(const U *matrix);
    template<typename U>
    void set(const mat2<U> &matrix);
    template<typename U>
    void set(const mat3<U> &matrix);
    template<typename U>
    void set(const mat4<U> &matrix);

    template<typename U>
    void setRow(I32 index, const U value);
    template<typename U>
    void setRow(I32 index, const vec2<U> &value);
    template<typename U>
    void setRow(I32 index, const U x, const U y);
    const vec2<T>& getRow(I32 index) const;

    template<typename U>
    void setCol(I32 index, const vec2<U> &value);
    template<typename U>
    void setCol(I32 index, const U value);
    template<typename U>
    void setCol(I32 index, const U x, const U y);

    vec2<T> getCol(I32 index) const;

    void zero();
    void identity();
    bool isIdentity() const;
    void swap(mat2 &B);

    T det() const;
    T elementSum() const;
    void inverse();
    void transpose();
    void inverseTranspose();

    mat2 getInverse() const;
    void getInverse(mat2 &ret) const;

    mat2 getTranspose() const;
    void getTranspose(mat2 &ret) const;

    mat2 getInverseTranspose() const;
    void getInverseTranspose(mat2 &ret) const;

    union {
        struct {
            T _11, _12;
            T _21, _22;
        };
        T mat[4];
        T m[2][2];
        vec2<T> _vec[2];
    };
};

/*********************************
 * mat3
 *********************************/
template <typename T>
class mat3 {
    // m0 m1 m2
    // m3 m4 m5
    // m7 m8 m9
    static_assert(std::is_arithmetic<T>::value && 
                  !std::is_same<T, bool>::value,
                  "non-arithmetic matrix type");
   public:
    mat3() noexcept;
    template<typename U>
    mat3(U m) noexcept;
    template<typename U>
    mat3(U m0, U m1, U m2,
         U m3, U m4, U m5,
         U m6, U m7, U m8) noexcept;
    template<typename U>
    mat3(const U *m) noexcept;
    template<typename U>
    mat3(const mat2<U> &B, bool zeroFill) noexcept;
    mat3(const mat3 &B) noexcept;
    template<typename U>
    mat3(const mat3<U> &B) noexcept;
    template<typename U>
    mat3(const mat4<U> &B) noexcept;

    mat3 &operator=(const mat3& other) noexcept;
    template<typename U>
    mat3 &operator=(const mat3<U>& other) noexcept;

    template<typename U>
    vec2<U> operator*(const vec2<U> &v) const;
    template<typename U>
    vec3<U> operator*(const vec3<U> &v) const;
    template<typename U>
    vec4<U> operator*(const vec4<U> &v) const; 

    template<typename U>
    mat3 operator*(const mat3<U> &B) const;
    template<typename U>
    mat3 operator/(const mat3<U> &B) const;
    template<typename U>
    mat3 operator+(const mat3<U> &B) const;
    template<typename U>
    mat3 operator-(const mat3<U> &B) const;

    template<typename U>
    mat3 &operator*=(const mat3<U> &B);
    template<typename U>
    mat3 &operator/=(const mat3<U> &B);
    template<typename U>
    mat3 &operator+=(const mat3<U> &B);
    template<typename U>
    mat3 &operator-=(const mat3<U> &B);

    template<typename U>
    mat3 operator*(U f) const;
    template<typename U>
    mat3 operator/(U f) const;
    template<typename U>
    mat3 operator+(U f) const;
    template<typename U>
    mat3 operator-(U f) const;

    template<typename U>
    mat3 &operator*=(U f);
    template<typename U>
    mat3 &operator/=(U f);
    template<typename U>
    mat3 &operator+=(U f);
    template<typename U>
    mat3 &operator-=(U f);

    bool operator==(const mat3 &B) const;
    bool operator!=(const mat3 &B) const;

    template<typename U>
    bool operator==(const mat3<U> &B) const;
    template<typename U>
    bool operator!=(const mat3<U> &B) const;

    bool compare(const mat3 &B, F32 epsilon) const;
    template<typename U>
    bool compare(const mat3<U> &B, F32 epsilon) const;

    operator T *();
    operator const T *() const;

    T &operator[](I32 i);
    const T operator[](I32 i) const noexcept;

    T &element(I8 row, I8 column);
    const T &element(I8 row, I8 column) const;

    template<typename U>
    void set(U m0, U m1, U m2, U m3, U m4, U m5, U m6, U m7, U m8);
    template<typename U>
    void set(const U *matrix);
    template<typename U>
    void set(const mat2<U> &matrix);
    template<typename U>
    void set(const mat3<U> &matrix);
    template<typename U>
    void set(const mat4<U> &matrix);

    template<typename U>
    void setRow(I32 index, const U value);
    template<typename U>
    void setRow(I32 index, const vec3<U> &value);
    template<typename U>
    void setRow(I32 index, const U x, const U y, const U z);

    const vec3<T>& getRow(I32 index) const;

    template<typename U>
    void setCol(I32 index, const vec3<U> &value);
    template<typename U>
    void setCol(I32 index, const U value);
    template<typename U>
    void setCol(I32 index, const U x, const U y, const U z);

    vec3<T> getCol(I32 index) const;

    void zero();
    void identity();
    bool isIdentity() const;
    void swap(mat3 &B);

    T det() const;
    T elementSum() const;
    void inverse();
    void transpose();
    void inverseTranspose();

    mat3 getInverse() const;
    void getInverse(mat3 &ret) const;

    mat3 getTranspose() const;
    void getTranspose(mat3 &ret) const;

    mat3 getInverseTranspose() const;
    void getInverseTranspose(mat3 &ret) const;

    template<typename U>
    void fromRotation(const vec3<U> &v, Angle::RADIANS<U> angle);
    template<typename U>
    void fromRotation(U x, U y, U z, Angle::RADIANS<U> angle);
    template<typename U>
    void fromXRotation(Angle::RADIANS<U> angle);
    template<typename U>
    void fromYRotation(Angle::RADIANS<U> angle);
    template<typename U>
    void fromZRotation(Angle::RADIANS<U> angle);

    // setScale replaces the main diagonal!
    template<typename U>
    inline void setScale(U x, U y, U z);
    template<typename U>
    void setScale(const vec3<U> &v);

    void orthonormalize();

    union {
        struct {
            T _11, _12, _13;  // standard names for components
            T _21, _22, _23;  // standard names for components
            T _31, _32, _33;  // standard names for components
        };
        T mat[9];
        T m[3][3];
        vec3<T> _vec[3];
    };
};

/***************
 * mat4
 ***************/
template <typename T>
class mat4 : public std::conditional<std::is_same<T, F32>::value, alligned_base<16>, non_aligned_base>::type {
    // m0  m1  m2  m3
    // m4  m5  m6  m7
    // m8  m9  m10 m11
    // m12 m13 m14 m15
    static_assert(std::is_arithmetic<T>::value &&
                  !std::is_same<T, bool>::value,
                  "non-arithmetic matrix type");
   public:
    mat4() noexcept;
    template<typename U>
    mat4(U m) noexcept;
    template<typename U>
    mat4(U m0,  U m1,  U m2,  U m3,
         U m4,  U m5,  U m6,  U m7,
         U m8,  U m9,  U m10, U m11,
         U m12, U m13, U m14, U m15) noexcept;
    template<typename U>
    mat4(const U *m) noexcept;
    template<typename U>
    mat4(const mat2<U> &B, bool zeroFill) noexcept;
    template<typename U>
    mat4(const mat3<U> &B, bool zeroFill) noexcept;
    mat4(const mat4 &B) noexcept;
    template<typename U>
    mat4(const mat4<U> &B) noexcept;
    template<typename U>
    mat4(const vec3<U> &translation, const vec3<U> &scale) noexcept;
    template<typename U>
    mat4(const vec3<U> &translation, const vec3<U> &scale, const mat4<U>& rotation) noexcept;
    template<typename U>
    mat4(const vec3<U> &translation) noexcept;
    template<typename U>
    mat4(U translationX, U translationY, U translationZ) noexcept;
    template<typename U>
    mat4(const vec3<U> &axis, Angle::RADIANS<U> angle) noexcept;
    template<typename U>
    mat4(U x, U y, U z, Angle::RADIANS<U> angle) noexcept;
    template<typename U>
    mat4(const vec3<U> &eye, const vec3<U> &target, const vec3<U> &up) noexcept;
    template<typename U>
    mat4(const Plane<U>& reflectionPlane) noexcept;

    mat4 &operator=(const mat4& other) noexcept;
    template<typename U>
    mat4 &operator=(const mat4<U>& other) noexcept;

    template<typename U>
    vec2<U> operator*(const vec2<U> &v) const;
    template<typename U>
    vec3<U> operator*(const vec3<U> &v) const;
    template<typename U>
    vec4<U> operator*(const vec4<U> &v) const;

    template<typename U>
    mat4 operator*(const mat4<U>& matrix) const;
    template<typename U>
    mat4 operator/(const mat4<U>& matrix) const;
    template<typename U>
    mat4 operator+(const mat4<U> &matrix) const;
    template<typename U>
    mat4 operator-(const mat4<U> &matrix) const;

    template<typename U>
    mat4 &operator*=(const mat4<U> &matrix);
    template<typename U>
    mat4 &operator/=(const mat4<U> &matrix);
    template<typename U>
    mat4 &operator+=(const mat4<U> &matrix);
    template<typename U>
    mat4 &operator-=(const mat4<U> &matrix);

    template<typename U>
    mat4 operator*(U f) const;
    template<typename U>
    mat4 operator/(U f) const;
    template<typename U>
    mat4 operator+(U f) const;
    template<typename U>
    mat4 operator-(U f) const;
    template<typename U>
    mat4 &operator*=(U f);
    template<typename U>
    mat4 &operator/=(U f);

    bool operator==(const mat4& B) const;
    bool operator!=(const mat4 &B) const;
    template<typename U>
    bool operator==(const mat4<U>& B) const;
    template<typename U>
    bool operator!=(const mat4<U> &B) const;

    bool compare(const mat4 &B, F32 epsilon) const;
    template<typename U>
    bool compare(const mat4<U> &B, F32 epsilon) const;

    operator T *();
    operator const T *() const;

    T &operator[](I32 i) noexcept;
    const T &operator[](I32 i) const noexcept;

    T &element(I8 row, I8 column);
    const T &element(I8 row, I8 column) const;

    template<typename U>
    void set(U m0, U m1, U m2, U m3, U m4, U m5, U m6, U m7, U m8, U m9, U m10, U m11, U m12, U m13, U m14, U m15) noexcept;
    template<typename U>
    void set(U const *matrix);
    template<typename U>
    void set(const mat2<U> &matrix);
    template<typename U>
    void set(const mat3<U> &matrix);
    template<typename U>
    void set(const mat4<U> &matrix);
    template<typename U>
    void set(const vec3<U> &translation, const vec3<U> &scale, const mat4<U>& rotation);

    template<typename U>
    void setRow(I32 index, const U value);
    template<typename U>
    void setRow(I32 index, const vec4<U> &value);
    template<typename U>
    void setRow(I32 index, const U x, const U y, const U z, const U w);

    const vec4<T>& getRow(I32 index) const;

    template<typename U>
    void setCol(I32 index, const vec4<U> &value);
    template<typename U>
    void setCol(I32 index, const U value);
    template<typename U>
    void setCol(I32 index, const U x, const U y, const U z, const U w);

    vec4<T> getCol(I32 index) const;

    void zero();
    void identity();
    bool isIdentity() const;
    void swap(mat4 &B);

    T det() const noexcept;
    T elementSum() const;
    void inverse();
    void transpose();
    void inverseTranspose();
    mat4 transposeRotation() const;

    mat4 getInverse() const;
    void getInverse(mat4 &ret) const;

    mat4 getTranspose() const;
    void getTranspose(mat4 &out) const;

    mat4 getInverseTranspose() const;
    void getInverseTranspose(mat4 &ret) const;

    mat4 getTransposeRotation() const;
    void getTransposeRotation(mat4 &ret) const;

    template<typename U>
    void fromRotation(U x, U y, U z, Angle::RADIANS<U> angle);
    template<typename U>
    void fromXRotation(Angle::RADIANS<U> angle);
    template<typename U>
    void fromYRotation(Angle::RADIANS<U> angle);
    template<typename U>
    void fromZRotation(Angle::RADIANS<U> angle);

    template<typename U>
    void setTranslation(const vec3<U> &v);
    template<typename U>
    void setTranslation(U x, U y, U z) noexcept;

    template<typename U>
    void setScale(U x, U y, U z) noexcept;
    template<typename U>
    void setScale(const vec3<U> &v);
    
    template<typename U>
    vec3<U> transform(const vec3<U> &v, bool homogeneous) const;
    template<typename U>
    vec3<U> transformHomogeneous(const vec3<U> &v) const;
    template<typename U>
    vec3<U> transformNonHomogeneous(const vec3<U> &v) const;
       
    template<typename U>
    void translate(const vec3<U> &v);
    template<typename U>
    void translate(U x, U y, U z);

    template<typename U>
    void scale(const vec3<U> &v);
    template<typename U>
    void scale(U x, U y, U z);

    template<typename U>
    vec3<U> getTranslation() const;
    mat4 getRotation(void) const;

    template<typename U>
    const mat4& reflect(U x, U y, U z, U w);
    template<typename U>
    const mat4& reflect(const Plane<U> &plane);

    template<typename U>
    void lookAt(const vec3<U> &eye, const vec3<U> &target, const vec3<U> &up);
    template<typename U>
    void ortho(U left, U right, U bottom, U top, U zNear, U zFar);
    template<typename U>
    void perspective(Angle::DEGREES<U> fovyRad, U aspect, U zNear, U zFar);
    template<typename U>
    void frustum(U left, U right, U bottom, U top, U nearVal, U farVal);

    template<typename U>
    void extractMat3(mat3<U> &matrix3) const;

    static void Multiply(const mat4<T>& matrixA, const mat4<T>& matrixB, mat4<T>& ret);

    // Copyright 2011 The Closure Library Authors. All Rights Reserved.
    static void Inverse(const T* in, T* out);

    union {
        struct {
            T _11, _12, _13, _14;  // standard names for components
            T _21, _22, _23, _24;  // standard names for components
            T _31, _32, _33, _34;  // standard names for components
            T _41, _42, _43, _44;  // standard names for components
        };
        T mat[16];
        T m[4][4];
        simd_vector<T> _reg[4];
        vec4<T> _vec[4];
    };
};

extern mat2<F32> MAT2_BIAS;
extern mat3<F32> MAT3_BIAS;
extern mat4<F32> MAT4_BIAS;

extern mat2<F32> MAT2_IDENTITY;
extern mat3<F32> MAT3_IDENTITY;
extern mat4<F32> MAT4_IDENTITY;

};  // namespace Divide

#endif //_MATH_MATRICES_H_

#include "MathMatrices.inl"

Commits for Divide-Framework/trunk/Source Code/Core/Math/Headers/MathMatrices.h

Diff revisions: vs.
Revision Author Commited Message
1029 Diff Diff IonutCava picture IonutCava Tue 30 Jan, 2018 17:28:39 +0000

[Ionut]
- Update copyright notices

993 Diff Diff IonutCava picture IonutCava Sun 10 Dec, 2017 20:07:57 +0000

[Ionut]
- Finished initial port of the old scene graph system to the new ECS based system.
- Finished converting 2 components to the new ECS system: Transform and RigidBody
- Fixed the “Deploy” build error with the CEGUI OpenGL renderer.
- Compilation now needs C++14 support (it’s sufficiently wide-spread now)

877 Diff Diff IonutCava picture IonutCava Thu 16 Mar, 2017 21:55:59 +0000

[IonutCava]
- Reflection updates
- Sky parallax fixes
- Initial support for Tessellation patches (used by the new terrain system – W.I.P.)

869 Diff Diff IonutCava picture IonutCava Sun 26 Feb, 2017 23:25:54 +0000

[IonutCava]
- Reduce loading time using profile guided optimizations
- Camera/Quaternion work in an attempt to fix a weird Yaw-rotation bug.

868 Diff Diff IonutCava picture IonutCava Sat 25 Feb, 2017 21:46:55 +0000

[IonutCava]
- Fix buggy SSE Quaternion math
- Fix some typos and naming issues

867 Diff Diff IonutCava picture IonutCava Mon 20 Feb, 2017 17:01:12 +0000

[IonutCava]
- Rename to_XNN and to_const_XNN functions to reflect the target data type they are converting to.
- Cleanup Angle namespace and remove all “inDegrees” parameters from rotation functions. Use aliases to differentiate between Degree and Radian parameters.
- Profile guided optimizations.

864 Diff Diff IonutCava picture IonutCava Thu 16 Feb, 2017 17:29:19 +0000

[IonutCava]
- Profile guided optimizations

843 Diff Diff IonutCava picture IonutCava Thu 02 Feb, 2017 17:03:33 +0000

[IonutCava]
- Add more matrix unit tests and fix discovered bugs
- Fix compile warning in ShaderProgram
- Rework script function binding and add unit test for this usecase

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

[IonutCava]
- Update copyright notice

790 IonutCava picture IonutCava Wed 02 Nov, 2016 17:06:20 +0000

[IonutCava]
- Fix a few crashes:
— Missing language file during startup causes crash instead of log + exit
— Closing application causes crash due to RenderTarget cleanup of the GPU Object arena
-— Still not fully fixed: leaking graphics resources on shutdown
- Make mat and vec constructors and assignment operators “noexcept” (helps with usage in containers)
- Add a “NonMovable” class, similar to the “NonCopyable” class to help with readability in certain situations