packages feed

light 0.1.0.0 → 0.2.0.0

raw patch · 4 files changed

+28/−28 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Physics.Light: detectCollision :: PhysicsWorld -> [(Int, Int)]
+ Physics.Light: detectCollision :: IntMap Object2D -> [(Int, Int)]
- Physics.Light: update :: Double -> PhysicsWorld -> PhysicsWorld
+ Physics.Light: update :: Double -> IntMap Object2D -> IntMap Object2D

Files

LICENSE view
@@ -1,30 +1,29 @@-Copyright Suzumiya (c) 2017+BSD 3-Clause License +Copyright (c) 2017, suzumiyasmith All rights reserved.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -    * Redistributions of source code must retain the above copyright-      notice, this list of conditions and the following disclaimer.+* Redistributions of source code must retain the above copyright notice, this+  list of conditions and the following disclaimer. -    * Redistributions in binary form must reproduce the above-      copyright notice, this list of conditions and the following-      disclaimer in the documentation and/or other materials provided-      with the distribution.+* Redistributions in binary form must reproduce the above copyright notice,+  this list of conditions and the following disclaimer in the documentation+  and/or other materials provided with the distribution. -    * Neither the name of Suzumiya nor the names of other-      contributors may be used to endorse or promote products derived-      from this software without specific prior written permission.+* Neither the name of the copyright holder nor the names of its+  contributors may be used to endorse or promote products derived from+  this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR-A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT-OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT-LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
light.cabal view
@@ -1,5 +1,5 @@ name:                light-version:             0.1.0.0+version:             0.2.0.0 synopsis:            a simple physics engine description:         A simple physics engine(dynamics only) with collision dection homepage:            https://github.com/suzumiyasmith/light#readme@@ -15,6 +15,7 @@  library   hs-source-dirs:      src+  ghc-options:         -Wall   exposed-modules:     Physics.Light   build-depends:       base >= 4.7 && < 5                      , linear >= 1.20 && < 2
src/Physics/Light.hs view
@@ -4,7 +4,6 @@  import GJK -import Control.Arrow import Control.Lens import Control.Monad.Writer.Lazy import Data.Fixed@@ -37,8 +36,8 @@ addObjects (o:os) w = addObjects os $ addObject o w addObjects [] w = w -update :: Double -> PhysicsWorld -> PhysicsWorld-update dt = first (fmap w)+update :: Double -> IM.IntMap Object2D -> IM.IntMap Object2D+update dt = fmap w   where     w :: Object2D -> Object2D     w o = o@@ -46,8 +45,8 @@       & velocity %~ (+ o ^. acceleration ^* dt)       & position .  _z %~ (`mod'` (2 * pi)) -detectCollision :: PhysicsWorld -> [(Int, Int)]-detectCollision (w, _) =+detectCollision :: IM.IntMap Object2D -> [(Int, Int)]+detectCollision w =   execWriter $ IM.traverseWithKey (\k o -> tell $ fmap ((,) k) (detect w k o)) w  detect :: IM.IntMap Object2D -> Int -> Object2D -> [Int]
test/Spec.hs view
@@ -1,11 +1,12 @@ import Control.Lens+import Control.Arrow import qualified Data.IntMap.Lazy as IM import Linear import Physics.Light  main :: IO () main = do-  print $ detectCollision <$> (updateTest <$> [1 .. 1000] <*> [testWorld1, testWorld2])+  print $ (detectCollision . fst) <$> (updateTest <$> [1 .. 1000] <*> [testWorld1, testWorld2])  testShape1 = [circle 1, ellipse 0.5 3] @@ -25,4 +26,4 @@  updateTest :: Int -> PhysicsWorld -> PhysicsWorld updateTest 0 w = w-updateTest n w = update 0.1 $ updateTest (n - 1) w+updateTest n w = first (update 0.1) $ updateTest (n - 1) w