godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.05k stars 65 forks source link

Add AABB (Simple Box) to Collision Shape Type in Mesh > Create Collision Shape #9685

Open Nodragem opened 1 week ago

Nodragem commented 1 week ago

Describe the project you are working on

Top Down Shooter with Modular Asset Kits

Describe the problem or limitation you are having in your project

I can easily create complex collision shapes, but I cannot easily create the simplest collision shape of all: the AABB (Axis-Aligned Bounding Box).

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

One argument for not adding it before (can't remember the issue number) was that it would clutter the Mesh menu. But since Godot 4.3dev6, we have a new pop-up menu that allows to add a lot of different ways of making Collision Shape for MeshInstance3D (https://github.com/godotengine/godot/pull/86627) 🎊 🍾 🎊 .

image

We can now simply add an entry "Axis-Aligned Bounding Box (AABB)" to that menu! πŸš€

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

In GDScript it looks like that: https://github.com/Nodragem/twin-stick-shooter-starter-kit/blob/make-new-level/tools/automation/build_collision_boxes.gd

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

yes it can! I did. But just feel a bit silly that I need to code it when Create Collision Shape already exist for more complex shapes!

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

Create Collision Shape already exists in core. We simply add the most basic one.

Calinou commented 1 week ago

I would also expose sphere, capsuld and cylinder options, although there will need to be a way to choose the capsule/cylinder axis.

aXu-AP commented 1 week ago

I think making an extra option appear if the user chooses capsule or cylinder. kuva

Additionally for sphere, capsule and cylinder it is needed to determine radius/height since they don't have 3 axes of dimensions. Use average, smallest or largest dimension? Maybe have a grow/shrink parameter to adjust the generated shape?

In similiar vein, but not directly related, advanced import also has option to generate collision primitives to meshes, but user needs to manually input all the values. For consistency and better import workflow it would be nice to generate those from aabb also.

Nodragem commented 1 week ago

The alignment option looks great. I can't really think about the use cases for sphere/cylinder/capsule on top of my head, but it seems to be a nice-to-have if that's not adding too much work.

Also, while we are there, we should probably not repeat (and solve) this bug when creating the AABB: #91755