From cdf867d71095743f37c1198aad7cafd8aaa29082 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 25 Oct 2024 08:38:52 +0200 Subject: [PATCH 01/54] add operator= for glm:: matrices corresponding to our at home matrices - we were never be able to do ourMatrixT = glmMatrixT and its important since a lot of utils create glmMatrixT actually --- include/nbl/builtin/hlsl/cpp_compat/matrix.hlsl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/nbl/builtin/hlsl/cpp_compat/matrix.hlsl b/include/nbl/builtin/hlsl/cpp_compat/matrix.hlsl index b1d33f097b..9a8ce9e51f 100644 --- a/include/nbl/builtin/hlsl/cpp_compat/matrix.hlsl +++ b/include/nbl/builtin/hlsl/cpp_compat/matrix.hlsl @@ -28,6 +28,12 @@ struct matrix final : private glm::mat return *this; } + matrix& operator=(Base const& rhs) + { + Base::operator=(rhs); + return *this; + } + friend matrix operator+(matrix const& lhs, matrix const& rhs){ return matrix(reinterpret_cast(lhs) + reinterpret_cast(rhs)); } friend matrix operator-(matrix const& lhs, matrix const& rhs){ return matrix(reinterpret_cast(lhs) - reinterpret_cast(rhs)); } From 6ef4f89383e012e8309e52f2cd7ade7fddf26599 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 25 Oct 2024 09:04:26 +0200 Subject: [PATCH 02/54] I'm stupid, I have explicit at home matrix constructor taking glm:: matrix xD remove the = operator glm -> to ours --- include/nbl/builtin/hlsl/cpp_compat/matrix.hlsl | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/include/nbl/builtin/hlsl/cpp_compat/matrix.hlsl b/include/nbl/builtin/hlsl/cpp_compat/matrix.hlsl index 9a8ce9e51f..cc89f9d003 100644 --- a/include/nbl/builtin/hlsl/cpp_compat/matrix.hlsl +++ b/include/nbl/builtin/hlsl/cpp_compat/matrix.hlsl @@ -27,13 +27,7 @@ struct matrix final : private glm::mat Base::operator=(rhs); return *this; } - - matrix& operator=(Base const& rhs) - { - Base::operator=(rhs); - return *this; - } - + friend matrix operator+(matrix const& lhs, matrix const& rhs){ return matrix(reinterpret_cast(lhs) + reinterpret_cast(rhs)); } friend matrix operator-(matrix const& lhs, matrix const& rhs){ return matrix(reinterpret_cast(lhs) - reinterpret_cast(rhs)); } From 22f505c8c7a976aa1b47e90e20bfca71fb2571ca Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 25 Oct 2024 10:33:28 +0200 Subject: [PATCH 03/54] steal include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl from https://github.com/Devsh-Graphics-Programming/Nabla/pull/760 --- .../transformation_matrix_utils.hlsl | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl diff --git a/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl b/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl new file mode 100644 index 0000000000..d50bc16869 --- /dev/null +++ b/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl @@ -0,0 +1,112 @@ +#ifndef _NBL_BUILTIN_HLSL_TRANSFORMATION_MATRIX_UTILS_INCLUDED_ +#define _NBL_BUILTIN_HLSL_TRANSFORMATION_MATRIX_UTILS_INCLUDED_ + +#include + +namespace nbl +{ +namespace hlsl +{ + +template +matrix getMatrix3x4As4x4(const matrix& mat) +{ + matrix output; + for (int i = 0; i < 3; ++i) + output[i] = mat[i]; + output[3] = float32_t4(0.0f, 0.0f, 0.0f, 1.0f); + + return output; +} + +// TODO: use portable_float when merged +//! multiplies matrices a and b, 3x4 matrices are treated as 4x4 matrices with 4th row set to (0, 0, 0 ,1) +template +inline matrix concatenateBFollowedByA(const matrix& a, const matrix& b) +{ + const matrix a4x4 = getMatrix3x4As4x4(a); + const matrix b4x4 = getMatrix3x4As4x4(b); + return matrix(mul(a4x4, b4x4)); +} + +template +inline matrix buildCameraLookAtMatrixLH( + const vector& position, + const vector& target, + const vector& upVector) +{ + const vector zaxis = core::normalize(target - position); + const vector xaxis = core::normalize(core::cross(upVector, zaxis)); + const vector yaxis = core::cross(zaxis, xaxis); + + matrix r; + r[0] = vector(xaxis, -dot(xaxis, position)); + r[1] = vector(yaxis, -dot(yaxis, position)); + r[2] = vector(zaxis, -dot(zaxis, position)); + + return r; +} + +float32_t3x4 buildCameraLookAtMatrixRH( + const float32_t3& position, + const float32_t3& target, + const float32_t3& upVector) +{ + const float32_t3 zaxis = core::normalize(position - target); + const float32_t3 xaxis = core::normalize(core::cross(upVector, zaxis)); + const float32_t3 yaxis = core::cross(zaxis, xaxis); + + float32_t3x4 r; + r[0] = float32_t4(xaxis, -dot(xaxis, position)); + r[1] = float32_t4(yaxis, -dot(yaxis, position)); + r[2] = float32_t4(zaxis, -dot(zaxis, position)); + + return r; +} + +// TODO: test, check if there is better implementation +// TODO: move quaternion to nbl::hlsl +// TODO: why NBL_REF_ARG(MatType) doesn't work????? + +//! Replaces curent rocation and scale by rotation represented by quaternion `quat`, leaves 4th row and 4th colum unchanged +template +inline void setRotation(matrix& outMat, NBL_CONST_REF_ARG(core::quaternion) quat) +{ + static_assert(N == 3 || N == 4); + + outMat[0] = vector( + 1 - 2 * (quat.y * quat.y + quat.z * quat.z), + 2 * (quat.x * quat.y - quat.z * quat.w), + 2 * (quat.x * quat.z + quat.y * quat.w), + outMat[0][3] + ); + + outMat[1] = vector( + 2 * (quat.x * quat.y + quat.z * quat.w), + 1 - 2 * (quat.x * quat.x + quat.z * quat.z), + 2 * (quat.y * quat.z - quat.x * quat.w), + outMat[1][3] + ); + + outMat[2] = vector( + 2 * (quat.x * quat.z - quat.y * quat.w), + 2 * (quat.y * quat.z + quat.x * quat.w), + 1 - 2 * (quat.x * quat.x + quat.y * quat.y), + outMat[2][3] + ); +} + +template +inline void setTranslation(matrix& outMat, NBL_CONST_REF_ARG(vector) translation) +{ + static_assert(N == 3 || N == 4); + + outMat[0].w = translation.x; + outMat[1].w = translation.y; + outMat[2].w = translation.z; +} + +} +} + +#endif \ No newline at end of file From 51f4cedff116b7777c6bcb922f30ed00e88c77b4 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 25 Oct 2024 11:06:23 +0200 Subject: [PATCH 04/54] fix getMatrix3x4As4x4 (return type issues) & buildCameraLookAtMatrixRH (ambiguity dependent type issues), reference https://github.com/Devsh-Graphics-Programming/Nabla/pull/760 --- .../transformation_matrix_utils.hlsl | 31 ++++++++++--------- include/nbl/core/math/glslFunctions.h | 1 + 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl b/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl index d50bc16869..3c5b2adcd0 100644 --- a/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl +++ b/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl @@ -9,7 +9,7 @@ namespace hlsl { template -matrix getMatrix3x4As4x4(const matrix& mat) +matrix getMatrix3x4As4x4(const matrix& mat) { matrix output; for (int i = 0; i < 3; ++i) @@ -24,8 +24,8 @@ matrix getMatrix3x4As4x4(const matrix& mat) template inline matrix concatenateBFollowedByA(const matrix& a, const matrix& b) { - const matrix a4x4 = getMatrix3x4As4x4(a); - const matrix b4x4 = getMatrix3x4As4x4(b); + const auto a4x4 = getMatrix3x4As4x4(a); + const auto b4x4 = getMatrix3x4As4x4(b); return matrix(mul(a4x4, b4x4)); } @@ -47,19 +47,20 @@ inline matrix buildCameraLookAtMatrixLH( return r; } -float32_t3x4 buildCameraLookAtMatrixRH( - const float32_t3& position, - const float32_t3& target, - const float32_t3& upVector) +template +inline matrix buildCameraLookAtMatrixRH( + const vector& position, + const vector& target, + const vector& upVector) { - const float32_t3 zaxis = core::normalize(position - target); - const float32_t3 xaxis = core::normalize(core::cross(upVector, zaxis)); - const float32_t3 yaxis = core::cross(zaxis, xaxis); - - float32_t3x4 r; - r[0] = float32_t4(xaxis, -dot(xaxis, position)); - r[1] = float32_t4(yaxis, -dot(yaxis, position)); - r[2] = float32_t4(zaxis, -dot(zaxis, position)); + const vector zaxis = core::normalize(position - target); + const vector xaxis = core::normalize(core::cross(upVector, zaxis)); + const vector yaxis = core::cross(zaxis, xaxis); + + matrix r; + r[0] = vector(xaxis, -dot(xaxis, position)); + r[1] = vector(yaxis, -dot(yaxis, position)); + r[2] = vector(zaxis, -dot(zaxis, position)); return r; } diff --git a/include/nbl/core/math/glslFunctions.h b/include/nbl/core/math/glslFunctions.h index 2bd17cd642..3c9cc98850 100644 --- a/include/nbl/core/math/glslFunctions.h +++ b/include/nbl/core/math/glslFunctions.h @@ -362,6 +362,7 @@ NBL_FORCE_INLINE vectorSIMDf cross(const vectorSIMDf& a, const vect template NBL_FORCE_INLINE T normalize(const T& v) { + // TODO: THIS CREATES AMGIGUITY WITH GLM:: NAMESPACE! auto d = dot(v, v); #ifdef __NBL_FAST_MATH return v * core::inversesqrt(d); From 7f2c0857be1555d591971ec84639576bcb895926 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 25 Oct 2024 14:38:27 +0200 Subject: [PATCH 05/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index c5f12f0075..038c5d7992 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit c5f12f0075f34e5dca36079b09b75aef19f07681 +Subproject commit 038c5d799269a026ffa71e48f5963013632e4634 From f1daa257e1d2d097a77c986ef15065acb874332c Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 25 Oct 2024 16:24:30 +0200 Subject: [PATCH 06/54] actually *this* addresses https://github.com/Devsh-Graphics-Programming/Nabla/pull/760/files#r1816728485 for https://github.com/Devsh-Graphics-Programming/Nabla/pull/760 PR, update examples_tests submodule --- examples_tests | 2 +- .../transformation_matrix_utils.hlsl | 26 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/examples_tests b/examples_tests index 038c5d7992..0415999a70 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 038c5d799269a026ffa71e48f5963013632e4634 +Subproject commit 0415999a7035f56f3d9cca7255329916c697ab36 diff --git a/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl b/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl index 3c5b2adcd0..b2534f9ac8 100644 --- a/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl +++ b/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl @@ -29,20 +29,22 @@ inline matrix concatenateBFollowedByA(const matrix& a, const m return matrix(mul(a4x4, b4x4)); } +// /Arek: glm:: for normalize till dot product is fixed (ambiguity with glm namespace + linker issues) + template inline matrix buildCameraLookAtMatrixLH( const vector& position, const vector& target, const vector& upVector) { - const vector zaxis = core::normalize(target - position); - const vector xaxis = core::normalize(core::cross(upVector, zaxis)); - const vector yaxis = core::cross(zaxis, xaxis); + const vector zaxis = glm::normalize(target - position); + const vector xaxis = glm::normalize(hlsl::cross(upVector, zaxis)); + const vector yaxis = hlsl::cross(zaxis, xaxis); matrix r; - r[0] = vector(xaxis, -dot(xaxis, position)); - r[1] = vector(yaxis, -dot(yaxis, position)); - r[2] = vector(zaxis, -dot(zaxis, position)); + r[0] = vector(xaxis, -hlsl::dot(xaxis, position)); + r[1] = vector(yaxis, -hlsl::dot(yaxis, position)); + r[2] = vector(zaxis, -hlsl::dot(zaxis, position)); return r; } @@ -53,14 +55,14 @@ inline matrix buildCameraLookAtMatrixRH( const vector& target, const vector& upVector) { - const vector zaxis = core::normalize(position - target); - const vector xaxis = core::normalize(core::cross(upVector, zaxis)); - const vector yaxis = core::cross(zaxis, xaxis); + const vector zaxis = glm::normalize(position - target); + const vector xaxis = glm::normalize(hlsl::cross(upVector, zaxis)); + const vector yaxis = hlsl::cross(zaxis, xaxis); matrix r; - r[0] = vector(xaxis, -dot(xaxis, position)); - r[1] = vector(yaxis, -dot(yaxis, position)); - r[2] = vector(zaxis, -dot(zaxis, position)); + r[0] = vector(xaxis, -hlsl::dot(xaxis, position)); + r[1] = vector(yaxis, -hlsl::dot(yaxis, position)); + r[2] = vector(zaxis, -hlsl::dot(zaxis, position)); return r; } From 2192e99e91d359bf7f8c544990d03fdef56a7b4f Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 25 Oct 2024 16:56:07 +0200 Subject: [PATCH 07/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 0415999a70..84f35e5d62 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 0415999a7035f56f3d9cca7255329916c697ab36 +Subproject commit 84f35e5d6259d0c814af72ccefcba0d00818668e From 520b1f5d8702098505bfc111f481d07814158a97 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 28 Oct 2024 11:44:40 +0100 Subject: [PATCH 08/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 84f35e5d62..0574d725b2 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 84f35e5d6259d0c814af72ccefcba0d00818668e +Subproject commit 0574d725b2d0ae02a0d0e409e642a14981bc1e97 From a0890f0df957e0d989d956ec41c41fd3be72791a Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sat, 2 Nov 2024 08:52:21 +0100 Subject: [PATCH 09/54] forgot to commit projection build methods, update examples_tests submodule --- examples_tests | 2 +- .../transformation_matrix_utils.hlsl | 68 +++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 0574d725b2..ccbb37cf2b 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 0574d725b2d0ae02a0d0e409e642a14981bc1e97 +Subproject commit ccbb37cf2bf150dec0c9ad8ea5d328fbb3806745 diff --git a/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl b/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl index b2534f9ac8..aee84405a2 100644 --- a/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl +++ b/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl @@ -109,6 +109,74 @@ inline void setTranslation(matrix& outMat, NBL_CONST_REF_ARG(vector +inline matrix buildProjectionMatrixPerspectiveFovRH(float fieldOfViewRadians, float aspectRatio, float zNear, float zFar) +{ + const float h = core::reciprocal(tanf(fieldOfViewRadians * 0.5f)); + _NBL_DEBUG_BREAK_IF(aspectRatio == 0.f); //division by zero + const float w = h / aspectRatio; + + _NBL_DEBUG_BREAK_IF(zNear == zFar); //division by zero + + matrix m; + m[0] = vector(w, 0.f, 0.f, 0.f); + m[1] = vector(0.f, -h, 0.f, 0.f); + m[2] = vector(0.f, 0.f, -zFar / (zFar - zNear), -zNear * zFar / (zFar - zNear)); + m[3] = vector(0.f, 0.f, -1.f, 0.f); + + return m; +} +template +inline matrix buildProjectionMatrixPerspectiveFovLH(float fieldOfViewRadians, float aspectRatio, float zNear, float zFar) +{ + const float h = core::reciprocal(tanf(fieldOfViewRadians * 0.5f)); + _NBL_DEBUG_BREAK_IF(aspectRatio == 0.f); //division by zero + const float w = h / aspectRatio; + + _NBL_DEBUG_BREAK_IF(zNear == zFar); //division by zero + + matrix m; + m[0] = vector(w, 0.f, 0.f, 0.f); + m[1] = vector(0.f, -h, 0.f, 0.f); + m[2] = vector(0.f, 0.f, zFar / (zFar - zNear), -zNear * zFar / (zFar - zNear)); + m[3] = vector(0.f, 0.f, 1.f, 0.f); + + return m; +} + +template +inline matrix buildProjectionMatrixOrthoRH(float widthOfViewVolume, float heightOfViewVolume, float zNear, float zFar) +{ + _NBL_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); //division by zero + _NBL_DEBUG_BREAK_IF(heightOfViewVolume == 0.f); //division by zero + _NBL_DEBUG_BREAK_IF(zNear == zFar); //division by zero + + matrix m; + m[0] = vector(2.f / widthOfViewVolume, 0.f, 0.f, 0.f); + m[1] = vector(0.f, -2.f / heightOfViewVolume, 0.f, 0.f); + m[2] = vector(0.f, 0.f, -1.f / (zFar - zNear), -zNear / (zFar - zNear)); + m[3] = vector(0.f, 0.f, 0.f, 1.f); + + return m; +} + +template +inline matrix buildProjectionMatrixOrthoLH(float widthOfViewVolume, float heightOfViewVolume, float zNear, float zFar) +{ + _NBL_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); //division by zero + _NBL_DEBUG_BREAK_IF(heightOfViewVolume == 0.f); //division by zero + _NBL_DEBUG_BREAK_IF(zNear == zFar); //division by zero + + matrix m; + m[0] = vector(2.f / widthOfViewVolume, 0.f, 0.f, 0.f); + m[1] = vector(0.f, -2.f / heightOfViewVolume, 0.f, 0.f); + m[2] = vector(0.f, 0.f, 1.f / (zFar - zNear), -zNear / (zFar - zNear)); + m[3] = vector(0.f, 0.f, 0.f, 1.f); + + return m; +} + } } From 0109b22b397ef99053e7b87ff028ca49a8ab8e2d Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sat, 2 Nov 2024 15:50:37 +0100 Subject: [PATCH 10/54] add is_smart_refctd_ptr_v, update examples_tests submodule --- examples_tests | 2 +- .../hlsl/matrix_utils/transformation_matrix_utils.hlsl | 8 ++++---- include/nbl/core/decl/smart_refctd_ptr.h | 9 +++++++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/examples_tests b/examples_tests index ccbb37cf2b..d3f325d6d2 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit ccbb37cf2bf150dec0c9ad8ea5d328fbb3806745 +Subproject commit d3f325d6d2b4c9c623b8e70a0882a1bae17471fb diff --git a/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl b/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl index aee84405a2..22bc82ea13 100644 --- a/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl +++ b/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl @@ -110,7 +110,7 @@ inline void setTranslation(matrix& outMat, NBL_CONST_REF_ARG(vector +template inline matrix buildProjectionMatrixPerspectiveFovRH(float fieldOfViewRadians, float aspectRatio, float zNear, float zFar) { const float h = core::reciprocal(tanf(fieldOfViewRadians * 0.5f)); @@ -127,7 +127,7 @@ inline matrix buildProjectionMatrixPerspectiveFovRH(float fieldOfViewRa return m; } -template +template inline matrix buildProjectionMatrixPerspectiveFovLH(float fieldOfViewRadians, float aspectRatio, float zNear, float zFar) { const float h = core::reciprocal(tanf(fieldOfViewRadians * 0.5f)); @@ -145,7 +145,7 @@ inline matrix buildProjectionMatrixPerspectiveFovLH(float fieldOfViewRa return m; } -template +template inline matrix buildProjectionMatrixOrthoRH(float widthOfViewVolume, float heightOfViewVolume, float zNear, float zFar) { _NBL_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); //division by zero @@ -161,7 +161,7 @@ inline matrix buildProjectionMatrixOrthoRH(float widthOfViewVolume, flo return m; } -template +template inline matrix buildProjectionMatrixOrthoLH(float widthOfViewVolume, float heightOfViewVolume, float zNear, float zFar) { _NBL_DEBUG_BREAK_IF(widthOfViewVolume == 0.f); //division by zero diff --git a/include/nbl/core/decl/smart_refctd_ptr.h b/include/nbl/core/decl/smart_refctd_ptr.h index 7c231fea4b..74fdf61693 100644 --- a/include/nbl/core/decl/smart_refctd_ptr.h +++ b/include/nbl/core/decl/smart_refctd_ptr.h @@ -144,6 +144,15 @@ smart_refctd_ptr move_and_dynamic_cast(smart_refctd_ptr& smart_ptr); template< class U, class T > smart_refctd_ptr move_and_dynamic_cast(smart_refctd_ptr&& smart_ptr) {return move_and_dynamic_cast(smart_ptr);} +template +struct is_smart_refctd_ptr : std::false_type {}; + +template +struct is_smart_refctd_ptr> : std::true_type {}; + +template +inline constexpr bool is_smart_refctd_ptr_v = is_smart_refctd_ptr::value; + } // end namespace nbl::core /* From 2a29a2f970ea114476cec1fa741075773ad1dbf0 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sun, 3 Nov 2024 19:30:28 +0100 Subject: [PATCH 11/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index d3f325d6d2..f9fce56971 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit d3f325d6d2b4c9c623b8e70a0882a1bae17471fb +Subproject commit f9fce56971dd80264eb107c413ba0b038f4ebf96 From 7673769d878a6a12034d2a97fd51a49abb077a6c Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sun, 3 Nov 2024 20:12:10 +0100 Subject: [PATCH 12/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index f9fce56971..2f44640ec4 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit f9fce56971dd80264eb107c413ba0b038f4ebf96 +Subproject commit 2f44640ec4e823c5d97b427562b291fd0e3eb62f From 9a139df50bbf14c01a1b6e45bd7c9370f5ea2670 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Wed, 6 Nov 2024 17:58:29 +0100 Subject: [PATCH 13/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 2f44640ec4..4428dbb6c4 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 2f44640ec4e823c5d97b427562b291fd0e3eb62f +Subproject commit 4428dbb6c4b03ea80aae746b3f7ba51ed040f027 From 24a80c98802a4c418bc1e63db0ff623458bea892 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 8 Nov 2024 16:28:39 +0100 Subject: [PATCH 14/54] create ui::E_MOUSE_CODE & constexpr ui::mouseCodeToString - we really were missing an equivalent of E_KEY_CODE. Update examples_tests submodule --- examples_tests | 2 +- include/nbl/ui/KeyCodes.h | 51 ++++++++++++++++++++++++++++++++++++ include/nbl/ui/SInputEvent.h | 1 - 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/examples_tests b/examples_tests index 4428dbb6c4..4d32863a11 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 4428dbb6c4b03ea80aae746b3f7ba51ed040f027 +Subproject commit 4d32863a11a727b255d9dfaa8592336edb4151b9 diff --git a/include/nbl/ui/KeyCodes.h b/include/nbl/ui/KeyCodes.h index b6d05aed36..eae8edaf5f 100644 --- a/include/nbl/ui/KeyCodes.h +++ b/include/nbl/ui/KeyCodes.h @@ -276,5 +276,56 @@ enum E_MOUSE_BUTTON : uint8_t EMB_COUNT, }; +// Unambiguous set of "codes" to represent various mouse actions we support with Nabla - equivalent of E_KEY_CODE +enum E_MOUSE_CODE : uint8_t +{ + EMC_NONE = 0, + + // I know its E_MOUSE_BUTTON, this enum *must* be more abstract to standardize mouse + EMC_LEFT_BUTTON, + EMC_RIGHT_BUTTON, + EMC_MIDDLE_BUTTON, + EMC_BUTTON_4, + EMC_BUTTON_5, + + // and this is kinda SMouseEvent::E_EVENT_TYPE::EET_SCROLL + EMC_VERTICAL_POSITIVE_SCROLL, + EMC_VERTICAL_NEGATIVE_SCROLL, + EMC_HORIZONTAL_POSITIVE_SCROLL, + EMC_HORIZONTAL_NEGATIVE_SCROLL, + + // SMouseEvent::E_EVENT_TYPE::EET_MOVEMENT + EMC_RELATIVE_POSITIVE_MOVEMENT_X, + EMC_RELATIVE_POSITIVE_MOVEMENT_Y, + EMC_RELATIVE_NEGATIVE_MOVEMENT_X, + EMC_RELATIVE_NEGATIVE_MOVEMENT_Y, + + EMC_COUNT, +}; + +constexpr std::string_view mouseCodeToString(E_MOUSE_CODE code) +{ + switch (code) + { + case EMC_LEFT_BUTTON: return "LEFT_BUTTON"; + case EMC_RIGHT_BUTTON: return "RIGHT_BUTTON"; + case EMC_MIDDLE_BUTTON: return "MIDDLE_BUTTON"; + case EMC_BUTTON_4: return "BUTTON_4"; + case EMC_BUTTON_5: return "BUTTON_5"; + + case EMC_VERTICAL_POSITIVE_SCROLL: return "VERTICAL_POSITIVE_SCROLL"; + case EMC_VERTICAL_NEGATIVE_SCROLL: return "VERTICAL_NEGATIVE_SCROLL"; + case EMC_HORIZONTAL_POSITIVE_SCROLL: return "HORIZONTAL_POSITIVE_SCROLL"; + case EMC_HORIZONTAL_NEGATIVE_SCROLL: return "HORIZONTAL_NEGATIVE_SCROLL"; + + case EMC_RELATIVE_POSITIVE_MOVEMENT_X: return "RELATIVE_POSITIVE_MOVEMENT_X"; + case EMC_RELATIVE_POSITIVE_MOVEMENT_Y: return "RELATIVE_POSITIVE_MOVEMENT_Y"; + case EMC_RELATIVE_NEGATIVE_MOVEMENT_X: return "RELATIVE_NEGATIVE_MOVEMENT_X"; + case EMC_RELATIVE_NEGATIVE_MOVEMENT_Y: return "RELATIVE_NEGATIVE_MOVEMENT_Y"; + + default: return "NONE"; + } +} + } #endif diff --git a/include/nbl/ui/SInputEvent.h b/include/nbl/ui/SInputEvent.h index d791d08e53..9575f626d4 100644 --- a/include/nbl/ui/SInputEvent.h +++ b/include/nbl/ui/SInputEvent.h @@ -55,7 +55,6 @@ struct SMouseEvent : SEventBase IWindow* window; }; - struct SKeyboardEvent : SEventBase { inline SKeyboardEvent(std::chrono::microseconds ts) : SEventBase(ts) { } From 21b89b48d1d0574ddadd34eca64cac36848aa6f5 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Tue, 12 Nov 2024 00:58:02 +0100 Subject: [PATCH 15/54] @alichraghi small homework - read https://en.cppreference.com/w/cpp/language/inline and afterwards https://gudok.xyz/inline/ please --- src/nbl/asset/utils/IShaderCompiler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nbl/asset/utils/IShaderCompiler.cpp b/src/nbl/asset/utils/IShaderCompiler.cpp index bde89557ec..01cd360389 100644 --- a/src/nbl/asset/utils/IShaderCompiler.cpp +++ b/src/nbl/asset/utils/IShaderCompiler.cpp @@ -24,7 +24,7 @@ IShaderCompiler::IShaderCompiler(core::smart_refctd_ptr&& syste m_defaultIncludeFinder = core::make_smart_refctd_ptr(core::smart_refctd_ptr(m_system)); } -inline core::smart_refctd_ptr nbl::asset::IShaderCompiler::compileToSPIRV(const std::string_view code, const SCompilerOptions& options) const +core::smart_refctd_ptr nbl::asset::IShaderCompiler::compileToSPIRV(const std::string_view code, const SCompilerOptions& options) const { CCache::SEntry entry; std::vector dependencies; From 68bc7be7837318fd60658d2b0a1b703babee7732 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Tue, 12 Nov 2024 08:23:11 +0100 Subject: [PATCH 16/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index c991edf6fd..797ba40eac 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit c991edf6fdee8a721285cc8940e6b4111fd6427b +Subproject commit 797ba40eacaf8c03417d9b20df8d051edc80413d From 866e84409a0e69ba91069de4b7733974c1d09b29 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 15 Nov 2024 14:15:34 +0100 Subject: [PATCH 17/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 797ba40eac..65efa99add 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 797ba40eacaf8c03417d9b20df8d051edc80413d +Subproject commit 65efa99addb6e968a923f5f646023b0c0823f156 From 8bd64367c8f5454273f7849ee48ae4e22016816d Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 15 Nov 2024 14:40:19 +0100 Subject: [PATCH 18/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 65efa99add..2c428694d4 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 65efa99addb6e968a923f5f646023b0c0823f156 +Subproject commit 2c428694d4a6e71a61e969ad3cac263b072f7fe3 From de69afe3ed04a3a4c221358f688ec43a87040f4f Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 18 Nov 2024 14:55:56 +0100 Subject: [PATCH 19/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 2c428694d4..c1063e29ed 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 2c428694d4a6e71a61e969ad3cac263b072f7fe3 +Subproject commit c1063e29ed38f85410f97232b9372cb43a7a551e From a55bd390d189900ed05058838f92f0c4f950b71b Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 18 Nov 2024 15:29:01 +0100 Subject: [PATCH 20/54] update imguizmo with its upstream --- 3rdparty/CMakeLists.txt | 13 +++++++++++-- 3rdparty/imguizmo | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 0165b912e7..5357588043 100755 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -382,8 +382,17 @@ if(NBL_BUILD_IMGUI) target_link_libraries(imtestengine PUBLIC imtestsuite) - set(IMGUIZMO_BUILD_EXAMPLE OFF) - add_subdirectory(imguizmo EXCLUDE_FROM_ALL) + # imguizmo + add_library(imguizmo + "${CMAKE_CURRENT_SOURCE_DIR}/imguizmo/GraphEditor.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/imguizmo/ImCurveEdit.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/imguizmo/ImGradient.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/imguizmo/ImGuizmo.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/imguizmo/ImSequencer.cpp" + ) + + target_include_directories(imguizmo PUBLIC $) + target_link_libraries(imguizmo PUBLIC imgui) # note we override imgui config with our own set(NBL_IMGUI_USER_CONFIG_FILEPATH "${NBL_IMGUI_ROOT}/nabla_imconfig.h") diff --git a/3rdparty/imguizmo b/3rdparty/imguizmo index 6f4b2197ef..b10e91756d 160000 --- a/3rdparty/imguizmo +++ b/3rdparty/imguizmo @@ -1 +1 @@ -Subproject commit 6f4b2197efd715d16b19775b00f36c6c6f5aacb6 +Subproject commit b10e91756d32395f5c1fefd417899b657ed7cb88 From 6f3c5fc7a581c35922c0749076e8300647460bf0 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 18 Nov 2024 16:35:14 +0100 Subject: [PATCH 21/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index c1063e29ed..d6db4a7f0e 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit c1063e29ed38f85410f97232b9372cb43a7a551e +Subproject commit d6db4a7f0e10535d44e925e7237a6d4fa56cc740 From 0d126dfbb9530fd0a9f574b3cf6f42bbf03fe977 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 2 Dec 2024 09:48:37 +0100 Subject: [PATCH 22/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index d6db4a7f0e..c170c5d687 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit d6db4a7f0e10535d44e925e7237a6d4fa56cc740 +Subproject commit c170c5d68719977a9000af4ad5eed35a517a8d1d From 31e85e78cda8a6d76dce4d11b23e7b9e5f8c6bd8 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 2 Dec 2024 19:32:40 +0100 Subject: [PATCH 23/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index c170c5d687..df0d70210a 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit c170c5d68719977a9000af4ad5eed35a517a8d1d +Subproject commit df0d70210a02f8bbc47aaaab750d4b06c505a248 From 08f11f61d37a22f090d5543c19db604026ced80e Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Tue, 3 Dec 2024 16:45:27 +0100 Subject: [PATCH 24/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index df0d70210a..6cd5e18f6a 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit df0d70210a02f8bbc47aaaab750d4b06c505a248 +Subproject commit 6cd5e18f6a62f6387d40a4137ac577ca42140613 From 5bcd6ef7a80815748db0a36dfbb63099abb7bbc5 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Thu, 12 Dec 2024 11:08:03 +0100 Subject: [PATCH 25/54] add getCastedMatrix & getCastedVector, update examples_tests submodule --- examples_tests | 2 +- .../transformation_matrix_utils.hlsl | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 6cd5e18f6a..11585e2355 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 6cd5e18f6a62f6387d40a4137ac577ca42140613 +Subproject commit 11585e2355b15b6c22cdbdde81c785ed9b8e6b01 diff --git a/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl b/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl index 22bc82ea13..926398354f 100644 --- a/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl +++ b/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl @@ -19,6 +19,28 @@ matrix getMatrix3x4As4x4(const matrix& mat) return output; } +template +inline vector getCastedVector(const vector& in) +{ + vector out; + + for (int i = 0; i < N; ++i) + out[i] = (Tout)(in[i]); + + return out; +} + +template +inline matrix getCastedMatrix(const matrix& in) +{ + matrix out; + + for (int i = 0; i < N; ++i) + out[i] = getCastedVector(in[i]); + + return out; +} + // TODO: use portable_float when merged //! multiplies matrices a and b, 3x4 matrices are treated as 4x4 matrices with 4th row set to (0, 0, 0 ,1) template From 5a07fe7141474ccb44f68fc9e43db13c9bf85f96 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 13 Dec 2024 08:26:46 +0100 Subject: [PATCH 26/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 11585e2355..ded92d8f53 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 11585e2355b15b6c22cdbdde81c785ed9b8e6b01 +Subproject commit ded92d8f53b10c9ab87dde982cf19e37a0cc29df From f55b268bf602497c48852451dabdf92f60f039f8 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 13 Dec 2024 10:59:43 +0100 Subject: [PATCH 27/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index ded92d8f53..5e5c6814c1 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit ded92d8f53b10c9ab87dde982cf19e37a0cc29df +Subproject commit 5e5c6814c1446073387b76296f7565afbb415134 From 01f909ae696aa84f993fae31b425029ce07132aa Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 13 Dec 2024 16:06:14 +0100 Subject: [PATCH 28/54] add examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 5e5c6814c1..1d799e1af6 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 5e5c6814c1446073387b76296f7565afbb415134 +Subproject commit 1d799e1af6319f5989721cd38108ac8e3b12e93f From ab90d33d6bfc13ec4028169ef9f5629ce12eafed Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 13 Dec 2024 17:21:10 +0100 Subject: [PATCH 29/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 1d799e1af6..73c2a6a696 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 1d799e1af6319f5989721cd38108ac8e3b12e93f +Subproject commit 73c2a6a696c7c49ef444e0006c3901a8b36b19be From c9f09608fcb81cac8f149bb147be78d92df24afb Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sat, 14 Dec 2024 14:51:37 +0100 Subject: [PATCH 30/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 73c2a6a696..6ad873ee20 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 73c2a6a696c7c49ef444e0006c3901a8b36b19be +Subproject commit 6ad873ee20c8bbf15f7e497907b9936f2f7f74e8 From 3727ae3e38dc9d6a653528d2e5b7fd34e9e5f2f1 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sat, 14 Dec 2024 16:03:41 +0100 Subject: [PATCH 31/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 6ad873ee20..c615d58beb 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 6ad873ee20c8bbf15f7e497907b9936f2f7f74e8 +Subproject commit c615d58bebb71e5ddb27f48f8a09425a7ba0b33d From e9f78a2fbd995540e2ede9be445d5a6492142567 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sat, 14 Dec 2024 17:04:01 +0100 Subject: [PATCH 32/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index c615d58beb..10fe3b2972 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit c615d58bebb71e5ddb27f48f8a09425a7ba0b33d +Subproject commit 10fe3b297287b576b6689b959f46f57362410ab9 From 33f8d01e10cbf1f6ee1e5c51b7ec74d26dc65986 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 16 Dec 2024 15:58:27 +0100 Subject: [PATCH 33/54] add constexpr stringToKeyCode & stringToMouseCode --- include/nbl/ui/KeyCodes.h | 149 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) diff --git a/include/nbl/ui/KeyCodes.h b/include/nbl/ui/KeyCodes.h index eae8edaf5f..fb749cb801 100644 --- a/include/nbl/ui/KeyCodes.h +++ b/include/nbl/ui/KeyCodes.h @@ -266,6 +266,136 @@ constexpr char keyCodeToChar(E_KEY_CODE code, bool shiftPressed) return result; } +constexpr E_KEY_CODE stringToKeyCode(std::string_view str) +{ + if (str == "BACKSPACE") return EKC_BACKSPACE; + if (str == "TAB") return EKC_TAB; + if (str == "CLEAR") return EKC_CLEAR; + if (str == "ENTER") return EKC_ENTER; + if (str == "LEFT_SHIFT") return EKC_LEFT_SHIFT; + if (str == "RIGHT_SHIFT") return EKC_RIGHT_SHIFT; + if (str == "LEFT_CONTROL") return EKC_LEFT_CONTROL; + if (str == "RIGHT_CONTROL") return EKC_RIGHT_CONTROL; + if (str == "LEFT_ALT") return EKC_LEFT_ALT; + if (str == "RIGHT_ALT") return EKC_RIGHT_ALT; + if (str == "PAUSE") return EKC_PAUSE; + if (str == "CAPS_LOCK") return EKC_CAPS_LOCK; + if (str == "ESCAPE") return EKC_ESCAPE; + if (str == "SPACE") return EKC_SPACE; + if (str == "PAGE_UP") return EKC_PAGE_UP; + if (str == "PAGE_DOWN") return EKC_PAGE_DOWN; + if (str == "END") return EKC_END; + if (str == "HOME") return EKC_HOME; + if (str == "LEFT_ARROW") return EKC_LEFT_ARROW; + if (str == "RIGHT_ARROW") return EKC_RIGHT_ARROW; + if (str == "DOWN_ARROW") return EKC_DOWN_ARROW; + if (str == "UP_ARROW") return EKC_UP_ARROW; + if (str == "SELECT") return EKC_SELECT; + if (str == "PRINT") return EKC_PRINT; + if (str == "EXECUTE") return EKC_EXECUTE; + if (str == "PRINT_SCREEN") return EKC_PRINT_SCREEN; + if (str == "INSERT") return EKC_INSERT; + if (str == "DELETE") return EKC_DELETE; + if (str == "HELP") return EKC_HELP; + if (str == "LEFT_WIN") return EKC_LEFT_WIN; + if (str == "RIGHT_WIN") return EKC_RIGHT_WIN; + if (str == "APPS") return EKC_APPS; + if (str == "COMMA") return EKC_COMMA; + if (str == "PERIOD") return EKC_PERIOD; + if (str == "SEMICOLON") return EKC_SEMICOLON; + if (str == "OPEN_BRACKET") return EKC_OPEN_BRACKET; + if (str == "CLOSE_BRACKET") return EKC_CLOSE_BRACKET; + if (str == "BACKSLASH") return EKC_BACKSLASH; + if (str == "APOSTROPHE") return EKC_APOSTROPHE; + if (str == "ADD") return EKC_ADD; + if (str == "SUBTRACT") return EKC_SUBTRACT; + if (str == "MULTIPLY") return EKC_MULTIPLY; + if (str == "DIVIDE") return EKC_DIVIDE; + + if (str == "A" || str == "a") return EKC_A; + if (str == "B" || str == "b") return EKC_B; + if (str == "C" || str == "c") return EKC_C; + if (str == "D" || str == "d") return EKC_D; + if (str == "E" || str == "e") return EKC_E; + if (str == "F" || str == "f") return EKC_F; + if (str == "G" || str == "g") return EKC_G; + if (str == "H" || str == "h") return EKC_H; + if (str == "I" || str == "i") return EKC_I; + if (str == "J" || str == "j") return EKC_J; + if (str == "K" || str == "k") return EKC_K; + if (str == "L" || str == "l") return EKC_L; + if (str == "M" || str == "m") return EKC_M; + if (str == "N" || str == "n") return EKC_N; + if (str == "O" || str == "o") return EKC_O; + if (str == "P" || str == "p") return EKC_P; + if (str == "Q" || str == "q") return EKC_Q; + if (str == "R" || str == "r") return EKC_R; + if (str == "S" || str == "s") return EKC_S; + if (str == "T" || str == "t") return EKC_T; + if (str == "U" || str == "u") return EKC_U; + if (str == "V" || str == "v") return EKC_V; + if (str == "W" || str == "w") return EKC_W; + if (str == "X" || str == "x") return EKC_X; + if (str == "Y" || str == "y") return EKC_Y; + if (str == "Z" || str == "z") return EKC_Z; + + if (str == "0") return EKC_0; + if (str == "1") return EKC_1; + if (str == "2") return EKC_2; + if (str == "3") return EKC_3; + if (str == "4") return EKC_4; + if (str == "5") return EKC_5; + if (str == "6") return EKC_6; + if (str == "7") return EKC_7; + if (str == "8") return EKC_8; + if (str == "9") return EKC_9; + + if (str == "F1") return EKC_F1; + if (str == "F2") return EKC_F2; + if (str == "F3") return EKC_F3; + if (str == "F4") return EKC_F4; + if (str == "F5") return EKC_F5; + if (str == "F6") return EKC_F6; + if (str == "F7") return EKC_F7; + if (str == "F8") return EKC_F8; + if (str == "F9") return EKC_F9; + if (str == "F10") return EKC_F10; + if (str == "F11") return EKC_F11; + if (str == "F12") return EKC_F12; + if (str == "F13") return EKC_F13; + if (str == "F14") return EKC_F14; + if (str == "F15") return EKC_F15; + if (str == "F16") return EKC_F16; + if (str == "F17") return EKC_F17; + if (str == "F18") return EKC_F18; + if (str == "F19") return EKC_F19; + if (str == "F20") return EKC_F20; + if (str == "F21") return EKC_F21; + if (str == "F22") return EKC_F22; + if (str == "F23") return EKC_F23; + if (str == "F24") return EKC_F24; + + if (str == "NUMPAD_0") return EKC_NUMPAD_0; + if (str == "NUMPAD_1") return EKC_NUMPAD_1; + if (str == "NUMPAD_2") return EKC_NUMPAD_2; + if (str == "NUMPAD_3") return EKC_NUMPAD_3; + if (str == "NUMPAD_4") return EKC_NUMPAD_4; + if (str == "NUMPAD_5") return EKC_NUMPAD_5; + if (str == "NUMPAD_6") return EKC_NUMPAD_6; + if (str == "NUMPAD_7") return EKC_NUMPAD_7; + if (str == "NUMPAD_8") return EKC_NUMPAD_8; + if (str == "NUMPAD_9") return EKC_NUMPAD_9; + + if (str == "NUM_LOCK") return EKC_NUM_LOCK; + if (str == "SCROLL_LOCK") return EKC_SCROLL_LOCK; + + if (str == "VOLUME_MUTE") return EKC_VOLUME_MUTE; + if (str == "VOLUME_UP") return EKC_VOLUME_UP; + if (str == "VOLUME_DOWN") return EKC_VOLUME_DOWN; + + return EKC_NONE; +} + enum E_MOUSE_BUTTON : uint8_t { EMB_LEFT_BUTTON, @@ -327,5 +457,24 @@ constexpr std::string_view mouseCodeToString(E_MOUSE_CODE code) } } +constexpr E_MOUSE_CODE stringToMouseCode(std::string_view str) +{ + if (str == "LEFT_BUTTON") return EMC_LEFT_BUTTON; + if (str == "RIGHT_BUTTON") return EMC_RIGHT_BUTTON; + if (str == "MIDDLE_BUTTON") return EMC_MIDDLE_BUTTON; + if (str == "BUTTON_4") return EMC_BUTTON_4; + if (str == "BUTTON_5") return EMC_BUTTON_5; + if (str == "VERTICAL_POSITIVE_SCROLL") return EMC_VERTICAL_POSITIVE_SCROLL; + if (str == "VERTICAL_NEGATIVE_SCROLL") return EMC_VERTICAL_NEGATIVE_SCROLL; + if (str == "HORIZONTAL_POSITIVE_SCROLL") return EMC_HORIZONTAL_POSITIVE_SCROLL; + if (str == "HORIZONTAL_NEGATIVE_SCROLL") return EMC_HORIZONTAL_NEGATIVE_SCROLL; + if (str == "RELATIVE_POSITIVE_MOVEMENT_X") return EMC_RELATIVE_POSITIVE_MOVEMENT_X; + if (str == "RELATIVE_POSITIVE_MOVEMENT_Y") return EMC_RELATIVE_POSITIVE_MOVEMENT_Y; + if (str == "RELATIVE_NEGATIVE_MOVEMENT_X") return EMC_RELATIVE_NEGATIVE_MOVEMENT_X; + if (str == "RELATIVE_NEGATIVE_MOVEMENT_Y") return EMC_RELATIVE_NEGATIVE_MOVEMENT_Y; + + return EMC_NONE; +} + } #endif From b3d7710149ee40b3e41ce274e3edd437bf4c6052 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Tue, 17 Dec 2024 20:51:50 +0100 Subject: [PATCH 34/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 10fe3b2972..3ea910c6b5 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 10fe3b297287b576b6689b959f46f57362410ab9 +Subproject commit 3ea910c6b56110eee49547328396c9edcc0fda7e From 53f72ecfd4c3789c70d3c7c1bc891f364e4f2d66 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Wed, 18 Dec 2024 16:40:07 +0100 Subject: [PATCH 35/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 3ea910c6b5..e34cb66487 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 3ea910c6b56110eee49547328396c9edcc0fda7e +Subproject commit e34cb66487eea0e847a7c6a607978c14a806a752 From e3d282b13bac34f4aca6bd8aaad5dfe766d2b34f Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Thu, 19 Dec 2024 14:35:29 +0100 Subject: [PATCH 36/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index e34cb66487..1332a87201 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit e34cb66487eea0e847a7c6a607978c14a806a752 +Subproject commit 1332a872013c3e90528d8ddb3c1dbb24fd9ce328 From 5124136a09af43f0c8b1801cf096ae8cbf6a1a5d Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Thu, 19 Dec 2024 16:37:40 +0100 Subject: [PATCH 37/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 1332a87201..a5e77b05f7 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 1332a872013c3e90528d8ddb3c1dbb24fd9ce328 +Subproject commit a5e77b05f7b4d11bd8defe62d5b7f76cbe28bfbe From fb2ce01c838f97f6be6192e75e6eef455f64e7ca Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 20 Dec 2024 10:42:38 +0100 Subject: [PATCH 38/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index a5e77b05f7..e89b1c1033 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit a5e77b05f7b4d11bd8defe62d5b7f76cbe28bfbe +Subproject commit e89b1c1033fe6c68db4c9b2b0af2aa5791c048ff From 7ce37ba3d18cb5e6068a5d41aac13344ed64c046 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 20 Dec 2024 16:51:08 +0100 Subject: [PATCH 39/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index e89b1c1033..237dd4394e 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit e89b1c1033fe6c68db4c9b2b0af2aa5791c048ff +Subproject commit 237dd4394e8a4268ee0290cd597e6f6d7318abde From 406fef84d11fb7feb36b403449d3895f7832b9be Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sat, 21 Dec 2024 11:34:31 +0100 Subject: [PATCH 40/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 237dd4394e..4f0e0e8c60 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 237dd4394e8a4268ee0290cd597e6f6d7318abde +Subproject commit 4f0e0e8c603724217637ce2fdbd8389713764515 From 661dae9398c8810c90bb3de36f8d351ff817ea17 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sat, 21 Dec 2024 13:01:36 +0100 Subject: [PATCH 41/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 4f0e0e8c60..ae342b53e8 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 4f0e0e8c603724217637ce2fdbd8389713764515 +Subproject commit ae342b53e80745bef42eec89f078365f7f7739d2 From 183a8fd7eb243ef4ea47a277efb462e5a171f66e Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sun, 22 Dec 2024 12:49:07 +0100 Subject: [PATCH 42/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index ae342b53e8..cb06b7105c 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit ae342b53e80745bef42eec89f078365f7f7739d2 +Subproject commit cb06b7105c4543a2a829c789521d912da3606106 From a30c409e155ef0d0fe7411ce3e21a33f999e32b6 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sun, 22 Dec 2024 13:23:57 +0100 Subject: [PATCH 43/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index cb06b7105c..7a96b2b433 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit cb06b7105c4543a2a829c789521d912da3606106 +Subproject commit 7a96b2b4339641f3a1d2ceeeae9e7d3bf9c5c249 From 5f033af8f0fc4031ba5a99d8cd218022d5be9c66 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 23 Dec 2024 08:55:55 +0100 Subject: [PATCH 44/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 7a96b2b433..374f5cf2a8 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 7a96b2b4339641f3a1d2ceeeae9e7d3bf9c5c249 +Subproject commit 374f5cf2a8aec7e6ed95fb2920f7b68afb28f4e7 From 0529f8aa9314a1c5fbb2d71eb07b0f559560ef8d Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 23 Dec 2024 09:15:29 +0100 Subject: [PATCH 45/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 374f5cf2a8..6ed9686297 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 374f5cf2a8aec7e6ed95fb2920f7b68afb28f4e7 +Subproject commit 6ed9686297804ba5df97a5d3cb5fbf89c3ddbae0 From 74b8c11f4c71df61f8c919021c5d4f1dac8192c0 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 23 Dec 2024 12:16:42 +0100 Subject: [PATCH 46/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 6ed9686297..6231737b62 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 6ed9686297804ba5df97a5d3cb5fbf89c3ddbae0 +Subproject commit 6231737b62576453c0ef3b5e9cb2e33831aceb77 From 2fdf296917e93c63d7536f0575e339e0ebab7a75 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 23 Dec 2024 15:04:49 +0100 Subject: [PATCH 47/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 6231737b62..38168d3a1b 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 6231737b62576453c0ef3b5e9cb2e33831aceb77 +Subproject commit 38168d3a1b461b45a3861762a96516f5f2b1f134 From 3b6844464be03d9477add3bb630ef086de04861c Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Mon, 30 Dec 2024 17:02:36 +0100 Subject: [PATCH 48/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 38168d3a1b..9f9c77eda5 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 38168d3a1b461b45a3861762a96516f5f2b1f134 +Subproject commit 9f9c77eda5539650b9f6d0974581e989f980886b From 2693caf4c02d68233665a9c1e802fba4fe21a3e7 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 24 Jan 2025 12:40:29 +0100 Subject: [PATCH 49/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index b44c1f9f20..0bebf6cf03 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit b44c1f9f20d8ad1b212fb6edb28b3eb28d517357 +Subproject commit 0bebf6cf033a13495bf9d59e5d36c30694a668eb From ae315a0b494897fc9919881d6211961f91f29409 Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 24 Jan 2025 14:00:17 +0100 Subject: [PATCH 50/54] a comment for glslFunctions, update examples_tests submodule --- examples_tests | 2 +- include/nbl/core/math/glslFunctions.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 0bebf6cf03..45a576252a 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 0bebf6cf033a13495bf9d59e5d36c30694a668eb +Subproject commit 45a576252a698f4acd516726e3c6ac122753c174 diff --git a/include/nbl/core/math/glslFunctions.h b/include/nbl/core/math/glslFunctions.h index 3c9cc98850..1412be95d5 100644 --- a/include/nbl/core/math/glslFunctions.h +++ b/include/nbl/core/math/glslFunctions.h @@ -372,6 +372,7 @@ NBL_FORCE_INLINE T normalize(const T& v) } // TODO : matrixCompMult, outerProduct, inverse +// Arek: old and to be killed (missing .tcc include?), no definition in Nabla causing linker errors template NBL_FORCE_INLINE T transpose(const T& m); template<> From 07eeef771f1b36b035deecc3144d8db403c22a0f Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Fri, 31 Jan 2025 17:16:22 +0100 Subject: [PATCH 51/54] small temporary updates to transformation_matrix_utils.hlsl, update examples_tests submodule --- examples_tests | 2 +- .../transformation_matrix_utils.hlsl | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 45a576252a..578fc0cf5c 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 45a576252a698f4acd516726e3c6ac122753c174 +Subproject commit 578fc0cf5c0d74c37aef6e7c99c2f1cae68e911d diff --git a/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl b/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl index 926398354f..6ad1e636df 100644 --- a/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl +++ b/include/nbl/builtin/hlsl/matrix_utils/transformation_matrix_utils.hlsl @@ -8,6 +8,25 @@ namespace nbl namespace hlsl { +// TODO: -> move somewhere else and nbl:: to implement it +template +bool isOrthoBase(const T& x, const T& y, const T& z, const E epsilon = 1e-6) +{ + auto isNormalized = [](const auto& v, const auto& epsilon) -> bool + { + return glm::epsilonEqual(glm::length(v), 1.0, epsilon); + }; + + auto isOrthogonal = [](const auto& a, const auto& b, const auto& epsilon) -> bool + { + return glm::epsilonEqual(glm::dot(a, b), 0.0, epsilon); + }; + + return isNormalized(x, epsilon) && isNormalized(y, epsilon) && isNormalized(z, epsilon) && + isOrthogonal(x, y, epsilon) && isOrthogonal(x, z, epsilon) && isOrthogonal(y, z, epsilon); +} +// <- + template matrix getMatrix3x4As4x4(const matrix& mat) { @@ -19,6 +38,17 @@ matrix getMatrix3x4As4x4(const matrix& mat) return output; } +template +matrix getMatrix3x3As4x4(const matrix& mat) +{ + matrix output; + for (int i = 0; i < 3; ++i) + output[i] = float32_t4(mat[i], 1.0f); + output[3] = float32_t4(0.0f, 0.0f, 0.0f, 1.0f); + + return output; +} + template inline vector getCastedVector(const vector& in) { From 15aa72f5a81fdeb92f95fe6a733b0de64036a96d Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sun, 2 Feb 2025 20:46:51 +0100 Subject: [PATCH 52/54] introduce reference frame concept to imguizmo - commit submodule update --- 3rdparty/imguizmo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/imguizmo b/3rdparty/imguizmo index b10e91756d..4d3445248b 160000 --- a/3rdparty/imguizmo +++ b/3rdparty/imguizmo @@ -1 +1 @@ -Subproject commit b10e91756d32395f5c1fefd417899b657ed7cb88 +Subproject commit 4d3445248b9d598b92e877d752fd1f7fe6c1f134 From 661f999b8fa1f58807ac325fc72467a5b765a76d Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Sun, 2 Feb 2025 20:52:24 +0100 Subject: [PATCH 53/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 578fc0cf5c..61b5db004a 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 578fc0cf5c0d74c37aef6e7c99c2f1cae68e911d +Subproject commit 61b5db004af20259dd18b65c994f7d807194333f From db1102c4fa7c0892c2aa493cf0b59b988717282c Mon Sep 17 00:00:00 2001 From: AnastaZIuk Date: Thu, 6 Feb 2025 16:37:16 +0100 Subject: [PATCH 54/54] update examples_tests submodule --- examples_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples_tests b/examples_tests index 61b5db004a..cb450ba85c 160000 --- a/examples_tests +++ b/examples_tests @@ -1 +1 @@ -Subproject commit 61b5db004af20259dd18b65c994f7d807194333f +Subproject commit cb450ba85c7aafa5767268251ea3971b31abfd68