Code Monkey home page Code Monkey logo

shapes's People

Contributors

schell avatar ublubu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

schell

shapes's Issues

rename effMassM2 to invEffMass...

The inverse effective mass of a pair of objects along the constraint axis

-- TODO: rename effMassM2 to invEffMass
-- | The inverse effective mass of a pair of objects along the constraint axis
effMassM2 :: V6 -- ^ Jacobian

  • Found on swizzle
  • Found on prim
  • Found on swizzle-noinline
  • Found on master

Why doesn't GeneralizedNewtypeDeriving work in Physics.Constraint?...

Lagrangian multiplier - the (signed) magnitude of the impulse
required to solve a constraint equation.

-- TODO: Why doesn't GeneralizedNewtypeDeriving work in Physics.Constraint?
-- | Lagrangian multiplier - the (signed) magnitude of the impulse
-- required to solve a constraint equation.
newtype Lagrangian =

  • Found on swizzle
  • Found on prim
  • Found on swizzle-noinline
  • Found on master

Profile and optimize culledPairs

I'm guessing you already knew this as you mention in first in your reddit link but just doing a quick stack build --executable-profiling --library-profiling --ghc-options="-fprof-auto" shows that Physics.Broadphase.Opt.Aabb.culledPairs.f is the biggest CPU cost center. It has two IntMap lookups which at first I thought may be the culprit but IM.lookup doesn't even show up in the prof file, and I've enabled library profiling. I'm not sure - I'd like to take a look at the generated core and see if I can make any sense of it. It could be that using a list is the culprit.

screenshot 2016-03-29 23 14 05

Documentation?

I've been following this project for a few months and I'm excited that there's a physics library that's not stuck in the IO, but there's a pretty severe lack of haddock documentation right now which is making it difficult to learn the library.

add another type variable to track values that originated in the same local space...

see lap, Geometry.overlap

-- TODO: add another type variable to track values that originated in the same local space
-- see lap, Geometry.overlap
data LocalT a b = LocalT !(WorldTransform a) !b deriving (Show, Eq)
type LV2 a = LocalT a (V2 a)

see lap, Geometry.overlap

-- TODO: add another type variable to track values that originated in the same local space
-- see lap, Geometry.overlap
data LocalT b = LocalT !WorldTransform !b deriving Show

  • Found on swizzle
  • Found on prim
  • Found on swizzle-noinline
  • Found on master

version bounds for dependencies

set some version bounds for the dependencies. i plan to just use the major versions of whatever i'm building with using stack.

dedupe this & _constrainedVel6...

Get a 6D velocity vector for a pair of objects.
Same as '_constrainedVel6'

-- TODO: dedupe this & _constrainedVel6
-- | Get a 6D velocity vector for a pair of objects.
-- Same as '_constrainedVel6'
velocity2 :: PhysicalObj -> PhysicalObj -> V6
velocity2 a b = (va `append2` wa) `join3v3` (vb `append2` wb)

  • Found on swizzle
  • Found on prim
  • Found on swizzle-noinline
  • Found on master

how did demo run 100fps with 15x15?

pre-descZipVector, profiled 10 frames at 130ms
post-descZipVector, profiled 10 frames at 190ms
post-descZipVector-inline, profiled 10 frames at 130ms

why does pre-descZipVector run 100fps in the demo?

Question: Deterministic simulation

There are lots of 2d physics engines out there and a couple already have Haskell bindings (box2d, chipmunk). These are both battle tested and proven technologies. I don’t think shapes can compete with them in a standard “technology pull” project environment (one where the tech is picked based on the needs of the project). Asking a game developer to write their game in Haskell is a hard sell. So what can Haskell do that other languages cannot?
Haskell can guarantee reproducible results through referential transparency. Shapes already does this to a certain extent - it’s pure, so one set of inputs should always give you the same output, but the implementation of some underlying floating point operations (1) are platform dependent! Simulations on different machines or different build targets may produce different results.
Would it be worth it to use the techniques outlined by Joachim Breitner (@nomeata) in section 5.1 of this paper to ensure deterministic simulation under all circumstances?

Pro

  • Gives shapes and Haskell a reason to be used above all other tech stacks.
  • I think this space is bigger and more fun than it seems at first.

