fix incorrect translate function

v1
Brett 2023-04-01 02:55:00 -04:00
parent 5d841afe8c
commit 289af13171
4 changed files with 47 additions and 3 deletions

View File

@ -58,15 +58,19 @@ namespace blt {
} }
inline mat4x4& translate(float x, float y, float z) { inline mat4x4& translate(float x, float y, float z) {
mat4x4 translation_mat {};
/** /**
* 9.005 Are OpenGL matrices column-major or row-major? * 9.005 Are OpenGL matrices column-major or row-major?
* For programming purposes, OpenGL matrices are 16-value arrays with base vectors laid out contiguously in memory. * For programming purposes, OpenGL matrices are 16-value arrays with base vectors laid out contiguously in memory.
* The translation components occupy the 13th, 14th, and 15th elements of the 16-element matrix, * The translation components occupy the 13th, 14th, and 15th elements of the 16-element matrix,
* where indices are numbered from 1 to 16 as described in section 2.11.2 of the OpenGL 2.1 Specification. * where indices are numbered from 1 to 16 as described in section 2.11.2 of the OpenGL 2.1 Specification.
*/ */
m03(x); translation_mat.m03(x);
m13(y); translation_mat.m13(y);
m23(z); translation_mat.m23(z);
*this = *this * translation_mat;
return *this; return *this;
} }
@ -74,9 +78,14 @@ namespace blt {
inline mat4x4& translate(const vec3& vec) { return translate(vec[0], vec[1], vec[2]); } inline mat4x4& translate(const vec3& vec) { return translate(vec[0], vec[1], vec[2]); }
inline mat4x4& scale(float x, float y, float z) { inline mat4x4& scale(float x, float y, float z) {
mat4x4 scale_mat {};
m00(m00() * x); m00(m00() * x);
m11(m11() * y); m11(m11() * y);
m22(m11() * z); m22(m11() * z);
*this = *this * scale_mat;
return *this; return *this;
} }

View File

@ -0,0 +1,11 @@
/*
* Created by Brett on 31/03/23.
* Licensed under GNU General Public License V3.0
* See LICENSE file for license detail
*/
#ifndef BLT_HASH_MAP_H
#define BLT_HASH_MAP_H
#endif //BLT_HASH_MAP_H

18
src/tests/hashmap_tests.h Normal file
View File

@ -0,0 +1,18 @@
/*
* Created by Brett on 31/03/23.
* Licensed under GNU General Public License V3.0
* See LICENSE file for license detail
*/
#ifndef BLT_TESTS_HASHMAP_TEXTS_H
#define BLT_TESTS_HASHMAP_TEXTS_H
#include <blt/std/hash_map.h>
inline static int test_hashmaps(){
return 0;
}
#endif //BLT_TESTS_HASHMAP_TEXTS_H

View File

@ -8,6 +8,7 @@
#include "blt/math/vectors.h" #include "blt/math/vectors.h"
#include "blt/math/matrix.h" #include "blt/math/matrix.h"
#include <bitset> #include <bitset>
#include "hashmap_tests.h"
int main() { int main() {
binaryTreeTest(); binaryTreeTest();
@ -41,5 +42,10 @@ int main() {
std::cout << result.x() << " " << result.y() << " " << result.z() << " " << result.w() << std::endl; std::cout << result.x() << " " << result.y() << " " << result.z() << " " << result.w() << std::endl;
if (test_hashmaps()){
BLT_FATAL("Hashmap test failed!");
return 1;
}
return 0; return 0;
} }