/apps/demos/scenery: culling
This commit is contained in:
@ -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 };
|
||||
}
|
||||
|
Reference in New Issue
Block a user