-
Notifications
You must be signed in to change notification settings - Fork 11
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
Destroy out of range scene entities #2808
base: dev
Are you sure you want to change the base?
Conversation
for (var i = 0; i < definition.ParcelsCorners.Count; i++) | ||
corners[i] = definition.ParcelsCorners[i]; | ||
World.InlineQuery<PartitionScenes, SceneDefinitionComponent, PartitionComponent>( | ||
in existingScenesQuery, ref partitionScenes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this takes 0.12 ms to run on my laptop. If I change it to InlineParallelQuery, it takes 1 ms to run. Crazy.
Bounds sceneBounds = new (); | ||
sceneBounds.SetMinMax(min, max); | ||
|
||
float sqrDistance = sceneBounds.SqrDistance(CameraPosition); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Behaviour change: measure the distance to the surface of the bounding box instead the distance to the nearest corner. This is more correct, but might break some other code due to accidental reliance on the quirks of the previous implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Behaviour change: this implementation takes maximum scene height into account. So, if you fly high above the city, it will get unloaded. Or if you look up at the sky, a tall scene next to you will now not count as behind you. Again, this is more "3D correct", but might not be what we want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Behaviour change: use the bounds of the scene instead of the individual parcels to do the math. This is faster, but if the scene is oddly shaped, less accurate.
What does this PR change?
This change reduces memory and CPU usage of PartitionSceneEntitiesSystem and ResolveVisualSceneStateSystem.
fix: #2694
How to test the changes?
Our Code Review Standards
https://github.com/decentraland/unity-renderer/blob/master/docs/code-review-standards.md