Skip to content
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

Revert: Sprite sorting optimisation sorted incorrectly. #6970

Merged
merged 1 commit into from Nov 18, 2018

Conversation

frosch123
Copy link
Member

This reverts commit 25ab9c1.

The optimisation consists of pre-sorting the bounding boxes in X direction.
During the actual sorting it then short-circuits loops with the assumption

/* all following sprites have xmin >= ps2->xmin */

However, the pre-sorting only applies as long as no sprites are moved.
"psd" is a vector iterator, thus the

/* Move ps2 in front of ps */

also affects elements including and after "psd".

This seems to be the core of this patch, so I do not see any other option, but revert.

frosch123 referenced this pull request Nov 15, 2018
When zooming out with a high res display, there can be about 150k sprites
to be sorted before displaying. With the O(n^2) complexity of the sprite
sorter, this can take several seconds.

This patch works around this by sorting the sprites by the xmin coordinate
first using QSort, which later allows an early bailout out of the inner
loop. This is enough to cut down the full unzoom time on a 4k display to a
fraction of second.
@nielsmh nielsmh merged commit 1a12044 into OpenTTD:master Nov 18, 2018
@frosch123 frosch123 deleted the revert6911 branch March 3, 2019 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants