Skip to content

Instantly share code, notes, and snippets.

@BitPuffin
Created January 22, 2014 21:17
Show Gist options
  • Save BitPuffin/8567509 to your computer and use it in GitHub Desktop.
Save BitPuffin/8567509 to your computer and use it in GitHub Desktop.
type
TTerrainSection* = tuple
buffer: PArrayBuffer
geometry: ref tuple [
indices: array[0..sectionTriangleCount-1, array[0..2, int]],
vertices: array[0..sectionArea-1, TVec3]]
heightmap: ref array[0..sectionWidth-1, array[0..sectionHeight-1, uint32]]
PTerrainSection* = ref TTerrainSection
TTerrainSections* = TQuadTree[PTerrainSection]
...
proc generateVertices(section: PTerrainSection) =
debug("Generating vertices from heightmap")
if section.heightmap == nil: # ERROR: Type mismatch blaablablabla
# This might attempt to read from disk in the future
error("Heightmap was nil, this shouldn't happen!")
raise newException(E_Base, "Heightmap was nil, this is unacceptable")
if section.geometry.vertices != nil:
error("Vertices are not nil, this shouldn't happen")
raise newException(E_Base, "Vertices are not nil")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment