Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5620f5d
Template all distance functions for scalar type
zfergus Apr 23, 2026
59969f3
Refactor smooth contact distance code to use unified distance functions
zfergus Apr 23, 2026
4761904
Ensured all arithmetic in auto-generated and hand-written code uses the
zfergus Apr 23, 2026
68e77b3
Templatize barrier functions and classes for float/double support
zfergus Apr 24, 2026
a7123fd
Merge branch 'main' into template-distances
zfergus May 1, 2026
51351b9
Replace EigenExpression concept with typename
zfergus May 4, 2026
1d89967
Fix template scalar typedef in edge-edge
zfergus May 4, 2026
758fce9
Merge branch 'main' into template-distances
zfergus Aug 29, 2026
3b28d6e
Fix float precision and explicit-scalar calls in the templated distan…
zfergus Aug 29, 2026
c18c644
Split the distance API into deducing front ends over fixed-size kernels
zfergus Aug 31, 2026
aabca00
Unify the non-floating-point distance-type guard and the autogen inst…
zfergus Aug 31, 2026
65044f3
Name every unsupported scalar family in the AUTO distance-type error
zfergus Aug 31, 2026
899b423
Extend the two-layer template design across the remaining geometry ke…
zfergus Sep 1, 2026
a75a312
Bind the distance and tangent kernels directly in Python
zfergus Sep 1, 2026
9e4ea42
Bind the remaining 3D distance kernels directly in Python
zfergus Sep 1, 2026
6fee1d1
Document the geometry-kernel conversion in the release notes
zfergus Sep 1, 2026
f4d91bd
Rename NormalizedBarrier's private scalar alias to avoid an MSVC clash
zfergus Sep 1, 2026
53978e4
Allow the _v variable-template suffix in the clang-tidy naming check
zfergus Sep 1, 2026
c006d90
Match the CI clang-format version to the pinned pre-commit hook
zfergus Sep 1, 2026
4769e4b
Key the CI build cache on the runner CPU
zfergus Sep 2, 2026
4f956fd
Merge branch 'main' into feature/template-distances
zfergus Sep 2, 2026
aeb3db0
Clean up release_notes.rst.
zfergus Sep 2, 2026
9d98b69
Move low-level normal/distance templates into ipc::detail behind SFIN…
zfergus Sep 2, 2026
17aa8e8
Fix documentation
zfergus Sep 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ BreakArrays: false
BreakBeforeBinaryOperators: NonAssignment
BreakStringLiterals: false
ColumnLimit: 80
CommentPragmas: '^@.+'
CommentPragmas: '^(@|NOTE|TODO|WARNING|FIXME).+'
FixNamespaceComments: true
# Regroup includes with a priority system
IncludeBlocks: Regroup
Expand Down
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ CheckOptions:
readability-identifier-naming.FunctionCase: lower_case
readability-identifier-naming.FunctionIgnoredRegexp: '^(AbslHashValue|.*[123][Ddf].*)$'
readability-identifier-naming.GlobalConstantCase: UPPER_CASE
# Variable templates follow the standard library's `_v` suffix convention
# (e.g. std::is_same_v), not the UPPER_CASE global-constant convention.
readability-identifier-naming.GlobalConstantIgnoredRegexp: '^(.*_v)$'
readability-identifier-naming.MemberCase: lower_case
readability-identifier-naming.MemberIgnoredRegexp: '^([A-Z])$'
readability-identifier-naming.MethodCase: lower_case
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ jobs:
- name: clang-format style check
uses: jidicula/clang-format-action@v4.17.0
with:
clang-format-version: '20'
clang-format-version: '21'
check-path: ${{ matrix.path }}
8 changes: 8 additions & 0 deletions docs/source/_static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ table.autosummary {
font-size: 0.75rem !important;
}

/* Compress the padding inside table cells for the custom class */
.tight-table th,
.tight-table td {
padding-top: 2px !important;
padding-bottom: 2px !important;
line-height: 1.2 !important;
}

/* ── Gallery Grid ── */
.gallery-grid {
display: grid;
Expand Down
206 changes: 206 additions & 0 deletions docs/source/about/release_notes.rst

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/source/cpp-api/barrier/Barrier.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Barrier
=======

.. doxygenclass:: ipc::Barrier
.. doxygenclass:: ipc::BarrierBase
:allow-dot-graphs:
6 changes: 3 additions & 3 deletions docs/source/cpp-api/barrier/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ Functions
Function Details
----------------

.. doxygenfunction:: barrier(const double, const double)
.. doxygenfunction:: barrier_first_derivative
.. doxygenfunction:: barrier_second_derivative
.. doxygenfunction:: barrier(const T d, const T dhat)
.. doxygenfunction:: barrier_first_derivative(const T d, const T dhat)
.. doxygenfunction:: barrier_second_derivative(const T d, const T dhat)

Barrier Force Magnitude
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
66 changes: 33 additions & 33 deletions docs/source/cpp-api/distance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,72 +8,72 @@ Distance Type
.. doxygenenum:: EdgeEdgeDistanceType
.. doxygenenum:: PointTriangleDistanceType

.. doxygenfunction:: point_edge_distance_type
.. doxygenfunction:: edge_edge_distance_type
.. doxygenfunction:: point_triangle_distance_type
.. doxygenfunction:: ipc::point_edge_distance_type
.. doxygenfunction:: ipc::edge_edge_distance_type
.. doxygenfunction:: ipc::point_triangle_distance_type

Edge-Edge Mollifier
-------------------

.. doxygenfunction:: edge_edge_mollifier_threshold
.. doxygenfunction:: edge_edge_cross_squarednorm
.. doxygenfunction:: ipc::edge_edge_mollifier_threshold
.. doxygenfunction:: ipc::edge_edge_cross_squarednorm
.. doxygenfunction:: ipc::edge_edge_cross_squarednorm_gradient
.. doxygenfunction:: ipc::edge_edge_cross_squarednorm_hessian
.. doxygenfunction:: edge_edge_mollifier(Eigen::ConstRef<Eigen::Vector3d> ea0, Eigen::ConstRef<Eigen::Vector3d> ea1, Eigen::ConstRef<Eigen::Vector3d> eb0, Eigen::ConstRef<Eigen::Vector3d> eb1, const double eps_x)
.. doxygenfunction:: edge_edge_mollifier(const double x, const double eps_x)
.. doxygenfunction:: edge_edge_mollifier_gradient(Eigen::ConstRef<Eigen::Vector3d> ea0, Eigen::ConstRef<Eigen::Vector3d> ea1, Eigen::ConstRef<Eigen::Vector3d> eb0, Eigen::ConstRef<Eigen::Vector3d> eb1, const double eps_x)
.. doxygenfunction:: edge_edge_mollifier_gradient(const double x, const double eps_x)
.. doxygenfunction:: edge_edge_mollifier_hessian(Eigen::ConstRef<Eigen::Vector3d> ea0, Eigen::ConstRef<Eigen::Vector3d> ea1, Eigen::ConstRef<Eigen::Vector3d> eb0, Eigen::ConstRef<Eigen::Vector3d> eb1, const double eps_x)
.. doxygenfunction:: edge_edge_mollifier_hessian(const double x, const double eps_x)
.. doxygenfunction:: ipc::edge_edge_mollifier(const Eigen::MatrixBase<DerivedEA0>& ea0, const Eigen::MatrixBase<DerivedEA1>& ea1, const Eigen::MatrixBase<DerivedEB0>& eb0, const Eigen::MatrixBase<DerivedEB1>& eb1, const typename DerivedEA0::Scalar eps_x)
.. doxygenfunction:: ipc::edge_edge_mollifier(const T x, const T eps_x)
.. doxygenfunction:: ipc::edge_edge_mollifier_gradient(const Eigen::MatrixBase<DerivedEA0>& ea0, const Eigen::MatrixBase<DerivedEA1>& ea1, const Eigen::MatrixBase<DerivedEB0>& eb0, const Eigen::MatrixBase<DerivedEB1>& eb1, const typename DerivedEA0::Scalar eps_x)
.. doxygenfunction:: ipc::edge_edge_mollifier_gradient(const T x, const T eps_x)
.. doxygenfunction:: ipc::edge_edge_mollifier_hessian(const Eigen::MatrixBase<DerivedEA0>& ea0, const Eigen::MatrixBase<DerivedEA1>& ea1, const Eigen::MatrixBase<DerivedEB0>& eb0, const Eigen::MatrixBase<DerivedEB1>& eb1, const typename DerivedEA0::Scalar eps_x)
.. doxygenfunction:: ipc::edge_edge_mollifier_hessian(const T x, const T eps_x)

Edge-Edge
---------

.. doxygenfunction:: edge_edge_distance
.. doxygenfunction:: edge_edge_distance_gradient
.. doxygenfunction:: edge_edge_distance_hessian
.. doxygenfunction:: ipc::edge_edge_distance
.. doxygenfunction:: ipc::edge_edge_distance_gradient
.. doxygenfunction:: ipc::edge_edge_distance_hessian

Line-Line
---------

.. doxygenfunction:: line_line_distance
.. doxygenfunction:: ipc::line_line_distance
.. doxygenfunction:: ipc::line_line_distance_gradient
.. doxygenfunction:: ipc::line_line_distance_hessian

Point-Edge
----------

.. doxygenfunction:: point_edge_distance
.. doxygenfunction:: point_edge_distance_gradient
.. doxygenfunction:: point_edge_distance_hessian
.. doxygenfunction:: ipc::point_edge_distance
.. doxygenfunction:: ipc::point_edge_distance_gradient
.. doxygenfunction:: ipc::point_edge_distance_hessian

Point-Line
----------

.. doxygenfunction:: point_line_distance
.. doxygenfunction:: point_line_distance_gradient
.. doxygenfunction:: point_line_distance_hessian
.. doxygenfunction:: ipc::point_line_distance
.. doxygenfunction:: ipc::point_line_distance_gradient
.. doxygenfunction:: ipc::point_line_distance_hessian

Point-Plane
-----------

.. doxygenfunction:: point_plane_distance(Eigen::ConstRef<Eigen::Vector3d> p, Eigen::ConstRef<Eigen::Vector3d> origin, Eigen::ConstRef<Eigen::Vector3d> normal)
.. doxygenfunction:: point_plane_distance(Eigen::ConstRef<Eigen::Vector3d> p, Eigen::ConstRef<Eigen::Vector3d> t0, Eigen::ConstRef<Eigen::Vector3d> t1, Eigen::ConstRef<Eigen::Vector3d> t2)
.. doxygenfunction:: point_plane_distance_gradient(Eigen::ConstRef<Eigen::Vector3d> p, Eigen::ConstRef<Eigen::Vector3d> origin, Eigen::ConstRef<Eigen::Vector3d> normal)
.. doxygenfunction:: point_plane_distance_gradient(Eigen::ConstRef<Eigen::Vector3d> p, Eigen::ConstRef<Eigen::Vector3d> t0, Eigen::ConstRef<Eigen::Vector3d> t1, Eigen::ConstRef<Eigen::Vector3d> t2)
.. doxygenfunction:: point_plane_distance_hessian(Eigen::ConstRef<Eigen::Vector3d> p, Eigen::ConstRef<Eigen::Vector3d> origin, Eigen::ConstRef<Eigen::Vector3d> normal)
.. doxygenfunction:: point_plane_distance_hessian(Eigen::ConstRef<Eigen::Vector3d> p, Eigen::ConstRef<Eigen::Vector3d> t0, Eigen::ConstRef<Eigen::Vector3d> t1, Eigen::ConstRef<Eigen::Vector3d> t2)
.. doxygenfunction:: point_plane_distance(const Eigen::MatrixBase<DerivedP>& p, const Eigen::MatrixBase<DerivedOrigin>& origin, const Eigen::MatrixBase<DerivedNormal>& normal)
.. doxygenfunction:: point_plane_distance(const Eigen::MatrixBase<DerivedP>& p, const Eigen::MatrixBase<DerivedT0>& t0, const Eigen::MatrixBase<DerivedT1>& t1, const Eigen::MatrixBase<DerivedT2>& t2)
.. doxygenfunction:: point_plane_distance_gradient(const Eigen::MatrixBase<DerivedP>& p, const Eigen::MatrixBase<DerivedOrigin>& origin, const Eigen::MatrixBase<DerivedNormal>& normal)
.. doxygenfunction:: point_plane_distance_gradient(const Eigen::MatrixBase<DerivedP>& p, const Eigen::MatrixBase<DerivedT0>& t0, const Eigen::MatrixBase<DerivedT1>& t1, const Eigen::MatrixBase<DerivedT2>& t2)
.. doxygenfunction:: point_plane_distance_hessian(const Eigen::MatrixBase<DerivedP>& p, const Eigen::MatrixBase<DerivedOrigin>& origin, const Eigen::MatrixBase<DerivedNormal>& normal)
.. doxygenfunction:: point_plane_distance_hessian(const Eigen::MatrixBase<DerivedP>& p, const Eigen::MatrixBase<DerivedT0>& t0, const Eigen::MatrixBase<DerivedT1>& t1, const Eigen::MatrixBase<DerivedT2>& t2)

Point-Point
-----------

.. doxygenfunction:: point_point_distance
.. doxygenfunction:: point_point_distance_gradient
.. doxygenfunction:: point_point_distance_hessian
.. doxygenfunction:: ipc::point_point_distance
.. doxygenfunction:: ipc::point_point_distance_gradient
.. doxygenfunction:: ipc::point_point_distance_hessian

Point-Triangle
--------------

.. doxygenfunction:: point_triangle_distance
.. doxygenfunction:: point_triangle_distance_gradient
.. doxygenfunction:: point_triangle_distance_hessian
.. doxygenfunction:: ipc::point_triangle_distance
.. doxygenfunction:: ipc::point_triangle_distance_gradient
.. doxygenfunction:: ipc::point_triangle_distance_hessian
20 changes: 11 additions & 9 deletions python/src/barrier/barrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ void define_barrier(py::module_& m)
The units of the barrier function.
)ipc_Qu8mg5v7");

