From 89b10a78c24513b125fc505c78533a4ad6febd4c Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Tue, 16 Jul 2019 20:59:39 -0400 Subject: Refactor Wavefront.parse. --- doc/mtl-format.txt | 2 +- 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: Ir = (intensity of reflection map) - 9 This illumination model is similar to illumination model 4without + 9 This illumination model is similar to illumination model 4 without ray tracing. The formula is: 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 parse :: L.ByteString -> OBJ Vector parse bs = Rank2.fmap (Vector.fromList . DList.toList) obj where - b = objBookKeeping buildOBJ - substvars = ObjConfig IntMap.empty - (obj,_) = execState (runStateT (parseOBJ b substvars bs) emptyCounts) (mzeroOBJ,blankElement) + go = parseCustom buildOBJ (const $ return ()) bs + (obj,_) = execState go (mzeroOBJ,blankElement) + +parseCustom :: Monad m => ObjBuilder m -> (OBJ Count -> m b) -> L.ByteString -> m b +parseCustom builder finish bs = do + counts <- execStateT (parseOBJ (objBookKeeping builder) (ObjConfig IntMap.empty) bs) emptyCounts + finish counts -- cgit v1.2.3