diff --git a/include/math/fwd_declare.hpp b/include/math/fwd_declare.hpp index a59a2df..875fac4 100644 --- a/include/math/fwd_declare.hpp +++ b/include/math/fwd_declare.hpp @@ -26,6 +26,8 @@ //Provide aliases for common matrix, vector, and quaternion types namespace math{ + + //Must forward declare type traits for use in concepts because you can't forward declare concepts template struct is_vector; template @@ -33,6 +35,7 @@ namespace math{ template struct is_matrix; + //Create concepts that depend on the type traits template concept Quaternion = is_quaternion::value; template @@ -177,16 +180,6 @@ namespace math{ static constexpr bool value = (detail::is_matrix_helper::value && ...); }; - template - concept Compatible_Scalar = requires(T&& t, U&& u){ - requires !is_matrix::value; - requires std::is_convertible_v>; - requires std::is_convertible_v>; - requires std::is_convertible_v>; - requires std::is_convertible_v>; - }; - - } #endif diff --git a/include/math/mat.hpp b/include/math/mat.hpp index 6ef8085..161ec3e 100644 --- a/include/math/mat.hpp +++ b/include/math/mat.hpp @@ -232,6 +232,10 @@ namespace math{ template constexpr decltype(auto) operator-=(matrix& left, const matrix& right); + extern template class matrix; + extern template class matrix; + extern template class matrix; + } #include "mat.tpp" diff --git a/include/math/quat.hpp b/include/math/quat.hpp index 78c2f1e..2cbf8f8 100644 --- a/include/math/quat.hpp +++ b/include/math/quat.hpp @@ -141,6 +141,7 @@ namespace math{ template decltype(auto) operator/=(quaternion& left, U&& right); + extern template class quaternion; } #include "quat.tpp" diff --git a/include/math/quat.tpp b/include/math/quat.tpp index f900a33..29674a3 100644 --- a/include/math/quat.tpp +++ b/include/math/quat.tpp @@ -99,7 +99,7 @@ namespace math{ quaternion(angles.x(), angles.y(), angles.z()){} template quaternion::quaternion(value_type angle, const vec3& axis): - quaternion(angle, axis.get_x(), axis.get_y(), axis.get_z()){} + quaternion(angle, axis.x(), axis.y(), axis.z()){} template quaternion::quaternion(value_type angle, value_type x, value_type y, value_type z){ angle /= value_type{2.0}; @@ -181,11 +181,11 @@ namespace math{ auto quaternion::get_axis(void)const -> vec3{ quaternion tmp(*this); if(m_data[0] > value_type{1.0}) - tmp.set_normalized(); + tmp = tmp.normalize(); value_type s = std::sqrt(1 - tmp.m_data[0] * tmp.m_data[0]); if(s <= value_type{0.001}) return vec3(1, 0, 0); - return vec3(tmp.data[1] / s, tmp.data[2] / s, tmp.data[3] / s); + return vec3(tmp.m_data[1] / s, tmp.m_data[2] / s, tmp.m_data[3] / s); } template void quaternion::set_angle(value_type t){ diff --git a/include/math/vec.hpp b/include/math/vec.hpp index 735b125..b30963c 100644 --- a/include/math/vec.hpp +++ b/include/math/vec.hpp @@ -117,6 +117,10 @@ namespace math{ template constexpr decltype(auto) operator-=(vector& left, const vector& right); + extern template class vector; + extern template class vector; + extern template class vector; + } #include "vec.tpp" diff --git a/makefile b/makefile index 9848eb0..2dbc122 100644 --- a/makefile +++ b/makefile @@ -19,7 +19,7 @@ ifeq ($(OS),Windows_NT) WINDOWS::=1 endif -SOURCE_DIRS::=src src/audio src/audio/impl src/gfx src/gfx/ogl src/egn src/ttt src/wip src/util +SOURCE_DIRS::=src src/audio src/audio/impl src/gfx src/gfx/ogl src/egn src/ttt src/wip src/util src/math SOURCES::= OBJDIR::=obj DEPDIR::=$(OBJDIR)/dep diff --git a/src/math/mat.cpp b/src/math/mat.cpp new file mode 100644 index 0000000..8728926 --- /dev/null +++ b/src/math/mat.cpp @@ -0,0 +1,28 @@ +/** + This file is a part of our_dick + Copyright (C) 2022 rexy712 + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +#include "math/mat.hpp" +#include "math/fwd_declare.hpp" + +namespace math{ + + template class matrix; + template class matrix; + template class matrix; + +} diff --git a/src/math/quat.cpp b/src/math/quat.cpp new file mode 100644 index 0000000..f6a4010 --- /dev/null +++ b/src/math/quat.cpp @@ -0,0 +1,26 @@ +/** + This file is a part of our_dick + Copyright (C) 2022 rexy712 + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +#include "math/quat.hpp" +#include "math/fwd_declare.hpp" + +namespace math{ + + template class quaternion; + +} diff --git a/src/math/vec.cpp b/src/math/vec.cpp new file mode 100644 index 0000000..117d888 --- /dev/null +++ b/src/math/vec.cpp @@ -0,0 +1,28 @@ +/** + This file is a part of our_dick + Copyright (C) 2022 rexy712 + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +#include "math/vec.hpp" +#include "math/fwd_declare.hpp" + +namespace math{ + + template class vector; + template class vector; + template class vector; + +}