Giter Site home page Giter Site logo

Comments (2)

mihe avatar mihe commented on June 10, 2024

I was looking at the automatically calculated inertia vector and comparing it to the one that the default 3D physics provides and it looks like the y and z are swapped, as if GodotJolt is mistaking Z as the up vector.

I'm not sure how this went unreported for this long, nor how I missed this to begin with, but yes, the inertia as reported by PhysicsDirectBodyState3D.inverse_inertia is indeed incorrect. Apparently I had missed that you need to multiply Jolt's GetInverseInertiaDiagonal() with its GetInertiaRotation() in some way to get the proper local-space inertia. So the inertia is correct within Jolt, but reported incorrectly by this extension.

If you need a workaround (until I can publish a fix) you should be able to extract the inertia diagonal from the world-space inertia tensor instead, as that one is actually correct, by doing something like this:

var inverse_inertia_tensor := state.transform.basis.transposed() * state.inverse_inertia_tensor * state.transform.basis
var inverse_inertia := Vector3(inverse_inertia_tensor[0][0], inverse_inertia_tensor[1][1], inverse_inertia_tensor[2][2])

I've got a body that is very narrow but tall and I wanted to make sure it could spin freely along the y axis but be hard to topple (so in default physics this would be making the x and z inertia very high) but this does not do anything at all in GodotJolt.

I'm guessing you're leaving the Y-component at zero? It appears I've also missed the fact that Godot Physics allows for a partial custom inertia, where leaving only certain components at zero will still use the automatically computed value for those components. Right now you'll only get the automatically computed value for the inertia if you leave all three components at zero, meaning you actually get zero (which is not valid) if you only leave one or two components at zero. The workaround in this case (until I can get a fix in) would be to set a non-zero value for all components if you want to use a custom inertia.

from godot-jolt.

mihe avatar mihe commented on June 10, 2024

The fix for both of these issues can now be found in the latest pre-release, 0.13.0-beta1, which you'll find here.

Note that this version targets the just recently released Godot 4.3-beta1, so won't work with Godot 4.2. Also note that this version is not available through the Godot Asset Library, so you'll need to download it through GitHub.

A proper release will be out some time around Godot 4.3-stable.

from godot-jolt.

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.