Files
sanspie dae4bc19e1 Stage 1: engine core, platform, gpu, vfs
Foundation for the aego engine.

core/    errs, log, handle arena, mathx, clock, stats
platform SDL3 backend plus a headless one, input state, events
gpu      device abstraction with gl33 and null backends
vfs      scheme-based virtual filesystem with overlay mounts
engine   builder, module registry, phase-ordered system loop, jobs
demos    basic, resize, input, headless; sandbox driver

OpenGL bindings are generated into gpu/gl33/gl by tools/gen-gl.sh,
so the module has no external dependencies.
2026-09-18 20:51:54 +03:00

41 lines
888 B
Go

package mathx
type Rect struct{ X, Y, W, H float32 }
type AABB struct{ Min, Max Vec2 }
func (r Rect) Contains(p Vec2) bool {
return p.X >= r.X && p.Y >= r.Y && p.X < r.X+r.W && p.Y < r.Y+r.H
}
func (r Rect) ToAABB() AABB {
return AABB{
Min: Vec2{X: r.X, Y: r.Y},
Max: Vec2{X: r.X + r.W, Y: r.Y + r.H},
}
}
func (r Rect) Center() Vec2 {
return Vec2{X: r.X + r.W/2, Y: r.Y + r.H/2}
}
func (a AABB) Intersects(b AABB) bool {
return a.Min.X < b.Max.X && b.Min.X < a.Max.X &&
a.Min.Y < b.Max.Y && b.Min.Y < a.Max.Y
}
func (a AABB) Contains(p Vec2) bool {
return p.X >= a.Min.X && p.Y >= a.Min.Y && p.X <= a.Max.X && p.Y <= a.Max.Y
}
func (a AABB) Union(b AABB) AABB {
return AABB{
Min: Vec2{X: min(a.Min.X, b.Min.X), Y: min(a.Min.Y, b.Min.Y)},
Max: Vec2{X: max(a.Max.X, b.Max.X), Y: max(a.Max.Y, b.Max.Y)},
}
}
func (a AABB) Size() Vec2 {
return a.Max.Sub(a.Min)
}