Compare commits

..

2 Commits

Author SHA1 Message Date
veclavtalica
e281ba593c twn_vec.h: add vec2_length(), remove legacy code 2025-01-24 04:28:09 +03:00
veclavtalica
a20be2c523 twn_draw.c: add warning for erroneous fov parameters 2025-01-24 04:27:45 +03:00
2 changed files with 11 additions and 3 deletions

View File

@ -29,6 +29,10 @@ static inline Vec2 vec2_scale(Vec2 a, float s) {
return (Vec2) { a.x * s, a.y * s };
}
static inline float vec2_length(Vec2 a) {
return sqrtf(a.x * a.x + a.y * a.y);
}
static inline Vec3 vec3_add(Vec3 a, Vec3 b) {
return (Vec3) { a.x + b.x, a.y + b.y, a.z + b.z };
}
@ -98,10 +102,8 @@ static inline Vec3 vec3_rotate(Vec3 v, float angle, Vec3 axis) {
return v;
}
#define m_vec2_from(p_any_vec2) (_Generic((p_any_vec2), \
Vec2i: vec2_from_vec2i, \
)(p_any_vec2))
/* TODO: remove. */
#define m_vec_add(p_any_vec0, p_any_vec1) (_Generic((p_any_vec0), \
Vec2: vec2_add, \
Vec3: vec3_add \

View File

@ -414,6 +414,9 @@ void render(void) {
void draw_camera(Vec3 position, float fov, Vec3 up, Vec3 direction) {
if (fabsf(0.0f - fov) < 0.00001f || fov > (M_PIf / 2))
log_warn("Invalid fov given (%f)", (double)fov);
Camera const camera = {
.fov = fov,
.pos = position,
@ -428,6 +431,9 @@ void draw_camera(Vec3 position, float fov, Vec3 up, Vec3 direction) {
/* TODO: https://stackoverflow.com/questions/62493770/how-to-add-roll-in-camera-class */
DrawCameraFromPrincipalAxesResult draw_camera_from_principal_axes(Vec3 position, float fov, float roll, float pitch, float yaw) {
if (fabsf(0.0f - fov) < 0.00001f || fov > (M_PIf / 2))
log_warn("Invalid fov given (%f)", (double)fov);
(void)roll;
float yawc, yaws, pitchc, pitchs;