Skip to content

Allow customizing the inertia tensor in user code #7033

@aaronfranke

Description

@aaronfranke

This PR is a revival of #1114 and half of #945

Describe the project you are working on

I am working on the ability to represent complex physics objects in Godot.

Describe the problem or limitation you are having in your project

This chair cannot have its inertia properly described without access to the full 3x3 matrix inertia tensor (or changing the orientation). An object as simple as a chair does not seem like a niche use case to me, it seems very common.

Currently the only way for this object to have remotely close to the correct inertia would be to let Godot calculate a tensor, but this would not be very accurate if the collision shapes do not match up perfectly, and they would not be very precise if the chair's material was not uniformly dense.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The proposal is to expose the inertia tensor to the user, so advanced users can set up their own custom inertia tensors to improve the accuracy of advanced physics simulations.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The engine's internal physics system already uses an inertia tensor matrix, but it's not exposed to the user.

I have a compiles-but-completely-broken branch here: https://github.com/aaronfranke/godot/tree/rigid-body-intertia-tensor-mass-dist maybe someone can figure out what's wrong.

Here is what it would look like in the inspector, a matrix for inertia instead of a vector:

Screenshot 2023-06-07 at 1 10 35 AM

EDIT: Actually, instead of the inertia tensor, I think it would be better to expose the inertia orientation as an Euler Vector3 or Quaternion. I think it's more intuitive to work with and also it aligns with the updated glTF physics specs.

If this enhancement will not be used often, can it be worked around with a few lines of script?

It will not be used very often, but it is important for the small percentage of users who want to put in the work to have accurate physics simulations. It can't be worked around, this is about exposing.

Is there a reason why this should be core and not an add-on in the asset library?

Physics is a core feature, and this is about exposing something in physics currently hidden from the user.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions