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
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
/***************************************************************************
 * 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 color 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) 2013 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_CLASSES_H_
#define _MATH_CLASSES_H_

#include "config.h"
#define USE_SIMD_HEADER
#define EPSILON				0.000001f
#ifndef M_PI
#define M_PI				3.141592653589793238462643383279f		//  PI
#endif

#include "Plane.h"
#include "MathVectors.h"

/******************************//**
/* mat3
/*********************************/
template<class T>
class mat3 {
public:
	mat3() {
		mat[0] = 1.0; mat[3] = 0.0; mat[6] = 0.0;
		mat[1] = 0.0; mat[4] = 1.0; mat[7] = 0.0;
		mat[2] = 0.0; mat[5] = 0.0; mat[8] = 1.0;
	}
	mat3(T m0, T m1, T m2,
		 T m3, T m4, T m5,
		 T m6, T m7, T m8) {
		mat[0] = m0; mat[3] = m3; mat[6] = m6;
		mat[1] = m1; mat[4] = m4; mat[7] = m7;
		mat[2] = m2; mat[5] = m5; mat[8] = m8;
	}
	mat3(const T *m) {
		mat[0] = m[0]; mat[3] = m[3]; mat[6] = m[6];
		mat[1] = m[1]; mat[4] = m[4]; mat[7] = m[7];
		mat[2] = m[2]; mat[5] = m[5]; mat[8] = m[8];
	}
	mat3(const mat3 &m) {
		mat[0] = m[0]; mat[3] = m[3]; mat[6] = m[6];
		mat[1] = m[1]; mat[4] = m[4]; mat[7] = m[7];
		mat[2] = m[2]; mat[5] = m[5]; mat[8] = m[8];
	}
	mat3(const mat4<T> &m);

	vec3<T> operator*(const vec3<T> &v) const {
		return vec3<T>(mat[0] * v[0] + mat[3] * v[1] + mat[6] * v[2],
					   mat[1] * v[0] + mat[4] * v[1] + mat[7] * v[2],
					   mat[2] * v[0] + mat[5] * v[1] + mat[8] * v[2]);
	}

	vec4<T> operator*(const vec4<T> &v) const {
		return vec4<T>(mat[0] * v[0] + mat[3] * v[1] + mat[6] * v[2],
					   mat[1] * v[0] + mat[4] * v[1] + mat[7] * v[2],
					   mat[2] * v[0] + mat[5] * v[1] + mat[8] * v[2],
					   v[3]);
	}
	mat3 operator*(T f) const {
		return mat3(mat[0] * f, mat[1] * f, mat[2] * f,
					mat[3] * f,	mat[4] * f,	mat[5] * f,
					mat[6] * f,	mat[7] * f,	mat[8] * f);
	}
	mat3 operator*(const mat3 &m) const {
		return mat3(mat[0] * m[0] + mat[3] * m[1] + mat[6] * m[2],
					mat[1] * m[0] + mat[4] * m[1] + mat[7] * m[2],
					mat[2] * m[0] + mat[5] * m[1] + mat[8] * m[2],
					mat[0] * m[3] + mat[3] * m[4] + mat[6] * m[5],
					mat[1] * m[3] + mat[4] * m[4] + mat[7] * m[5],
					mat[2] * m[3] + mat[5] * m[4] + mat[8] * m[5],
					mat[0] * m[6] + mat[3] * m[7] + mat[6] * m[8],
					mat[1] * m[6] + mat[4] * m[7] + mat[7] * m[8],
					mat[2] * m[6] + mat[5] * m[7] + mat[8] * m[8]);
	}
	mat3 operator+(const mat3 &m) const {
		return mat3(mat[0] + m[0], mat[1] + m[1], mat[2] + m[2],
					mat[3] + m[3], mat[4] + m[4], mat[5] + m[5],
					mat[6] + m[6], mat[7] + m[7], mat[8] + m[8]);
	}
	mat3 operator-(const mat3 &m) const {
		return mat3(mat[0] - m[0], mat[1] - m[1], mat[2] - m[2],
					mat[3] - m[3], mat[4] - m[4], mat[5] - m[5],
					mat[6] - m[6], mat[7] - m[7], mat[8] - m[8]);
	}

	mat3 &operator*=(T f) { return *this = *this * f; }
	mat3 &operator*=(const mat3 &m) { return *this = *this * m; }
	mat3 &operator+=(const mat3 &m) { return *this = *this + m; }
	mat3 &operator-=(const mat3 &m) { return *this = *this - m; }

	bool operator == (mat3& B){
        for (I32 i = 0; i < 9; i++){
            if (!FLOAT_COMPARE(this->m[i],B[i])) return false;
        }
        return true;
    }

    bool operator != (mat3& B){ return !(*this == B);}

	operator T*()             { return this->mat; }
	operator const T*() const { return this->mat; }

	T &operator[](I8 i)             { return this->mat[i]; }
	const T operator[](I32 i) const { return this->mat[i]; }

	inline void set(T m0, T m1, T m2,
					T m3, T m4, T m5,
					T m6, T m7, T m8) {
		this->mat[0] = m0; this->mat[3] = m3; this->mat[6] = m6;
		this->mat[1] = m1; this->mat[4] = m4; this->mat[7] = m7;
		this->mat[2] = m2; this->mat[5] = m5; this->mat[8] = m8;
	}

	inline void set(const T *m) {
		memcpy(this->mat, m, sizeof(T) * 9);
		/*
		this->mat[0] = m[0]; this->mat[3] = m[3]; this->mat[6] = m[6];
		this->mat[1] = m[1]; this->mat[4] = m[4]; this->mat[7] = m[7];
		this->mat[2] = m[2]; this->mat[5] = m[5]; this->mat[8] = m[8];
		*/
	}

