Skip to content

Collision filter#235

Merged
zfergus merged 6 commits into
mainfrom
collision-filter
May 12, 2026
Merged

Collision filter#235
zfergus merged 6 commits into
mainfrom
collision-filter

Conversation

@zfergus
Copy link
Copy Markdown
Member

@zfergus zfergus commented May 12, 2026

Description

Make collision filters composable and easier to use. Add several factory functions for common filter types, and update the documentation to reflect these improvements.

  • Introduced a new CollisionFilter class in both C++ and Python, which wraps any bool(int, int) callable and supports logical composition via |, &, and ~ operators.
  • Added factory functions: make_sparse_filter, make_vertex_patches_filter, make_static_obstacle_filter, and make_connected_components_filter for common collision filtering scenarios.
  • Rewrote the FAQ documentation to explain the new composable collision filter system, including usage examples and descriptions of the new factory functions in both C++ and Python.

Type of change

  • Enhancement (non-breaking change which improves existing functionality)

zfergus added 3 commits May 11, 2026 15:51
- Introduce ipc::CollisionFilter (type-erased, composable predicate)
  with |, &, !, |=, &= and callable construction
- Add inline factories: make_vertex_patches_filter and
  make_static_obstacle_filter; declare make_connected_components_filter
- Implement make_connected_components_filter using libigl
- Wire CollisionFilter into broad_phase, CollisionMesh bindings, and
  CMake lists
- Add Catch2 unit tests and Python tests validating filter APIs
Copilot AI review requested due to automatic review settings May 12, 2026 13:49
@zfergus zfergus added the enhancement New feature or request label May 12, 2026
@zfergus zfergus added this to the v1.6.0 milestone May 12, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a composable CollisionFilter abstraction (C++ + Python) to unify and simplify collision-pair filtering, adds several factory helpers for common scenarios, and updates tests/docs to reflect the new workflow.

Changes:

  • Added a new C++ ipc::CollisionFilter type with logical composition operators and factory helpers (make_vertex_patches_filter, make_static_obstacle_filter, make_connected_components_filter).
  • Updated CollisionMesh::can_collide and BroadPhase::can_vertices_collide to use CollisionFilter instead of std::function.
  • Added/updated C++ + Python tests and refreshed FAQ documentation with examples and new factory functions.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
tests/src/tests/test_collision_filter.cpp New C++ unit tests covering CollisionFilter behavior and factory helpers.
tests/src/tests/CMakeLists.txt Registers the new C++ collision-filter test file.
src/ipc/collision_mesh.hpp Switches CollisionMesh::can_collide to CollisionFilter.
src/ipc/collision_filter.hpp Adds the CollisionFilter type and inline factory helpers.
src/ipc/collision_filter.cpp Implements make_connected_components_filter via libigl connected components.
src/ipc/CMakeLists.txt Adds collision filter sources to the IPC library build.
src/ipc/broad_phase/broad_phase.hpp Switches BroadPhase::can_vertices_collide to CollisionFilter.
python/tests/test_collision_mesh.py Updates Python tests to use new factory helpers instead of deprecated functor classes.
python/tests/test_collision_filter.py Adds Python unit tests for CollisionFilter composition + factories.
python/src/collision_mesh.cpp Exposes CollisionFilter + factory functions to Python; updates can_collide property behavior.
docs/source/tutorials/faq.rst Rewrites FAQ collision-filtering section to describe the new composable system.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ipc/collision_filter.hpp
Comment thread src/ipc/collision_filter.hpp
Comment thread src/ipc/collision_filter.hpp Outdated
Comment thread src/ipc/collision_filter.hpp Outdated
Comment thread src/ipc/collision_filter.hpp Outdated
Comment thread tests/src/tests/test_collision_filter.cpp
Comment thread python/src/collision_mesh.cpp Outdated
Comment thread python/src/collision_mesh.cpp
Comment thread docs/source/tutorials/faq.rst Outdated
Comment thread src/ipc/broad_phase/broad_phase.hpp
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 92.85714% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.75%. Comparing base (c8a134f) to head (bd8b563).

Files with missing lines Patch % Lines
src/ipc/collision_filter.hpp 88.88% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #235      +/-   ##
==========================================
+ Coverage   95.74%   95.75%   +0.01%     
==========================================
  Files         161      163       +2     
  Lines       16633    16650      +17     
  Branches      920      920              
==========================================
+ Hits        15925    15944      +19     
+ Misses        708      706       -2     
Flag Coverage Δ
unittests 95.75% <92.85%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

zfergus and others added 3 commits May 12, 2026 10:53
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- Add make_codim_cross_filter(nCV) to allow only mixed codim pairs
- Change CollisionFilter callables to use size_t indices
- Add implicit conversion to std::function<bool(size_t,size_t)>
- Compose filter with mesh.can_collide in Candidates to skip
  c-vertex/c-vertex and c-edge/c-edge pairs
- Add missing include and adjust lambdas accordingly
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@zfergus zfergus merged commit 46647df into main May 12, 2026
21 checks passed
@zfergus zfergus deleted the collision-filter branch May 12, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants