delete unneeded things

Wed, 25 May 2022 17:56:30 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 25 May 2022 17:56:30 +0300
changeset 196
6bcb284679d4
parent 195
6e79c1cb83e6
child 197
0e729e681a2c

delete unneeded things

CMakeLists.txt file | annotate | diff | comparison | revisions
src/basics.h file | annotate | diff | comparison | revisions
src/colors.h file | annotate | diff | comparison | revisions
src/gl/vertexprogram.cpp file | annotate | diff | comparison | revisions
src/ldrawalgorithm.h file | annotate | diff | comparison | revisions
src/linetypes/circularprimitive.cpp file | annotate | diff | comparison | revisions
src/main.h file | annotate | diff | comparison | revisions
src/maths.h file | annotate | diff | comparison | revisions
src/types/boundingbox.cpp file | annotate | diff | comparison | revisions
src/types/boundingbox.h file | annotate | diff | comparison | revisions
src/utility.h file | annotate | diff | comparison | revisions
--- 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
--- 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<typename T = float>
 constexpr std::enable_if_t<std::is_floating_point_v<T>, T> pi = static_cast<T>(M_PIl);
+constexpr double infinity = std::numeric_limits<double>::infinity();
+
 
 Q_DECLARE_METATYPE(glm::vec3)
 Q_DECLARE_METATYPE(glm::mat4)
--- 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};
 }
--- 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);
--- 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<typename Fn>
 	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(
--- 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)
--- 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 <memory>
 #include "basics.h"
 #include "utility.h"
-#include "maths.h"
 #include "geometry.h"
 #include "functional.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 <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-#include <cmath>
-#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<typename T, typename... Rest>
-	inline auto hypot(T&& x, Rest&&... rest)
-	{
-		return math::hypot(x, math::hypot(rest...));
-	}
-	template<typename T, typename... Rest>
-	const T& max(const T& x, const T& y)
-	{
-		if (x > y)
-			return x;
-		else
-			return y;
-	}
-	template<typename T, typename... Rest>
-	const T& max(const T& x, const T& y, Rest&&... rest)
-	{
-		return math::max(x, math::max(y, rest...));
-	}
-	template<typename T, typename... Rest>
-	const T& min(const T& x, const T& y)
-	{
-		if (x < y)
-			return x;
-		else
-			return y;
-	}
-	template<typename T, typename... Rest>
-	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<double>::infinity();
-	constexpr long double pi = M_PIl;
-	// Returns the minimum value of a container
-	template<typename T>
-	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<typename T>
-	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<typename T>
-	constexpr T sum()
-	{
-		return {};
-	}
-
-	/*
-	 * Returns the sum of n arguments.
-	 */
-	template<typename T, typename... Rest>
-	constexpr auto sum(const T& arg, Rest&&... rest)
-	{
-		return arg + sum<T>(rest...);
-	}
-
-	std::optional<glm::vec3> linePlaneIntersection();
-}
-
-template<typename T, glm::qualifier Q>
-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));
-}
--- 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);
 }
 
 /*
--- 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 = {};
--- 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<typename T, std::size_t N>
-	constexpr std::size_t countof(T(&)[N])
-	{
-		return N;
-	}
-
 	// http://stackoverflow.com/a/18204188/3629665
 	template<typename T>
 	inline T rotl10(T x)
@@ -65,12 +59,6 @@
 		return string;
 	}
 
-	template<typename T, typename R>
-	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<typename T, glm::qualifier Q>
+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));
+}

mercurial