render: move render_world_helper, remove chunks drawn behind view

This commit is contained in:
2022-01-27 01:09:45 +08:00
parent d8df67bc20
commit 7b6c16789c
11 changed files with 257 additions and 56 deletions

View File

@ -14,12 +14,36 @@ type Rectf struct {
Width, Height float32
}
func (r Rectf) MinPoint() Vec2f {
return Vec2f{r.Left, r.Top}
}
func (r Rectf) MaxPoint() Vec2f {
return Vec2f{r.Left + r.Width, r.Top + r.Height}
}
func (r Rectf) Size() Vec2f {
return Vec2f{r.Width, r.Height}
}
// Rectd is a 2D rectangle with float64 coordinates.
type Rectd struct {
Left, Top float64
Width, Height float64
}
func (r Rectd) MinPoint() Vec2d {
return Vec2d{r.Left, r.Top}
}
func (r Rectd) MaxPoint() Vec2d {
return Vec2d{r.Left + r.Width, r.Top + r.Height}
}
func (r Rectd) Size() Vec2d {
return Vec2d{r.Width, r.Height}
}
// Boxi is a 3D box with int coordinates.
type Boxi struct {
OffX, OffY, OffZ int

View File

@ -79,6 +79,10 @@ func (v Vec2f) ToFloat64() Vec2d {
// Vec3f is a three-element float vector
type Vec3f [3]float32
func (v Vec3f) Negative() Vec3f {
return Vec3f{-v[0], -v[1], -v[2]}
}
func (v Vec3f) Add(add Vec3f) Vec3f {
return Vec3f{v[0] + add[0], v[1] + add[1], v[2] + add[2]}
}