summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitriSabadie <>2017-03-20 22:02:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2017-03-20 22:02:00 (GMT)
commit527ec6d1a9a41fa2b97671d3d61f0177d3505774 (patch)
treefc1b9da18a5c95873d6f223cf7f1447b8bb02f89
parentfa2c361a7c553a993472fd28bcfe14094ca84388 (diff)
version 0.7.10.7.1
-rw-r--r--CHANGELOG.md5
-rw-r--r--src/Codec/Wavefront/Token.hs11
-rw-r--r--wavefront.cabal2
3 files changed, 13 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7fc5eab..732bc14 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+### 0.7.1
+
+- Allow missing group names.
+- Spaced object and material names are now supported.
+
#### 0.7.0.2
- Added support for `vector-0.12.0.0`.
diff --git a/src/Codec/Wavefront/Token.hs b/src/Codec/Wavefront/Token.hs
index 9eff0d0..166c621 100644
--- a/src/Codec/Wavefront/Token.hs
+++ b/src/Codec/Wavefront/Token.hs
@@ -21,7 +21,7 @@ import Control.Applicative ( Alternative(..) )
import Data.Attoparsec.Text as AP
import Data.Char ( isSpace )
import Data.Maybe ( catMaybes )
-import Data.Text ( Text, unpack )
+import Data.Text ( Text, unpack, strip )
import qualified Data.Text as T ( empty )
import Numeric.Natural ( Natural )
import Prelude hiding ( lines )
@@ -166,13 +166,13 @@ face = do
-- Groups ------------------------------------------------------------------------------------------
groups :: Parser [Text]
-groups = skipSpace *> string "g " *> skipHSpace *> name `sepBy1` skipHSpace <* eol
+groups = skipSpace *> string "g " *> skipHSpace *> name `sepBy` skipHSpace <* eol
----------------------------------------------------------------------------------------------------
-- Objects -----------------------------------------------------------------------------------------
object :: Parser Text
-object = skipSpace *> string "o " *> skipHSpace *> name <* eol
+object = skipSpace *> string "o " *> skipHSpace *> spacedName <* eol
----------------------------------------------------------------------------------------------------
-- Material libraries ------------------------------------------------------------------------------
@@ -184,7 +184,7 @@ mtllib = skipSpace *> string "mtllib " *> skipHSpace *> name `sepBy1` skipHSpace
-- Using materials ---------------------------------------------------------------------------------
usemtl :: Parser Text
-usemtl = skipSpace *> string "usemtl " *> skipHSpace *> name <* skipHSpace <* eol
+usemtl = skipSpace *> string "usemtl " *> skipHSpace *> spacedName <* eol
----------------------------------------------------------------------------------------------------
-- Smoothing groups --------------------------------------------------------------------------------
@@ -217,6 +217,9 @@ eol = skipMany (satisfy isHorizontalSpace) *> (endOfLine <|> endOfInput)
name :: Parser Text
name = takeWhile1 $ not . isSpace
+spacedName :: Parser Text
+spacedName = strip <$> AP.takeWhile (flip notElem ("\n\r" :: String))
+
skipHSpace :: Parser ()
skipHSpace = () <$ AP.takeWhile isHorizontalSpace
diff --git a/wavefront.cabal b/wavefront.cabal
index 9f60c61..ac35b43 100644
--- a/wavefront.cabal
+++ b/wavefront.cabal
@@ -1,5 +1,5 @@
name: wavefront
-version: 0.7.0.3
+version: 0.7.1
synopsis: Wavefront OBJ loader
description: A Wavefront OBJ loader. Currently supports polygonal information. More could
be added if needed (like curves and surface) if people contribute. Feel free