Kaynağa Gözat

Most unit tests working

Thomas Buck 10 yıl önce
ebeveyn
işleme
cb3e837080
6 değiştirilmiş dosya ile 181 ekleme ve 139 silme
  1. 6
    0
      ChangeLog
  2. 33
    11
      Makefile
  3. 11
    3
      src/GLString.cpp
  4. 58
    57
      src/hel/Matrix.cpp
  5. 46
    41
      src/hel/Quaternion.cpp
  6. 27
    27
      src/hel/math.cpp

+ 6
- 0
ChangeLog Dosyayı Görüntüle

@@ -5,6 +5,12 @@
5 5
 
6 6
  OpenRaider (0.1.2) xythobuz <xythobuz@xythobuz.de>
7 7
 
8
+	[ 20140104 ]
9
+	* Hel Unit Test build & passes
10
+	* Spring & Simulation Tests unbuildable, missing files?
11
+	* GLString Unit Test builds, works not every time?
12
+	* TombRaider Unit & Regression Test working
13
+
8 14
 	[ 20140103 ]
9 15
 	* Removed more (unused?) code, PSKModel & UTPackage
10 16
 	* Removed unused MD3, mtk3d, MtkImage stuff!

+ 33
- 11
Makefile Dosyayı Görüntüle

@@ -15,13 +15,12 @@ NAME_DEB=openraider
15 15
 MAJOR_VERSION=0
16 16
 MINOR_VERSION=1
17 17
 MICRO_VERSION=2
18
-BUILD_ID=20140102
18
+BUILD_ID=$(shell date "+%Y%m%d")
19 19
 PRE=
20 20
 VERSION=$(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)$(PRE)
21 21
 VERSION_DEB=$(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION).$(BUILD_ID)
22 22
 BUILD_HOST=$(shell uname -s -n -r -m)
23 23
 ARCH=$(shell uname -m)
24
-#ARCH=i386
25 24
 UNAME=$(shell uname -s)
26 25
 
27 26
 ###############################################################
@@ -166,7 +165,7 @@ ded:
166 165
 memory:
167 166
 	@-mkdir -p $(BUILD_MEM_DIR)
168 167
 	$(MAKE) targets BUILDDIR=$(BUILD_MEM_DIR) \
169
-	DEBUG_OBJ="$(BUILD_MEM_DIR)/memeory_test.o" \
168
+	DEBUG_OBJ="$(BUILD_MEM_DIR)/memory_test.o" \
170 169
 	CFLAGS="$(DEBUG_CFLAGS) -DDEBUG_MEMEORY" \
171 170
 	LD_FLAGS="$(LD_FLAGS)"
172 171
 
@@ -367,10 +366,22 @@ TombRaider.test:
367 366
 	$(MAKE) targets NAME=TombRaider.test BUILDDIR=$(BUILD_TEST_DIR) \
368 367
 	OBJS="$(BUILD_TEST_DIR)/TombRaider.o $(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/memeory_test.o" \
369 368
 	CFLAGS="$(BASE_CFLAGS) -g -D__TOMBRAIDER_TEST__ -D__TEST_TR5_DUMP_TGA -D__TEST_32BIT_TEXTILES -DDEBUG_MEMEORY" \
370
-	LD_FLAGS="-lz"
369
+	LD_FLAGS="-lz -lstdc++"
371 370
 
372 371
 #################################################################
373 372
 
373
+ifeq ($(UNAME),Darwin)
374
+GLString.test:
375
+	mkdir -p $(BUILD_TEST_DIR)
376
+	$(CC) -Wall -Isrc -D__TEST__ -DHAVE_MTK -DHAVE_SDL -DUSING_MTK_TGA \
377
+	$(shell sdl-config --cflags) $(shell sdl-config --libs) \
378
+	-I/opt/local/include -I/usr/local/include \
379
+	-framework OpenGL \
380
+	-framework GLUT \
381
+	-lm -lstdc++ \
382
+	src/Texture.cpp src/mtk_tga.cpp \
383
+	src/GLString.cpp -o $(BUILD_TEST_DIR)/GLString.test
384
+else
374 385
 GLString.test:
375 386
 	mkdir -p $(BUILD_TEST_DIR)
376 387
 	$(CC) -Wall -Isrc -D__TEST__ -DHAVE_MTK -DHAVE_SDL -DUSING_MTK_TGA \
@@ -378,9 +389,15 @@ GLString.test:
378 389
 	-lGL -lGLU -lm \
379 390
 	src/Texture.cpp src/mtk_tga.cpp \
380 391
 	src/GLString.cpp -o $(BUILD_TEST_DIR)/GLString.test
392
+endif
381 393
 
382 394
 #################################################################
395
+
396
+# CollisionObject and HeightCollisionObject seem to be missing?
397
+# -- xythobuz, 2014-01-04
398
+
383 399
 SIMULATION_CFLAGS=-Wall -O0 -g -Isrc $(shell sdl-config --cflags) \
400
+		-I/opt/local/include \
384 401
 		-DUSING_OPENGL -DUSING_HEL -DUSING_MTK_TGA \
385 402
 		-DUNIT_TEST_SIMULATION
