diff options
author | Joe Crayne <joe@jerkface.net> | 2019-07-16 20:59:39 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-07-16 21:00:19 -0400 |
commit | 89b10a78c24513b125fc505c78533a4ad6febd4c (patch) | |
tree | 7851e91eb3a75b24cbd0b83b46bab4d994d03364 | |
parent | eb13dbaed4a2e6483870f09dfc4e5a7f743e664f (diff) |
Refactor Wavefront.parse.
-rw-r--r-- | doc/mtl-format.txt | 2 | ||||
-rw-r--r-- | src/Wavefront.hs | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/doc/mtl-format.txt b/doc/mtl-format.txt index ebeab6e..13155b8 100644 --- a/doc/mtl-format.txt +++ b/doc/mtl-format.txt | |||
@@ -1349,7 +1349,7 @@ ray tracing. The formula is: | |||
1349 | 1349 | ||
1350 | Ir = (intensity of reflection map) | 1350 | Ir = (intensity of reflection map) |
1351 | 1351 | ||
1352 | 9 This illumination model is similar to illumination model 4without | 1352 | 9 This illumination model is similar to illumination model 4 without |
1353 | ray tracing. The formula is: | 1353 | ray tracing. The formula is: |
1354 | 1354 | ||
1355 | 1355 | ||
diff --git a/src/Wavefront.hs b/src/Wavefront.hs index 2131d96..638b849 100644 --- a/src/Wavefront.hs +++ b/src/Wavefront.hs | |||
@@ -152,6 +152,10 @@ mzeroOBJ = OBJ | |||
152 | parse :: L.ByteString -> OBJ Vector | 152 | parse :: L.ByteString -> OBJ Vector |
153 | parse bs = Rank2.fmap (Vector.fromList . DList.toList) obj | 153 | parse bs = Rank2.fmap (Vector.fromList . DList.toList) obj |
154 | where | 154 | where |
155 | b = objBookKeeping buildOBJ | 155 | go = parseCustom buildOBJ (const $ return ()) bs |
156 | substvars = ObjConfig IntMap.empty | 156 | (obj,_) = execState go (mzeroOBJ,blankElement) |
157 | (obj,_) = execState (runStateT (parseOBJ b substvars bs) emptyCounts) (mzeroOBJ,blankElement) | 157 | |
158 | parseCustom :: Monad m => ObjBuilder m -> (OBJ Count -> m b) -> L.ByteString -> m b | ||
159 | parseCustom builder finish bs = do | ||
160 | counts <- execStateT (parseOBJ (objBookKeeping builder) (ObjConfig IntMap.empty) bs) emptyCounts | ||
161 | finish counts | ||