'Get Instances Overlapping Box/Sphere' not working as expected in UE 5.0

Ok I fixed it for my specific case. I observed the following…

UE5.0 introduced a variable on InstancedFoliage.cpp called bUseTranslatedInstanceSpace - From what I loosely understand, this aims to solve foliage precision in large worlds due to the use of floating points. The logic takes the first instance position and uses that as an origin space for all other foliage to calculate from.

The problem I believe is that this value is used when building the foliage tree, but not taken into consideration in both the GetOverlappingSphereCount or GetOverlappingBoxCount functions.

As for why I was experiencing this only after the first case, I think my foliage still had data stored from UE4.27, then when I removed instances it rebuilt the tree, causing the bug to be introduced. I also noticed that if I painted in the editor, the bug would occur on the first instance too.

So to fix this, as my worlds aren’t very latge - I put bUseTranslatedInstanceSpace to false instead which means the positions would always be based on 0, 0, 0 space. What I then had to do was make small edits to my foliage so the data was regenerated to whatever the UE5 required. I suspect that this might also be fixed if I rework the logic in the overlap functions to use this new variable.

2 Likes