	inline mat3 transpose() const {
		return mat3(mat[0], mat[3], mat[6],
					mat[1], mat[4], mat[2],
					mat[7], mat[5], mat[8]);
	}

	inline T det() const {
		return ((mat[0] * mat[4] * mat[8]) +
				(mat[3] * mat[7] * mat[2]) +
				(mat[6] * mat[1] * mat[5]) -
				(mat[6] * mat[4] * mat[2]) -
				(mat[3] * mat[1] * mat[8]) -
				(mat[0] * mat[7] * mat[5]));
	}

	inline mat3 inverse() const {
		T idet = 1.0f / det();
		return mat3( (mat[4] * mat[8] - mat[7] * mat[5]) * idet,
					-(mat[1] * mat[8] - mat[7] * mat[2]) * idet,
					 (mat[1] * mat[5] - mat[4] * mat[2]) * idet,
					-(mat[3] * mat[8] - mat[6] * mat[5]) * idet,
					 (mat[0] * mat[8] - mat[6] * mat[2]) * idet,
					-(mat[0] * mat[5] - mat[3] * mat[2]) * idet,
					 (mat[3] * mat[7] - mat[6] * mat[4]) * idet,
					-(mat[0] * mat[7] - mat[6] * mat[1]) * idet,
					 (mat[0] * mat[4] - mat[3] * mat[1]) * idet);
	}

	inline void zero() {
		mat[0] = 0.0; mat[3] = 0.0; mat[6] = 0.0;
		mat[1] = 0.0; mat[4] = 0.0; mat[7] = 0.0;
		mat[2] = 0.0; mat[5] = 0.0; mat[8] = 0.0;
	}

	inline void identity() {
		mat[0] = 1.0; mat[3] = 0.0; mat[6] = 0.0;
		mat[1] = 0.0; mat[4] = 1.0; mat[7] = 0.0;
		mat[2] = 0.0; mat[5] = 0.0; mat[8] = 1.0;
	}

    inline bool isIdentity() const{
           return  (FLOAT_COMPARE(mat[0],1.0) && IS_ZERO(mat[1])           && IS_ZERO(mat[2])            && IS_ZERO(mat[3])  &&
                    IS_ZERO(mat[4])           && FLOAT_COMPARE(mat[5],1.0) && IS_ZERO(mat[6])            && IS_ZERO(mat[7])  &&
                    IS_ZERO(mat[8])           && IS_ZERO(mat[9])           && FLOAT_COMPARE(mat[10],1.0) && IS_ZERO(mat[11]) &&
                    IS_ZERO(mat[12])          && IS_ZERO(mat[13])          && IS_ZERO(mat[14])           && FLOAT_COMPARE(mat[15],1.0));
    }

	inline void rotate(const vec3<T> &v,T angle) {
		rotate(v.x,v.y,v.z,angle);
	}

	void rotate(T x,T y,T z,T angle) {
		DegToRad(angle);
		T c = (T)cos(angle);
		T s = (T)sin(angle);
		T l = Util::square_root_tpl(x * x + y * y + z * z);
		if(l < EPSILON) l = 1;
		else l = 1 / l;
		x *= l;
		y *= l;
		z *= l;
		T xy = x * y;
		T yz = y * z;
		T zx = z * x;
		T xs = x * s;
		T ys = y * s;
		T zs = z * s;
		T c1 = 1 - c;
		mat[0] = c1 * x * x + c;	mat[3] = c1 * xy - zs;		mat[6] = c1 * zx + ys;
		mat[1] = c1 * xy + zs;		mat[4] = c1 * y * y + c;	mat[7] = c1 * yz - xs;
		mat[2] = c1 * zx - ys;		mat[5] = c1 * yz + xs;		mat[8] = c1 * z * z + c;
	}

	inline void rotate_x(T angle) {
		DegToRad(angle);
		T c = (T)cos(angle);
		T s = (T)sin(angle);
		mat[0] = 1; mat[3] = 0; mat[6] = 0;
		mat[1] = 0; mat[4] = c; mat[7] = -s;
		mat[2] = 0; mat[5] = s; mat[8] = c;
	}

	inline void rotate_y(T angle) {
		DegToRad(angle);
		T c = (T)cos(angle);
		T s = (T)sin(angle);
		mat[0] = c;  mat[3] = 0; mat[6] = s;
		mat[1] = 0;  mat[4] = 1; mat[7] = 0;
		mat[2] = -s; mat[5] = 0; mat[8] = c;
	}

	inline void rotate_z(T angle) {
		DegToRad(angle);
		T c = (T)cos(angle);
		T s = (T)sin(angle);
		mat[0] = c; mat[3] = -s; mat[6] = 0;
		mat[1] = s; mat[4] = c;  mat[7] = 0;
		mat[2] = 0; mat[5] = 0;  mat[8] = 1;
	}

	inline void scale(T x,T y,T z) {
		mat[0] = x; mat[3] = 0; mat[6] = 0;
		mat[1] = 0; mat[4] = y; mat[7] = 0;
		mat[2] = 0; mat[5] = 0; mat[8] = z;
	}

	inline void scale(const vec3<T> &v) {
		scale(v.x,v.y,v.z);
	}

