fast functions of common math (untested!)

v1
Brett 2023-02-28 23:50:13 -05:00
parent b2666dc39e
commit b77638436e
5 changed files with 29 additions and 4 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.24) cmake_minimum_required(VERSION 3.24)
project(BLT VERSION 0.5.0) project(BLT VERSION 0.5.1)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)

View File

@ -181,7 +181,7 @@ CMAKE_PROJECT_HOMEPAGE_URL:STATIC=
CMAKE_PROJECT_NAME:STATIC=BLT_TESTS CMAKE_PROJECT_NAME:STATIC=BLT_TESTS
//Value Computed by CMake //Value Computed by CMake
CMAKE_PROJECT_VERSION:STATIC=0.5.0 CMAKE_PROJECT_VERSION:STATIC=0.5.1
//Value Computed by CMake //Value Computed by CMake
CMAKE_PROJECT_VERSION_MAJOR:STATIC=0 CMAKE_PROJECT_VERSION_MAJOR:STATIC=0
@ -190,7 +190,7 @@ CMAKE_PROJECT_VERSION_MAJOR:STATIC=0
CMAKE_PROJECT_VERSION_MINOR:STATIC=5 CMAKE_PROJECT_VERSION_MINOR:STATIC=5
//Value Computed by CMake //Value Computed by CMake
CMAKE_PROJECT_VERSION_PATCH:STATIC=0 CMAKE_PROJECT_VERSION_PATCH:STATIC=1
//Value Computed by CMake //Value Computed by CMake
CMAKE_PROJECT_VERSION_TWEAK:STATIC= CMAKE_PROJECT_VERSION_TWEAK:STATIC=

View File

@ -3,7 +3,7 @@ Standard Files /home/brett/Documents/code/c++/BLT/src/blt/std/filesystem.cpp;/ho
Profiler Files /home/brett/Documents/code/c++/BLT/src/blt/profiling/profiler.cpp Profiler Files /home/brett/Documents/code/c++/BLT/src/blt/profiling/profiler.cpp
Source: /home/brett/Documents/code/c++/BLT Source: /home/brett/Documents/code/c++/BLT
Current Source: /home/brett/Documents/code/c++/BLT Current Source: /home/brett/Documents/code/c++/BLT
BLT 0.5.0 Successfully included! BLT 0.5.1 Successfully included!
BLT tests included! BLT tests included!
-- Configuring done -- Configuring done
-- Generating done -- Generating done

View File

@ -12,6 +12,30 @@
namespace blt { namespace blt {
/**
* fast number integer
*/
unsigned int f_randi(unsigned int seed) {
seed = (seed << 13) ^ seed;
return ((seed * (seed * seed * 15731 + 789221) + 1376312589) & 0x7fffffff);
}
/**
* fast inverse sqrt
*/
float fsqrt(float n){
int i;
float x, y;
x = n * 0.5f;
y = n;
i = * (int*) &y;
i = 0x5f3759df - (i >> 1);
y = * (float*) &i;
y = y * (1.5f - (x * y * y));
y = y * (1.5f - (x * y * y));
return y;
}
// inline std::ostream& operator<<(std::ostream& out, const mat4x4& v) { // inline std::ostream& operator<<(std::ostream& out, const mat4x4& v) {
// return out << "\rMatrix4x4{" << v.m00() << ", " << v.m01() << ", " << v.m02() << ", " << v.m03() << "} \n"\ // return out << "\rMatrix4x4{" << v.m00() << ", " << v.m01() << ", " << v.m02() << ", " << v.m03() << "} \n"\
// << " {" << v.m10() << ", " << v.m11() << ", " << v.m12() << ", " << v.m13() << "} \n"\ // << " {" << v.m10() << ", " << v.m11() << ", " << v.m12() << ", " << v.m13() << "} \n"\

View File

@ -262,6 +262,7 @@ namespace blt {
// https://www.scratchapixel.com/lessons/3d-basic-rendering/perspective-and-orthographic-projection-matrix/building-basic-perspective-projection-matrix.html // https://www.scratchapixel.com/lessons/3d-basic-rendering/perspective-and-orthographic-projection-matrix/building-basic-perspective-projection-matrix.html
// https://ogldev.org/www/tutorial12/tutorial12.html // https://ogldev.org/www/tutorial12/tutorial12.html
// http://www.songho.ca/opengl/gl_projectionmatrix.html
static inline mat4x4 perspective(float fov, float aspect_ratio, float near, float far){ static inline mat4x4 perspective(float fov, float aspect_ratio, float near, float far){
mat4x4 perspectiveMat4x4 {emptyMatrix}; mat4x4 perspectiveMat4x4 {emptyMatrix};