diff --git a/sweet_math.c b/sweet_math.c index 8fe96fb..9045d0e 100644 --- a/sweet_math.c +++ b/sweet_math.c @@ -516,6 +516,36 @@ sweet_vector_add4 (vec4 v1, vec4 v2) return v1; } +vec2 +sweet_vector_middle2 (vec2 vector1, vec2 vector2) +{ + vec2 v; + v.x = (vector1.x + vector2.x) * 0.5; + v.y = (vector1.y + vector2.y) * 0.5; + return v; +} + +vec3 +sweet_vector_middle3 (vec3 vector1, vec3 vector2) +{ + vec3 v; + v.x = (vector1.x + vector2.x) * 0.5; + v.y = (vector1.y + vector2.y) * 0.5; + v.z = (vector1.z + vector2.z) * 0.5; + return v; +} + +vec4 +sweet_vector_middle4 (vec4 vector1, vec4 vector2) +{ + vec4 v; + v.x = (vector1.x + vector2.x) * 0.5; + v.y = (vector1.y + vector2.y) * 0.5; + v.z = (vector1.z + vector2.z) * 0.5; + v.w = (vector1.w + vector2.w) * 0.5; + return v; +} + vec2 sweet_vector_sub2 (vec2 v1, vec2 v2) { diff --git a/sweet_math.h b/sweet_math.h index 2ee18b8..52ce27a 100644 --- a/sweet_math.h +++ b/sweet_math.h @@ -191,6 +191,14 @@ vec2 sweet_vector_add2 (vec2 vector1, vec2 vector2); vec3 sweet_vector_add3 (vec3 vector1, vec3 vector2); vec4 sweet_vector_add4 (vec4 vector1, vec4 vector2); +/** Middle */ +/** @param Vector1 as vector */ +/** @param Vector2 as vector */ +/** @return middle point between vector1 and vector2 */ +vec2 sweet_vector_middle2 (vec2 vector1, vec2 vector2); +vec3 sweet_vector_middle3 (vec3 vector1, vec3 vector2); +vec4 sweet_vector_middle4 (vec4 vector1, vec4 vector2); + /** Sub */ /** @param Vector1 as vector */ /** @param Vector2 as vector */ diff --git a/sweet_matrix.c b/sweet_matrix.c index b3519cb..4d893c6 100644 --- a/sweet_matrix.c +++ b/sweet_matrix.c @@ -242,7 +242,6 @@ mat4 sweet_matrix_look_at (vec3 pos, vec3 dir, vec3 up) { mat4 m; - mat4 t; vec3 side; side = sweet_vector_cross (dir, up); side = sweet_vector_normalize3 (side); @@ -885,15 +884,12 @@ sweet_matrix_product4 (mat4 * p, mat4 * a, mat4 * b) float bv0 = b->v[0]; float bv1 = b->v[1]; float bv2 = b->v[2]; - float bv3 = b->v[3]; float bv4 = b->v[4]; float bv5 = b->v[5]; float bv6 = b->v[6]; - float bv7 = b->v[7]; float bv8 = b->v[8]; float bv9 = b->v[9]; float bv10 = b->v[10]; - float bv11 = b->v[11]; float bv12 = b->v[12]; float bv13 = b->v[13]; float bv14 = b->v[14]; diff --git a/sweet_matrix_stack.c b/sweet_matrix_stack.c index b2b1dbb..323f367 100644 --- a/sweet_matrix_stack.c +++ b/sweet_matrix_stack.c @@ -72,7 +72,7 @@ sweet_matrix_stack4_push (matrix_stack4 * ms) if (ms->position >= SWEET_MATRIX_STACK_SIZE) { return 1; } ms->matrix[ms->position + 1] = ms->matrix[ms->position]; - ms->position = ms->position++; + ms->position++; return 0; }