Open darkerbit opened 3 years ago
I doubt this proposal will be implemented, as https://github.com/godotengine/godot/pull/39105 already implemented additional import hints but they were ultimately rejected: https://github.com/godotengine/godot/pull/39105#issuecomment-753481845
Also similar thing was suggested in #542.
Describe the project you are working on
This problem applies to multiple of my projects, and is generally a problem when importing external 3D scenes as physics objects.
Describe the problem or limitation you are having in your project
The existing 3D scene importer uses import hints to create both the collision shape AND the PhysicsBody node simultaneously. Collision shape creation can be done either from the visual mesh, or another collision mesh, and it can create either a StaticBody or a RigidBody node in the resulting node tree. This approach has a few flaws:
-rigidonly
import hint, but the code that was merged seems to have disappeared.Table illustrating problem 1
-col
/-convcol
-colonly
/-convcolonly
-rigid
Describe the feature / enhancement and how it helps to overcome the problem or limitation
I propose that the functionality for creating a PhysicsBody node and the functionality for generating a collision shape be separated into different sets of import hints. This way, the 3D artist and game developer are free to organize their node structure in whatever way they see fit, and can produce all permutations of physics body and collision shape generation.
The existing import hints should also be kept for backwards compatibility.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Here is a list of my proposed new import hints with descriptions.
-staticbody
,-kinematicbody
and-rigidbody
: Creates a Static-, Kinematic or RigidBody node, with the imported scene's node's visual mesh as a child of that node.-staticonly
,-kinematiconly
and-rigidonly
: Only creates the corresponding PhysicsBody node, discards imported node's mesh.-colnode
: Generates a concave CollisionShape node from the imported node's visual mesh, and also keeps the visual mesh. Only usable with StaticBodies.-colnodeonly
: Generates a concave CollisionShape from the imported node's mesh, and discards the visual mesh. Only usable with StaticBodies. Works with objects with no visual data, like Blender's Empties.-convnode
: Generates a convex CollisionShape from the imported node's visual mesh, and also keeps the visual mesh. Works with all PhysicsBodies.-convnodeonly
: Generates a convex CollisionShape from the imported node's visual mesh, and discards the visual mesh. Works with all PhysicsBodies. Works with objects with no visual data, like Blender's Empties.This allows for many kinds of scene structures to be brought into Godot as-is. Here are a few common setups:
A simple physics object with just one mesh
The 3D artist has setup a GLTF scene as follows:
With my proposal, this setup would be imported as:
This example also illustrates what happens on a name conflict if an import hint generates multiple nodes. The game developer should not rely on the specifics on name suffixes or conflict resolution, and instead use explicit separation as in the FPS character example below.
A simple physics object with separate collision mesh
The 3D artist has setup a GLTF scene as follows:
With my proposal, this setup would be imported as:
An FPS character with a collision mesh and optional visual mesh that can be turned off
The 3D artist has setup a GLTF scene as follows:
With my proposal, this setup would be imported as:
If this enhancement will not be used often, can it be worked around with a few lines of script?
Some individual usecases can be worked around with editor scripts, however these usually end up being the same across projects and really just indicate a flaw of the existing system.
Is there a reason why this should be core and not an add-on in the asset library?
The problems I mentioned are flaws of the main 3D scene importer itself. I believe that these issues should be fixed directly, rather than via external add-ons.