Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase precision of RigidBody mass property #89468

Merged

Conversation

smnast
Copy link
Contributor

@smnast smnast commented Mar 14, 2024

Increase precision of mass property in RigidBody2D and RigidBody3D from 0.01 kg to 0.001 kg for more precise simulations.

Fixes #89465

@smnast smnast requested review from a team as code owners March 14, 2024 04:35
@YeldhamDev YeldhamDev added this to the 4.x milestone Mar 14, 2024
Copy link
Member

@rburing rburing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is a band-aid on a wider editor issue, but this fix is fine for now.

@akien-mga akien-mga modified the milestones: 4.x, 4.3 Mar 14, 2024
@L30n4rd0-4rg3nt1n0
Copy link

L30n4rd0-4rg3nt1n0 commented Mar 14, 2024

I'm making this comment like the one that started post #89465
(excuse me my bad level of english)

Perhaps increasing the precision of the mass property from 0.01 kg to 0.001 kg can be an improvement. But there is a more fundamental problem that it does not solve.

You may want to work on a milligram scale or smaller. And then again you won't have the precision you need. This problem can be repeated with other units such as length (or position) if you want to work with bodies that have a size of few centimeters (or even millimeters). Additionally, the minimum ZOOM value (20cm) and the minimum navigation speed (20cm/s) can be very large (and uncomfortable) working at that scale.

I think the underlying problem is that certain units are the ones that have been kept in mind for use with the editor tools, or for the Physics engine.

I haven't seen the GODOT source code (maybe I wouldn't even understand it) but I suspect that I wouldn't get good results with the Physics engine if I work with objects whose mass and size are an arbitrary fraction of the reference units, probably because precision will be lost (due to rounding).

I perfectly understand that you can work with the units in an abstract way, you can consider that each unit of length or mass is on the scale you want, you would only have to adjust some physical constants taken into account in the simulation. There are magnitudes such as the acceleration of gravity that is set to 9.81 by default. This value forces to interpretate that the unit of length is equal to one meter (1m). You could always replace this value with 981 and then reinterpret the unit of length to be equal to one centimeter (1cm). But the editor will still show the "m" symbol which represents meters. That can be confusing.

I like properties's boxes, like position and mass, showing explicitly stated units. BUT THAT SYMBOL OF UNIT SHOULD BE CONFIGURABLE. At least one prefix should be configurable such as deci-, centi-, milli-,... Each could represent a multiplicative factor that would be replaced everywhere at the same time, including where constants such as the acceleration of gravity or in internal variables of the Physics engine.

@akien-mga akien-mga changed the title Increase Precision of Rigidbody Mass Property Increase precision of RigidBody mass property Mar 14, 2024
@akien-mga akien-mga merged commit c6d5a78 into godotengine:master Mar 14, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks! And congrats for your first merged Godot contribution 🎉


@L30n4rd0-4rg3nt1n0 For more context on additional flexibility for inputting arbitrary precision, see godotengine/godot-proposals#3524

For your suggestion to make units configurable, this would warrant a new proposal or discussion on https://github.com/godotengine/godot-proposals/discussions. I think this would add significant complexity for a relatively niche scenario - if using a non-standard unit scaling, it would probably make more sense to outright disable displaying SI units which no longer match the used scale.

@L30n4rd0-4rg3nt1n0
Copy link

@akien-mga , I understand what you're saying about increasing complexity. The truth is that at this moment I would not know how to estimate the work that this type of change represents.

When I mentioned modifying "prefixes" globally everywhere I was thinking it would be more aesthetic to be able to define the symbol for new units instead of just deleting them. After all the units appear in various places, for example when adjusting the zoom or navigation speed, as well as in multiple properties in the inspector. At this point, it would be strange to see them disappear completely.

I was also thinking about physics constants like the acceleration of gravity (and perhaps some internal parameter of the physics engine), and perhaps a user starts working on one scale and then discovers it's better to move to another. Modifying a prefix would rescale all those magnitudes at the same time, it would be more comfortable for the user.

But you're right, I guess the best thing would be I think carefully about what I'm saying in order to express it in a new proposal post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The inspector does not allow you to configure masses with one gram of precision
5 participants