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