packages feed

wavefront 0.6 → 0.7

raw patch · 5 files changed

+29/−8 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Codec.Wavefront: [elSmoothingGroup] :: Element a -> Natural
+ Codec.Wavefront.Element: [elSmoothingGroup] :: Element a -> Natural
- Codec.Wavefront: Element :: Maybe Text -> [Text] -> Maybe Text -> a -> Element a
+ Codec.Wavefront: Element :: Maybe Text -> [Text] -> Maybe Text -> Natural -> a -> Element a
- Codec.Wavefront.Element: Element :: Maybe Text -> [Text] -> Maybe Text -> a -> Element a
+ Codec.Wavefront.Element: Element :: Maybe Text -> [Text] -> Maybe Text -> Natural -> a -> Element a

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+## 0.7++- Changed `Element` constructor by adding `elSmoothingGroup`.+ ## 0.6  - `Face` has just a single constructor now; pattern synonmys are available to pattern match against
src/Codec/Wavefront/Element.hs view
@@ -15,13 +15,15 @@   ) where  import Data.Text ( Text )+import Numeric.Natural ( Natural ) --- |An element holds a value along with the user-defined object’s name (if exists), the associated--- groups and the used material. Those values can be used to sort the data per object or per group--- and to lookup materials.+-- |An element holds a value along with the user-defined object’s name (if any), the associated+-- groups, the used material and the smoothing group the element belongs to (if any). Those values+-- can be used to sort the data per object or per group and to lookup materials. data Element a = Element {     elObject :: Maybe Text   , elGroups :: [Text]-  , elMtl    :: Maybe Text-  , elValue  :: a+  , elMtl :: Maybe Text+  , elSmoothingGroup :: Natural+  , elValue :: a   } deriving (Eq,Show)
src/Codec/Wavefront/Lexer.hs view
@@ -23,6 +23,7 @@ import Data.Text ( Text ) import Control.Monad.State ( State, execState, gets, modify ) import Data.Foldable ( traverse_ )+import Numeric.Natural ( Natural )  -- |The lexer context. The result of lexing a stream of tokens is this exact type. data Ctxt = Ctxt {@@ -46,6 +47,8 @@   , ctxtCurrentMtl :: Maybe Text     -- |Material libraries.   , ctxtMtlLibs :: DList Text+    -- |Current smoothing group.+  , ctxtCurrentSmoothingGroup :: Natural   } deriving (Eq,Show)  -- |The empty 'Ctxt'. Such a context exists at the beginning of the token stream and gets altered@@ -62,6 +65,7 @@   , ctxtCurrentGroups = ["default"]   , ctxtCurrentMtl = Nothing   , ctxtMtlLibs = empty+  , ctxtCurrentSmoothingGroup = 0   }  -- |The lexer function, consuming tokens and yielding a 'Ctxt'.@@ -93,9 +97,10 @@         libs <- gets ctxtMtlLibs         modify $ \ctxt -> ctxt { ctxtMtlLibs = libs `append` fromList l }       TknUseMtl mtl -> modify $ \ctxt -> ctxt { ctxtCurrentMtl = Just mtl }+      TknS sg -> modify $ \ctxt -> ctxt { ctxtCurrentSmoothingGroup = sg }  -- Prepare to create a new 'Element' by retrieving its associated list. prepareElement :: (Ctxt -> DList (Element a)) -> State Ctxt (DList (Element a),a -> Element a) prepareElement field = do-  (aList,obj,grp,mtl) <- gets $ (\ctxt -> (field ctxt,ctxtCurrentObject ctxt,ctxtCurrentGroups ctxt,ctxtCurrentMtl ctxt))-  pure (aList,Element obj grp mtl)+  (aList,obj,grp,mtl,sg) <- gets $ (\ctxt -> (field ctxt,ctxtCurrentObject ctxt,ctxtCurrentGroups ctxt,ctxtCurrentMtl ctxt,ctxtCurrentSmoothingGroup ctxt))+  pure (aList,Element obj grp mtl sg)
src/Codec/Wavefront/Token.hs view
@@ -23,6 +23,7 @@ import Data.Maybe ( catMaybes ) import Data.Text ( Text, unpack ) import qualified Data.Text as T ( empty )+import Numeric.Natural ( Natural ) import Prelude hiding ( lines )  ----------------------------------------------------------------------------------------------------@@ -39,6 +40,7 @@   | TknO Text   | TknMtlLib [Text]   | TknUseMtl Text+  | TknS Natural     deriving (Eq,Show)  -- |A stream of 'Token'.@@ -59,6 +61,7 @@       , fmap (Just . TknO) object       , fmap (Just . TknMtlLib) mtllib       , fmap (Just . TknUseMtl) usemtl+      , fmap (Just . TknS) smoothingGroup       , Nothing <$ comment       ] @@ -182,6 +185,13 @@  usemtl :: Parser Text usemtl = skipSpace *> string "usemtl " *> skipHSpace *> name <* skipHSpace <* eol++----------------------------------------------------------------------------------------------------+-- Smoothing groups --------------------------------------------------------------------------------+smoothingGroup :: Parser Natural+smoothingGroup = skipSpace *> string "s " *> skipHSpace *> offOrIndex <* skipHSpace <* eol+  where+    offOrIndex = string "off" *> pure 0 <|> decimal  ---------------------------------------------------------------------------------------------------- -- Comments ----------------------------------------------------------------------------------------
wavefront.cabal view
@@ -1,5 +1,5 @@ name:                wavefront-version:             0.6+version:             0.7 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