	void orthonormalize(void) {
		vec3<T> x(mat[0],mat[1],mat[2]);
		vec3<T> y(mat[3],mat[4],mat[5]);
		vec3<T> z;
		x.normalize();
		z.cross(x,y);
		z.normalize();
		y.cross(z,x);
		y.normalize();
		mat[0] = x.x; mat[3] = y.x; mat[6] = z.x;
		mat[1] = x.y; mat[4] = y.y; mat[7] = z.y;
		mat[2] = x.z; mat[5] = y.z; mat[8] = z.z;
	}

	inline void swap(mat3& B){
        for(U8 i = 0; i < 3; i++){
		    std::swap(m[i][0], B.m[i][0]);
		    std::swap(m[i][1], B.m[i][1]);
		    std::swap(m[i][2], B.m[i][2]);
        }
	}

    union{
	    T mat[9];
        T m[3][3];
    };
};

/*************//**
/* mat4
/***************/
template<class T>
class mat4 {
public:
	mat4()/* : mat(NULL)*/{
		allocateMem();
		mat[0] = 1.0; mat[4] = 0.0; mat[8]  = 0.0; mat[12] = 0.0;
		mat[1] = 0.0; mat[5] = 1.0; mat[9]  = 0.0; mat[13] = 0.0;
		mat[2] = 0.0; mat[6] = 0.0; mat[10] = 1.0; mat[14] = 0.0;
		mat[3] = 0.0; mat[7] = 0.0; mat[11] = 0.0; mat[15] = 1.0;
	}

	mat4(T m0, T m1, T m2, T m3,
		 T m4, T m5, T m6, T m7,
		 T m8, T m9, T m10,T m11,
		 T m12,T m13,T m14,T m15)/* : mat(NULL)*/{
		allocateMem();
		mat[0] = m0; mat[4] = m4; mat[8]  = m8;  mat[12] = m12;
		mat[1] = m1; mat[5] = m5; mat[9]  = m9;  mat[13] = m13;
		mat[2] = m2; mat[6] = m6; mat[10] = m10; mat[14] = m14;
		mat[3] = m3; mat[7] = m7; mat[11] = m11; mat[15] = m15;
	}

	mat4(const vec4<T> &col1,const vec4<T> &col2,const vec4<T> &col3,const vec4<T> &col4)/* : mat(NULL)*/{
		allocateMem();
		mat[0] = col1.x; mat[4] = col2.x; mat[8]  = col3.x; mat[12] = col4.x;
		mat[1] = col1.y; mat[5] = col2.y; mat[9]  = col3.y; mat[13] = col4.y;
		mat[2] = col1.z; mat[6] = col2.z; mat[10] = col3.z; mat[14] = col4.z;
		mat[3] = col1.w; mat[7] = col2.w; mat[11] = col3.w; mat[15] = col4.w;
	}

	mat4(const vec3<T> &v)/* : mat(NULL)*/{
		allocateMem();
		translate(v);
	}

	mat4(T x,T y,T z)/* : mat(NULL)*/{
		allocateMem();
		translate(x,y,z);
	}

	mat4(const vec3<T> &axis,T angle)/* : mat(NULL)*/{
		allocateMem();
		rotate(axis,angle);
	}

	mat4(T x,T y,T z,T angle)/* : mat(NULL)*/{
		allocateMem();
		rotate(x,y,z,angle);
	}

	mat4(const mat3<T> &m)/* : mat(NULL)*/{
		allocateMem();
		mat[0] = m[0]; mat[4] = m[3]; mat[8]  = m[6]; mat[12] = 0.0;
		mat[1] = m[1]; mat[5] = m[4]; mat[9]  = m[7]; mat[13] = 0.0;
		mat[2] = m[2]; mat[6] = m[5]; mat[10] = m[8]; mat[14] = 0.0;
		mat[3] = 0.0;  mat[7] = 0.0;  mat[11] = 0.0;  mat[15] = 1.0;
	}

	mat4(const T *m)/* : mat(NULL)*/{
		allocateMem();
		mat[0] = m[0]; mat[4] = m[4]; mat[8]  = m[8];  mat[12] = m[12];
		mat[1] = m[1]; mat[5] = m[5]; mat[9]  = m[9];  mat[13] = m[13];
		mat[2] = m[2]; mat[6] = m[6]; mat[10] = m[10]; mat[14] = m[14];
		mat[3] = m[3]; mat[7] = m[7]; mat[11] = m[11]; mat[15] = m[15];
	}

	mat4(const mat4 &m)/* : mat(NULL)*/{
		allocateMem();
		mat[0] = m[0]; mat[4] = m[4]; mat[8]  = m[8];  mat[12] = m[12];
		mat[1] = m[1]; mat[5] = m[5]; mat[9]  = m[9];  mat[13] = m[13];
		mat[2] = m[2]; mat[6] = m[6]; mat[10] = m[10]; mat[14] = m[14];
		mat[3] = m[3]; mat[7] = m[7]; mat[11] = m[11]; mat[15] = m[15];
	}
	 
	/*Transforms the given 3-D vector by the matrix, projecting the result back into <i>w</i> = 1. (OGRE reference)*/
    inline vec3<T> transform( const vec3<T> &v ) const {
        vec3<T> r;

        T fInvW = 1.0f / ( m[3][0] * v.x + m[3][1] * v.y + m[3][2] * v.z + m[3][3] );

        r.x = ( m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3] ) * fInvW;
        r.y = ( m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z + m[1][3] ) * fInvW;
        r.z = ( m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z + m[2][3] ) * fInvW;

