Builds and runs; output is crazily wrong...
This commit is contained in:
parent
4187b52c66
commit
fd15e41952
|
@ -1,6 +1,8 @@
|
||||||
(ns cc.journeyman.walkmap.ocean
|
(ns cc.journeyman.walkmap.ocean
|
||||||
"Deal with (specifically, at this stage, cull) ocean areas"
|
"Deal with (specifically, at this stage, cull) ocean areas"
|
||||||
(:require [cc.journeyman.walkmap.utils :refer [=ish]]))
|
(:require [cc.journeyman.walkmap.polygon :refer [triangle?]]
|
||||||
|
[cc.journeyman.walkmap.stl :refer [stl?]]
|
||||||
|
[cc.journeyman.walkmap.utils :refer [=ish]]))
|
||||||
|
|
||||||
(def ^:dynamic *sea-level*
|
(def ^:dynamic *sea-level*
|
||||||
"The sea level on heightmaps we're currently handling. If characters are to
|
"The sea level on heightmaps we're currently handling. If characters are to
|
||||||
|
@ -21,5 +23,11 @@
|
||||||
(defn cull-ocean-facets
|
(defn cull-ocean-facets
|
||||||
"Ye cannae walk on water. Remove all facets from this `stl` structure which
|
"Ye cannae walk on water. Remove all facets from this `stl` structure which
|
||||||
are at sea level."
|
are at sea level."
|
||||||
[stl]
|
[stl-or-seq]
|
||||||
(assoc stl :facets (remove ocean? (:facets stl))))
|
(cond
|
||||||
|
(and (seq? stl-or-seq)
|
||||||
|
(every? triangle? stl-or-seq)) (remove ocean? stl-or-seq)
|
||||||
|
(stl? stl-or-seq)(assoc stl-or-seq :facets
|
||||||
|
(cull-ocean-facets (:facets stl-or-seq)))
|
||||||
|
:else (throw (IllegalArgumentException.
|
||||||
|
"Expected STL structure, or sequence of triangles."))))
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
[o]
|
[o]
|
||||||
(and
|
(and
|
||||||
(coll? o)
|
(coll? o)
|
||||||
|
(#{:polygon :triangle} (kind-type o))
|
||||||
(= (count (:vertices o)) 3)))
|
(= (count (:vertices o)) 3)))
|
||||||
|
|
||||||
(defmacro check-triangle
|
(defmacro check-triangle
|
||||||
|
|
|
@ -207,8 +207,8 @@
|
||||||
([stl solidname]
|
([stl solidname]
|
||||||
(str
|
(str
|
||||||
"solid "
|
"solid "
|
||||||
solidname
|
(or solidname
|
||||||
(s/trim (:header stl))
|
(when (:header stl)(s/trim (:header stl))))
|
||||||
"\n"
|
"\n"
|
||||||
(s/join
|
(s/join
|
||||||
(map
|
(map
|
||||||
|
@ -227,7 +227,7 @@
|
||||||
filename stl
|
filename stl
|
||||||
(subs b 0 (or (s/index-of b ".") (count b))))))
|
(subs b 0 (or (s/index-of b ".") (count b))))))
|
||||||
([filename stl solidname]
|
([filename stl solidname]
|
||||||
(debug "Solid name is " solidname)
|
(debug (format "Writing STL to '%s'; solid name is %s" filename solidname))
|
||||||
(spit
|
(spit
|
||||||
filename
|
filename
|
||||||
(stl->ascii stl solidname))))
|
(stl->ascii stl solidname))))
|
||||||
|
|
19
src/cc/journeyman/walkmap/test_all.clj
Normal file
19
src/cc/journeyman/walkmap/test_all.clj
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
(ns cc.journeyman.walkmap.test-all
|
||||||
|
(:require [cc.journeyman.walkmap.mw-stl :refer [mw->stl]]
|
||||||
|
[cc.journeyman.walkmap.stl :refer [write-ascii-stl]]
|
||||||
|
[mw-engine.world :refer [world?]]))
|
||||||
|
|
||||||
|
(defn run-test
|
||||||
|
([^String name]
|
||||||
|
(run-test (str name ".edn") (str name ".stl") name))
|
||||||
|
([^String mw-name ^String stl-name ^String title]
|
||||||
|
(let [mw (read-string (slurp mw-name))]
|
||||||
|
(if (world? mw)
|
||||||
|
(write-ascii-stl
|
||||||
|
stl-name
|
||||||
|
(mw->stl mw)
|
||||||
|
title)
|
||||||
|
(throw (IllegalArgumentException.
|
||||||
|
(format
|
||||||
|
"Content of file '%s' was not recognised as a valid world"
|
||||||
|
mw-name)))))))
|
Loading…
Reference in a new issue