GithubHelp home page GithubHelp logo

Comments (4)

jes avatar jes commented on June 26, 2024

If I change yPivotOffset of the first body from 0 to -1, then it also exhibits erratic behaviour sometimes, but not quite as easily.

It certainly seems that there is something wrong whenever the pivot is anywhere other than the centre of mass.

from matter-js.

jes avatar jes commented on June 26, 2024

I have found a solution: https://incoherency.co.uk/matterjs-test-case/fixed.html

I needed to leave the two balls as separate bodies and constrain their locations with constraints, instead of trying to turn them into oen body.

It seems like this is a bug in compound bodies, since to my mind the two methods should give the same outcome.

from matter-js.

oli414 avatar oli414 commented on June 26, 2024

I seem to be running into this bug as well:

https://jsfiddle.net/Oli414/2gapbwoq/

@jes did you notice a performance difference with your solution compared to using a compound? I'd expect there to be some extra overhead. I'm a bit concerned about using your solution at a larger scale.

from matter-js.

oli414 avatar oli414 commented on June 26, 2024

I've been trying to dig a bit deeper, I might have found the underlying issue. But for now the best I've got is a better temporary solution.

First of all some discoveries regarding this bug:

With that in mind I ended up cloning the repo to see if I could figure out what was going on, focusing on a single iteration of the constraint solver. I found that there was a discrepancy in the inertia value between single-part bodies and multi-part bodies.

A compound consisting of 3 squares (3 times 64x64, forming a 192x64 rectangle) has an inertia of 33554.432 as opposed to a single rectangle having an inertia of 167772.16 (1 time 192x64), 5 times that of the 3 separate squares.

You can manually set the compound's inertia to the correct value and the constraint starts to behave identically to a constraint with a non-compound body.
https://jsfiddle.net/Oli414/dw8zf3yn/

I'm don't know enough about the inner workings of this physics engine to make a bugfix, but something seems off about the way the inertia is calculated for compound bodies.

from matter-js.

Related Issues (20)

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.