Skip to content

Commit d30ad32

Browse files
committed
Add can_collide to FAQ
1 parent 893dbf2 commit d30ad32

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

docs/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
numpy
2+
scipy
13
sphinx<9.0.0
24
sphinx-sitemap
35
sphinx-immaterial

docs/source/tutorials/faq.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,41 @@ How do I build the edge matrix from the face matrix?
3131

3232
To build the edge matrix you can use :cpp:`igl::edges(faces, edges);` in C++ or :python:`ipctk.edges(faces)` in Python.
3333

34+
Is there a way to ignore select collisions?
35+
-------------------------------------------
36+
37+
Yes, it is possible to ignore select collisions.
38+
39+
The functionality for doing so is through the :cpp:`BroadPhase::can_vertices_collide`.
40+
This function takes two vertex IDs and returns a true if the vertices can collide otherwise false.
41+
42+
This is used to determine if any geometry connected to the verties can collide. E.g., when checking if vertex ``vi`` can collide with triangle ``f = (vj, vk, vl)``, the code checks:
43+
44+
.. code-block::
45+
46+
can_face_vertex_collide(f, vi) := can_vertices_collide(vj, vi) && can_vertices_collide(vk, vi) && can_vertices_collide(vl, vi)
47+
48+
This is a little limited since it will ignore the one-ring around a vertex instead of a single face-vertex pair, but hopefully that can get you started.
49+
50+
To get something more customized, you can try to modify the BroadPhase class, which has these functions hard-coded:
51+
52+
.. code-block:: c++
53+
54+
virtual bool can_edge_vertex_collide(size_t ei, size_t vi) const;
55+
virtual bool can_edges_collide(size_t eai, size_t ebi) const;
56+
virtual bool can_face_vertex_collide(size_t fi, size_t vi) const;
57+
virtual bool can_edge_face_collide(size_t ei, size_t fi) const;
58+
virtual bool can_faces_collide(size_t fai, size_t fbi) const;
59+
60+
You can modify these with function pointers or override them to have the specific implementation you are interested in.
61+
62+
.. note::
63+
64+
If you are building collisions through the ``Candidates`` class, the ``Candidates::build`` function sets the ``BroadPhase::can_vertices_collide`` using the ``CollisionMesh::can_collide`` function pointer. This ``CollisionMesh::can_collide`` function uses the same interface as the ``BroadPhase::can_vertices_collide`` above.
65+
66+
.. warning::
67+
This method is not recommended for Python since calling a Python lambda function from the C++ side is too slow to use. Instead there are ``SparseCanCollide`` and ``VertexPatchesCanCollide`` classes in Python to help do this efficiently.
68+
3469
My question is not answered here. What should I do?
3570
---------------------------------------------------
3671

0 commit comments

Comments
 (0)