pinocchio  3.3.1
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
broadphase-manager-base.hpp
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>
16  {
18  BroadPhaseManagerBase() // for std::vector
19  : model_ptr(nullptr)
20  , geometry_model_ptr(nullptr)
21  , geometry_data_ptr(nullptr)
22  {
23  }
24 
27  const Model * model_ptr,
33  {
34  }
35 
38  : model_ptr(other.model_ptr)
41  {
42  }
43 
45  operator=(const BroadPhaseManagerBase & other) // Copy assignment operator
46  {
47  model_ptr = other.model_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 
64  bool check() const
65  {
66  return derived().check();
67  }
68 
70  bool check(CollisionCallBackBase * callback) const
71  {
72  return derived().check(callback);
73  }
74 
82  void update(bool compute_local_aabb = false)
83  {
84  derived().update(compute_local_aabb);
85  }
86 
92  void update(GeometryData * geom_data_ptr_new)
93  {
94  derived().update(geom_data_ptr_new);
95  }
96 
99  bool collide(CollisionObject & obj, CollisionCallBackBase * callback) const
100  {
101  return derived().collide(obj, callback);
102  }
103 
105  bool collide(CollisionCallBackBase * callback) const
106  {
107  return derived().collide(callback);
108  }
109 
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 
127  const Model & getModel() const
128  {
129  return *model_ptr;
130  }
131 
134  {
135  return *geometry_model_ptr;
136  }
137 
140  {
141  return *geometry_data_ptr;
142  }
143 
146  {
147  return *geometry_data_ptr;
148  }
149 
150  protected:
152  const Model * model_ptr;
153 
156 
159 
160  }; // struct BroadPhaseManagerBase<Derived>
161 
162 } // namespace pinocchio
163 
164 #endif // ifndef __pinocchio_collision_broadphase_manager_base_hpp__
Main pinocchio namespace.
Definition: treeview.dox:11
void update(GeometryData *geom_data_ptr_new)
Update the manager with a new geometry data.
bool collide(CollisionObject &obj, CollisionCallBackBase *callback) const
Performs collision test between one object and all the objects belonging to the manager.
const GeometryModel & getGeometryModel() const
Returns the geometry model associated to the manager.
const Model & getModel() const
Returns the model associated to the manager.
BroadPhaseManagerBase(const Model *model_ptr, const GeometryModel *geometry_model_ptr, GeometryData *geometry_data_ptr)
Constructor from a given geometry model and geometry data.
BroadPhaseManagerBase(const BroadPhaseManagerBase &other)
Copy constructor.
const GeometryModel * geometry_model_ptr
Pointer to the geometry model.
const Model * model_ptr
Pointer to the model.
GeometryData * geometry_data_ptr
Pointer to the geometry data.
bool check() const
Check whether the base broad phase manager is aligned with the current collision_objects.
bool check(CollisionCallBackBase *callback) const
Check whether the callback is inline with *this.
bool collide(BroadPhaseManagerBase &other_manager, CollisionCallBackBase *callback) const
Performs collision test with objects belonging to another manager.
const GeometryData & getGeometryData() const
Returns the geometry data associated to the manager.
void update(bool compute_local_aabb=false)
Update the manager from the current geometry positions and update the underlying FCL broad phase mana...
GeometryData & getGeometryData()
Returns the geometry data associated to the manager.
bool collide(CollisionCallBackBase *callback) const
Performs collision test for the objects belonging to the manager.
Interface for Pinocchio collision callback functors.