        return r;
    }

	vec3<T> operator*(const vec3<T> &v) const {
		return vec3<T>(this->mat[0] * v[0] + this->mat[4] * v[1] + this->mat[8]  * v[2] + this->mat[12],
					   this->mat[1] * v[0] + this->mat[5] * v[1] + this->mat[9]  * v[2] + this->mat[13],
					   this->mat[2] * v[0] + this->mat[6] * v[1] + this->mat[10] * v[2] + this->mat[14]);
	}

	vec4<T> operator*(const vec4<T> &v) const {
		return vec4<T>(this->mat[0] * v[0] + this->mat[4] * v[1] + this->mat[8]  * v[2] + this->mat[12] * v[3],
					   this->mat[1] * v[0] + this->mat[5] * v[1] + this->mat[9]  * v[2] + this->mat[13] * v[3],
					   this->mat[2] * v[0] + this->mat[6] * v[1] + this->mat[10] * v[2] + this->mat[14] * v[3],
					   this->mat[3] * v[0] + this->mat[7] * v[1] + this->mat[11] * v[2] + this->mat[15] * v[3]);
	}

	mat4<T> operator*(T f) const {
		return mat4<T>(this->mat[0]  * f, this->mat[1]  * f, this->mat[2]  * f, this->mat[3]  * f,
					   this->mat[4]  * f, this->mat[5]  * f, this->mat[6]  * f, this->mat[7]  * f,
					   this->mat[8]  * f, this->mat[9]  * f, this->mat[10] * f, this->mat[11] * f,
					   this->mat[12] * f, this->mat[13] * f, this->mat[14] * f, this->mat[15] * f);
	}

	mat4<T> operator*(const mat4<T> &m) const {
		mat4<T> ret;
		Mat4::Multiply(this->mat,m.mat,ret.mat);
		return ret;
	}

    bool operator == (mat4& B){
        for (I32 i = 0; i < 16; i++){
            if (!FLOAT_COMPARE(this->mat[i],B[i])) return false;
        }
        return true;
    }

    bool operator != (mat4& B){ return !(*this == B);}

	inline void set(T m0, T m1, T m2, T m3,
			        T m4, T m5, T m6, T m7,
			        T m8, T m9, T m10,T m11,
			        T m12,T m13,T m14,T m15){
		this->mat[0] = m0; this->mat[4] = m4; this->mat[8]  = m8;  this->mat[12] = m12;
		this->mat[1] = m1; this->mat[5] = m5; this->mat[9]  = m9;  this->mat[13] = m13;
		this->mat[2] = m2; this->mat[6] = m6; this->mat[10] = m10; this->mat[14] = m14;
		this->mat[3] = m3; this->mat[7] = m7; this->mat[11] = m11; this->mat[15] = m15;
	}
	
	inline void set(const T *m) {
		memcpy(this->mat, m, sizeof(T) * 16);
		/*
		this->mat[0] = m[0]; this->mat[3] = m[3]; this->mat[6]  = m[6];  this->mat[12] = m[12];
		this->mat[1] = m[1]; this->mat[4] = m[4]; this->mat[7]  = m[7];  this->mat[13] = m[13];
		this->mat[2] = m[2]; this->mat[5] = m[5]; this->mat[8]  = m[8];  this->mat[14] = m[14];
		this->mat[3] = m[3]; this->mat[7] = m[7]; this->mat[11] = m[11]; this->mat[15] = m[15];
		*/
	}

	inline vec4<T> getCol(I32 index) const {
		return vec4<T>(this->mat[0 + (index*4)],
					   this->mat[1 + (index*4)],
					   this->mat[2 + (index*4)],
					   this->mat[3 + (index*4)]);
		/*return vec4<T>(this->m[0][index],
                         this->m[1][index],
                         this->m[2][index],
                         this->m[3][index]);*/
	}

	inline void setCol(I32 index, const vec4<T>& value){
		this->mat[0 + (index*4)] = value.x;
		this->mat[1 + (index*4)] = value.y;
		this->mat[2 + (index*4)] = value.z;
		this->mat[3 + (index*4)] = value.w;
		/*this->m[0][index] = value.x;
		this->m[1][index] = value.y;
		this->m[2][index] = value.z;
		this->m[3][index] = value.w;*/
	}

	/// premultiply the matrix by the given matrix
	void multmatrix(const mat4& matrix) {
		T tmp[4];
		for (I8 j=0; j<4; j++) {
			tmp[0] = this->mat[j];
			tmp[1] = this->mat[4+j];
			tmp[2] = this->mat[8+j];
			tmp[3] = this->mat[12+j];
			for (I8 i=0; i<4; i++) {
				this->mat[4*i+j] = matrix[4*i]*tmp[0] + matrix[4*i+1]*tmp[1] + matrix[4*i+2]*tmp[2] + matrix[4*i+3]*tmp[3];
			}
		}
	}

	mat4 operator+(const mat4 &matrix) const {
		return mat4(this->mat[0]  + matrix[0],  this->mat[1]  + matrix[1],  this->mat[2]  + matrix[2],  this->mat[3]  + matrix[3],
					this->mat[4]  + matrix[4],  this->mat[5]  + matrix[5],  this->mat[6]  + matrix[6],  this->mat[7]  + matrix[7],
					this->mat[8]  + matrix[8],  this->mat[9]  + matrix[9],  this->mat[10] + matrix[10], this->mat[11] + matrix[11],
					this->mat[12] + matrix[12], this->mat[13] + matrix[13], this->mat[14] + matrix[14], this->mat[15] + matrix[15]);
	}

	mat4 operator-(const mat4 &matrix) const {
		return mat4(this->mat[0]  - matrix[0],  this->mat[1]  - matrix[1],  this->mat[2]  - matrix[2],  this->mat[3]  - matrix[3],
					this->mat[4]  - matrix[4],  this->mat[5]  - matrix[5],  this->mat[6]  - matrix[6],  this->mat[7]  - matrix[7],
					this->mat[8]  - matrix[8],  this->mat[9]  - matrix[9],  this->mat[10] - matrix[10], this->mat[11] - matrix[11],
					this->mat[12] - matrix[12], this->mat[13] - matrix[13], this->mat[14] - matrix[14], this->mat[15] - matrix[15]);
	}

	inline T &element(I8 row, I8 column, bool rowMajor = false)	{
		//return (rowMajor ? this->m[column][row] : this->m[row][column]);
		return (rowMajor ? this->mat[column+row*4] : this->mat[row+column*4]);
	}

	inline const T &element(I8 row, I8 column, bool rowMajor = false) const {
		//return (rowMajor ? this->m[column][row] : this->m[row][column]);
		return (rowMajor ? this->mat[column+row*4] : this->mat[row+column*4]);
	}

	mat4 &operator*=(T f)                { return *this = *this * f; }
	mat4 &operator*=(const mat4 &matrix) { return *this = *this * matrix; }
	mat4 &operator+=(const mat4 &matrix) { return *this = *this + matrix; }
	mat4 &operator-=(const mat4 &matrix) { return *this = *this - matrix; }

	operator T*()             { return this->mat; }
	operator const T*() const { return this->mat; }

	T &operator[](I32 i)             { return this->mat[i]; }
	const T &operator[](I32 i) const { return this->mat[i]; }

	inline mat4 rotation(void) const {
		return mat4(this->mat[0], this->mat[1], this->mat[2],  0,
					this->mat[4], this->mat[5], this->mat[6],  0,
					this->mat[8], this->mat[9], this->mat[10], 0,
					0,            0,            0,             1);
	}

	inline void transpose(mat4& out) const {
		out = mat4(this->mat[0], this->mat[4], this->mat[8],  this->mat[12],
				   this->mat[1], this->mat[5], this->mat[9],  this->mat[13],
				   this->mat[2], this->mat[6], this->mat[10], this->mat[14],
				   this->mat[3], this->mat[7], this->mat[11], this->mat[15]);
	}

	inline mat4 transpose() const {
		return mat4(this->mat[0], this->mat[4], this->mat[8],  this->mat[12],
					this->mat[1], this->mat[5], this->mat[9],  this->mat[13],
					this->mat[2], this->mat[6], this->mat[10], this->mat[14],
					this->mat[3], this->mat[7], this->mat[11], this->mat[15]);
	}

	inline mat4 transpose_rotation() const {
		return mat4(this->mat[0],  this->mat[4],  this->mat[8],  this->mat[3],
					this->mat[1],  this->mat[5],  this->mat[9],  this->mat[7],
					this->mat[2],  this->mat[6],  this->mat[10], this->mat[11],
					this->mat[12], this->mat[13], this->mat[14], this->mat[15]);
	}

	inline T det(void)             const { return Mat4::det(this->mat); }
	inline void inverse(mat4& ret) const { Mat4::Inverse(this->mat,ret.mat); }

	inline void zero() {
		this->mat[0] = 0.0; this->mat[4] = 0.0; this->mat[8]  = 0.0; this->mat[12] = 0.0;
		this->mat[1] = 0.0; this->mat[5] = 0.0; this->mat[9]  = 0.0; this->mat[13] = 0.0;
		this->mat[2] = 0.0; this->mat[6] = 0.0; this->mat[10] = 0.0; this->mat[14] = 0.0;
		this->mat[3] = 0.0; this->mat[7] = 0.0; this->mat[11] = 0.0; this->mat[15] = 0.0;
	}

	inline void identity() {
		this->mat[0] = 1.0; this->mat[4] = 0.0; this->mat[8]  = 0.0; this->mat[12] = 0.0;
		this->mat[1] = 0.0; this->mat[5] = 1.0; this->mat[9]  = 0.0; this->mat[13] = 0.0;
		this->mat[2] = 0.0; this->mat[6] = 0.0; this->mat[10] = 1.0; this->mat[14] = 0.0;
		this->mat[3] = 0.0; this->mat[7] = 0.0; this->mat[11] = 0.0; this->mat[15] = 1.0;
	}

	void rotate(const vec3<T> &axis,T angle) {
		DegToRad(angle);
		T c = (T)cos(angle);
		T s = (T)sin(angle);
		vec3<T> v = axis;
		v.normalize();
		T xx = v.x * v.x;
		T yy = v.y * v.y;
		T zz = v.z * v.z;
		T xy = v.x * v.y;
		T yz = v.y * v.z;
		T zx = v.z * v.x;
		T xs = v.x * s;
		T ys = v.y * s;
		T zs = v.z * s;
		this->mat[0] = (1 - c) * xx + c;  this->mat[4] = (1 - c) * xy - zs; this->mat[8]  = (1 - c) * zx + ys;
		this->mat[1] = (1 - c) * xy + zs; this->mat[5] = (1 - c) * yy + c;  this->mat[9]  = (1 - c) * yz - xs;
		this->mat[2] = (1 - c) * zx - ys; this->mat[6] = (1 - c) * yz + xs; this->mat[10] = (1 - c) * zz + c;
	}

	inline void rotate(T x,T y,T z,T angle) {
		rotate(vec3<T>(x,y,z),angle);
	}

	inline void rotate_x(T angle) {
		DegToRad(angle);
		T c = (T)cos(angle);
		T s = (T)sin(angle);
		this->mat[5] =  c;  this->mat[9]  = -s;
		this->mat[6] =  s;  this->mat[10] =  c;
	}

	inline void rotate_y(T angle) {
		DegToRad(angle);
		T c = (T)cos(angle);
		T s = (T)sin(angle);
		this->mat[0] =  c; this->mat[8]  =  s;
		this->mat[2] = -s; this->mat[10] =  c;
	}

	inline void rotate_z(T angle) {
		DegToRad(angle);
		T c = (T)cos(angle);
		T s = (T)sin(angle);
		this->mat[0] =  c;  this->mat[4] = -s;
		this->mat[1] =  s;  this->mat[5] =  c;
	}

	inline void setScale(const vec3<T> &v){
		this->mat[0]  = v.x;
	    this->mat[5]  = v.y;
		this->mat[10] = v.z;
	}

	inline void scale(const vec3<T> &v) {
		this->mat[0] *= v.x;
		this->mat[1] *= v.x;
		this->mat[2] *= v.x;
		this->mat[3] *= v.x;

		this->mat[4] *= v.y;
		this->mat[5] *= v.y;
		this->mat[6] *= v.y;
		this->mat[7] *= v.y;

		this->mat[8] *= v.z;
		this->mat[9] *= v.z;
		this->mat[10] *= v.z;
		this->mat[11] *= v.z;
	}

	inline void scale(T x,T y,T z) {
		scale(vec3<T>(x,y,z));
	}

	inline void translate(const vec3<T> &v) {
		this->mat[12] = v.x;
		this->mat[13] = v.y;
		this->mat[14] = v.z;
	}

	inline void translate(T x,T y,T z) {
		translate(vec3<T>(x,y,z));
	}

	void reflect(const Plane<T>& plane) {
		vec4<T> eq = plane.getEquation();
		T x = eq.x;
		T y = eq.y;
		T z = eq.z;
		T x2 = x * 2.0f;
		T y2 = y * 2.0f;
		T z2 = z * 2.0f;
		this->mat[0] = 1 - x * x2; this->mat[4] = -y * x2;    this->mat[8] = -z * x2;      this->mat[12] = -eq.w * x2;
		this->mat[1] = -x * y2;    this->mat[5] = 1 - y * y2; this->mat[9] = -z * y2;      this->mat[13] = -eq.w * y2;
		this->mat[2] = -x * z2;    this->mat[6] = -y * z2;    this->mat[10] = 1 - z * z2;  this->mat[14] = -eq.w * z2;
		this->mat[3] = 0;          this->mat[7] = 0;          this->mat[11] = 0;           this->mat[15] = 1;
	}

	inline void reflect(T x,T y,T z,T w) {
		reflect(vec4<T>(x,y,z,w));
	}

	inline void perspective(T fov,T aspect,T znear,T zfar) {
		T y = (T)tan(fov * M_PI / 360.0f);
		T x = y * aspect;
		this->mat[0] = 1 / x; this->mat[4] = 0;     this->mat[8]  = 0;                                this->mat[12] = 0;
		this->mat[1] = 0;     this->mat[5] = 1 / y; this->mat[9]  = 0;                                this->mat[13] = 0;
		this->mat[2] = 0;     this->mat[6] = 0;     this->mat[10] = -(zfar + znear) / (zfar - znear); this->mat[14] = -(2 * zfar * znear) / (zfar - znear);
		this->mat[3] = 0;     this->mat[7] = 0;     this->mat[11] = -1;                               this->mat[15] = 0;
	}

	inline void look_at(const vec3<T> &eye,const vec3<T> &dir,const vec3<T> &up) {
		vec3<T> x,y,z;
		mat4<T> m0,m1;
		z = eye - dir;
		z.normalize();
		x.cross(up,z);
		x.normalize();
		y.cross(z,x);
		y.normalize();
		m0[0] = x.x; m0[4] = x.y; m0[8] = x.z; m0[12] = 0.0;
		m0[1] = y.x; m0[5] = y.y; m0[9] = y.z; m0[13] = 0.0;
		m0[2] = z.x; m0[6] = z.y; m0[10] = z.z; m0[14] = 0.0;
		m0[3] = 0.0; m0[7] = 0.0; m0[11] = 0.0; m0[15] = 1.0;
		m1.translate(-eye);
		*this = m0 * m1;
	}

	inline void look_at(const T *eye,const T *dir,const T *up) {
		look_at(vec3<T>(eye),vec3<T>(dir),vec3<T>(up));
	}

    inline void extractMat3(mat3<T>& matrix3) const {
        matrix3.m[0][0] = this->m[0][0];
        matrix3.m[0][1] = this->m[0][1];
        matrix3.m[0][2] = this->m[0][2];
        matrix3.m[1][0] = this->m[1][0];
        matrix3.m[1][1] = this->m[1][1];
        matrix3.m[1][2] = this->m[1][2];
        matrix3.m[2][0] = this->m[2][0];
        matrix3.m[2][1] = this->m[2][1];
        matrix3.m[2][2] = this->m[2][2];
    }

    inline void swap(mat4& B){
        for(U8 i = 0; i < 4; i++){
		    std::swap(this->m[i][0], B.m[i][0]);
		    std::swap(this->m[i][1], B.m[i][1]);
		    std::swap(this->m[i][2], B.m[i][2]);
            std::swap(this->m[i][3], B.m[i][3]);
        }
	}

