packages feed

apecs-physics 0.4.5 → 0.4.6

raw patch · 5 files changed

+25/−76 lines, 5 filesdep ~apecsdep ~containerssetup-changednew-uploaderPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: apecs, containers

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+## [0.4.6]+### Changed+- (#113) Ineffectual custom build removed from Setup.hs+ ## [0.4.5] ### Changed - (#78) Chipmunk bumped to `v7.0.3`, fixes the `sysctl.h` deprecation reported in #77
README.md view
@@ -13,11 +13,10 @@ ![Screenshot](helloworld.png)  ```haskell-makeWorld "World" [''Physics, ''BodyPicture, ''Camera]+makeWorld "World" [''Physics, ''Camera] ``` Generate a world. The `Physics` component adds a physics space to the world.-The `BodyPicture` contains a gloss `Picture`, which the renderer will match to the `Body`'s position and orientation. The `Camera` component tracks a camera position and zoom factor.  ```haskell@@ -31,12 +30,12 @@  ```haskell   let ballShape = cCircle 0.5-  newEntity ( DynamicBody-            , Shape ballShape+  ball <- newEntity ( DynamicBody             , Position (V2 0 3)             , Density 1             , Elasticity 0.9-            , BodyPicture . color red . toPicture $ ballShape )+  )+  ballEntity <- newEntity (Shape ball ballShape) ``` Still in the initialize function, here we see our first object being instantiated. The type of ballShape is `Convex`, the apecs-physics format for shapes.@@ -48,18 +47,13 @@ It is a normal body, fully affected by physical forces. The elasticity of a collision is the product of the elasticities of the colliding shapes. -The final line shows how to do rendering.-`BodyPicture` expects a gloss `Picture`, in this case we derive one from `ballShape :: Convex` using `toPicture`.-`color red` comes from gloss, and is just one of the many `Picture` manipulation functions.-Alternatively, you can use a `Bitmap` to use actual sprites.  ```haskell   let lineShape = hLine 6   newEntity ( StaticBody             , Angle (-pi/20)             , Shape lineShape-            , Elasticity 0.9-            , BodyPicture . color white . toPicture $ lineShape )+            , Elasticity 0.9 ) ``` Static bodies are not affected by physics, and generally rarely move. They are equivalent to bodies with infinite mass and moment, and zero velocity.@@ -85,8 +79,7 @@    let sides = toEdges $ cRectangle 5   tumbler <- newEntity ( KinematicBody-                       , AngularVelocity (-1)-                       , BodyPicture . color white . foldMap toPicture $ sides )+                       , AngularVelocity (-1) ) ``` As previously stated, both Chipmunk and gloss exclusively have _convex_ polygon primitives. Our tumbler, however, is obiously not convex.@@ -123,11 +116,10 @@     r <- liftIO$ randomRIO (0.1, 0.2)     let ballshape = cCircle r     let c = (realToFrac x+2)/3-    newEntity ( DynamicBody+    ball <- newEntity ( DynamicBody               , Position (V2 x y)-              , Shape ballshape-              , BodyPicture . color (makeColor 1 c c 1) . toPicture $ ballshape               , Density 1 )+    newEntity (Shape ball ballshape)    return () ```@@ -144,7 +136,6 @@ ```haskell let rubber = (Friction 0.5, Elasticity 0.5, Density 1) newEntity ( DynamicBody-          , someShape           , rubber ) ``` Nesting tuples creates composable and reusable pieces of configuration (this is an apecs thing, not an apecs-physics thing).@@ -155,3 +146,10 @@  Dragging an object with the mouse is also done using a constraint. The mouse position actually controls the position of a static body without shapes, and we use a PinJoint to attach whatever we are dragging to it.++### Rendering+A basic rendering system, `drawBody :: (Body, Transform, ShapeList) -> System m Picture` is provided for debugging and prototyping purposes. Inside your gloss draw function you can combine this with foldDrawM to draw every physics body. For example++```hs+draw = foldDrawM drawBody+```
Setup.hs view
@@ -1,50 +1,2 @@-{-# LANGUAGE CPP #-} import Distribution.Simple-import Distribution.Verbosity-import Distribution.PackageDescription-#if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(2,2,0)-import Distribution.PackageDescription.Parsec-#else-import Distribution.PackageDescription.Parse-#endif---main = do-#if defined(MIN_VERSION_Cabal) && MIN_VERSION_Cabal(2,0,0)-    pkgDescr <- readGenericPackageDescription verbose "apecs-physics.cabal"-#else-    pkgDescr <- readPackageDescription verbose "apecs-physics.cabal"-#endif-    defaultMainNoRead . addCFilesIfNeeded $ pkgDescr-  where-    addCFilesIfNeeded =-#if __GLASGOW_HASKELL__ >= 802-      id-#else-      addCFiles-#endif--    addCFiles genPkgDescr = genPkgDescr-      { condLibrary = fmap addCFiles' pkgLibrary-      }-      where-        pkgLibrary = condLibrary genPkgDescr --        addCFiles' (CondNode lib constraints components) =-          CondNode (addCFiles'' lib) constraints components--        addCFiles'' lib = lib-          { libBuildInfo =-              let buildInfo = libBuildInfo lib in-                buildInfo-                { cSources = cSources buildInfo ++-                    [ "src/Apecs/Physics/Constraint.c"-                    , "src/Apecs/Physics/Space.c"-                    , "src/Apecs/Physics/Query.c"-                    , "src/Apecs/Physics/Body.c"-                    , "src/Apecs/Physics/Collision.c"-                    , "src/Apecs/Physics/Shape.c"-                    ]-                }-          }-+main = defaultMain
apecs-physics.cabal view
@@ -1,5 +1,6 @@+cabal-version:      2.0 name:               apecs-physics-version:            0.4.5+version:            0.4.6 synopsis:           2D physics for apecs description:   2D physics for apecs. Uses Chipmunk physics library under the hood.@@ -11,8 +12,7 @@ maintainer:         jonascarpay@gmail.com copyright:          MIT category:           Web-build-type:         Custom-cabal-version:      >=1.10+build-type:         Simple extra-source-files:   CHANGELOG.md   Chipmunk2D/include/chipmunk/*.h@@ -23,11 +23,6 @@   type:     git   location: git://github.com/jonascarpay/apecs.git -custom-setup-  setup-depends:-      base   >=4.9  && <5-    , Cabal  >=1.14- flag release   description:     Release mode, better performance but no longer provides debug info on the command line.@@ -56,7 +51,7 @@     , inline-c          >=0.6  && <1     , linear            >=1.20 && <2     , template-haskell  >=2.12 && <3-    , vector            >=0.10 && <0.13+    , vector            >=0.10 && <0.14    ghc-options:     -Wall -O2 -Wno-orphans -Wno-unused-do-bind -Wno-name-shadowing
src/Apecs/Physics/Collision.hs view
@@ -155,6 +155,6 @@     let fn = castFunPtrToPtr funPtr     [C.block| void {       int *data = 0;-      cpSpaceAddPostStepCallback($(cpSpace *space), $(void*fn),$(int k), &data);+      cpSpaceAddPostStepCallback($(cpSpace *space), $(void*fn),(void*) (uintptr_t) $(int k), &data);     } |]   pure ()