001  (ns walkmap.ocean
002    "Deal with (specifically, at this stage, cull) ocean areas"
003    (:require [walkmap.utils :refer [=ish]]))
004  
005  (def ^:dynamic *sea-level*
006    "The sea level on heightmaps we're currently handling. If characters are to
007    be able to swin in the sea, we must model the sea bottom, so we need
008    heightmaps which cover at least the continental shelf. However, the sea
009    bottom is not walkable territory and can be culled from walkmaps.
010  
011    **Note** must be a floating point number. `(= 0 0.0)` returns `false`!"
012    0.0)
013  
014  (defn ocean?
015    "Of a `facet`, is the altitude of every vertice equal to `*sea-level*`?"
016    [facet]
017    (every?
018      #(=ish % *sea-level*)
019      (map :z (:vertices facet))))
020  
021  (defn cull-ocean-facets
022    "Ye cannae walk on water. Remove all facets from this `stl` structure which
023    are at sea level."
024    [stl]
025    (assoc stl :facets (remove ocean? (:facets stl))))