///It's hard to allow 16-bytes alignment here to use with SIMD instructions when all the values can
///be changed from anywhere in the code by reference / pointer. Use the slower unaligned loader instead for SSE
#ifdef USE_MATH_SIMD
#define DECL_ALIGN __declspec(align(ALIGNED_BYTES))
#define NEW_ALIGN(X,Y) (X*)malloc_simd(Y * sizeof(X))
#define DEL_ALIGN(X) free_simd(X)
#else
#define DECL_ALIGN
#define NEW_ALIGN(X,Y) New X[Y]
#define DEL_ALIGN(X) SAFE_DELETE_ARRAY(X)
#endif

     union {
	    DECL_ALIGN  T mat[16];/*T* mat;*/
        DECL_ALIGN  T m[4][4];/*T* mat;*/
     };
/*	~mat4()
	{
		DEL_ALIGN(mat);
	}
*/
	inline void allocateMem() { /*if(mat != NULL) DEL_ALIGN(mat); mat = NEW_ALIGN(T,16);*/}
};

template<class T>
inline mat3<T>::mat3(const mat4<T> &matrix) {
	this->mat[0] = matrix[0]; this->mat[3] = matrix[4]; this->mat[6] = matrix[8];
	this->mat[1] = matrix[1]; this->mat[4] = matrix[5]; this->mat[7] = matrix[9];
	this->mat[2] = matrix[2]; this->mat[5] = matrix[6]; this->mat[8] = matrix[10];
}

