func (this *HeightMap) Get2f(x, y float32) float32 {
	l := math32.Floor(x)
	r := math32.Floor(x + 1)
	b := math32.Floor(y)
	t := math32.Floor(y + 1)

	bl := this.Get(int(l), int(b))
	br := this.Get(int(r), int(b))
	tl := this.Get(int(l), int(t))
	tr := this.Get(int(r), int(t))

	bh := bl*(r-x) + br*(x-l)
	th := tl*(r-x) + tr*(x-l)

	h := bh*(t-y) + th*(y-b)

	return h
}
func (m *HeightMap) Normal2f(x float32, y float32) (n mgl.Vec3) {
	x0 := int(math32.Floor(x))
	x1 := x0 + 1
	y0 := int(math32.Floor(y))
	y1 := y0 + 1

	n00 := m.Normal(x0, y0)
	n10 := m.Normal(x1, y0)
	n01 := m.Normal(x0, y1)
	n11 := m.Normal(x1, y1)

	w := x - float32(x0)
	h := y - float32(y0)

	n0 := n00.Mul(1 - w).Add(n10.Mul(w))
	n1 := n01.Mul(1 - w).Add(n11.Mul(w))

	n = n0.Mul(1 - h).Add(n1.Mul(h))
	return
}
func raytrace(x0, y0, x1, y1 float32, visit func(x, y int) bool) {

	dx := math32.Abs(x1 - x0)
	dy := math32.Abs(y1 - y0)

	x := int(math32.Floor(x0))
	y := int(math32.Floor(y0))

	var x_inc, y_inc int
	var err float32

	if dx == 0 {
		x_inc = 0
		err = math32.Inf(1)
	} else if x1 > x0 {
		x_inc = 1
		err = (math32.Floor(x0) + 1 - x0) * dy
	} else {
		x_inc = -1
		err = (x0 - math32.Floor(x0)) * dy
	}

	if dy == 0 {
		y_inc = 0
		err -= math32.Inf(1)
	} else if y1 > y0 {
		y_inc = 1
		err -= (math32.Floor(y0) + 1 - y0) * dx
	} else {
		y_inc = -1
		err -= (y0 - math32.Floor(y0)) * dx
	}

	for visit(x, y) {
		if err > 0 {
			y += y_inc
			err -= dx
		} else {
			x += x_inc
			err += dy
		}
	}
}
func (this *EntityGrid) Remove(e *Entity) {
	x := int(math32.Floor(e.Position[0])) & (this.W - 1)
	y := int(math32.Floor(e.Position[1])) & (this.H - 1)
	index := this.W*y + x
	this.data[index] = remove(this.data[index], e)
}