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

simplify: Split quadrics update into a separate function #788

Merged
merged 3 commits into from
Oct 11, 2024
Merged

Conversation

zeux
Copy link
Owner

@zeux zeux commented Oct 10, 2024

Instead of updating quadrics as we are collapsing edges, we can update
them in batch after all collapses are done. This makes the code cleaner
since we do not need to replicate the collapse structure explicitly for
both remap and quadric update, and also makes it ~5-7% faster on large
meshes - presumably due to better data locality during the update.

The only subtle part here is vertex_quadrics update: we need to do this
just once, and we know the primary vertex will have to move if any
wedge moved, so we do that during the corresponding collapse. The
target vertex may not have had any collapses to the primary vertex in
case some vertex gets collapsed into a locked vertex.

This change results in exactly identical output; in the future, this
would result in a more careful handling of Complex collapses as our note
about the attribute quadrics not requiring a merge was incorrect - even
though the attributes might be similar, merging quadrics is still
valuable to get area accumulation.

This contribution is sponsored by Valve.

Instead of updating quadrics as we are collapsing edges, we can update
them in batch after all collapses are done. This makes the code cleaner
since we do not need to replicate the collapse structure explicitly for
both remap and quadric update, and also makes it ~5% faster on many
large meshes - presumably due to better data locality during the update.

The only subtle part here is vertex_quadrics update: we need to do this
just once, and we *know* the primary vertex will have to move if any
wedge moved, so we do that during the corresponding collapse. The
target vertex may not have had any collapses to the primary vertex in
case some vertex gets collapsed into a locked vertex.

This change results in exactly identical results; in the future, this
would result in a more careful handling of Complex collapses as our note
about the attribute quadrics not requiring a merge was incorrect - even
though the attributes might be similar, merging quadrics is still
valuable to get area accumulation.
This way performEdgeCollapses no longer needs access to quadrics data,
and when attributes are used and we need to compute distance error, the
access to vertex quadrics is maximally local as we use them right after
aggregation, which saves 1-2% on large meshes.

For now we keep the optimization of not recomputing the distance error
unless attributes are used; it makes the data flow slightly awkward and
seems to have <1% performance impact but we can remove it later if it
becomes more problematic.
The only reason why seam pair was computed separately was to reuse that
computation between collapse and quadric updates as it is fragile; now
that we have split quadric updates completely, sx is only used for
collapse update and it's thus better and cheaper to process inline.
@zeux zeux merged commit 5a9b07b into master Oct 11, 2024
12 checks passed
@zeux zeux deleted the simp-qup branch October 11, 2024 15:05
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