Broad Phase¶
- enum class ipc::BroadPhaseMethod¶
Enumeration of implemented broad phase methods.
Values:
- enumerator BRUTE_FORCE¶
- enumerator HASH_GRID¶
- enumerator SPATIAL_HASH¶
- enumerator BVH¶
- enumerator SWEEP_AND_PRUNE¶
- enumerator SWEEP_AND_TINIEST_QUEUE¶
- enumerator NUM_METHODS¶
-
static constexpr BroadPhaseMethod ipc::DEFAULT_BROAD_PHASE_METHOD
= BroadPhaseMethod::HASH_GRID¶
Broad Phase¶
- class BroadPhase¶
Inheritence diagram for ipc::BroadPhase:
Subclassed by ipc::BVH, ipc::BruteForce, ipc::HashGrid, ipc::SpatialHash, ipc::SweepAndPrune
Public Functions
- inline virtual ~BroadPhase()¶
-
virtual void build(const Eigen::MatrixXd& vertices,
const Eigen::MatrixXi& edges, const Eigen::MatrixXi& faces,
const double inflation_radius = 0)¶ Build the broad phase for static collision detection.
-
virtual void build(const Eigen::MatrixXd& vertices_t0,
const Eigen::MatrixXd& vertices_t1,
const Eigen::MatrixXi& edges, const Eigen::MatrixXi& faces,
const double inflation_radius = 0)¶ Build the broad phase for continuous collision detection.
- Parameters:¶
- const Eigen::MatrixXd &vertices_t0¶
Starting vertices of the vertices.
- const Eigen::MatrixXd &vertices_t1¶
Ending vertices of the vertices.
- const Eigen::MatrixXi &edges¶
Collision mesh edges
- const Eigen::MatrixXi &faces¶
Collision mesh faces
- const double inflation_radius = 0¶
Radius of inflation around all elements.
- virtual void clear()¶
Clear any built data.
-
virtual void detect_vertex_vertex_candidates(
std::vector<VertexVertexCandidate>& candidates) const = 0¶ Find the candidate vertex-vertex collisions.
- Parameters:¶
- std::vector<VertexVertexCandidate> &candidates¶
[out] The candidate vertex-vertex collisions.
-
virtual void detect_edge_vertex_candidates(
std::vector<EdgeVertexCandidate>& candidates) const = 0¶ Find the candidate edge-vertex collisions.
- Parameters:¶
- std::vector<EdgeVertexCandidate> &candidates¶
[out] The candidate edge-vertex collisions.
-
virtual void detect_edge_edge_candidates(
std::vector<EdgeEdgeCandidate>& candidates) const = 0¶ Find the candidate edge-edge collisions.
- Parameters:¶
- std::vector<EdgeEdgeCandidate> &candidates¶
[out] The candidate edge-edge collisions.
-
virtual void detect_face_vertex_candidates(
std::vector<FaceVertexCandidate>& candidates) const = 0¶ Find the candidate face-vertex collisions.
- Parameters:¶
- std::vector<FaceVertexCandidate> &candidates¶
[out] The candidate face-vertex collisions.
-
virtual void detect_edge_face_candidates(
std::vector<EdgeFaceCandidate>& candidates) const = 0¶ Find the candidate edge-face intersections.
- Parameters:¶
- std::vector<EdgeFaceCandidate> &candidates¶
[out] The candidate edge-face intersections.
-
virtual void detect_face_face_candidates(
std::vector<FaceFaceCandidate>& candidates) const = 0¶ Find the candidate face-face collisions.
-
virtual void detect_collision_candidates(
int dim, Candidates& candidates) const¶ Detect all collision candidates needed for a given dimensional simulation.
- Parameters:¶
- int dim¶
The dimension of the simulation (i.e., 2 or 3).
- Candidates &candidates¶
The detected collision candidates.
Public Members
-
std::function<bool(size_t, size_t)> can_vertices_collide
= default_can_vertices_collide¶ Function for determining if two vertices can collide.
Public Static Functions
-
static std::shared_ptr<BroadPhase> make_broad_phase(
const BroadPhaseMethod method)¶ Construct a registered broad phase object.
- Parameters:¶
- const BroadPhaseMethod method¶
The broad phase method to use.
- Returns:¶
The constructed broad phase object.
Protected Functions
Protected Attributes
Protected Static Functions
- static inline bool default_can_vertices_collide(size_t, size_t)¶
Brute Force¶
- class BruteForce : public ipc::BroadPhase¶
Inheritence diagram for ipc::BruteForce:
Collaboration diagram for ipc::BruteForce:
Public Functions
- BruteForce() = default¶
-
virtual void detect_vertex_vertex_candidates(
std::vector<VertexVertexCandidate>& candidates) const override¶ Find the candidate vertex-vertex collisions.
- Parameters:¶
- std::vector<VertexVertexCandidate> &candidates¶
[out] The candidate vertex-vertex collisions.
-
virtual void detect_edge_vertex_candidates(
std::vector<EdgeVertexCandidate>& candidates) const override¶ Find the candidate edge-vertex collisions.
- Parameters:¶
- std::vector<EdgeVertexCandidate> &candidates¶
[out] The candidate edge-vertex collisions.
-
virtual void detect_edge_edge_candidates(
std::vector<EdgeEdgeCandidate>& candidates) const override¶ Find the candidate edge-edge collisions.
- Parameters:¶
- std::vector<EdgeEdgeCandidate> &candidates¶
[out] The candidate edge-edge collisions.
-
virtual void detect_face_vertex_candidates(
std::vector<FaceVertexCandidate>& candidates) const override¶ Find the candidate face-vertex collisions.
- Parameters:¶
- std::vector<FaceVertexCandidate> &candidates¶
[out] The candidate face-vertex collisions.
-
virtual void detect_edge_face_candidates(
std::vector<EdgeFaceCandidate>& candidates) const override¶ Find the candidate edge-face intersections.
- Parameters:¶
- std::vector<EdgeFaceCandidate> &candidates¶
[out] The candidate edge-face intersections.
-
virtual void detect_face_face_candidates(
std::vector<FaceFaceCandidate>& candidates) const override¶ Find the candidate face-face collisions.
Private Functions
-
template <typename Candidate, bool triangular = false>
void detect_candidates(const std::vector<AABB>& boxes0,
const std::vector<AABB>& boxes1,
const std::function<bool(size_t, size_t)>& can_collide,
std::vector<Candidate>& candidates) const¶ Detect candidates for collisions between two sets of boxes.
- Template Parameters:¶
- Parameters:¶
- const std::vector<AABB> &boxes0¶
[in] First set of boxes.
- const std::vector<AABB> &boxes1¶
[in] Second set of boxes.
- const std::function<bool(size_t, size_t)> &can_collide¶
[in] Function to determine if two primitives can collide given their ids.
- std::vector<Candidate> &candidates¶
[out] The candidate collisions.
Hash Grid¶
- class HashGrid : public ipc::BroadPhase¶
Inheritence diagram for ipc::HashGrid:
Collaboration diagram for ipc::HashGrid:
Public Functions
- HashGrid() = default¶
-
virtual void build(const Eigen::MatrixXd& vertices,
const Eigen::MatrixXi& edges, const Eigen::MatrixXi& faces,
double inflation_radius = 0) override¶ Build the broad phase for static collision detection.
-
virtual void build(const Eigen::MatrixXd& vertices_t0,
const Eigen::MatrixXd& vertices_t1,
const Eigen::MatrixXi& edges, const Eigen::MatrixXi& faces,
double inflation_radius = 0) override¶ Build the broad phase for continuous collision detection.
- Parameters:¶
- const Eigen::MatrixXd &vertices_t0¶
Starting vertices of the vertices.
- const Eigen::MatrixXd &vertices_t1¶
Ending vertices of the vertices.
- const Eigen::MatrixXi &edges¶
Collision mesh edges
- const Eigen::MatrixXi &faces¶
Collision mesh faces
- double inflation_radius = 0¶
Radius of inflation around all elements.
- inline virtual void clear() override¶
Clear the hash grid.
-
virtual void detect_vertex_vertex_candidates(
std::vector<VertexVertexCandidate>& candidates) const override¶ Find the candidate vertex-vertex collisions.
-
virtual void detect_edge_vertex_candidates(
std::vector<EdgeVertexCandidate>& candidates) const override¶ Find the candidate edge-vertex collisions.
- Parameters:¶
- std::vector<EdgeVertexCandidate> &candidates¶
[out] The candidate edge-vertex collisions.
-
virtual void detect_edge_edge_candidates(
std::vector<EdgeEdgeCandidate>& candidates) const override¶ Find the candidate edge-edge collisions.
- Parameters:¶
- std::vector<EdgeEdgeCandidate> &candidates¶
[out] The candidate edge-edge collisions.
-
virtual void detect_face_vertex_candidates(
std::vector<FaceVertexCandidate>& candidates) const override¶ Find the candidate face-vertex collisions.
- Parameters:¶
- std::vector<FaceVertexCandidate> &candidates¶
[out] The candidate face-vertex collisions.
-
virtual void detect_edge_face_candidates(
std::vector<EdgeFaceCandidate>& candidates) const override¶ Find the candidate edge-face intersections.
- Parameters:¶
- std::vector<EdgeFaceCandidate> &candidates¶
[out] The candidate edge-face intersections.
-
virtual void detect_face_face_candidates(
std::vector<FaceFaceCandidate>& candidates) const override¶ Find the candidate face-face collisions.
- inline double cell_size() const¶
- inline const ArrayMax3i& grid_size() const¶
- inline const ArrayMax3d& domain_min() const¶
- inline const ArrayMax3d& domain_max() const¶
Protected Functions
-
void resize(const ArrayMax3d& domain_min,
const ArrayMax3d& domain_max, double cell_size)¶
- void insert_boxes()¶
Protected Attributes
- double m_cell_size¶
- ArrayMax3i m_grid_size¶
- ArrayMax3d m_domain_min¶
- ArrayMax3d m_domain_max¶
- std::vector<HashItem> vertex_items¶
- std::vector<HashItem> edge_items¶
- std::vector<HashItem> face_items¶
Private Functions
-
template <typename Candidate>
void detect_candidates(const std::vector<HashItem>& items0,
const std::vector<HashItem>& items1,
const std::vector<AABB>& boxes0,
const std::vector<AABB>& boxes1,
const std::function<bool(size_t, size_t)>& can_collide,
std::vector<Candidate>& candidates) const¶ Find the candidate collisions between two sets of items.
- Template Parameters:¶
- typename Candidate¶
The type of collision candidate.
- Parameters:¶
- const std::vector<HashItem> &items0¶
[in] First set of items.
- const std::vector<HashItem> &items1¶
[in] Second set of items.
- const std::vector<AABB> &boxes0¶
[in] First set’s boxes.
- const std::vector<AABB> &boxes1¶
[in] Second set’s boxes.
- const std::function<bool(size_t, size_t)> &can_collide¶
[in] Function to determine if two items can collide.
- std::vector<Candidate> &candidates¶
[out] The candidate collisions.
-
template <typename Candidate>
void detect_candidates(const std::vector<HashItem>& items,
const std::vector<AABB>& boxes,
const std::function<bool(size_t, size_t)>& can_collide,
std::vector<Candidate>& candidates) const¶ Find the candidate collisions among a set of items.
Spatial Hash¶
- class SpatialHash : public ipc::BroadPhase¶
Inheritence diagram for ipc::SpatialHash:
Collaboration diagram for ipc::SpatialHash:
Public Functions
- SpatialHash() = default¶
-
inline SpatialHash(const Eigen::MatrixXd& vertices,
const Eigen::MatrixXi& edges, const Eigen::MatrixXi& faces,
double inflation_radius = 0, double voxel_size = -1)¶
-
inline SpatialHash(const Eigen::MatrixXd& vertices_t0,
const Eigen::MatrixXd& vertices_t1,
const Eigen::MatrixXi& edges, const Eigen::MatrixXi& faces,
double inflation_radius = 0, double voxel_size = -1)¶
-
inline virtual void build(const Eigen::MatrixXd& vertices,
const Eigen::MatrixXi& edges, const Eigen::MatrixXi& faces,
double inflation_radius = 0) override¶ Build the broad phase for static collision detection.
-
inline virtual void build(const Eigen::MatrixXd& vertices_t0,
const Eigen::MatrixXd& vertices_t1,
const Eigen::MatrixXi& edges, const Eigen::MatrixXi& faces,
double inflation_radius = 0) override¶ Build the broad phase for continuous collision detection.
- Parameters:¶
- const Eigen::MatrixXd &vertices_t0¶
Starting vertices of the vertices.
- const Eigen::MatrixXd &vertices_t1¶
Ending vertices of the vertices.
- const Eigen::MatrixXi &edges¶
Collision mesh edges
- const Eigen::MatrixXi &faces¶
Collision mesh faces
- double inflation_radius = 0¶
Radius of inflation around all elements.
-
void build(const Eigen::MatrixXd& vertices,
const Eigen::MatrixXi& edges, const Eigen::MatrixXi& faces,
double inflation_radius, double voxel_size)¶
-
void build(const Eigen::MatrixXd& vertices_t0,
const Eigen::MatrixXd& vertices_t1,
const Eigen::MatrixXi& edges, const Eigen::MatrixXi& faces,
double inflation_radius, double voxel_size)¶
- inline virtual void clear() override¶
Clear any built data.
-
virtual void detect_vertex_vertex_candidates(
std::vector<VertexVertexCandidate>& candidates) const override¶ Find the candidate vertex-vertex collisions.
-
virtual void detect_edge_vertex_candidates(
std::vector<EdgeVertexCandidate>& candidates) const override¶ Find the candidate edge-vertex collisions.
-
virtual void detect_edge_edge_candidates(
std::vector<EdgeEdgeCandidate>& candidates) const override¶ Find the candidate edge-edge collisions.
-
virtual void detect_face_vertex_candidates(
std::vector<FaceVertexCandidate>& candidates) const override¶ Find the candidate face-vertex collisions.
-
virtual void detect_edge_face_candidates(
std::vector<EdgeFaceCandidate>& candidates) const override¶ Find the candidate edge-face intersections.
-
virtual void detect_face_face_candidates(
std::vector<FaceFaceCandidate>& candidates) const override¶ Find the candidate face-face collisions.
Public Members
- ArrayMax3d left_bottom_corner¶
The left bottom corner of the world bounding box.
- ArrayMax3d right_top_corner¶
The right top corner of the world bounding box.
- ArrayMax3i voxel_count¶
The number of voxels in each dimension.
- double one_div_voxelSize¶
1.0 / voxel_size
- int voxel_count_0x1¶
The number of voxels in the first two dimensions.
- int edge_start_ind¶
- int tri_start_ind¶
- unordered_map<int, std::vector<int>> voxel_to_primitives¶
Map from voxel index to the primitive indices it contains.
- std::vector<std::vector<int>> point_to_voxels¶
Map from point index to the voxel indices it occupies.
- std::vector<std::vector<int>> edge_to_voxels¶
Map from edge index to the voxel indices it occupies.
- std::vector<std::vector<int>> face_to_voxels¶
Map from face index to the voxel indices it occupies.
Protected Functions
-
void locate_box_voxel_axis_index(ArrayMax3d min_corner,
ArrayMax3d max_corner, ArrayMax3i& min_index,
ArrayMax3i& max_index, const double inflation_radius = 0) const¶
-
int voxel_axis_index_to_voxel_index(
const ArrayMax3i& voxel_axis_index) const¶
Private Functions
-
template <typename Candidate, bool swap_order,
bool triangular = false>
void detect_candidates(const std::vector<AABB>& boxesA,
const std::vector<AABB>& boxesB,
const std::function<void(int, unordered_set<int>&)>&
query_A_for_Bs,
const std::function<bool(int, int)>& can_collide,
std::vector<Candidate>& candidates) const¶ Detect candidate collisions between type A and type B.
- Template Parameters:¶
- Parameters:¶
- const std::vector<AABB> &boxesA¶
[in] The boxes of type A to detect collisions with.
- const std::vector<AABB> &boxesB¶
[in] The boxes of type B to detect collisions with.
- const std::function<void(int, unordered_set<int>&)> &query_A_for_Bs¶
[in] Function to query boxes of type B for boxes of type A.
- const std::function<bool(int, int)> &can_collide¶
[in] Function to determine if two primitives can collide given their ids.
- std::vector<Candidate> &candidates¶
[out] The candidate collisions.
-
template <typename Candidate>
void detect_candidates(const std::vector<AABB>& boxesA,
const std::function<void(int, unordered_set<int>&)>&
query_A_for_As,
const std::function<bool(int, int)>& can_collide,
std::vector<Candidate>& candidates) const¶ Detect candidate collisions between type A and type A.
- Template Parameters:¶
- typename Candidate¶
Type of candidate collision.
- Parameters:¶
- const std::vector<AABB> &boxesA¶
[in] The boxes of type A to detect collisions with.
- const std::function<void(int, unordered_set<int>&)> &query_A_for_As¶
[in] Function to query boxes of type A for boxes of type A.
- const std::function<bool(int, int)> &can_collide¶
[in] Function to determine if two primitives can collide given their ids.
- std::vector<Candidate> &candidates¶
[out] The candidate collisions.
BVH¶
- class BVH : public ipc::BroadPhase¶
Inheritence diagram for ipc::BVH:
Collaboration diagram for ipc::BVH:
Public Functions
- BVH() = default¶
-
virtual void build(const Eigen::MatrixXd& vertices,
const Eigen::MatrixXi& edges, const Eigen::MatrixXi& faces,
const double inflation_radius = 0) override¶ Build the broad phase for static collision detection.
-
virtual void build(const Eigen::MatrixXd& vertices_t0,
const Eigen::MatrixXd& vertices_t1,
const Eigen::MatrixXi& edges, const Eigen::MatrixXi& faces,
const double inflation_radius = 0) override¶ Build the broad phase for continuous collision detection.
- Parameters:¶
- const Eigen::MatrixXd &vertices_t0¶
Starting vertices of the vertices.
- const Eigen::MatrixXd &vertices_t1¶
Ending vertices of the vertices.
- const Eigen::MatrixXi &edges¶
Collision mesh edges
- const Eigen::MatrixXi &faces¶
Collision mesh faces
- const double inflation_radius = 0¶
Radius of inflation around all elements.
- virtual void clear() override¶
Clear any built data.
-
virtual void detect_vertex_vertex_candidates(
std::vector<VertexVertexCandidate>& candidates) const override¶ Find the candidate vertex-vertex collisions.
- Parameters:¶
- std::vector<VertexVertexCandidate> &candidates¶
[out] The candidate vertex-vertex collisions.
-
virtual void detect_edge_vertex_candidates(
std::vector<EdgeVertexCandidate>& candidates) const override¶ Find the candidate edge-vertex collisions.
- Parameters:¶
- std::vector<EdgeVertexCandidate> &candidates¶
[out] The candidate edge-vertex collisions.
-
virtual void detect_edge_edge_candidates(
std::vector<EdgeEdgeCandidate>& candidates) const override¶ Find the candidate edge-edge collisions.
- Parameters:¶
- std::vector<EdgeEdgeCandidate> &candidates¶
[out] The candidate edge-edge collisions.
-
virtual void detect_face_vertex_candidates(
std::vector<FaceVertexCandidate>& candidates) const override¶ Find the candidate face-vertex collisions.
- Parameters:¶
- std::vector<FaceVertexCandidate> &candidates¶
[out] The candidate face-vertex collisions.
-
virtual void detect_edge_face_candidates(
std::vector<EdgeFaceCandidate>& candidates) const override¶ Find the candidate edge-face intersections.
- Parameters:¶
- std::vector<EdgeFaceCandidate> &candidates¶
[out] The candidate edge-face intersections.
-
virtual void detect_face_face_candidates(
std::vector<FaceFaceCandidate>& candidates) const override¶ Find the candidate face-face collisions.
Protected Attributes
Protected Static Functions
-
static void init_bvh(
const std::vector<AABB>& boxes, SimpleBVH::BVH& bvh)¶ Initialize a BVH from a set of boxes.
-
template <typename Candidate, bool swap_order = false,
bool triangular = false>
static void detect_candidates(const std::vector<AABB>& boxes,
const SimpleBVH::BVH& bvh,
const std::function<bool(size_t, size_t)>& can_collide,
std::vector<Candidate>& candidates)¶ Detect candidate collisions between a BVH and a sets of boxes.
- Template Parameters:¶
- Parameters:¶
- const std::vector<AABB> &boxes¶
[in] The boxes to detect collisions with.
- const SimpleBVH::BVH &bvh¶
[in] The BVH to detect collisions with.
- const std::function<bool(size_t, size_t)> &can_collide¶
[in] Function to determine if two primitives can collide given their ids.
- std::vector<Candidate> &candidates¶
[out] The candidate collisions.
Sweep and Prune¶
- class SweepAndPrune : public ipc::BroadPhase¶
Inheritence diagram for ipc::SweepAndPrune:
Collaboration diagram for ipc::SweepAndPrune:
Public Functions
- SweepAndPrune() = default¶
-
virtual void build(const Eigen::MatrixXd& vertices,
const Eigen::MatrixXi& edges, const Eigen::MatrixXi& faces,
double inflation_radius = 0) override¶ Build the broad phase for static collision detection.
-
virtual void build(const Eigen::MatrixXd& vertices_t0,
const Eigen::MatrixXd& vertices_t1,
const Eigen::MatrixXi& edges, const Eigen::MatrixXi& faces,
double inflation_radius = 0) override¶ Build the broad phase for continuous collision detection.
- Parameters:¶
- virtual void clear() override¶
Clear any built data.
-
virtual void detect_vertex_vertex_candidates(
std::vector<VertexVertexCandidate>& candidates) const override¶ Find the candidate vertex-vertex collisions.
- Parameters:¶
- std::vector<VertexVertexCandidate> &candidates¶
[out] The candidate vertex-vertex collisions.
-
virtual void detect_edge_vertex_candidates(
std::vector<EdgeVertexCandidate>& candidates) const override¶ Find the candidate edge-vertex collisions.
- Parameters:¶
- std::vector<EdgeVertexCandidate> &candidates¶
[out] The candidate edge-vertex collisions.
-
virtual void detect_edge_edge_candidates(
std::vector<EdgeEdgeCandidate>& candidates) const override¶ Find the candidate edge-edge collisions.
- Parameters:¶
- std::vector<EdgeEdgeCandidate> &candidates¶
[out] The candidate edge-edge collisions.
-
virtual void detect_face_vertex_candidates(
std::vector<FaceVertexCandidate>& candidates) const override¶ Find the candidate face-vertex collisions.
- Parameters:¶
- std::vector<FaceVertexCandidate> &candidates¶
[out] The candidate face-vertex collisions.
-
virtual void detect_edge_face_candidates(
std::vector<EdgeFaceCandidate>& candidates) const override¶ Find the candidate edge-face intersections.
- Parameters:¶
- std::vector<EdgeFaceCandidate> &candidates¶
[out] The candidate edge-face intersections.
-
virtual void detect_face_face_candidates(
std::vector<FaceFaceCandidate>& candidates) const override¶ Find the candidate face-face collisions.
Protected Functions
Protected Attributes
- std::vector<scalable_ccd::AABB> vertex_boxes¶
- std::vector<scalable_ccd::AABB> edge_boxes¶
- std::vector<scalable_ccd::AABB> face_boxes¶
- mutable int vv_sort_axis = 0¶
- mutable int ev_sort_axis = 0¶
- mutable int ee_sort_axis = 0¶
- mutable int fv_sort_axis = 0¶
- mutable int ef_sort_axis = 0¶
- mutable int ff_sort_axis = 0¶
Sweep and Tiniest Queue¶
AABB¶
- class AABB¶
Axis aligned bounding-box of some type.
Public Functions
- AABB() = default¶
Public Members
Public Static Functions
-
static AABB from_point(
const VectorMax3d& p, const double inflation_radius = 0)¶ Construct an AABB for a static point.
-
static inline AABB from_point(const VectorMax3d& p_t0,
const VectorMax3d& p_t1, const double inflation_radius = 0)¶ Construct an AABB for a moving point (i.e.
temporal edge).
-
static void conservative_inflation(ArrayMax3d& min, ArrayMax3d& max,
const double inflation_radius)¶ Compute a conservative inflation of the AABB.