예제 #1
0
func (this *HeightMap) Bump(center mgl.Vec2, height float32) {
	minX := mathint.Max(math32.RoundInt(center[0])-5, 0)
	maxX := mathint.Min(math32.RoundInt(center[0])+5, this.W)
	minY := mathint.Max(math32.RoundInt(center[1])-5, 0)
	maxY := mathint.Min(math32.RoundInt(center[1])+5, this.H)

	for x := minX; x < maxX; x++ {
		for y := minY; y < maxY; y++ {
			v := mgl.Vec2{float32(x), float32(y)}
			v = v.Sub(center)
			bump := math32.Gauss(v.Len())
			h := this.Get(x, y)
			this.Set(x, y, h+bump)
		}
	}
	this.HasChanges = true
}
예제 #2
0
func Gauss2fv(v mgl.Vec2) float32 {
	return math32.Gauss(v.Len())
}