/// Converts a point from world coordinates to projection coordinates
///(from Y = depth, Z = up to Y = up, Z = depth)
template <class T>
inline void projectPoint(const vec3<T>& position,vec3<T>& output){
	output.x = position.x;
	output.y = position.z;
	output.z = position.y;
}

#endif

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

Diff revisions: vs.
Revision Author Commited Message
168 Diff Diff k1ngp1n picture k1ngp1n Sat 26 Oct, 2013 19:03:21 +0000

- Reworked the Camera class[[BR]]
— Now fully quaternion based [[BR]]
— Basic camera types added but not used yet (third person, first person, orbit) [[BR]]
- Cleaned up Material and Texture handling [[BR]]
- Added clipping plane support [[BR]]
— Similar to OpenGL fixed-function clip planes but fully shader driven [[BR]]
— Added a new class, “Plane”, that helps define clip planes [[BR]]
- Optimized the Singleton class to allow faster “getInstance” calls without performance penalties [[BR]]
-- “createInstance” must be called for each singleton class before usage. Or “gerOrCreateInstance” can be used, which is basically the former “getInstance” implementation [[BR]]
- Improved console logging by changing some heap allocations to stack and removing dependencies on the std::string class [[BR]]
- Added a lot of performance optimizations related to coding standards and redundant calculations [[BR]]
— e.g. Frustum AABB check didn’t need to recompute the AABB points as they were calculated already [[BR]]
— e.g. A vector did not need to be set to 0 on initialization as that is already it’s default state on creation [[BR]]
— e.g. Faster Framerate and Timing calculations by using less member variables that are not needed outsied of calling functions [[BR]]
- The SceneState now contains the SceneRenderState and is passed on to the SceneGraph’s update calls [[BR]]
- Better material export/import to/from XML format [[BR]]
- More bug fixes and cleanups [[BR]]

