feat: Build optimizations

This commit is contained in:
2026-04-23 21:37:44 +01:00
parent 6cab255d92
commit 153fb762af
11 changed files with 157 additions and 139 deletions

40
src/dxd_math.hpp Normal file
View File

@@ -0,0 +1,40 @@
#pragma once
#include <float.h>
#include <math.h>
typedef struct vec2 { float x, y; } vec2;
typedef struct vec2i { int x, y; } vec2i;
static const vec2 vec2_zero = { 0, 0 };
static const vec2 vec2_one = { 1, 1 };
static const vec2 vec2_unitx = { 1, 0 };
static const vec2 vec2_unity = { 0, 1 };
static const vec2 vec2_max = { FLT_MAX, FLT_MAX };
static const vec2 vec2_min = { -FLT_MAX, -FLT_MAX };
static const vec2i vec2i_zero = { 0, 0 };
static const vec2i vec2i_one = { 1, 1 };
vec2 operator+(vec2 const &v);
vec2 operator-(vec2 const &v);
vec2 operator+(vec2 const &a, vec2 const &b);
vec2 operator-(vec2 const &a, vec2 const &b);
vec2 operator*(vec2 const &a, float const &b);
vec2 operator/(vec2 const &a, float const &b);
bool operator<(vec2 const &a, vec2 const &b);
bool operator>(vec2 const &a, vec2 const &b);
float dot(vec2 const &a, vec2 const &b);
float norm2(vec2 const &v);
float norm(vec2 const &v);
vec2 normalize(vec2 const &v);
vec2 min2(vec2 const &a, vec2 const &b);
vec2 max2(vec2 const &a, vec2 const &b);
vec2 polar_to_vec2(const float angle, const float len);
float vec2_angle(const vec2 v);
float normalize_angle(const float angle);
float normalize_angle_diff(const float diff);