GetInstancesOverlappingSphere reports instances that have been removed

Digging some more, GetInstancesOverlappingSphere doesn’t trace against phyics bodies at all (which makes sense since I believe physics can be disabled on HISMCs and their instances). It actually uses some geometry algorithms to literally compute if spheres are overlapping one another (see attached images). Pretty nifty actually.

I would say that these algorithms almost certainly do not run asynchronously.

However, I may have noticed something. If you look in in GetInstancesOverlappingSphere, the first branch check to see if something called the ClusterTreePtr is valid. I think the ClusterTree contains some cached data about the locations of the instances in the HISMC, and that data is used to calculate the sphere overlaps.

Looking in RemoveInstances(), there is this if block:

	if (bAutoRebuildTreeOnInstanceChanges)
	{
		BuildTreeIfOutdated(true, false);
	}

So this ClusterTree is optionally rebuilt each time an instance is removed.

Perhaps try setting bAutoRebuildTreeOnInstanceChanges to ‘true’, and see if the problem still persists. That should force a rebuild of the ClusterTree each time you call RemoveInstances, which will hopefully make the sphere overlap calculations more accurate!