Line |
Branch |
Exec |
Source |
1 |
|
|
// |
2 |
|
|
// Copyright (c) 2022 INRIA |
3 |
|
|
// |
4 |
|
|
|
5 |
|
|
#ifndef __pinocchio_collision_broadphase_manager_base_hpp__ |
6 |
|
|
#define __pinocchio_collision_broadphase_manager_base_hpp__ |
7 |
|
|
|
8 |
|
|
#include "pinocchio/multibody/geometry.hpp" |
9 |
|
|
#include "pinocchio/collision/broadphase-callbacks.hpp" |
10 |
|
|
|
11 |
|
|
namespace pinocchio |
12 |
|
|
{ |
13 |
|
|
|
14 |
|
|
template<typename Derived> |
15 |
|
|
struct BroadPhaseManagerBase |
16 |
|
|
{ |
17 |
|
|
/// @brief Default constructor |
18 |
|
|
BroadPhaseManagerBase() // for std::vector |
19 |
|
|
: model_ptr(nullptr) |
20 |
|
|
, geometry_model_ptr(nullptr) |
21 |
|
|
, geometry_data_ptr(nullptr) |
22 |
|
|
{ |
23 |
|
|
} |
24 |
|
|
|
25 |
|
|
/// @brief Constructor from a given geometry model and geometry data |
26 |
|
✗ |
BroadPhaseManagerBase( |
27 |
|
|
const Model * model_ptr, |
28 |
|
|
const GeometryModel * geometry_model_ptr, |
29 |
|
|
GeometryData * geometry_data_ptr) |
30 |
|
✗ |
: model_ptr(model_ptr) |
31 |
|
✗ |
, geometry_model_ptr(geometry_model_ptr) |
32 |
|
✗ |
, geometry_data_ptr(geometry_data_ptr) |
33 |
|
|
{ |
34 |
|
|
} |
35 |
|
|
|
36 |
|
|
/// @brief Copy constructor |
37 |
|
✗ |
BroadPhaseManagerBase(const BroadPhaseManagerBase & other) |
38 |
|
✗ |
: model_ptr(other.model_ptr) |
39 |
|
✗ |
, geometry_model_ptr(other.geometry_model_ptr) |
40 |
|
✗ |
, geometry_data_ptr(other.geometry_data_ptr) |
41 |
|
|
{ |
42 |
|
|
} |
43 |
|
|
|
44 |
|
|
BroadPhaseManagerBase & |
45 |
|
|
operator=(const BroadPhaseManagerBase & other) // Copy assignment operator |
46 |
|
|
{ |
47 |
|
|
model_ptr = other.model_ptr; |
48 |
|
|
geometry_model_ptr = other.geometry_model_ptr; |
49 |
|
|
geometry_data_ptr = other.geometry_data_ptr; |
50 |
|
|
return *this; |
51 |
|
|
} |
52 |
|
|
|
53 |
|
✗ |
Derived & derived() |
54 |
|
|
{ |
55 |
|
✗ |
return static_cast<Derived &>(*this); |
56 |
|
|
} |
57 |
|
✗ |
const Derived & derived() const |
58 |
|
|
{ |
59 |
|
✗ |
return static_cast<const Derived &>(*this); |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
/// @brief Check whether the base broad phase manager is aligned with the current |
63 |
|
|
/// collision_objects. |
64 |
|
|
bool check() const |
65 |
|
|
{ |
66 |
|
|
return derived().check(); |
67 |
|
|
} |
68 |
|
|
|
69 |
|
|
/// @brief Check whether the callback is inline with *this |
70 |
|
✗ |
bool check(CollisionCallBackBase * callback) const |
71 |
|
|
{ |
72 |
|
✗ |
return derived().check(callback); |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
/// |
76 |
|
|
/// @brief Update the manager from the current geometry positions and update the underlying FCL |
77 |
|
|
/// broad phase manager. |
78 |
|
|
/// |
79 |
|
|
/// @param[in] compute_local_aabb whether to recompute the local AABB of the collision |
80 |
|
|
/// geometries which have changed. |
81 |
|
|
/// |
82 |
|
✗ |
void update(bool compute_local_aabb = false) |
83 |
|
|
{ |
84 |
|
✗ |
derived().update(compute_local_aabb); |
85 |
|
|
} |
86 |
|
|
|
87 |
|
|
/// |
88 |
|
|
/// @brief Update the manager with a new geometry data. |
89 |
|
|
/// |
90 |
|
|
/// \param[in] geom_data_ptr_new pointer to the new geometry data. |
91 |
|
|
/// |
92 |
|
|
void update(GeometryData * geom_data_ptr_new) |
93 |
|
|
{ |
94 |
|
|
derived().update(geom_data_ptr_new); |
95 |
|
|
} |
96 |
|
|
|
97 |
|
|
/// @brief Performs collision test between one object and all the objects belonging to the |
98 |
|
|
/// manager. |
99 |
|
|
bool collide(CollisionObject & obj, CollisionCallBackBase * callback) const |
100 |
|
|
{ |
101 |
|
|
return derived().collide(obj, callback); |
102 |
|
|
} |
103 |
|
|
|
104 |
|
|
/// @brief Performs collision test for the objects belonging to the manager. |
105 |
|
✗ |
bool collide(CollisionCallBackBase * callback) const |
106 |
|
|
{ |
107 |
|
✗ |
return derived().collide(callback); |
108 |
|
|
} |
109 |
|
|
|
110 |
|
|
/// @brief Performs collision test with objects belonging to another manager. |
111 |
|
|
bool collide(BroadPhaseManagerBase & other_manager, CollisionCallBackBase * callback) const |
112 |
|
|
{ |
113 |
|
|
return derived().collide(other_manager.derived(), callback); |
114 |
|
|
} |
115 |
|
|
|
116 |
|
|
// /// @brief Performs distance computation between one object and all the objects belonging to |
117 |
|
|
// the manager void distance(CollisionObject* obj, DistanceCallBackBase * callback) const; |
118 |
|
|
|
119 |
|
|
// /// @brief Performs distance test for the objects belonging to the manager (i.e., N^2 self |
120 |
|
|
// distance) void distance(DistanceCallBackBase * callback) const; |
121 |
|
|
|
122 |
|
|
// /// @brief Performs distance test with objects belonging to another manager |
123 |
|
|
// void distance(BroadPhaseCollisionManager* other_manager, DistanceCallBackBase * callback) |
124 |
|
|
// const; |
125 |
|
|
|
126 |
|
|
/// @brief Returns the model associated to the manager. |
127 |
|
✗ |
const Model & getModel() const |
128 |
|
|
{ |
129 |
|
✗ |
return *model_ptr; |
130 |
|
|
} |
131 |
|
|
|
132 |
|
|
/// @brief Returns the geometry model associated to the manager. |
133 |
|
✗ |
const GeometryModel & getGeometryModel() const |
134 |
|
|
{ |
135 |
|
✗ |
return *geometry_model_ptr; |
136 |
|
|
} |
137 |
|
|
|
138 |
|
|
/// @brief Returns the geometry data associated to the manager. |
139 |
|
✗ |
const GeometryData & getGeometryData() const |
140 |
|
|
{ |
141 |
|
✗ |
return *geometry_data_ptr; |
142 |
|
|
} |
143 |
|
|
|
144 |
|
|
/// @brief Returns the geometry data associated to the manager. |
145 |
|
✗ |
GeometryData & getGeometryData() |
146 |
|
|
{ |
147 |
|
✗ |
return *geometry_data_ptr; |
148 |
|
|
} |
149 |
|
|
|
150 |
|
|
protected: |
151 |
|
|
/// @brief Pointer to the model |
152 |
|
|
const Model * model_ptr; |
153 |
|
|
|
154 |
|
|
/// @brief Pointer to the geometry model |
155 |
|
|
const GeometryModel * geometry_model_ptr; |
156 |
|
|
|
157 |
|
|
/// @brief Pointer to the geometry data |
158 |
|
|
GeometryData * geometry_data_ptr; |
159 |
|
|
|
160 |
|
|
}; // struct BroadPhaseManagerBase<Derived> |
161 |
|
|
|
162 |
|
|
} // namespace pinocchio |
163 |
|
|
|
164 |
|
|
#endif // ifndef __pinocchio_collision_broadphase_manager_base_hpp__ |
165 |
|
|
|