386 403
 SIMULATION_OBJS=$(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/Texture.o \
@@ -399,12 +416,17 @@ Simulation.test:
399 416
 	$(MAKE) targets NAME=Simulation.test BUILDDIR=$(BUILD_TEST_DIR) \
400 417
 		OBJS="$(SIMULATION_OBJS)" \
401 418
 		CFLAGS="$(SIMULATION_CFLAGS)" \
402
-		LD_FLAGS="-lm -lstdc++ -lGL -lGLU $(shell sdl-config --libs)"
419
+		LD_FLAGS="-lm -lstdc++ -lSDL_ttf -lSDL -lGL -lGLU $(shell sdl-config --libs)"
403 420
 
404 421
 #################################################################
422
+
423
+# Spring files seem to be missing?
424
+# -- xythobuz, 2014-01-04
425
+
405 426
 HEL_PARTICLE_CFLAGS=-Wall -O0 -g -Isrc $(shell sdl-config --cflags) \
427
+		-I/opt/local/include \
406 428
 		-DUSING_OPENGL -DUSING_HEL -DUSING_MTK_TGA \
407
-		-DUNIT_TEST_SPRING -DHAVE_SDL_TTF -lSDL_ttf
429
+		-DUNIT_TEST_SPRING -DHAVE_SDL_TTF
408 430
 HEL_PARTICLE_OBJS=$(BUILD_TEST_DIR)/mtk_tga.o $(BUILD_TEST_DIR)/Texture.o \
409 431
 		$(BUILD_TEST_DIR)/Mass.o \
410 432
 		$(BUILD_TEST_DIR)/Spring.o \
@@ -422,7 +444,7 @@ Spring.test:
422 444
 	$(MAKE) targets NAME=Spring.test BUILDDIR=$(BUILD_TEST_DIR) \
423 445
 		OBJS="$(HEL_PARTICLE_OBJS)" \
424 446
 		CFLAGS="$(HEL_PARTICLE_CFLAGS)" \
425
-		LD_FLAGS="-lm -lstdc++ -lGL -lGLU $(shell sdl-config --libs)"
447
+		LD_FLAGS="-lm -lstdc++ -lSDL_ttf-lGL -lGLU $(shell sdl-config --libs)"
426 448
 
427 449
 #################################################################
428 450
 
@@ -441,7 +463,7 @@ Matrix.test:
441 463
 Quaternion.test:
442 464
 	@-echo "Building Quaternion unit test"
443 465
 	mkdir -p $(BUILD_TEST_DIR)
444
-	$(CC) -Wall -g -DQUATERNION_UNIT_TEST -lm -lstdc++ -Isrc \
466
+	$(CC) -Wall -g -DUNIT_TEST_QUATERNION -lm -lstdc++ -Isrc \
445 467
 	src/hel/Quaternion.cpp -o $(BUILD_TEST_DIR)/Quaternion.test
446 468
 	@-echo "================================================="
447 469
 	@-echo "Running Quaternion unit test"
@@ -451,18 +473,18 @@ Math.test:
451 473
 	@-echo "Building Math unit test"
452 474
 	mkdir -p $(BUILD_TEST_DIR)
453 475
 	$(CC) -Wall -g -DMATH_UNIT_TEST -lm -lstdc++ -Isrc \
454
-	src/hel/math.cpp -o $(BUILD_TEST_DIR)/Math.test
476
+	src/hel/math.cpp src/hel/Vector3d.cpp -o $(BUILD_TEST_DIR)/Math.test
455 477
 	@-echo "================================================="
456 478
 	@-echo "Running hel unit test"
457 479
 	$(BUILD_TEST_DIR)/Math.test
458 480
 
459 481
 #################################################################
460 482
 
461
-Memeory.test:
483
+Memory.test:
462 484
 	mkdir -p $(BUILD_TEST_DIR)
463 485
 	$(CC) -Wall -g -D__TEST__ -lstdc++ \
464 486
 	-DDEBUG_MEMEORY -DDEBUG_MEMEORY_ERROR \
465
-	src/memeory_test.cpp -o $(BUILD_TEST_DIR)/memeory_test.test
487
+	src/memeory_test.cpp -o $(BUILD_TEST_DIR)/memory_test.test
466 488
 
467 489
 #################################################################
468 490
 

+ 11
- 3
src/GLString.cpp Dosyayı Görüntüle

@@ -410,7 +410,13 @@ gl_string_t *GLString::GetString(unsigned int id)
410 410
 
411 411
 #ifdef __TEST__
412 412
 
413
+#include <math.h>
414
+
415
+#ifdef __APPLE__
416
+#include <OpenGL/glu.h>
417
+#else
413 418
 #include <GL/glu.h>
419
+#endif
414 420
 
415 421
 #ifdef HAVE_MTK
416 422
 #   include "Texture.h"
@@ -533,9 +539,9 @@ void init_gl(unsigned int width, unsigned int height,
533 539
 	else
534 540
 	{
535 541
 		id[0] = gTexture.loadTGA("data/font-0.tga");
536
-		id[1] = gTexture.loadTGA("data/font-1.tga");
537
-		id[2] = gTexture.loadTGA("data/font-2.tga");
538
-		id[3] = gTexture.loadTGA("data/font-3.tga");
542
+		id[1] = gTexture.loadTGA("data/font-0.tga");
543
+		id[2] = gTexture.loadTGA("data/font-0.tga");
544
+		id[3] = gTexture.loadTGA("data/font-0.tga");
539 545
 	}
540 546
 
541 547
 	printf("%i %i %i %i\n", id[0], id[1], id[2], id[3]);
@@ -596,6 +602,7 @@ int main_gl(int argc, char *argv[])
596 602
   // Create GL context
597 603
   SDL_Init(SDL_INIT_VIDEO);
598 604
 
605
+#ifndef __APPLE__
599 606
   if (!driver || !driver[0] || SDL_GL_LoadLibrary(driver) < 0)
600 607
   {
601 608
 	  SDL_ClearError();
@@ -614,6 +621,7 @@ int main_gl(int argc, char *argv[])
614 621
 		  }
615 622
 	  }
616 623
   }
624
+#endif
617 625
 
618 626
   flags = SDL_OPENGL | SDL_GL_DOUBLEBUFFER;
619 627
 

+ 58
- 57
src/hel/Matrix.cpp Dosyayı Görüntüle

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : Freyja
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -10,10 +10,10 @@
10 10
  * Comments: 3d Matrix class
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------- 
15
+ *
16
+ *-- History -------------------------------------------------
17 17
  *
18 18
  * 2002.05.11:
19 19
  * Mongoose - Created
@@ -76,25 +76,25 @@ bool Matrix::getInvert(matrix_t out)
76 76
 	/* NB. OpenGL Matrices are COLUMN major. */
77 77
 #define SWAP_ROWS(a, b) { float *_tmp = a; (a)=(b); (b)=_tmp; }
78 78
 #define MAT(m,r,c) (m)[(c)*4+(r)]
79
-	
79
+
80 80
 	float wtmp[4][8];
81 81
 	float m0, m1, m2, m3, s;
82 82
 	float *r0, *r1, *r2, *r3;
