func getSnapshot(x, y, z, w, h, d int) *blocksSnapshot { bs := &blocksSnapshot{ Blocks: make([]uint16, w*h*d), BlockLight: nibble.New(w * h * d), SkyLight: nibble.New(w * h * d), Biome: make([]*biome.Type, w*d), } bs.init(x, y, z, w, h, d) return bs }
type blocksSnapshot struct { Blocks []uint16 BlockLight nibble.Array SkyLight nibble.Array Biome []*biome.Type x, y, z int w, h, d int } var snapshotPool = sync.Pool{ New: func() interface{} { const w, h, d = 20, 20, 20 return &blocksSnapshot{ Blocks: make([]uint16, w*h*d), BlockLight: nibble.New(w * h * d), SkyLight: nibble.New(w * h * d), Biome: make([]*biome.Type, w*d), } }, } func getPooledSnapshot(x, y, z int) *blocksSnapshot { bs := snapshotPool.Get().(*blocksSnapshot) bs.init(x, y, z, 20, 20, 20) return bs } func getSnapshot(x, y, z, w, h, d int) *blocksSnapshot { bs := &blocksSnapshot{ Blocks: make([]uint16, w*h*d),
for _, s := range c.Sections { if s != nil { s.Buffer.Free() for _, e := range s.BlockEntities { Client.entities.container.RemoveEntity(e) } sectionPool.Put(s) } } render.FreeColumn(c.X, c.Z) } var sectionPool = sync.Pool{ New: func() interface{} { return &chunkSection{ BlockLight: nibble.New(16 * 16 * 16), SkyLight: nibble.New(16 * 16 * 16), } }, } type chunkSection struct { chunk *chunk Y int Blocks *bit.Map nextBlockID int blockMap []*csBlockInfo revBlockMap map[Block]int BlockLight nibble.Array