Code Monkey home page Code Monkey logo

Comments (1)

zachreizner avatar zachreizner commented on May 25, 2024

My workaround of using a timestep of 0.0 ended up not being so good because it would cause dynamic bodies that are temporarily colliding with static bodies to be forced apart, which is not viable behavior for an editor. Therefore I took another look at what made step work for interferences_with_point by removing chunks of MechanicalWorld::step until the editor exhibited the original issue.

After some false positives, I narrowed it to this chunk:

bodies.foreach_mut(&mut |_, b: &mut dyn Body<N>| {
    b.clear_forces();
    b.validate_advancement();
});

I transplanted this into my sync with step function and it works! My theory is that even though I was setting the body and collider position to the new position, the old body position is temporarily cached and used to reset the attached collider position before the broad phase based point interference is run. The call to Body::validate_advancement clears out the old position allowing the broad phase to work as expected with the new collider position. After simplifying my sync function looks like this:

pub fn sync(&mut self) {
    self.mech.maintain(&mut self.geo, &mut self.bodies, &mut self.colliders, &mut self.joints);
    self.bodies.foreach_mut(&mut |_, b| {
        b.validate_advancement();
    });
    self.geo.sync_colliders(&self.bodies, &mut self.colliders);
    self.geo.perform_broad_phase(&self.colliders);
}

I'm not sure if this is a supported use case or if it will continue to work, so it would be nice to get some input from a maintainer, but I'm basically happy with my solution. Thanks for taking a look.

from nphysics.

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.