83
-	
83
+
84 84
 	r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3];
85
-	
85
+
86 86
 	r0[0] = MAT(m,0,0), r0[1] = MAT(m,0,1),
87 87
 	r0[2] = MAT(m,0,2), r0[3] = MAT(m,0,3),
88 88
 	r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0,
89
-	
89
+
90 90
 	r1[0] = MAT(m,1,0), r1[1] = MAT(m,1,1),
91 91
 	r1[2] = MAT(m,1,2), r1[3] = MAT(m,1,3),
92 92
 	r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0,
93
-	
93
+
94 94
 	r2[0] = MAT(m,2,0), r2[1] = MAT(m,2,1),
95 95
 	r2[2] = MAT(m,2,2), r2[3] = MAT(m,2,3),
96 96
 	r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0,
97
-	
97
+
98 98
 	r3[0] = MAT(m,3,0), r3[1] = MAT(m,3,1),
99 99
 	r3[2] = MAT(m,3,2), r3[3] = MAT(m,3,3),
100 100
 	r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0;
@@ -104,7 +104,7 @@ bool Matrix::getInvert(matrix_t out)
104 104
 	if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1);
105 105
 	if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0);
106 106
 	if (0.0 == r0[0])  return false;
107
-	
107
+
108 108
 	/* eliminate first variable     */
109 109
 	m1 = r1[0]/r0[0]; m2 = r2[0]/r0[0]; m3 = r3[0]/r0[0];
110 110
 	s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s;
@@ -118,12 +118,12 @@ bool Matrix::getInvert(matrix_t out)
118 118
 	if (s != 0.0) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; }
119 119
 	s = r0[7];
120 120
 	if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
121
-	
121
+
122 122
 	/* choose pivot - or die */
123 123
 	if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2);
124 124
 	if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1);
125 125
 	if (0.0 == r1[1])  return false;
126
-	
126
+
127 127
 	/* eliminate second variable */
128 128
 	m2 = r2[1]/r1[1]; m3 = r3[1]/r1[1];
129 129
 	r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2];
@@ -132,23 +132,23 @@ bool Matrix::getInvert(matrix_t out)
132 132
 	s = r1[5]; if (0.0 != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; }
133 133
 	s = r1[6]; if (0.0 != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; }
134 134
 	s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
135
-	
135
+
136 136
 	/* choose pivot - or die */
137 137
 	if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2);
138 138
 	if (0.0 == r2[2])  return false;
139
-	
139
+
140 140
 	/* eliminate third variable */
141 141
 	m3 = r3[2]/r2[2];
142 142
 	r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4],
143 143
 	r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6],
144 144
 	r3[7] -= m3 * r2[7];
145
-	
145
+
146 146
 	/* last check */
147 147
 	if (0.0 == r3[3]) return false;
148
-	
148
+
149 149
 	s = 1.0/r3[3];              /* now back substitute row 3 */
150 150
 	r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s;
151
-	
151
+
152 152
 	m2 = r2[3];                 /* now back substitute row 2 */
153 153
 	s  = 1.0/r2[2];
154 154
 	r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2),
@@ -159,7 +159,7 @@ bool Matrix::getInvert(matrix_t out)
159 159
 	m0 = r0[3];
160 160
 	r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0,
161 161
 	r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0;
162
-	
162
+
163 163
 	m1 = r1[2];                 /* now back substitute row 1 */
164 164
 	s  = 1.0/r1[1];
165 165
 	r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1),
@@ -167,22 +167,22 @@ bool Matrix::getInvert(matrix_t out)
167 167
 	m0 = r0[2];
168 168
 	r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0,
169 169
 	r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0;
170
-	
170
+
171 171
 	m0 = r0[1];                 /* now back substitute row 0 */
172 172
 	s  = 1.0/r0[0];
173 173
 	r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0),
174 174
 	r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0);
175
-	
176
-	MAT(out,0,0) = r0[4]; 
177
-	MAT(out,0,1) = r0[5], MAT(out,0,2) = r0[6]; 
175
+
176
+	MAT(out,0,0) = r0[4];
177
+	MAT(out,0,1) = r0[5], MAT(out,0,2) = r0[6];
178 178
 	MAT(out,0,3) = r0[7], MAT(out,1,0) = r1[4];
179 179
 	MAT(out,1,1) = r1[5], MAT(out,1,2) = r1[6];
180 180
 	MAT(out,1,3) = r1[7], MAT(out,2,0) = r2[4];
181 181
 	MAT(out,2,1) = r2[5], MAT(out,2,2) = r2[6];
182 182
 	MAT(out,2,3) = r2[7], MAT(out,3,0) = r3[4];
183 183
 	MAT(out,3,1) = r3[5], MAT(out,3,2) = r3[6];
184
-	MAT(out,3,3) = r3[7]; 
185
-	
184
+	MAT(out,3,3) = r3[7];
185
+
186 186
 	return true;
187 187
 #undef MAT
188 188
 #undef SWAP_ROWS
