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

MeshInstance3D AABB doesn't return merged AABB dimensions, nor is it affected by any transformations #94758

Closed
yosimba2000 opened this issue Jul 25, 2024 · 4 comments

Comments

@yosimba2000
Copy link

yosimba2000 commented Jul 25, 2024

Tested versions

Godot 4.2 .Net, Godot 4.3 RC1 .Net

System information

Win10 x64 22H2

Issue description

Merging multiple MeshInstance3D's AABBs does not return the dimensions of the combined AABB.
Also, AABB does NOT seem to be affected by any transformations.

Steps to reproduce

  1. Place a standard MeshInstance3D Cube in the hierarchy. Leave cube size as default (1 x 1 x 1).

  2. Place another standard MeshInstance3D Cube in the hierarchy. Leave cube size as default (1 x 1 x 1).

  3. Move the second cube along the Global X-axis by 5 units. It can be any axis and any amount, but this is for testing.

  4. Realize that the AABB which encloses both cubes SHOULD have an X-axis length of AT LEAST 5 units. Exact value should be 6 units.

  5. Perform AABB mergedAABB = Cube1.GetAABB().Merge( Cube2.GetAABB() )

  6. Perform GD.Print( mergedAABB .GetLongestAxisSize() )

  7. See that the output is always 1. You can output AABB origin and dimensions as well with GD.Print( mergedAABB ). Observe that the values don't make sense.

  8. Transform any cube by scaling/rotating it, then return its AABB. Observe that the AABB does not take into account any transformations.

Minimal reproduction project (MRP)

aabb-issue.zip

@clayjohn
Copy link
Member

The AABB returned by MeshInstance3D::get_aabb returns the AABB of the mesh resource which doesn't have information about the transform of the Mesh. In other words, the AABB is in the local space of the mesh and needs to be transformed by the MeshIntance3D's transform.

This fact should be documented in VisualInstance:get_aabb (after checking that the same is true for all other classes that inherit that method)

@yosimba2000
Copy link
Author

Maybe I'm confused, but if the AABB is defined in mesh local-space, then it sounds like it's actually OOBB?

https://en.wikipedia.org/wiki/Bounding_volume#Common_types
https://www.youtube.com/watch?v=HYO5Pthe3TE

@clayjohn
Copy link
Member

Maybe I'm confused, but if the AABB is defined in mesh local-space, then it sounds like it's actually OOBB?

https://en.wikipedia.org/wiki/Bounding_volume#Common_types https://www.youtube.com/watch?v=HYO5Pthe3TE

You could call it that. It depends on your frame of reference.

@yosimba2000
Copy link
Author

yosimba2000 commented Jul 26, 2024

Ok thanks, I have opened a Godot suggestion!
godotengine/godot-proposals#10282

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

No branches or pull requests

3 participants