/apps/demos/scenery: culling

This commit is contained in:
veclavtalica
2025-02-26 17:08:45 +03:00
parent 6812c7c13d
commit ed2afec5a7
3 changed files with 30 additions and 6 deletions

View File

@ -29,10 +29,20 @@ static inline Vec2 vec2_scale(Vec2 a, float s) {
return (Vec2) { a.x * s, a.y * s };
}
static inline float vec2_dot(Vec2 a, Vec2 b) {
return a.x * b.x + a.y * b.y;
}
static inline float vec2_length(Vec2 a) {
return sqrtf(a.x * a.x + a.y * a.y);
}
static inline Vec2 vec2_norm(Vec2 a) {
const float n = sqrtf(vec2_dot(a, a));
/* TODO: do we need truncating over epsilon as cglm does? */
return vec2_scale(a, 1.0f / n);
}
static inline Vec3 vec3_add(Vec3 a, Vec3 b) {
return (Vec3) { a.x + b.x, a.y + b.y, a.z + b.z };
}