Con

  • Lots of work
  • Will be slower at runtime

Fun to think about, none the less.

(1) - transcendental functions like exp, sin, cos, log, etc.

INLINE pragmas

add INLINE pragmas, particularly in shapes-math and Utils.Utils

shapes-math build error with ghc8

Using stackage nightly to build with ghc8 I found that shapes-math is erring with:

    /Users/schell/Code/shapes/shapes-math/src/Shapes/Linear/Template.hs:43:20: error:
         Data constructor not in scope: NotStrict
         Perhaps you meant variable notStrict (imported from Language.Haskell.TH)

    /Users/schell/Code/shapes/shapes-math/src/Shapes/Linear/Template.hs:54:34: error:
         Couldn't match expected type Maybe Kind
                      with actual type [Con]
         In the fourth argument of DataD, namely
            [NormalC vectorN (replicate dim constrArg)]
          In the first argument of (:), namely
            DataD
               [] vectorN [] [NormalC vectorN (replicate dim constrArg)] []
          In the expression:
            DataD [] vectorN [] [NormalC vectorN (replicate dim constrArg)] []
            : impls

    /Users/schell/Code/shapes/shapes-math/src/Shapes/Linear/Template.hs:54:83: error:
         Couldn't match type Dec with Cxt -> Dec
          Expected type: [Cxt -> Dec]
            Actual type: [Dec]
         In the second argument of (:), namely impls
          In the expression:
            DataD [] vectorN [] [NormalC vectorN (replicate dim constrArg)] []
            : impls
          In an equation for decs’:
              decs
                = DataD
                    [] vectorN [] [NormalC vectorN (replicate dim constrArg)] []
                  : impls

    /Users/schell/Code/shapes/shapes-math/src/Shapes/Linear/Template.hs:55:3: error:
         Couldn't match type Cxt -> Dec with Dec
          Expected type: Q [Dec]
            Actual type: Q [Cxt -> Dec]
         In a stmt of a 'do' block: return decs
          In the expression:
            do { let vectorN = makeVectorN dim
                     constrArg = ...
                     ....;
                 impls <- concat <$> mapM (\ f -> f vectorN vi dim) definers;
                 let decs = DataD ... vectorN ... ... ... : impls;
                 return decs }
          In an equation for makeVectorType’:
              makeVectorType vi@(ValueInfo {..}) dim
                = do { let vectorN = ...
                           ....;
                       impls <- concat <$> mapM (\ f -> f vectorN vi dim) definers;
                       let decs = ...;
                       .... }

It seems template-haskell 2.11 has some breaking changes. What is the TH mostly used for in shapes-math? Maybe there's a non-TH way to accomplish this?

3d

I know shapes is 2d and that 3d isn't on the roadmap, but how much more work is adding a separate 3d module? Maybe only using boxes or spheres?

split contactsolution cache

split contactsolution cache into impulse cache (copied between frames) and constraint cache (single frame)

make ConvexHull a proper WorldTransformable...

instance (Epsilon a, Floating a, Ord a) => WorldTransformable (ConvexHull a) a where
transform t = flip transformHull (transform t)
untransform t = flip transformHull (untransform t)

-- TODO: make ConvexHull a proper WorldTransformable
--instance (Epsilon a, Floating a, Ord a) => WorldTransformable (ConvexHull a) a where
--transform t = flip transformHull (transform t)
--untransform t = flip transformHull (untransform t)

  • Found on swizzle
  • Found on prim
  • Found on swizzle-noinline
  • Found on master

consider clearing out the Engine/Demo typeclasses

now that there's only one implementation of the physics engine, there isn't really a need for these classes.

arguments in favor of keeping the typeclasses:

  • documents the "API" of an actual "physics engine"
  • adding engine variants in the future

try unboxed vector instead of hashtable for caches

culledKeys are in order
change keyedContacts so they are also in order (make keyed contacts flippable and sort by feature?)

zip keyedContacts with old cache vector to create new cache vector

  • discard unmatched cache entries
  • solve contact to populate missing cache entries

^ new cache vector is dense; first contacts get an extra solver iteration - less jittery/bouncy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.