163 Diff Diff k1ngp1n picture k1ngp1n Thu 18 Jul, 2013 12:24:26 +0000

[Ionut] [[BR]]
- Fixed a rendering bug with the previous terrain rendering system (number of strips was not calculated correctly. had to add the primitive restart indices to the list as well) [[BR]]
- Fixed a rendering bug with the previous double sided Quad3D patch (water planes should not be double sided. The first parameter of the bool mask of the resource descriptor for water planes now controls whether the Quad will be single or double sided) [[BR]]
- NavMesh debug draw now uses a caching system for rendering instead of re-submitting the same geometry every frame [[BR]]
— Fixed a bug that prevented GLIM primitives to be cached if they had “canZombify” set to false [[BR]]
- Navigation meshes are now saved and loaded from file on creation. Delete the “nm” file from the navMeshes subfolder to recreate a navigation mesh for a scene. [[BR]]
- LightManager is now a FrameListener. ShadowMap generation is called with the “FramePreRenderEnd” event [[BR]]
- Terrain NavMesh uses the lowest LoD possible for now to improve creation times until all bugs are resolved [[BR]]
- Geometry importer now uses the “replace” operation for the base texture of objects [[BR]]
- glUniformBufferObjects are now a little less dependent on the GLM library [[BR]]
- Primitive restart is now toggled on or off at each VAO draw call [[BR]]
- Some GFXDevice inlining [[BR]]

161 Diff Diff k1ngp1n picture k1ngp1n Fri 12 Jul, 2013 19:51:50 +0000

[Ionut] [[BR]]
- Solved Navigation Mesh creation from Object3D nodes [[BR]]

160 Diff Diff k1ngp1n picture k1ngp1n Wed 10 Jul, 2013 17:07:04 +0000

[Ionut] [[BR]]
- Changed licensing from LGPL to the MIT license [[BR]]
— Code can now be used in non-commercial or commercial closed or open source projects [[BR]]

155 Diff Diff k1ngp1n picture k1ngp1n Thu 27 Jun, 2013 15:02:43 +0000

[Ionut] [[BR]]
- Small matrix stack optimization [[BR]]

154 Diff Diff k1ngp1n picture k1ngp1n Sun 23 Jun, 2013 23:39:07 +0000

[Ionut] [[BR]]
- Changed math computation for: Matrix multiplication, Normal and Tangent calculation, Quaternion to Matrix conversion and more [[BR]]
- Removed useless UBO classes and extended the functionality of the base UBO class [[BR]]
- Changed lighting shaders to be more streamlined [[BR]]
- Added full shader based fog [[BR]]
— Added per-scene optional fog settings [[BR]]
- Re-enabled sorting by shader program for Mesh Delegate Bin (was set to Front to Back for debugging purposes and forgotten there) [[BR]]

