Adding some components.

This commit is contained in:
2023-11-15 22:14:53 -06:00
parent 6c6203a41d
commit d8bc1d0fe3
18 changed files with 428 additions and 12 deletions

32
src/dawn/util/Flag.hpp Normal file
View File

@ -0,0 +1,32 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "dawnlibs.hpp"
namespace Dawn {
class Flag final {
public:
template<typename T>
static void turnOn(T &flag, const T check) {
flag |= check;
}
template<typename T>
static void turnOff(T &flag, const T check) {
flag &= ~check;
}
template<typename T>
static bool_t isOn(const T flag, const T check) {
return (flag & check) == check;
}
template<typename T>
static bool_t isOff(const T flag, const T check) {
return (flag & check) == 0;
}
};
}

View File

@ -11,7 +11,7 @@
#define MATH_PI 3.1415926535897f
namespace Dawn {
class Math {
class Math final {
/**
* Returns the largest of the two provided int32 numbers.
*
@ -32,7 +32,7 @@ namespace Dawn {
* @return Smaller of the two numbers.
*/
template<typename T>
static T mathMin(T left, T right) {
static T min(T left, T right) {
return left < right ? left : right;
}
@ -46,7 +46,7 @@ namespace Dawn {
* @return The value, or the closest clamped value.
*/
template<typename T>
static T mathClamp(T val, T min, T max) {
static T clamp(T val, T min, T max) {
return mathMin<T>(mathMax<T>(val, min), max);
}
@ -58,7 +58,7 @@ namespace Dawn {
* @return The absolute value (-value if value < 0)
*/
template<typename T>
static T mathAbs(T value) {
static T abs(T value) {
return value < 0 ? -value : value;
}
@ -70,11 +70,11 @@ namespace Dawn {
* @returns The modulo result.
*/
template<typename T>
static inline T mathMod(T value, T modulo) {
static inline T mod(T value, T modulo) {
return ((value % modulo) + modulo) % modulo;
}
static inline float_t mathMod(float_t value, float_t modulo) {
static inline float_t fmod(float_t value, float_t modulo) {
float_t n = fmod(value, modulo);
return n;
}
@ -85,7 +85,7 @@ namespace Dawn {
* @param n Degrees to convert.
* @returns The number in radians.
*/
static float_t mathDeg2Rad(float_t degrees) {
static float_t deg2rad(float_t degrees) {
return degrees * (MATH_PI / 180.0f);
}
@ -94,7 +94,7 @@ namespace Dawn {
* @param n Radians to convert.
* @returns The number in degrees.
*/
static float_t mathRad2Deg(float_t n) {
static float_t rad2deg(float_t n) {
return (n * 180.0f) / MATH_PI;
}
@ -104,7 +104,7 @@ namespace Dawn {
* @return Rounded number.
*/
template<typename T>
static T mathRound(float_t n) {
static T round(float_t n) {
return (T)roundf(n);
}
@ -114,7 +114,7 @@ namespace Dawn {
* @return Rounded number.
*/
template<typename T>
static T mathFloor(float_t n) {
static T floor(float_t n) {
return (T)floorf(n);
}
};