Giter Site home page Giter Site logo

Comments (3)

sebcrozet avatar sebcrozet commented on June 15, 2024

Hi! Sorry for the late response.

I believe there may be a mismatch with the way sprites are rendered. Where is the local origin of sprites? If it is not at the center of the sprite, then it won't match what Rapier assumes (the center of the ball in its local-space is its local origin).

from rapier.

jakerr avatar jakerr commented on June 15, 2024

I'm not at a computer where I can check right now, but I find it a bit hard to imagine this being a problem of the origins not being aligned. I'm saying this just looking at that motion where the top ball kind of hangs at about the half y position overlapping the lower one after falling a bit, and even pops back up briefly.

Another hint that this may be a bug was when I ran the same simulation with more sprites many of them seem to behave correctly while only a few exhibit this strange behavior. I reduced it to just the two before making this bug report to try to get the minimal reproduction.

from rapier.

sebcrozet avatar sebcrozet commented on June 15, 2024

You are right. I thought that perhaps the sprite center was on the top-left corner, which would cause this kind of weird behavior because a small rotation would make them appear as if there are penetrating. But if I run your code locally, I can see that when the ball rolls on the ground, it rotates properly wrt. the sprite center.

So, yes, this is a bug. However if I try your code with my local version of Rapier (the one I'm actively working on for #79), the bug appears to be gone. So chances are that this won't be a problem in the next release of Rapier.

By the way, I think you got your PIXEL_PER_METER thing reversed. If you intend to consider that 1 meter is, say, 60 pixels, then this means that when you have 1 unit in the physics world, you get 60 units in the graphics world. So you should not scale all the physics quantities by PIXEL_PER_METER, it is the graphics that needs to be scaled wrt. the physics. Otherwise you end up with huge objects in the physics engine (because everything is expressed in pixels) which is more prone to numerical errors.
To make this a bit easier to work with, you can set RapierConfiguration::scale to PIXEL_PER_METER. That way, the Rapier plugin will automatically multiply the rigid-body positions by PIXEL_PER_METER whenever it writes their position back to the Bevy Transform.

from rapier.

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.