<commit_before>---
layout:     post
title:      "PlanetKit week 3: hexagons!"
date:       2016-11-05
summary:    Turning the surface of the planet into a map of hexagonal voxel.
tags:       rust planetkit
published:  true
---

In my last post I used Perlin noise (now switched over to simplex noise) to create some basic terrain. Here's the lumpy blob we ended up with at the end:

![High-res terrain working](/images/terrain/high-res-terrain-working.png)

Let's see what I said I was going to tackle next:

> My next move will be to turn this into a proper voxmap of (mostly) hexagonal prisms, à la Minecraft. Or, you know, I might lie about that again and do something else instead.

Ok, then. Let's do it! Errr, the voxels bit, I mean---not the lying.

The first thing I did was to change what I store about the globe from being a 2D array of height values (a heightmap) to a 2D array of enum instances representing whether the cell contains dirt, or air.

{% highlight rust %}
#[derive(PartialEq, Eq)]
pub enum Material {
    Air,<commit_msg>Fix typo<commit_after>---
layout:     post
title:      "PlanetKit week 3: hexagons!"
date:       2016-11-05
summary:    Turning the surface of the planet into a map of hexagonal voxels.
tags:       rust planetkit
published:  true
---

In my last post I used Perlin noise (now switched over to simplex noise) to create some basic terrain. Here's the lumpy blob we ended up with at the end:

![High-res terrain working](/images/terrain/high-res-terrain-working.png)

Let's see what I said I was going to tackle next:

> My next move will be to turn this into a proper voxmap of (mostly) hexagonal prisms, à la Minecraft. Or, you know, I might lie about that again and do something else instead.

Ok, then. Let's do it! Errr, the voxels bit, I mean---not the lying.

The first thing I did was to change what I store about the globe from being a 2D array of height values (a heightmap) to a 2D array of enum instances representing whether the cell contains dirt, or air.

{% highlight rust %}
#[derive(PartialEq, Eq)]
pub enum Material {
    Air,
{'fraction_non_alphanumeric': 0.07279693486590039, 'fraction_numerical': 0.01053639846743295, 'mean_word_length': 3.502155172413793, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '749438', 'n_tokens_mistral': 637, 'n_tokens_neox': 597, 'n_words': 330}