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

Optimize polygon rasterization #522

Merged
merged 1 commit into from
Sep 8, 2024
Merged

Conversation

JD557
Copy link
Owner

@JD557 JD557 commented Sep 8, 2024

Adds some optimizations to the polygon rasterization.

  • Marks some stuff as lazy val (e.g. using the known face, one can do some preculling before computing the aabb, and vice versa), - Avoids the use of distinct (which allocates a HashSet)
  • Short-circuits faceAt and contains
  • Picks a better point for the knownFace test (the center sometimes was outside of the polygon... I ntoiced the same issue with the centroid, which is probably due to integer math)
  • Adds an AABB builder, to avoid iterating over the points multiple times.

This optimizations led to a ~2x performance improvement when rendering the Stanford bunny. After this, I mostly just see Iterator.next() on the hot spot list.

@JD557 JD557 added this to the 0.6.2 milestone Sep 8, 2024
@JD557 JD557 self-assigned this Sep 8, 2024
@JD557 JD557 merged commit 5992517 into master Sep 8, 2024
15 checks passed
@JD557 JD557 deleted the optimize-polygon-rasterization branch September 8, 2024 09:02
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.

1 participant