Skip to content

Use mesh scalar fields as optimization attributes in Studio (#2650) - #2664

Open
akenmorris wants to merge 11 commits into
masterfrom
amorris/mesh-scalar-attributes
Open

akenmorris wants to merge 11 commits into
masterfrom
amorris/mesh-scalar-attributes

Conversation

@akenmorris

@akenmorris akenmorris commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #2650

Meshes often carry per-vertex fields (thickness, curvature, parametric coordinates) that the optimizer can already match through field_attributes, but Studio had no way to select them and grooming discarded them.

  • Studio: new Mesh Scalars section in the Optimize panel, one row per field found on the meshes, with a weight for each.
  • Grooming: remesh and repair now carry point data through instead of rebuilding the surface from bare points and cells.
  • Errors: a clear message when a chosen field is missing from a groomed mesh or a domain is not a mesh.
  • Fixes:
    • crash in the field gradient on float arrays (it assumed doubles and dereferenced a null array)
    • attribute Jacobian was left in the mesh's local frame while the update is assembled in world space
    • a failed mesh reconstruction no longer aborts Studio
    • with a feature map selected, shape-only PCA no longer prints a points/scalars mismatch warning on every frame, and its particles keep their usual colors
  • Logging: reports the per-particle sampling and correspondence magnitudes during optimization, since one term can silently swamp the other.
  • Example: Examples/Studio/MeshScalars, ten near-identical ellipsoids carrying a field whose patch moves between subjects, with a tutorial page (docs/studio/studio-mesh-scalars.md). With the field in use, the same particle sits on the patch in every subject.

Tests added in MeshTests, GroomTests and OptimizeTests, including one that checks the attribute lines particles up on the field; docs updated for the Groom and Optimize panels and the optimize workflow.

Meshes often carry per-vertex fields -- thickness, curvature, parametric
coordinates -- that the optimizer can already match through field_attributes,
but there was no way to reach it from Studio, and grooming discarded the fields
first: remesh and repair both rebuild the surface from bare points and cells.
Adds a Mesh Scalars section to the Optimize panel, carries point data through
those grooming steps, and reports a clear error when a chosen field is missing
from a groomed mesh or a domain is not a mesh.

Also fixes a crash in the field gradient, which assumed double precision and
dereferenced a null array for the float fields meshes usually carry, and
corrects the attribute Jacobian, which was left in the mesh's own frame while
the update is assembled in world space.
A missing groomed mesh left the legacy point-cloud reconstruction as the only
option, and its fixed sample spacing asked for a volume too large to allocate.
The bad_alloc escaped MeshWorker's thread pool, which Qt turns into a
terminate.

The filter now refuses an impossible grid with a message naming the spacing and
the bounding box, and mesh generation catches its own exceptions so no failure
there can take the application down.
The two terms are combined without normalization, so one can be scaled out of
the calculation with no sign of it beyond a poor model. Logs the per-particle
magnitude of each, the attribute share of the correspondence update, and the
sampling scale factor.
The function is cloned for every shape on every iteration and each clone
counted from zero, so each one logged on its first call: ten lines an
iteration, enough to stall Studio's log. Share the count between clones.
Ten near-identical ellipsoids carrying a field whose patch moves between
subjects, with a tutorial page. Using the field puts the same particle on the
patch in every subject.
With a feature map selected and PCA in shape-only mode there are no computed
scalars, so every animation frame printed a points/scalars mismatch warning.
The first splits of an optimization have one or two particles, which Studio
tried to reconstruct for display and reported as a failure.
A shape-only PCA mode has no values for the feature map, so particle indices
were pushed through the feature's color scale: one blue, the rest red.
Repair copies fields point by point, so an array without a value for every
point was read past its end: garbage on macOS, an access violation on Windows.

This branch has not been deployed

No deployments
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.

Studio: Use mesh scalar fields as optimization attributes

1 participant