godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.14k stars 93 forks source link

Add an option to display PE force vectors in the running project for easier debugging #2749

Open FECU opened 3 years ago

FECU commented 3 years ago

Describe the project you are working on

Multiplayer 3d openworld game where the player controls

Describe the problem or limitation you are having in your project

I have a RigidBody amphibious craft, tracks for land / boat physics for sea. On sea I use _integrate_forces with add_force to have a centre of gravity, centre of buoyancy, a force vector for the propeller, etc - to simulate real world physics. The core Godot functionality here works beautifully. The issue is it can be unintuitive to envisage where to the resulting force vectors actually are in game. Take the propeller child as an example, it has two axis Euler rotations so I need a force vector with the correct offset, in the correct direction with the correct magnitude with a global basis and local origin.

The coding is straightforward, but the maths is abstract enough to make it very easy to make some trivial human error and very hard to see what that error is, especially after multiplying two constantly changing non-identity basis matrices and doing an xform on a position vector. Say, because of human error, the resulting force vector was mistakenly pointing the wrong way / rotating on an undesired axis / opposing forces were misaligned inducing undesired torque. It's not obvious exactly what is resulting in the undesired behaviour.

It's also not straightforward, quick or convenient for the dev to write custom code drawing the force vectors to visualise them. Given this is to address human error in matrix / vector calcs, the output of a custom vector visualisation implementation should be considered unreliable to advanced users and beyond the ability of less advanced users.

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

As with existing "Visible Collision Shapes" functionality, it would be great to have the option to view physics engine force vectors during runtime for debugging purposes. Then the dev would immediately know if the force vectors are as desired and be able to clearly understand any issues at a glance.

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

A "Visible PE Force Vectors" tick box in the debug menu. Then draw the line where the vectors are in runtime if true.

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

This is an optional visual aid to a developer using the physics engine.

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

It would be a core feature, same as viewing raycasts.

Calinou commented 3 years ago

See also https://github.com/godotengine/godot-proposals/issues/2579.

A "Visible PE Force Vectors" tick box in the debug menu. Then draw the line where the vectors are in runtime if true.

Since this is a relatively specialized use case, I would prefer if we merged this together with the Visible Collision Shapes debug option. As long as the lines use a different color, they should be distinguishable enough from each other.

FECU commented 3 years ago

That sounds great, thank you. Obviously mine is a more involved example but I do think this could be just as useful to a beginner coding Pong.