conworlds

changeset 16:7a2041ddb7e7

fixed line endings
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 24 Aug 2014 18:42:40 +0300
parents 9b0db7dbde6e
children c814f77d177e
files src/game.cc src/vr/mathutil.c src/vr/mathutil.h
diffstat 3 files changed, 98 insertions(+), 98 deletions(-) [+]
line diff
     1.1 --- a/src/game.cc	Sun Aug 24 14:36:00 2014 +0300
     1.2 +++ b/src/game.cc	Sun Aug 24 18:42:40 2014 +0300
     1.3 @@ -340,12 +340,12 @@
     1.4  }
     1.5  
     1.6  static void draw_pyramid(float basesz, float height)
     1.7 -{
     1.8 -	float hsz = basesz / 2.0;
     1.9 -	float theta = atan(hsz / height);
    1.10 -	float nx = cos(theta);
    1.11 -	float ny = sin(theta);
    1.12 -
    1.13 +{
    1.14 +	float hsz = basesz / 2.0;
    1.15 +	float theta = atan(hsz / height);
    1.16 +	float nx = cos(theta);
    1.17 +	float ny = sin(theta);
    1.18 +
    1.19  	glBegin(GL_TRIANGLES);
    1.20  	glNormal3f(0, ny, nx);
    1.21  	glVertex3f(-hsz, 0, hsz);
    1.22 @@ -364,4 +364,4 @@
    1.23  	glVertex3f(-hsz, 0, hsz);
    1.24  	glVertex3f(0, height, 0);
    1.25  	glEnd();
    1.26 -}
    1.27 \ No newline at end of file
    1.28 +}
     2.1 --- a/src/vr/mathutil.c	Sun Aug 24 14:36:00 2014 +0300
     2.2 +++ b/src/vr/mathutil.c	Sun Aug 24 18:42:40 2014 +0300
     2.3 @@ -1,78 +1,78 @@
     2.4 -#include <stdio.h>
     2.5 -#include <string.h>
     2.6 -#include "mathutil.h"
     2.7 -
     2.8 -#define M(i, j)	((i) * 4 + (j))
     2.9 -
    2.10 -static const float idmat[] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
    2.11 -
    2.12 -void rotation_matrix(const float *quat, float *matrix)
    2.13 -{
    2.14 -	matrix[0] = 1.0 - 2.0 * quat[1] * quat[1] - 2.0 * quat[2] * quat[2];
    2.15 -	matrix[1] = 2.0 * quat[0] * quat[1] + 2.0 * quat[3] * quat[2];
    2.16 -	matrix[2] = 2.0 * quat[2] * quat[0] - 2.0 * quat[3] * quat[1];
    2.17 -	matrix[3] = 0.0f;
    2.18 -
    2.19 -	matrix[4] = 2.0 * quat[0] * quat[1] - 2.0 * quat[3] * quat[2];
    2.20 -	matrix[5] = 1.0 - 2.0 * quat[0]*quat[0] - 2.0 * quat[2]*quat[2];
    2.21 -	matrix[6] = 2.0 * quat[1] * quat[2] + 2.0 * quat[3] * quat[0];
    2.22 -	matrix[7] = 0.0f;
    2.23 -
    2.24 -	matrix[8] = 2.0 * quat[2] * quat[0] + 2.0 * quat[3] * quat[1];
    2.25 -	matrix[9] = 2.0 * quat[1] * quat[2] - 2.0 * quat[3] * quat[0];
    2.26 -	matrix[10] = 1.0 - 2.0 * quat[0]*quat[0] - 2.0 * quat[1]*quat[1];
    2.27 -	matrix[11] = 0.0f;
    2.28 -
    2.29 -	matrix[12] = matrix[13] = matrix[14] = 0.0f;
    2.30 -	matrix[15] = 1.0f;
    2.31 -
    2.32 -	transpose_matrix(matrix);
    2.33 -}
    2.34 -
    2.35 -void translation_matrix(const float *vec, float *matrix)
    2.36 -{
    2.37 -	memcpy(matrix, idmat, sizeof idmat);
    2.38 -	matrix[12] = vec[0];
    2.39 -	matrix[13] = vec[1];
    2.40 -	matrix[14] = vec[2];
    2.41 -}
    2.42 -
    2.43 -void mult_matrix(float *dest, const float *m1, const float *m2)
    2.44 -{
    2.45 -	int i, j;
    2.46 -	float tmp[16];
    2.47 -
    2.48 -	for(i=0; i<4; i++) {
    2.49 -		for(j=0; j<4; j++) {
    2.50 -			tmp[M(i, j)] = m1[M(i, 0)] * m2[M(0, j)] + m1[M(i, 1)] * m2[M(1, j)] +
    2.51 -				m1[M(i, 2)] * m2[M(2, j)] + m1[M(i, 3)] * m2[M(3, j)];
    2.52 -		}
    2.53 -	}
    2.54 -	memcpy(dest, tmp, sizeof tmp);
    2.55 -}
    2.56 -
    2.57 -void transpose_matrix(float *matrix)
    2.58 -{
    2.59 -	int i, j;
    2.60 -	float tmp[16];
    2.61 -
    2.62 -	for(i=0; i<4; i++) {
    2.63 -		for(j=0; j<4; j++) {
    2.64 -			tmp[M(i, j)] = matrix[M(j, i)];
    2.65 -		}
    2.66 -	}
    2.67 -	memcpy(matrix, tmp, sizeof tmp);
    2.68 -}
    2.69 -
    2.70 -void print_matrix(const float *matrix)
    2.71 -{
    2.72 -	int i, j;
    2.73 -
    2.74 -	for(i=0; i<4; i++) {
    2.75 -		putchar('[');
    2.76 -		for(j=0; j<4; j++) {
    2.77 -			printf("%6.3f ", matrix[M(i, j)]);
    2.78 -		}
    2.79 -		printf("]\n");
    2.80 -	}
    2.81 -}
    2.82 \ No newline at end of file
    2.83 +#include <stdio.h>
    2.84 +#include <string.h>
    2.85 +#include "mathutil.h"
    2.86 +
    2.87 +#define M(i, j)	((i) * 4 + (j))
    2.88 +
    2.89 +static const float idmat[] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
    2.90 +
    2.91 +void rotation_matrix(const float *quat, float *matrix)
    2.92 +{
    2.93 +	matrix[0] = 1.0 - 2.0 * quat[1] * quat[1] - 2.0 * quat[2] * quat[2];
    2.94 +	matrix[1] = 2.0 * quat[0] * quat[1] + 2.0 * quat[3] * quat[2];
    2.95 +	matrix[2] = 2.0 * quat[2] * quat[0] - 2.0 * quat[3] * quat[1];
    2.96 +	matrix[3] = 0.0f;
    2.97 +
    2.98 +	matrix[4] = 2.0 * quat[0] * quat[1] - 2.0 * quat[3] * quat[2];
    2.99 +	matrix[5] = 1.0 - 2.0 * quat[0]*quat[0] - 2.0 * quat[2]*quat[2];
   2.100 +	matrix[6] = 2.0 * quat[1] * quat[2] + 2.0 * quat[3] * quat[0];
   2.101 +	matrix[7] = 0.0f;
   2.102 +
   2.103 +	matrix[8] = 2.0 * quat[2] * quat[0] + 2.0 * quat[3] * quat[1];
   2.104 +	matrix[9] = 2.0 * quat[1] * quat[2] - 2.0 * quat[3] * quat[0];
   2.105 +	matrix[10] = 1.0 - 2.0 * quat[0]*quat[0] - 2.0 * quat[1]*quat[1];
   2.106 +	matrix[11] = 0.0f;
   2.107 +
   2.108 +	matrix[12] = matrix[13] = matrix[14] = 0.0f;
   2.109 +	matrix[15] = 1.0f;
   2.110 +
   2.111 +	transpose_matrix(matrix);
   2.112 +}
   2.113 +
   2.114 +void translation_matrix(const float *vec, float *matrix)
   2.115 +{
   2.116 +	memcpy(matrix, idmat, sizeof idmat);
   2.117 +	matrix[12] = vec[0];
   2.118 +	matrix[13] = vec[1];
   2.119 +	matrix[14] = vec[2];
   2.120 +}
   2.121 +
   2.122 +void mult_matrix(float *dest, const float *m1, const float *m2)
   2.123 +{
   2.124 +	int i, j;
   2.125 +	float tmp[16];
   2.126 +
   2.127 +	for(i=0; i<4; i++) {
   2.128 +		for(j=0; j<4; j++) {
   2.129 +			tmp[M(i, j)] = m1[M(i, 0)] * m2[M(0, j)] + m1[M(i, 1)] * m2[M(1, j)] +
   2.130 +				m1[M(i, 2)] * m2[M(2, j)] + m1[M(i, 3)] * m2[M(3, j)];
   2.131 +		}
   2.132 +	}
   2.133 +	memcpy(dest, tmp, sizeof tmp);
   2.134 +}
   2.135 +
   2.136 +void transpose_matrix(float *matrix)
   2.137 +{
   2.138 +	int i, j;
   2.139 +	float tmp[16];
   2.140 +
   2.141 +	for(i=0; i<4; i++) {
   2.142 +		for(j=0; j<4; j++) {
   2.143 +			tmp[M(i, j)] = matrix[M(j, i)];
   2.144 +		}
   2.145 +	}
   2.146 +	memcpy(matrix, tmp, sizeof tmp);
   2.147 +}
   2.148 +
   2.149 +void print_matrix(const float *matrix)
   2.150 +{
   2.151 +	int i, j;
   2.152 +
   2.153 +	for(i=0; i<4; i++) {
   2.154 +		putchar('[');
   2.155 +		for(j=0; j<4; j++) {
   2.156 +			printf("%6.3f ", matrix[M(i, j)]);
   2.157 +		}
   2.158 +		printf("]\n");
   2.159 +	}
   2.160 +}
     3.1 --- a/src/vr/mathutil.h	Sun Aug 24 14:36:00 2014 +0300
     3.2 +++ b/src/vr/mathutil.h	Sun Aug 24 18:42:40 2014 +0300
     3.3 @@ -1,13 +1,13 @@
     3.4 -#ifndef MATHUTIL_H_
     3.5 -#define MATHUTIL_H_
     3.6 -
     3.7 -void rotation_matrix(const float *quat, float *matrix);
     3.8 -void translation_matrix(const float *vec, float *matrix);
     3.9 -
    3.10 -void mult_matrix(float *dest, const float *m1, const float *m2);
    3.11 -
    3.12 -void transpose_matrix(float *matrix);
    3.13 -
    3.14 -void print_matrix(const float *matrix);
    3.15 -
    3.16 -#endif	/* MATHUTIL_H_ */
    3.17 \ No newline at end of file
    3.18 +#ifndef MATHUTIL_H_
    3.19 +#define MATHUTIL_H_
    3.20 +
    3.21 +void rotation_matrix(const float *quat, float *matrix);
    3.22 +void translation_matrix(const float *vec, float *matrix);
    3.23 +
    3.24 +void mult_matrix(float *dest, const float *m1, const float *m2);
    3.25 +
    3.26 +void transpose_matrix(float *matrix);
    3.27 +
    3.28 +void print_matrix(const float *matrix);
    3.29 +
    3.30 +#endif	/* MATHUTIL_H_ */