py::class_<ClampedLogBarrier, Barrier, std::shared_ptr<ClampedLogBarrier>>(
py::class_<
ClampedLogBarrier<>, Barrier, std::shared_ptr<ClampedLogBarrier<>>>(
m, "ClampedLogBarrier",
R"ipc_Qu8mg5v7(
Smoothly clamped log barrier functions from [Li et al. 2020].
Expand All @@ -80,8 +81,8 @@ void define_barrier(py::module_& m)
.def(py::init());

py::class_<
NormalizedClampedLogBarrier, ClampedLogBarrier,
std::shared_ptr<NormalizedClampedLogBarrier>>(
NormalizedClampedLogBarrier<>, ClampedLogBarrier<>,
std::shared_ptr<NormalizedClampedLogBarrier<>>>(
m, "NormalizedClampedLogBarrier",
R"ipc_Qu8mg5v7(
Normalized barrier function from [Li et al. 2023].
Expand All @@ -94,7 +95,7 @@ void define_barrier(py::module_& m)
.def(py::init());

py::class_<
ClampedLogSqBarrier, Barrier, std::shared_ptr<ClampedLogSqBarrier>>(
ClampedLogSqBarrier<>, Barrier, std::shared_ptr<ClampedLogSqBarrier<>>>(
m, "ClampedLogSqBarrier",
R"ipc_Qu8mg5v7(
Clamped log barrier with a quadratic log term from [Huang et al. 2024].
Expand All @@ -106,7 +107,7 @@ void define_barrier(py::module_& m)
)ipc_Qu8mg5v7")
.def(py::init());

py::class_<CubicBarrier, Barrier, std::shared_ptr<CubicBarrier>>(
py::class_<CubicBarrier<>, Barrier, std::shared_ptr<CubicBarrier<>>>(
m, "CubicBarrier", R"ipc_Qu8mg5v7(
Cubic barrier function from [Ando 2024].

Expand All @@ -117,7 +118,7 @@ void define_barrier(py::module_& m)
)ipc_Qu8mg5v7")
.def(py::init());

py::class_<TwoStageBarrier, Barrier, std::shared_ptr<TwoStageBarrier>>(
py::class_<TwoStageBarrier<>, Barrier, std::shared_ptr<TwoStageBarrier<>>>(
m, "TwoStageBarrier",
R"ipc_Qu8mg5v7(
Two-stage activation barrier from [Chen et al. 2025].
Expand All @@ -135,7 +136,7 @@ void define_barrier(py::module_& m)
.def(py::init());

m.def(
"barrier", &barrier, "d"_a, "dhat"_a,
"barrier", &barrier<>, "d"_a, "dhat"_a,
R"ipc_Qu8mg5v7(
Function that grows to infinity as d approaches 0 from the right.

Expand All @@ -152,7 +153,8 @@ void define_barrier(py::module_& m)
)ipc_Qu8mg5v7");

m.def(
"barrier_first_derivative", &barrier_first_derivative, "d"_a, "dhat"_a,
"barrier_first_derivative", &barrier_first_derivative<>, "d"_a,
"dhat"_a,
R"ipc_Qu8mg5v7(
Derivative of the barrier function.

Expand All @@ -170,7 +172,7 @@ void define_barrier(py::module_& m)
)ipc_Qu8mg5v7");

m.def(
"barrier_second_derivative", &barrier_second_derivative, "d"_a,
"barrier_second_derivative", &barrier_second_derivative<>, "d"_a,
"dhat"_a,
R"ipc_Qu8mg5v7(
Second derivative of the barrier function.
Expand Down
14 changes: 10 additions & 4 deletions python/src/distance/distance_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ void define_distance_type(py::module_& m)
.export_values();

m.def(
"point_edge_distance_type", &point_edge_distance_type,
"point_edge_distance_type",
[](Eigen::ConstRef<VectorMax3d> p, Eigen::ConstRef<VectorMax3d> e0,
Eigen::ConstRef<VectorMax3d> e1) {
return point_edge_distance_type(p, e0, e1);
},
R"ipc_Qu8mg5v7(
Determine the closest pair between a point and edge.

Expand All @@ -101,7 +105,8 @@ void define_distance_type(py::module_& m)
"p"_a, "e0"_a, "e1"_a);

m.def(
"point_triangle_distance_type", &point_triangle_distance_type,
"point_triangle_distance_type",
&detail::point_triangle_distance_type<double>,
R"ipc_Qu8mg5v7(
Determine the closest pair between a point and triangle.

Expand All @@ -117,7 +122,7 @@ void define_distance_type(py::module_& m)
"p"_a, "t0"_a, "t1"_a, "t2"_a);

m.def(
"edge_edge_distance_type", &edge_edge_distance_type,
"edge_edge_distance_type", &detail::edge_edge_distance_type<double>,
R"ipc_Qu8mg5v7(
Determine the closest pair between two edges.

Expand All @@ -133,7 +138,8 @@ void define_distance_type(py::module_& m)
"ea0"_a, "ea1"_a, "eb0"_a, "eb1"_a);

m.def(
"edge_edge_parallel_distance_type", &edge_edge_parallel_distance_type,
"edge_edge_parallel_distance_type",
&detail::edge_edge_parallel_distance_type<double>,
R"ipc_Qu8mg5v7(
Determine the closest pair between two parallel edges.

Expand Down
8 changes: 5 additions & 3 deletions python/src/distance/edge_edge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace ipc;
void define_edge_edge_distance(py::module_& m)
{
m.def(
"edge_edge_distance", &edge_edge_distance,
"edge_edge_distance", &detail::edge_edge_distance<double>,
R"ipc_Qu8mg5v7(
Compute the distance between a two lines segments in 3D.

Expand All @@ -29,7 +29,8 @@ void define_edge_edge_distance(py::module_& m)
"dtype"_a = EdgeEdgeDistanceType::AUTO);

m.def(
"edge_edge_distance_gradient", &edge_edge_distance_gradient,
"edge_edge_distance_gradient",
&detail::edge_edge_distance_gradient<double>,
R"ipc_Qu8mg5v7(
Compute the gradient of the distance between a two lines segments.

Expand All @@ -50,7 +51,8 @@ void define_edge_edge_distance(py::module_& m)
"dtype"_a = EdgeEdgeDistanceType::AUTO);

m.def(
"edge_edge_distance_hessian", &edge_edge_distance_hessian,
"edge_edge_distance_hessian",
&detail::edge_edge_distance_hessian<double>,
R"ipc_Qu8mg5v7(
Compute the hessian of the distance between a two lines segments.

Expand Down
Loading
Loading