# HG changeset patch # User Teemu Piippo # Date 1653490590 -10800 # Node ID 6bcb284679d46e7414a6baed5ff5a97fb35d2fcc # Parent 6e79c1cb83e66b3196408eccecbd5c772cefeca0 delete unneeded things diff -r 6e79c1cb83e6 -r 6bcb284679d4 CMakeLists.txt --- a/CMakeLists.txt Wed May 25 17:48:18 2022 +0300 +++ b/CMakeLists.txt Wed May 25 17:56:30 2022 +0300 @@ -84,7 +84,6 @@ src/libraries.h src/main.h src/mainwindow.h - src/maths.h src/model.h src/modeleditor.h src/parser.h diff -r 6e79c1cb83e6 -r 6bcb284679d4 src/basics.h --- a/src/basics.h Wed May 25 17:48:18 2022 +0300 +++ b/src/basics.h Wed May 25 17:56:30 2022 +0300 @@ -223,6 +223,8 @@ template constexpr std::enable_if_t, T> pi = static_cast(M_PIl); +constexpr double infinity = std::numeric_limits::infinity(); + Q_DECLARE_METATYPE(glm::vec3) Q_DECLARE_METATYPE(glm::mat4) diff -r 6e79c1cb83e6 -r 6bcb284679d4 src/colors.h --- a/src/colors.h Wed May 25 17:48:18 2022 +0300 +++ b/src/colors.h Wed May 25 17:56:30 2022 +0300 @@ -64,12 +64,6 @@ namespace ldraw { - static constexpr Color BLACK {0}; - static constexpr Color BLUE {1}; - static constexpr Color GREEN {2}; - static constexpr Color RED {4}; - static constexpr Color YELLOW {14}; - static constexpr Color WHITE {15}; static constexpr Color MAIN_COLOR {16}; static constexpr Color EDGE_COLOR {24}; } diff -r 6e79c1cb83e6 -r 6bcb284679d4 src/gl/vertexprogram.cpp --- a/src/gl/vertexprogram.cpp Wed May 25 17:48:18 2022 +0300 +++ b/src/gl/vertexprogram.cpp Wed May 25 17:56:30 2022 +0300 @@ -37,12 +37,12 @@ result.reserve(12 * d2 * d2); for (int i = 0; i < d2; ++i) { - const float alpha = i * math::pi / d2; - const float alpha_2 = (i + 1) * math::pi / d2; + const float alpha = i * pi<> / d2; + const float alpha_2 = (i + 1) * pi<> / d2; for (int j = -d2; j < d2; ++j) { - const float beta = j * math::pi / d2; - const float beta_2 = (j + 1) * math::pi / d2; + const float beta = j * pi<> / d2; + const float beta_2 = (j + 1) * pi<> / d2; const float x1 = cos(beta) * sin(alpha); const float x2 = cos(beta) * sin(alpha_2); const float x3 = cos(beta_2) * sin(alpha_2); diff -r 6e79c1cb83e6 -r 6bcb284679d4 src/ldrawalgorithm.h --- a/src/ldrawalgorithm.h Wed May 25 17:48:18 2022 +0300 +++ b/src/ldrawalgorithm.h Wed May 25 17:56:30 2022 +0300 @@ -23,7 +23,7 @@ template void circle(int segments, int divisions, Fn&& fn) { - float factor = 2.0f * math::pi / divisions; + float factor = 2.0f * pi<> / divisions; for (int i = 0; i < segments; i += 1) { fn( diff -r 6e79c1cb83e6 -r 6bcb284679d4 src/linetypes/circularprimitive.cpp --- a/src/linetypes/circularprimitive.cpp Wed May 25 17:48:18 2022 +0300 +++ b/src/linetypes/circularprimitive.cpp Wed May 25 17:56:30 2022 +0300 @@ -77,8 +77,8 @@ { for (int i = 0; i < this->segments; i += 1) { - const float ang_1 = (2 * math::pi * i) / this->divisions; - const float ang_2 = (2 * math::pi * (i + 1)) / this->divisions; + const float ang_1 = (2 * pi<> * i) / this->divisions; + const float ang_2 = (2 * pi<> * (i + 1)) / this->divisions; const glm::vec3 p_1 = {std::sin(ang_1), 0, std::cos(ang_1)}; const glm::vec3 p_2 = {std::sin(ang_2), 0, std::cos(ang_2)}; switch (this->type) diff -r 6e79c1cb83e6 -r 6bcb284679d4 src/main.h --- a/src/main.h Wed May 25 17:48:18 2022 +0300 +++ b/src/main.h Wed May 25 17:56:30 2022 +0300 @@ -25,7 +25,6 @@ #include #include "basics.h" #include "utility.h" -#include "maths.h" #include "geometry.h" #include "functional.h" diff -r 6e79c1cb83e6 -r 6bcb284679d4 src/maths.h --- a/src/maths.h Wed May 25 17:48:18 2022 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,126 +0,0 @@ -/* - * LDForge: LDraw parts authoring CAD - * Copyright (C) 2013 - 2020 Teemu Piippo - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include "utility.h" - -namespace math -{ - using std::abs; - using std::sqrt; - using std::sin; - using std::cos; - using std::tan; - using std::atan; - using std::atan2; - using std::acos; - using std::asin; - using std::exp; - using std::log; - using std::log10; - using std::hypot; - using std::floor; - using std::ceil; - using std::trunc; - using std::round; - template - inline auto hypot(T&& x, Rest&&... rest) - { - return math::hypot(x, math::hypot(rest...)); - } - template - const T& max(const T& x, const T& y) - { - if (x > y) - return x; - else - return y; - } - template - const T& max(const T& x, const T& y, Rest&&... rest) - { - return math::max(x, math::max(y, rest...)); - } - template - const T& min(const T& x, const T& y) - { - if (x < y) - return x; - else - return y; - } - template - const T& min(const T& x, const T& y, Rest&&... rest) - { - return math::min(x, math::min(y, rest...)); - } - constexpr double infinity = std::numeric_limits::infinity(); - constexpr long double pi = M_PIl; - // Returns the minimum value of a container - template - inline auto nmin(T&& values) - { - auto it = std::begin(values); - auto result_p = it; - for (++it; it != std::end(values); ++it) - { - if (*it < *result_p) - result_p = it; - } - return *result_p; - } - // Returns the maximum value of a container - template - inline auto nmax(T&& values) - { - auto it = std::begin(values); - auto result_p = it; - for (++it; it != std::end(values); ++it) - { - if (*it > *result_p) - result_p = it; - } - return *result_p; - } - /* - * Returns the empty sum. (recursion base) - */ - template - constexpr T sum() - { - return {}; - } - - /* - * Returns the sum of n arguments. - */ - template - constexpr auto sum(const T& arg, Rest&&... rest) - { - return arg + sum(rest...); - } - - std::optional linePlaneIntersection(); -} - -template -inline unsigned int qHash(const glm::vec<3, T, Q>& key) -{ - return qHash(key.x) ^ utility::rotl10(qHash(key.y)) ^ utility::rotl20(qHash(key.z)); -} diff -r 6e79c1cb83e6 -r 6bcb284679d4 src/types/boundingbox.cpp --- a/src/types/boundingbox.cpp Wed May 25 17:48:18 2022 +0300 +++ b/src/types/boundingbox.cpp Wed May 25 17:56:30 2022 +0300 @@ -25,12 +25,12 @@ */ void addPointToBox(BoundingBox &box, const glm::vec3 &vertex) { - box.minimum.x = math::min(vertex.x, box.minimum.x); - box.minimum.y = math::min(vertex.y, box.minimum.y); - box.minimum.z = math::min(vertex.z, box.minimum.z); - box.maximum.x = math::max(vertex.x, box.maximum.x); - box.maximum.y = math::max(vertex.y, box.maximum.y); - box.maximum.z = math::max(vertex.z, box.maximum.z); + box.minimum.x = std::min(vertex.x, box.minimum.x); + box.minimum.y = std::min(vertex.y, box.minimum.y); + box.minimum.z = std::min(vertex.z, box.minimum.z); + box.maximum.x = std::max(vertex.x, box.maximum.x); + box.maximum.y = std::max(vertex.y, box.maximum.y); + box.maximum.z = std::max(vertex.z, box.maximum.z); } /* diff -r 6e79c1cb83e6 -r 6bcb284679d4 src/types/boundingbox.h --- a/src/types/boundingbox.h Wed May 25 17:48:18 2022 +0300 +++ b/src/types/boundingbox.h Wed May 25 17:56:30 2022 +0300 @@ -18,12 +18,11 @@ #pragma once #include "basics.h" -#include "maths.h" struct BoundingBox { - glm::vec3 minimum {math::infinity, math::infinity, math::infinity}; - glm::vec3 maximum {-math::infinity, -math::infinity, -math::infinity}; + glm::vec3 minimum {infinity, infinity, infinity}; + glm::vec3 maximum {-infinity, -infinity, -infinity}; }; constexpr BoundingBox emptyBoundingBox = {}; diff -r 6e79c1cb83e6 -r 6bcb284679d4 src/utility.h --- a/src/utility.h Wed May 25 17:48:18 2022 +0300 +++ b/src/utility.h Wed May 25 17:56:30 2022 +0300 @@ -21,12 +21,6 @@ namespace utility { - template - constexpr std::size_t countof(T(&)[N]) - { - return N; - } - // http://stackoverflow.com/a/18204188/3629665 template inline T rotl10(T x) @@ -65,12 +59,6 @@ return string; } - template - bool contains(T&& container, R&& value) - { - return std::find(std::begin(container), std::end(container), value) != std::end(container); - } - /** * @brief Converts the specified vertex to a simple string * @param vertex vertex to convert @@ -86,3 +74,9 @@ return utility::format("(%1, %2, %3)", vertex.x, vertex.y, vertex.z); } } + +template +inline unsigned int qHash(const glm::vec<3, T, Q>& key) +{ + return qHash(key.x) ^ utility::rotl10(qHash(key.y)) ^ utility::rotl20(qHash(key.z)); +}