152 Diff Diff k1ngp1n picture k1ngp1n Thu 20 Jun, 2013 14:23:31 +0000

[Ionut] [[BR]]
- New rendering pipeline (experimental and unstable): [[BR]]
— OpenGL 3.x clean context (glLight commands are still used for now, but UBO support is there, but not used yet) [[BR]]
— Custom matrix stacks and UBO based shader data (UBOs cause some link errors on some nVidia cards)[[BR]]
— Multi-threaded texture loading and shader compilation (mt shader compilation disabled for now. needs more tests) [[BR]]
— VAO rendering is self contained (no more enable/disable calls before a draw request) [[BR]]
— Render instance class used for rendering information [[BR]]
[[BR]]
- New unique ID generation base class: GUIDWrapper. Each class that derives from this, gets an application wide unique id on construction [[BR]]
- Added base code for an in-game editor using CEGUI [[BR]]
- Replaced some mutex locks with lockless data structures or atomic data [[BR]]
- CEGUI 0.8.2, FTGL-GL3 and GLIM 0.4 modified to support GLEW_MX if defined [[BR]]
- Dropped VS2008 support [[BR]]
- Networking library, server framework and ReCast files are now projects inside the Divide Framework solution [[BR]]
- New console command “setFov” that modifies the horizontal FoV value in realtime [[BR]]
- New console command “recompileShader” that reparses shader files, recompiles shaders and relinks shader programs who’s names match or contain the argument string [[BR]]
- New debug utility: axis angle drawn in corner of the screen if needed [[BR]]
- More ‘const’-s pasted around the code, more loop performance tweaks (allocations before a loop, tighter loops, etc), more utility member functions added to various classes [[BR]]

151 Diff Diff k1ngp1n picture k1ngp1n Tue 07 May, 2013 00:00:52 +0000

[Ionut] [[BR]]
- Better ReCast integration [[BR]]
— Any entity can be used as an obstacle in the NavMesh if that’s specified in each scene’s assets.xml file for said entity [[BR]]
— New console command, “createNavMesh”, that passes geometry data to ReCast [[BR]]
-— NavMesh generation is not yet complete [[BR]]
- Better PhysX integration [[BR]]
— Each scene passes data to and gets data from the Physics API better and safer[[BR]]
- Multi-threaded support extended: [[BR]]
— Event class replaced with Task [[BR]]
— Kernel uses a threadpool for scene tasks [[BR]]
— Each task can be added to a different threadpool if needed [[BR]]
— Most critical sections use the new boost::atomic wrapper for thread safety [[BR]]
- Rendering system updated [[BR]]
— VBO’s keep track of the geometry type internally [[BR]]
— Rendering by specific element list is internal to the VBO [[BR]]
— VBO’s can draw a “lite” version that doesn’t send Tangent, BiTangent and TexCoord data for depth rendering (disabled) [[BR]]
- Reflectors now offer a preview of the generated reflective texture if needed [[BR]]
- Buttons are now added and rendered by CEGUI [[BR]]
[[BR]]
Deprecation: [[BR]]
- Removed fixed pipeline material system [[BR]]
- Removed BoundingBox late update system [[BR]]
- Shadow references in the material system are now depth references [[BR]]
[[BR]]
Bug fixes: [[BR]]
- Problematic FBO double bind check removed [[BR]]
- Faster terrain rendering via chunk size selection through each scene’s terrain.xml[[BR]]
- Rendering is paused when the window is minimized [[BR]]
- CEGUI and impostors now render properly in deferred rendering mode [[BR]]
- Fixed various level 4 (VS2008) warnings [[BR]]
- Better state management and cleaning [[BR]]
- Better SceneGraph node management and trasformation/AABB update calls [[BR]]
- AITenisScene has proper collisions now [[BR]]

149 Diff Diff k1ngp1n picture k1ngp1n Sun 21 Apr, 2013 21:38:05 +0000

[Ionut] [[BR]]
- Major GUI revamp: [[BR]]
— Fixed CEGUI rendering (invalid state reset after VBO/VAO unbind) [[BR]]
— Added a working Console window with a basic command parser [[BR]]
— GUI inputs take priority over scene (e.g. pressing a key in the console, does not affect the scene)[[BR]]
— Added AutoKey repeat [[BR]]
— Added config options for the GUI [[BR]]
- Revamped OpenGL Vertex Array Object class [[BR]]
— VBO’s without a shader attached will not use VAO’s [[BR]]
— VAO’s and VBO’s cleanup all states after them [[BR]]
- Added multiple Joystick support [[BR]]
- FrameBufferObject take in account the combination of texture id and bind slot when checking for double binds [[BR]]
- Upgraded Framerate/timing system [[BR]]
- Fixed Deferred rendering (typo in normal buffer creation) [[BR]]
- Fixed initial camera placement via scene config (RotateX(Y) replace with setAngleX(Y)) on camera init) [[BR]]
- Added better thread deletion in Event class [[BR]]
- Major mutex/semaphore/shared_lock rework in threaded classes [[BR]]
- Better A.I. initialization/destruction [[BR]]
- Fixed a typo in window positioning [[BR]]
- Better Unit movement code [[BR]]

146 k1ngp1n picture k1ngp1n Wed 10 Apr, 2013 13:20:15 +0000

[Ionut] [[BR]]
*Final LightBranch updates 2/3 : Main trunk merge and build test (VC90, VC100, gDebugger) [[BR]]
-Merged light branch with trunk [[BR]]
-Deleted light branch [[BR]]