How to efficiently cull foliage inside volume at runtime

Hey guys

I have a need to remove/cull foliage efficiently inside of a specific volume. I’m making a survival bush-craft game and need to have all the grass and other foliage disappear once I have completed construction of a structure such as a shelter or fire etc to clear the area underneath the structure so the grass etc doesnt poke through and look terrible. Its a very simple idea and i have it working currently but the problem i have is that there is too much of a lag in doing so even on my small test map.

The way I have it working atm is that all structures have a sphere or box collision around them and once the structure is complete I go through all the foliage instances of the foliage actor and check if the location of the instance is inside the bounds of the collision and if they are they are removed. My map is a large open world forest with a ridiculous amount of foliage in it so this system doesn’t work as going through all the foliage instances would basically stall the game.

I was wondering if anyone had any ideas on how to better access the foliage in the immediate vicinity of the player so i dont have to search through every instance on the map. The built in culling for foliage is super efficient so I am wondering if there’s a way to access only the foliage that isn’t culled at that time or something of the like?

if anyone else is in need of a solution I have figured one out. I have decided to use multi sphere traces to get the foliage instances and index’s to remove. I have set all my foliage collision up to be query only and ignore all object types. This makes it so there is no performance hit with the foliage looking for overlap evets etc, but it means that I can still access each individual foliage instance with traces. In my example to remove the foliage in a certain area/volume I have a few different multi sphere traces that cover the area that I want to remove foliage from. I have them start in a position a few meters above the ground and end a few meters bellow their start point to ensure I capture all my foliage in the sweep. Then with the array of hits I I get back from the traces I cast to “instancedfoliagestaticmeshcomponent” and can then “removefoliageinstances” from there with the break result of the hit and using “hitcomponent” as the target and “hit target” as the index. I also add the IFSMC and its transform to a couple of arrays so that I can spawn the foliage back in when I want to. There can be a bit of a stutter if there is a lot of foliage hit due to the “CAST” I believe but I am looking at using a plugin that handles traces asynchronously to combat that. Hope this helps someone else out there.