Skip to content

Add float32 overload for signed_distance - #321

Open
alecjacobson wants to merge 4 commits into
mainfrom
feat/signed-distance-float
Open

alecjacobson wants to merge 4 commits into
mainfrom
feat/signed-distance-float

Conversation

@alecjacobson

@alecjacobson alecjacobson commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

igl.signed_distance currently converts float32 geometry and query points to double. Add a float instantiation so matching float32 arrays compute through libigl's float query path and return float32 distances, closest points, and normals. Face indices remain int64.

The float overload requires matching input dtypes and is registered first so it also wins when face indices need conversion (for example int32 → int64). Float64 and mixed float32/float64 inputs retain the default double conversion. Strided and read-only arrays remain supported; no new keyword argument is required.

Pin libigl to e810369e42090e66fc805370f9969771e93b431f from libigl/libigl#2586, which should land first. That standalone core PR includes the scalar-precision work from superseded #2583 and carries the nearest feature into 3D pseudonormal selection, eliminating feature-selection tolerances from the 3D signed-distance path. Final normal normalization is unchanged. Tracks alecjacobson/pseudonormal-tests#1.

Validation

  • All 26 precision tests pass using the cached extension compiled from this PR's actual signed-distance binding against the feature-selection core. The rebase onto current core main leaves every affected query source unchanged. Tests cover dtypes, C/F/strided/read-only arrays, int32/int64 indices, mixed-dtype conversion, existing sign methods, 2D, bounds, and a result distinguishing float arithmetic from double evaluation followed by a cast.
  • The closest-feature validation covers 4,963 models / 49.63 million cached points per precision, using original scales, saved double winding signs, and d > 0.001 * bbd. It gives 150 float and 62 double disagreements, compared with 1,061 and 441 for the prior tuned core. Float has 90 invalid-normal queries, down from 369. Four new float disagreements occur on an exactly collapsed triangle with equally nearest features and opposing normal signs.
  • Complete old/new signed-distance pipelines on 117 models / 1.17M points per precision match the cached replay, including distances, closest points, indices, signs, and normal bytes. The original 100 models give one float disagreement with an invalid normal and zero double disagreements.
  • The earlier complete core-extension build generated both type-stub overloads and passed the existing normals/distances smoke test. That build predates closest-feature selection; optional modules were not rebuilt for this pin update.
  • GCC 13.3.0, Eigen 3.4.0, nanobind 2.7.0, Python 3.12.3.

Full report, limitations, and provenance.

Prepared by OpenAI Codex at the repository owner's request.

Register a non-converting float overload before the existing default conversion. Preserve double inputs, mixed-dtype conversion, strided/read-only arrays, and integer face conversions. Pin libigl with scalar-generic pseudonormal arithmetic.

Cover output precision, true float arithmetic, all sign methods, feature queries, 2D and bounds. Refs alecjacobson/pseudonormal-tests#1. Prepared with OpenAI Codex.

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.

1 participant