@@ -267,7 +267,7 @@ void Matrix::multiply4v(vec4_t v, vec4_t result)
267 267
 {
268 268
 	vec_t x = v[0], y = v[1], z = v[2], w = v[3];
269 269
 
270
-	
270
+
271 271
    result[0] = mMatrix[ 0]*x + mMatrix[ 1]*y + mMatrix[ 2]*z + mMatrix[ 3]*w;
272 272
 	result[1] = mMatrix[ 4]*x + mMatrix[ 5]*y + mMatrix[ 6]*z + mMatrix[ 7]*w;
273 273
 	result[2] = mMatrix[ 8]*x + mMatrix[ 9]*y + mMatrix[10]*z + mMatrix[11]*w;
@@ -296,11 +296,11 @@ void Matrix::print()
296 296
 bool Matrix::isIdentity()
297 297
 {
298 298
 	// Hhhmm... floating point using direct comparisions
299
-	if (mMatrix[ 0] == 1 && mMatrix[ 1] == 0 && mMatrix[ 2] == 0 && 
300
-		 mMatrix[ 3] == 0 &&	mMatrix[ 4] == 0 && mMatrix[ 5] == 1 && 
301
-		 mMatrix[ 6] == 0 && mMatrix[ 7] == 0 && mMatrix[ 8] == 0 && 
299
+	if (mMatrix[ 0] == 1 && mMatrix[ 1] == 0 && mMatrix[ 2] == 0 &&
300
+		 mMatrix[ 3] == 0 &&	mMatrix[ 4] == 0 && mMatrix[ 5] == 1 &&
301
+		 mMatrix[ 6] == 0 && mMatrix[ 7] == 0 && mMatrix[ 8] == 0 &&
302 302
 		 mMatrix[ 9] == 0 && mMatrix[10] == 1 && mMatrix[11] == 0 &&
303
-		 mMatrix[12] == 0 && mMatrix[13] == 0 && mMatrix[14] == 0 && 
303
+		 mMatrix[12] == 0 && mMatrix[13] == 0 && mMatrix[14] == 0 &&
304 304
 		 mMatrix[15] == 1)
305 305
 		return true;
306 306
 
@@ -448,17 +448,17 @@ void Matrix::multiply(const matrix_t a, const matrix_t b, matrix_t result)
448 448
 	result[ 1] = a[ 0] * b[ 4] + a[ 4] * b[ 5] + a[ 8] * b[ 6] + a[12] * b[ 7];
449 449
 	result[ 2] = a[ 0] * b[ 8] + a[ 4] * b[ 9] + a[ 8] * b[10] + a[12] * b[11];
450 450
 	result[ 3] = a[ 0] * b[12] + a[ 4] * b[13] + a[ 8] * b[14] + a[12] * b[15];
451
-	
451
+
452 452
 	result[ 4] = a[ 1] * b[ 0] + a[ 5] * b[ 1] + a[ 9] * b[ 2] + a[13] * b[ 3];
453 453
 	result[ 5] = a[ 1] * b[ 4] + a[ 5] * b[ 5] + a[ 9] * b[ 6] + a[13] * b[ 7];
454 454
 	result[ 6] = a[ 1] * b[ 8] + a[ 5] * b[ 9] + a[ 9] * b[10] + a[13] * b[11];
455 455
 	result[ 7] = a[ 1] * b[12] + a[ 5] * b[13] + a[ 9] * b[14] + a[13] * b[15];
456
-	
456
+
457 457
 	result[ 8] = a[ 2] * b[ 0] + a[ 6] * b[ 1] + a[10] * b[ 2] + a[14] * b[ 3];
458 458
 	result[ 9] = a[ 2] * b[ 4] + a[ 6] * b[ 5] + a[10] * b[ 6] + a[14] * b[ 7];
459 459
 	result[10] = a[ 2] * b[ 8] + a[ 6] * b[ 9] + a[10] * b[10] + a[14] * b[11];
460 460
 	result[11] = a[ 2] * b[12] + a[ 6] * b[13] + a[10] * b[14] + a[14] * b[15];
461
-	
461
+
462 462
 	result[12] = a[ 3] * b[ 0] + a[ 7] * b[ 1] + a[11] * b[ 2] + a[15] * b[ 3];
463 463
 	result[13] = a[ 3] * b[ 4] + a[ 7] * b[ 5] + a[11] * b[ 6] + a[15] * b[ 7];
464 464
 	result[14] = a[ 3] * b[ 8] + a[ 7] * b[ 9] + a[11] * b[10] + a[15] * b[11];
@@ -469,17 +469,17 @@ void Matrix::multiply(const matrix_t a, const matrix_t b, matrix_t result)
469 469
 	result[ 1] = a[ 0] * b[ 1] + a[ 1] * b[ 5] + a[ 2] * b[ 9] + a[ 3] * b[13];
470 470
 	result[ 2] = a[ 0] * b[ 2] + a[ 1] * b[ 6] + a[ 2] * b[10] + a[ 3] * b[14];
471 471
 	result[ 3] = a[ 0] * b[ 3] + a[ 1] * b[ 7] + a[ 2] * b[11] + a[ 3] * b[15];
472
-	
472
+
473 473
 	result[ 4] = a[ 4] * b[ 0] + a[ 5] * b[ 4] + a[ 6] * b[ 8] + a[ 7] * b[12];
474 474
 	result[ 5] = a[ 4] * b[ 1] + a[ 5] * b[ 5] + a[ 6] * b[ 9] + a[ 7] * b[13];
475 475
 	result[ 6] = a[ 4] * b[ 2] + a[ 5] * b[ 6] + a[ 6] * b[10] + a[ 7] * b[14];
476 476
 	result[ 7] = a[ 4] * b[ 3] + a[ 5] * b[ 7] + a[ 6] * b[11] + a[ 7] * b[15];
477
-	
477
+
478 478
 	result[ 8] = a[ 8] * b[ 0] + a[ 9] * b[ 4] + a[10] * b[ 8] + a[11] * b[12];
479 479
 	result[ 9] = a[ 8] * b[ 1] + a[ 9] * b[ 5] + a[10] * b[ 9] + a[11] * b[13];
480 480
 	result[10] = a[ 8] * b[ 2] + a[ 9] * b[ 6] + a[10] * b[10] + a[11] * b[14];
481 481
 	result[11] = a[ 8] * b[ 3] + a[ 9] * b[ 7] + a[10] * b[11] + a[11] * b[15];
482
-	
482
+
483 483
 	result[12] = a[12] * b[ 0] + a[13] * b[ 4] + a[14] * b[ 8] + a[15] * b[12];
484 484
 	result[13] = a[12] * b[ 1] + a[13] * b[ 5] + a[14] * b[ 9] + a[15] * b[13];
485 485
 	result[14] = a[12] * b[ 2] + a[13] * b[ 6] + a[14] * b[10] + a[15] * b[14];
@@ -489,16 +489,17 @@ void Matrix::multiply(const matrix_t a, const matrix_t b, matrix_t result)
489 489
 
490 490
 
491 491
 ////////////////////////////////////////////////////////////
492
-// Unit Test 
492
+// Unit Test
493 493
 ////////////////////////////////////////////////////////////
494 494
 
495 495
 #ifdef MATRIX_UNIT_TEST
496
+#include <strings.h>
496 497
 /* <Order> is (r)ow or (c)ol */
497 498
 void generateMatrixSourceTest(char order)
498 499
 {
499 500
 	int i, j, k;
500 501
 
501
-	
502
+
502 503
 	if (order == 'r')
503 504
 	{
504 505
 		printf("/* Row order */\n");
@@ -507,7 +508,7 @@ void generateMatrixSourceTest(char order)
507 508
 	{
508 509
 		printf("/* Column order */\n");
509 510
 	}
510
-	
511
+
511 512
 	for (i = 0; i < 4; ++i)
512 513
 	{
513 514
 		for (j = 0; j < 4; ++j)
@@ -520,17 +521,17 @@ void generateMatrixSourceTest(char order)
520 521
 			{
521 522
 				printf("result[%2i] = ", j+i*4);
522 523
 			}
523
-			
524
+
524 525
 			for (k = 0; k < 4; ++k)
525 526
 			{
526 527
 				if (order == 'r')
527 528
 				{
528 529
 					printf("a[%2i] * b[%2i]%s",
529
-							  k+i*4, j+k*4, (k == 3) ? ";\n" : " + "); 
530
+							  k+i*4, j+k*4, (k == 3) ? ";\n" : " + ");
530 531
 				}
531 532
 				else
532 533
 				{
533
-					printf("a[%2i] * b[%2i]%s", 
534
+					printf("a[%2i] * b[%2i]%s",
534 535
 							 i+k*4, k+j*4, (k == 3) ? ";\n" : " + ");
535 536
 				}
536 537
 
@@ -584,7 +585,7 @@ int runMatrixUnitTest()
584 585
 			printf("Identity * Identity");
585 586
 			c.setIdentity();
586 587
 			b.setIdentity();
587
-			a = c * b; 
588
+			a = c * b;
588 589
 			break;
589 590
 		case 2:
590 591
 			printf("Identity *= Identity");
@@ -608,7 +609,7 @@ int runMatrixUnitTest()
608 609
 		printf("\n");
609 610
 	}
610 611
 
611
-	/* 2003.06.18, Mongoose - These tests are weak and 
612
+	/* 2003.06.18, Mongoose - These tests are weak and
612 613
 		only spot check some of the matrix */
613 614
 
614 615
 
@@ -619,23 +620,23 @@ int runMatrixUnitTest()
619 620
 
620 621
 #ifdef COLUMN_ORDER
621 622
 	unsigned char i0  = 0, i1  = 4, i2  =  8, i3  = 12;
622
-	unsigned char i4  = 1, i5  = 5, i6  =  9, i7  = 13; 
623
+	unsigned char i4  = 1, i5  = 5, i6  =  9, i7  = 13;
623 624
 	unsigned char i8  = 2, i9  = 6, i10 = 10, i11 = 14;
624 625
 	unsigned char i12 = 3, i13 = 7, i14 = 11, i15 = 15;
625 626
 #else
626
-	unsigned char i0  =  0, i1  =  1, i2  =  2, i3  =  3;
627
-	unsigned char i4  =  4, i5  =  5, i6  =  6, i7  =  7;
628
-	unsigned char i8  =  8, i9  =  9, i10 = 10, i11 = 11;
627
+	unsigned char i0  =  0, i1  =  1, i2  =  2; // i3  =  3
628
+	unsigned char i4  =  4, i6  =  6; // i5  =  5, i7  =  7
629
+	unsigned char i8  =  8, i9  =  9, i10 = 10; // i11 = 11
629 630
 	unsigned char i12 = 12, i13 = 13, i14 = 14, i15 = 15;
630 631
 #endif
631 632
 
632
-	if (a.mMatrix[i12] != 10 || 
633
-		 a.mMatrix[i13] != 20 || 
633
+	if (a.mMatrix[i12] != 10 ||
634
+		 a.mMatrix[i13] != 20 ||
634 635
 		 a.mMatrix[i14] != 30)
635 636
 	{
636 637
 			++errs;
637 638
 			printf(" \t[ Failed ]\a\n"); // beep
638
-			a.print();		
639
+			a.print();
639 640
 	}
640 641
 
641 642
 	/* Cheap X rotation test */
@@ -643,12 +644,12 @@ int runMatrixUnitTest()
643 644
 	printf("I -> Rotate (90 degrees, 0, 0)\n");
644 645
 	a.rotate(90*0.01745329251994329f, 0, 0);
645 646
 
646
-	if (a.mMatrix[i0] != 1 || a.mMatrix[i15] != 1 || 
647
+	if (a.mMatrix[i0] != 1 || a.mMatrix[i15] != 1 ||
647 648
 		 a.mMatrix[i9] != -1 || a.mMatrix[i6] != 1)
648 649
 	{
649 650
 			++errs;
650 651
 			printf(" \t[ Failed ]\a\n"); // beep
651
-			a.print();		
652
+			a.print();
652 653
 	}
653 654
 
654 655
 	/* Cheap Y rotation test */
@@ -661,7 +662,7 @@ int runMatrixUnitTest()
661 662
 	{
662 663
 			++errs;
663 664
 			printf(" \t[ Failed ]\a\n"); // beep
664
-			a.print();		
665
+			a.print();
665 666
 	}
666 667
 
667 668
 	/* Cheap Z rotation test */
@@ -669,12 +670,12 @@ int runMatrixUnitTest()
669 670
 	printf("I -> Rotate (0, 0, 90 degrees)\n");
670 671
 	a.rotate(0, 0, 90*0.01745329251994329f);
671 672
 
672
-	if (a.mMatrix[i4] != -1 || a.mMatrix[i15] != 1 || 
673
+	if (a.mMatrix[i4] != -1 || a.mMatrix[i15] != 1 ||
673 674
 		 a.mMatrix[i1] != 1 || a.mMatrix[i10] != 1)
674 675
 	{
675 676
 			++errs;
676 677
 			printf(" \t[ Failed ]\a\n"); // beep
677
-			a.print();		
678
+			a.print();
678 679
 	}
679 680
 
680 681
 	printf("\n%i errors\n", errs);
@@ -699,7 +700,7 @@ int runMatrixUnitTest()
699 700
 	a.translate(-10, -20, -30);
700 701
 	printf(" -> Rotate (0, 0, -90 degrees)\n");
701 702
 	a.rotate(0, 0, -90*0.01745329251994329f);
702
-	a.print();	
703
+	a.print();
703 704
 
704 705
 	printf("\n%i errors\n", errs);
705 706
 

+ 46
- 41
src/hel/Quaternion.cpp Dosyayı Görüntüle

@@ -1,6 +1,6 @@
1 1
 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
2 2
 /*================================================================
3
- * 
3
+ *
4 4
  * Project : Hel
5 5
  * Author  : Terry 'Mongoose' Hendrix II
6 6
  * Website : http://www.westga.edu/~stu7440/
@@ -10,10 +10,10 @@
10 10
  * Comments: Quaternion now in C++ class form fresh from the grove
11 11
  *
12 12
  *
13
- *           This file was generated using Mongoose's C++ 
13
+ *           This file was generated using Mongoose's C++
14 14
  *           template generator script.  <stu7440@westga.edu>
15
- * 
16
- *-- History ------------------------------------------------- 
15
+ *
16
+ *-- History -------------------------------------------------
17 17
  *
18 18
  * 2002.12.16:
19 19
  * Mongoose - Created, based on mtk3d ( freyja )
@@ -69,17 +69,17 @@ void Quaternion::getMatrix(matrix_t m)
69 69
 	m[ 1] = 2.0f * (mX*mY - mW*mZ);
70 70
 	m[ 2] = 2.0f * (mX*mZ + mW*mY);
71 71
 	m[ 3] = 0.0f;
72
-	
72
+
73 73
 	m[ 4] = 2.0f * (mX*mY + mW*mZ);
74 74
 	m[ 5] = 1.0f - 2.0f * (mX*mX + mZ*mZ);
75 75
 	m[ 6] = 2.0f * (mY*mZ - mW*mX);
76 76
 	m[ 7] = 0.0f;
77
-	
77
+
78 78
 	m[ 8] = 2.0f * (mX*mZ - mW*mY);
79 79
 	m[ 9] = 2.0f * (mY*mZ + mW*mX);
80 80
 	m[10] = 1.0 - 2.0f * (mX*mX + mY*mY);
81 81
 	m[11] = 0.0f;
82
-	
82
+
83 83
 	m[12] = 0.0f;
84 84
 	m[13] = 0.0f;
85 85
 	m[14] = 0.0f;
@@ -93,7 +93,7 @@ Quaternion Quaternion::operator =(const Quaternion &q)
93 93
 	mX = q.mX;
94 94
 	mY = q.mY;
95 95
 	mZ = q.mZ;
96
-  
96
+
97 97
   return (*this);
98 98
 }
99 99
 
@@ -175,21 +175,21 @@ void Quaternion::set(vec_t angle, vec_t x, vec_t y, vec_t z)
175 175
 {
176 176
 	vec_t temp, dist;
177 177
 
178
-	
178
+
179 179
 	// Normalize
180 180
 	temp = x*x + y*y + z*z;
181
-	
181
+
182 182
 	dist = (float)(1.0 / sqrt(temp));
183
-	
183
+
184 184
 	x *= dist;
185 185
 	y *= dist;
186 186
 	z *= dist;
187
-	
187
+
188 188
 	mX = x;
189 189
 	mY = y;
190 190
 	mZ = z;
191
-	
192
-	mW = (float)cos(angle / 2.0f);	
191
+
192
+	mW = (float)cos(angle / 2.0f);
193 193
 }
194 194
 
195 195
 
@@ -199,12 +199,12 @@ void Quaternion::normalize()
199 199
 
200 200
 
201 201
 	square = mX * mX + mY * mY + mZ * mZ + mW * mW;
202
-	
202
+
203 203
 	if (square > 0.0)
204 204
 	{
205 205
 		dist = (float)(1.0 / sqrt(square));
206 206
 	}
207
-	else 
207
+	else
208 208
 	{
209 209
 		dist = 1;
210 210
 	}
@@ -212,7 +212,7 @@ void Quaternion::normalize()
212 212
 	mX *= dist;
213 213
 	mY *= dist;
214 214
 	mZ *= dist;
215
-	mW *= dist; 
215
+	mW *= dist;
216 216
 }
217 217
 
218 218
 
@@ -237,7 +237,7 @@ Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time)
237 237
 	 *
238 238
 	 * http://www.magic-software.com/Documentation/quat.pdf
239 239
 	 *
240
-	 * Thanks to digiben for algorithms and basis of the notes in 
240
+	 * Thanks to digiben for algorithms and basis of the notes in
241 241
 	 * this func
242 242
 	 *
243 243
 	 *******************************************************************/
@@ -247,14 +247,14 @@ Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time)
247 247
 
248 248
 
249 249
 	// Don't bother if it's the same rotation, it's the same as the result
250
-	if (a == b) 
250
+	if (a == b)
251 251
 	{
252 252
 		return a;
253 253
 	}
254 254
 
255
-	// A . B 
255
+	// A . B
256 256
 	result = dot(a, b);
257
-  
257
+
258 258
 	// If the dot product is less than 0, the angle is greater than 90 degrees
259 259
 	if (result < 0.0f)
260 260
 	{
@@ -273,10 +273,10 @@ Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time)
273 273
 	// angle is fairly small, we can actually just do a simpler linear interpolation
274 274
 	// of the 2 quaternions, and skip all the complex math.  We create a "delta" value
275 275
 	// of 0.1 to say that if the cosine of the angle (result of the dot product) between
276
-	// the 2 quaternions is smaller than 0.1, then we do NOT want to perform the full on 
276
+	// the 2 quaternions is smaller than 0.1, then we do NOT want to perform the full on
277 277
 	// interpolation using.  This is because you won't really notice the difference.
278
-	
279
-	// Check if the angle between the 2 quaternions was big enough 
278
+
279
+	// Check if the angle between the 2 quaternions was big enough
280 280
 	// to warrant such calculations
281 281
 	if (1 - result > 0.1f)
282 282
 	{
@@ -289,7 +289,7 @@ Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time)
289 289
 		// the angle and it's sine value
290 290
 		scaleA = (float)sin((1 - time) * theta) / sinTheta;
291 291
 		scaleB = (float)sin((time * theta)) / sinTheta;
292
-	}	
292
+	}
293 293
 
294 294
 	// Calculate the x, y, z and w values for the quaternion by using a special
295 295
 	// form of linear interpolation for quaternions.
@@ -298,54 +298,54 @@ Quaternion Quaternion::slerp(Quaternion a, Quaternion b, vec_t time)
298 298
 
299 299
 
300 300
 void Quaternion::setByMatrix(matrix_t matrix)
301
-{   
301
+{
302 302
 	float diagonal = matrix[0] + matrix[5] + matrix[10] + 1.0f;
303 303
 	float scale = 0.0f;
304 304
 	float w = 0.0f, x = 0.0f, y = 0.0f, z = 0.0f;
305
-	
306
-	
305
+
306
+
307 307
 	if (diagonal > 0.00000001)
308 308
 	{
309 309
 		// Calculate the scale of the diagonal
310 310
 		scale = (float)(sqrt(diagonal) * 2);
311
-		
311
+
312 312
 		w = 0.25f * scale;
313 313
 		x = (matrix[9] - matrix[6]) / scale;
314 314
 		y = (matrix[2] - matrix[8]) / scale;
315 315
 		z = (matrix[4] - matrix[1]) / scale;
316 316
 	}
317
-	else 
317
+	else
318 318
 	{
319 319
 		 // If the first element of the diagonal is the greatest value
320 320
 		if (matrix[0] > matrix[5] && matrix[0] > matrix[10])
321
-		{   
321
+		{
322 322
 			 // Find the scale according to the first element, and double it
323 323
 			scale = (float)sqrt(1.0f + matrix[0] - matrix[5] - matrix[10])*2.0f;
324
-			
324
+
325 325
 			// Calculate the quaternion
326
-			w = (matrix[9] - matrix[6]) / scale; 
326
+			w = (matrix[9] - matrix[6]) / scale;
327 327
 			x = 0.25f * scale;
328 328
 			y = (matrix[4] + matrix[1]) / scale;
329 329
 			z = (matrix[2] + matrix[8]) / scale;
330
-		} 
330
+		}
331 331
 		// The second element of the diagonal is the greatest value
332
-		else if (matrix[5] > matrix[10]) 
332
+		else if (matrix[5] > matrix[10])
333 333
 		{
334 334
 			// Find the scale according to the second element, and double it
335 335
 			scale = (float)sqrt(1.0f + matrix[5] - matrix[0] - matrix[10])*2.0f;
336
-			
337
-			// Calculate the quaternion 
336
+
337
+			// Calculate the quaternion
338 338
 			w = (matrix[2] - matrix[8]) / scale;
339 339
 			x = (matrix[4] + matrix[1]) / scale;
340 340
 			y = 0.25f * scale;
341 341
 			z = (matrix[9] + matrix[6]) / scale;
342
-		} 
342
+		}
343 343
 		// The third element of the diagonal is the greatest value
344
-		else 
345
-		{   
344
+		else
345
+		{
346 346
 			// Find the scale according to the third element, and double it
347 347
 			scale = (float)sqrt(1.0f + matrix[10] - matrix[0] - matrix[5])*2.0f;
348
-			
348
+
349 349
 			// Calculate the quaternion
350 350
 			w = (matrix[4] - matrix[1]) / scale;
351 351
 			x = (matrix[2] + matrix[8]) / scale;
@@ -408,8 +408,13 @@ Quaternion Quaternion::subtract(Quaternion a, Quaternion b)
408 408
 ////////////////////////////////////////////////////////////
409 409
 
410 410
 #ifdef UNIT_TEST_QUATERNION
411
+
412
+#include <stdio.h>
413
+
411 414
 int runQuaternionUnitTest(int argc, char *argv[])
412 415
 {
416
+    //! \todo Implement Quaternion Unit Tests!
417
+    printf("Not implemented!\n");
413 418
 	return 0;
414 419
 }
415 420
 

+ 27
- 27
src/hel/math.cpp Dosyayı Görüntüle

@@ -25,7 +25,7 @@ void helVectorMatrixMult4dv(double v[4], matrix_t m, double result[4])
25 25
 }
26 26
 
27 27
 
28
-bool tmpHelSphereIntersectLine(Vector3d pos, Vector3d lastPos, 
28
+bool tmpHelSphereIntersectLine(Vector3d pos, Vector3d lastPos,
29 29
 										 Vector3d center, vec_t radius)
30 30
 {
31 31
 	Vector3d seg, segToCenter, delta;
@@ -65,12 +65,12 @@ vec_t helIntersectionOfAbstractSpheres(vec3_t centerA, vec_t radiusA,
65 65
 
66 66
 	dist = Vector3d::dot(d, d);
67 67
 	minDist = radiusA + radiusB;
68
-	
68
+
69 69
 	return (dist <= minDist * minDist);
70 70
 }
71 71
 
72 72
 
73
-inline vec_t square(vec_t a) 
73
+inline vec_t square(vec_t a)
74 74
 {
75 75
 	return a * a;
76 76
 }
@@ -85,10 +85,10 @@ int helIntersectionOfAbstractSphereAndLine(vec3_t center, vec_t radius,
85 85
 {
86 86
 	// float x , y , z;
87 87
 	vec_t a, b, c, mu, i ;
88
-	
89 88
 
90
-	a = (square(posB[0] - posA[0]) + 
91
-		  square(posB[1] - posA[1]) + 
89
+
90
+	a = (square(posB[0] - posA[0]) +
91
+		  square(posB[1] - posA[1]) +
92 92
 		  square(posB[2] - posA[2]));
93 93
 	b = (2 * ((posB[0] - posA[0]) * (posA[0] - center[0]) +
94 94
 				 (posB[1] - posA[1]) * (posA[1] - center[1]) +
@@ -96,12 +96,12 @@ int helIntersectionOfAbstractSphereAndLine(vec3_t center, vec_t radius,
96 96
 	c = (square(center[0]) + square(center[1]) +
97 97
 		  square(center[2]) + square(posA[0]) +
98 98
 		  square(posA[1]) + square(posA[2]) -
99
-		  2 * (center[0]*posA[0] + center[1]*posA[1] + center[2]*posA[2]) - 
99
+		  2 * (center[0]*posA[0] + center[1]*posA[1] + center[2]*posA[2]) -
100 100
 		  square(radius));
101 101
 
102 102
 	i = b * b - 4 * a * c;
103 103
 
104
-	
104
+
105 105
 	if (i < 0.0)
106 106
 	{
107 107
 		// No intersection
@@ -120,13 +120,13 @@ int helIntersectionOfAbstractSphereAndLine(vec3_t center, vec_t radius,
120 120
 	else
121 121
 	{
122 122
 		// Two intersections
123
-		
123
+
124 124
 		// First intersection
125 125
 		mu = (-b + sqrt( square(b) - 4*a*c)) / (2*a);
126 126
 		intersectionA[1] = posA[0] + mu*(posB[0]-posA[0]);
127 127
 		intersectionA[2] = posA[1] + mu*(posB[1]-posA[1]);
128 128
 		intersectionA[3] = posA[2] + mu*(posB[2]-posA[2]);
129
-		
129
+
130 130
 		// Second intersection
131 131
 		mu = (-b - sqrt(square(b) - 4*a*c)) / (2*a);
132 132
 		intersectionB[0] = posA[0] + mu*(posB[0]-posA[0]);
@@ -163,10 +163,10 @@ int helIntersectionLineAndPolygon(vec3_t intersect,
163 163
 
164 164
 	// find D
165 165
 	//d = (normal[0] * ploygon[0][0] -
166
-	//	  normal[1] * ploygon[0][1] - 
166
+	//	  normal[1] * ploygon[0][1] -
167 167
 	//	  normal[2] * ploygon[0][2]);
168 168
 	d = (normal.mVec[0] * ploygon[0][0] -
169
-		  normal.mVec[1] * ploygon[0][1] - 
169
+		  normal.mVec[1] * ploygon[0][1] -
170 170
 		  normal.mVec[2] * ploygon[0][2]);
171 171
 
172 172
 	// line segment parallel to plane?
@@ -196,7 +196,7 @@ int helIntersectionLineAndPolygon(vec3_t intersect,
196 196
 	intersect[0] = b.mVec[0];
197 197
 	intersect[1] = b.mVec[1];
198 198
 	intersect[2] = b.mVec[2];
199
-	
199
+
200 200
 
201 201
 	// See if the intercept is bound by polygon by winding number
202 202
 #ifdef WINDING_NUMBERS_TRIANGLE
@@ -233,9 +233,9 @@ vec_t helDistToSphereFromPlane3v(vec3_t center,	vec_t radius, vec4_t plane)
233 233
 	vec_t d;
234 234
 
235 235
 
236
-	d = (plane[0] * center[0] + 
236
+	d = (plane[0] * center[0] +
237 237
 		  plane[1] * center[1] +
238
-		  plane[2] * center[2] + 
238
+		  plane[2] * center[2] +
239 239
 		  plane[3]);
240 240
 
241 241
 	if (d <= -radius)
@@ -253,9 +253,9 @@ vec_t helDistToBboxFromPlane3v(vec3_t min, vec3_t max, vec4_t plane)
253 253
 
254 254
 	helMidpoint3v(min, max, center);
255 255
 
256
-	d = (plane[0] * center[0] + 
257
-		  plane[1] * center[1] + 
258
-		  plane[2] * center[2] + 
256
+	d = (plane[0] * center[0] +
257
+		  plane[1] * center[1] +
258
+		  plane[2] * center[2] +
259 259
 		  plane[3]);
260 260
 
261 261
 	radius = helDist3v(max, center);
@@ -270,7 +270,7 @@ vec_t helDistToBboxFromPlane3v(vec3_t min, vec3_t max, vec4_t plane)
270 270
 vec_t helDist3v(vec3_t a, vec3_t b)
271 271
 {
272 272
 	return (sqrt( ((b[0] - a[0]) * (b[0] - a[0])) +
273
-					  ((b[1] - a[1]) * (b[1] - a[1])) + 
273
+					  ((b[1] - a[1]) * (b[1] - a[1])) +
274 274
 					  ((b[2] - a[2]) * (b[2] - a[2]))));
275 275
 }
276 276
 
@@ -284,19 +284,19 @@ void helMidpoint3v(vec3_t a, vec3_t b, vec3_t mid)
284 284
 
285 285
 
286 286
 vec_t helNorm4v(vec4_t v)
287
-{ 
287
+{
288 288
 	return (sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2] + v[3]*v[3]));
289 289
 }
290 290
 
291 291
 
292 292
 vec_t helNorm3v(vec3_t v)
293
-{ 
293
+{
294 294
 	return (sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]));
295
-} 
295
+}
296 296
 
297 297
 
298 298
 vec_t helNorm2v(vec2_t v)
299
-{ 
299
+{
300 300
 	return (sqrt(v[0]*v[0] + v[1]*v[1]));
301 301
 }
302 302
 
@@ -321,7 +321,7 @@ vec_t helDegToRad(vec_t degrees)
321 321
 vec_t helRadToDeg(vec_t rad)
322 322
 {
323 323
 #ifdef COMPUTE
324
-	return ((rad / HEL_PI) * 180.0); 
324
+	return ((rad / HEL_PI) * 180.0);
325 325
 #else
326 326
 	// rad * (PI / 180.0);
327 327
 	return (rad * HEL_PI_OVER_180);
@@ -334,14 +334,14 @@ vec_t helRadToDeg(vec_t rad)
334 334
 
335 335
 void helMathTest()
336 336
 {
337
-	printf("180/PI: %f, %f, %f\n", 
338
-			 HEL_180_OVER_PI, 
337
+	printf("180/PI: %f, %f, %f\n",
338
+			 HEL_180_OVER_PI,
339 339
 			 180.0f / HEL_PI,
340 340
 			 180.0 / M_PI);
341 341
 }
342 342
 
343 343
 
344
-int main(int argc, char *argv)
344
+int main(int argc, char *argv[])
345 345
 {
346 346
 	helMathTest();
347 347
 

Loading…
İptal
Kaydet