random sound selection for triggers

This commit is contained in:
2026-01-06 16:26:57 -05:00
parent b41b6df19e
commit 5124f77817
12 changed files with 104 additions and 59 deletions

View File

@@ -1,5 +1,6 @@
#include "math.h"
#include <ctime>
#include <glm/ext/matrix_transform.hpp>
#include <string>
@@ -76,4 +77,7 @@ namespace anm2ed::util::math
return glm::translate(mat4(1.0f), vec3(position, 0.0f)) * local;
}
float random() { return (float)rand() / RAND_MAX; }
float random_in_range(float min, float max) { return min + random() * (max - min); }
void random_seed_set() { srand(std::time(nullptr)); }
}

View File

@@ -5,25 +5,13 @@
namespace anm2ed::util::math
{
template <typename T> constexpr T percent_to_unit(T value)
{
return value / 100.0f;
}
template <typename T> constexpr T percent_to_unit(T value) { return value / 100.0f; }
template <typename T> constexpr T unit_to_percent(T value)
{
return value * 100.0f;
}
template <typename T> constexpr T unit_to_percent(T value) { return value * 100.0f; }
constexpr float uint8_to_float(int value)
{
return (float)(value / 255.0f);
}
constexpr float uint8_to_float(int value) { return (float)(value / 255.0f); }
constexpr int float_to_uint8(float value)
{
return (int)(value * 255);
}
constexpr int float_to_uint8(float value) { return (int)(value * 255); }
constexpr std::array<float, 16> uv_vertices_get(glm::vec2 uvMin, glm::vec2 uvMax)
{
@@ -41,4 +29,8 @@ namespace anm2ed::util::math
glm::mat4 quad_model_get(glm::vec2 = {}, glm::vec2 = {}, glm::vec2 = {}, glm::vec2 = glm::vec2(1.0f), float = {});
glm::mat4 quad_model_parent_get(glm::vec2 = {}, glm::vec2 = {}, glm::vec2 = glm::vec2(1.0f), float = {});
float random();
float random_in_range(float min, float max);
void random_seed_set();
}