Skip to content

Skip unrequested curvature channels - #1981

Merged
elalish merged 1 commit into
elalish:masterfrom
Afloat16:afloat16/curvature-requested-channels-20261116
Nov 17, 2026
Merged

elalish merged 1 commit into
elalish:masterfrom
Afloat16:afloat16/curvature-requested-channels-20261116

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Problem

CalculateCurvature accepts a negative channel index to leave that result unstored, and mean-only calls are used by the smoothing examples/tests. The implementation still allocates both curvature buffers and calculates both results for every triangle.

Changes

Allocate and accumulate only the requested curvature channels. Skip the mean-curvature dihedral calculation when the mean channel is negative, and skip the Gaussian corner-angle calculation when the Gaussian channel is negative. Keep the shared area/degree calculation and the final property-channel writes unchanged.

Add coverage for mean-only and Gaussian-only requests on smooth, faceted, and concave inputs, both overwriting existing channels and extending the property set. The test also checks preserved channels and input immutability.

Validation

  • All 36 selected native tests pass (Properties.*, Smooth.*, and the curvature error-propagation test), using GCC 14.2, Release, assertions/debug checks enabled, and MANIFOLD_PAR=OFF.
  • Twelve public-API cases cover single channels, both channels, aliased channels, neither channel, existing properties, concave/faceted meshes, and an empty input. All 11 public MeshGL64 fields match the baseline byte for byte. Including before/after input snapshots, 16 serialized payloads totaling 37,635,779 bytes match.
  • On a 65,538-vertex / 131,072-triangle sphere, a single-channel request drops from 23 allocations / 30,475,290 requested bytes to 22 allocations / 29,950,986 bytes. The omitted buffer is exactly 8 * NumVert() = 524,304 bytes.
  • Requests for both channels and neither channel have unchanged allocation counts and requested bytes.
  • Clang-format 20 and git diff --check pass.

The benchmark records allocation requests during the actual public operation. Timing samples varied across runs, so this change makes no elapsed-time improvement claim. Source, raw results, full-field hashes, and native-test logs are in the validation record.

@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.43%. Comparing base (7449380) to head (395023a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1981   +/-   ##
=======================================
  Coverage   92.42%   92.43%           
=======================================
  Files          45       45           
  Lines        9917     9922    +5     
=======================================
+ Hits         9166     9171    +5     
  Misses        751      751           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zmerlynn zmerlynn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good. Locally, with MANIFOLD_PAR=OFF, the output hashes the same as master for 7 shapes and every pair of channels from {-1, 0, 1, 3, 7}. That covers aliased channels, channels past the current numProp, and an empty input. A 131k-triangle sphere also matches. I also tried guarding the mean block on the Gaussian buffer, and CurvatureChannels catches it. A mean-only call on that sphere went from about 31 to 28 ms serial for me.

@elalish
elalish merged commit c1978de into elalish:master Nov 17, 2026
45 checks passed
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.

3 participants