Godot Version
4.3 stable mono
Question
I have a Sprite3D on which I set a custom AABB, but for some reason, GetAabb() still returns ((0, 0, 0), (0, 0, 0)). Is that intended behavior?
I can access the custom AABB by accessing the CustomAabb field from GeometryInstance3D but ideally I’d like to pass around VisualInstance3D nodes to things that expect Aabbs and not have to special-case GeometryInstance3D.
Here’s a code snippet
GD.Print(GetAabb());
GD.Print(CustomAabb);
And here’s the output
(0, 0, 0), (0, 0, 0)
(-3, -1.5, 0), (6, 3, 0)
It’s odd that I have to resort to things like this :
public static Aabb ComputeBoundingBox(Node node)
{
var aabb = new Aabb();
if (node is GeometryInstance3D g && g.CustomAabb != new Aabb())
{
aabb = aabb.Merge(g.Transform * g.CustomAabb);
}
else if (node is VisualInstance3D v)
{
aabb = aabb.Merge(v.Transform * v.GetAabb());
}
foreach (var child in node.GetChildren())
{
aabb = aabb.Merge(ComputeBoundingBox(child));
}
return aabb;
}