coal  3.0.1
Coal, The Collision Detection Library. Previously known as HPP-FCL, fork of FCL -- The Flexible Collision Library
default_broadphase_callbacks.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2020, Toyota Research Institute
5  * Copyright (c) 2022-2023, INRIA
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
39 #ifndef COAL_BROADPHASE_DEFAULT_BROADPHASE_CALLBACKS_H
40 #define COAL_BROADPHASE_DEFAULT_BROADPHASE_CALLBACKS_H
41 
43 #include "coal/collision.h"
44 #include "coal/distance.h"
45 // #include "coal/narrowphase/continuous_collision.h"
46 // #include "coal/narrowphase/continuous_collision_request.h"
47 // #include "coal/narrowphase/continuous_collision_result.h"
48 // #include "coal/narrowphase/distance_request.h"
49 // #include "coal/narrowphase/distance_result.h"
50 
51 namespace coal {
52 
55 struct CollisionData {
56  CollisionData() { done = false; }
57 
60 
63 
65  bool done;
66 
68  void clear() {
69  result.clear();
70  done = false;
71  }
72 };
73 
76 struct DistanceData {
77  DistanceData() { done = false; }
78 
81 
84 
86  bool done;
87 
89  void clear() {
90  result.clear();
91  done = false;
92  }
93 };
94 
118  void* data);
119 
124 // struct DefaultContinuousCollisionData {
125 // ContinuousCollisionRequest request;
126 // ContinuousCollisionResult result;
127 //
128 // /// If `true`, requests that the broadphase evaluation stop.
129 // bool done{false};
130 // };
131 
154 // bool DefaultContinuousCollisionFunction(ContinuousCollisionObject* o1,
155 // ContinuousCollisionObject* o2,
156 // void* data) {
157 // assert(data != nullptr);
158 // auto* cdata = static_cast<DefaultContinuousCollisionData*>(data);
159 //
160 // if (cdata->done) return true;
161 //
162 // const ContinuousCollisionRequest& request = cdata->request;
163 // ContinuousCollisionResult& result = cdata->result;
164 // collide(o1, o2, request, result);
165 //
166 // return cdata->done;
167 // }
168 
192  void* data, Scalar& dist);
193 
199  void init() { data.clear(); }
200 
202 
204 
206 };
207 
213  void init() { data.clear(); }
214 
216 
218 
220 };
221 
224  typedef std::pair<CollisionObject*, CollisionObject*> CollisionPair;
225 
227  CollisionCallBackCollect(const size_t max_size);
228 
230 
232  size_t numCollisionPairs() const;
233 
235  const std::vector<CollisionPair>& getCollisionPairs() const;
236 
238  void init();
239 
241  bool exist(const CollisionPair& pair) const;
242 
244  bool exist(CollisionObject* o1, CollisionObject* o2) const;
245 
247 
248  protected:
249  std::vector<CollisionPair> collision_pairs;
250  size_t max_size;
251 };
252 
253 } // namespace coal
254 
255 #endif // COAL_BROADPHASE_DEFAULT_BROADPHASE_CALLBACKS_H
the object for collision or distance computation, contains the geometry and the transform information
Definition: collision_object.h:214
#define COAL_DLLAPI
Definition: config.hh:88
Main namespace.
Definition: broadphase_bruteforce.h:44
double Scalar
Definition: data_types.h:68
bool defaultDistanceFunction(CollisionObject *o1, CollisionObject *o2, void *data, Scalar &dist)
Collision data for use with the DefaultContinuousCollisionFunction. It stores the collision request a...
bool defaultCollisionFunction(CollisionObject *o1, CollisionObject *o2, void *data)
Provides a simple callback for the collision query in the BroadPhaseCollisionManager....
Base callback class for collision queries. This class can be supersed by child classes to provide des...
Definition: broadphase_callbacks.h:49
Collision callback to collect collision pairs potentially in contacts.
Definition: default_broadphase_callbacks.h:223
bool collide(CollisionObject *o1, CollisionObject *o2)
Collision evaluation between two objects in collision. This callback will cause the broadphase evalua...
std::pair< CollisionObject *, CollisionObject * > CollisionPair
Definition: default_broadphase_callbacks.h:224
std::vector< CollisionPair > collision_pairs
Definition: default_broadphase_callbacks.h:246
void init()
Reset the callback.
bool exist(CollisionObject *o1, CollisionObject *o2) const
Check whether a collision pair exists.
size_t max_size
Definition: default_broadphase_callbacks.h:250
size_t numCollisionPairs() const
Returns the number of registered collision pairs.
bool exist(const CollisionPair &pair) const
Check whether a collision pair exists.
const std::vector< CollisionPair > & getCollisionPairs() const
Returns a const reference to the active collision_pairs to check.
CollisionCallBackCollect(const size_t max_size)
Default constructor.
virtual ~CollisionCallBackCollect()
Definition: default_broadphase_callbacks.h:246
Default collision callback to check collision between collision objects.
Definition: default_broadphase_callbacks.h:196
bool collide(CollisionObject *o1, CollisionObject *o2)
Collision evaluation between two objects in collision. This callback will cause the broadphase evalua...
virtual ~CollisionCallBackDefault()
Definition: default_broadphase_callbacks.h:205
CollisionData data
Definition: default_broadphase_callbacks.h:203
void init()
Initialize the callback. Clears the collision result and sets the done boolean to false.
Definition: default_broadphase_callbacks.h:199
Collision data stores the collision request and the result given by collision algorithm.
Definition: default_broadphase_callbacks.h:55
CollisionResult result
Collision result.
Definition: default_broadphase_callbacks.h:62
CollisionData()
Definition: default_broadphase_callbacks.h:56
bool done
Whether the collision iteration can stop.
Definition: default_broadphase_callbacks.h:65
CollisionRequest request
Collision request.
Definition: default_broadphase_callbacks.h:59
void clear()
Clears the CollisionData.
Definition: default_broadphase_callbacks.h:68
request to the collision algorithm
Definition: collision_data.h:311
collision result
Definition: collision_data.h:390
void clear()
clear the results obtained
Definition: collision_data.h:482
Base callback class for distance queries. This class can be supersed by child classes to provide desi...
Definition: broadphase_callbacks.h:72
Default distance callback to check collision between collision objects.
Definition: default_broadphase_callbacks.h:210
void init()
Initialize the callback. Clears the distance result and sets the done boolean to false.
Definition: default_broadphase_callbacks.h:213
bool distance(CollisionObject *o1, CollisionObject *o2, Scalar &dist)
Distance evaluation between two objects in collision. This callback will cause the broadphase evaluat...
DistanceData data
Definition: default_broadphase_callbacks.h:217
virtual ~DistanceCallBackDefault()
Definition: default_broadphase_callbacks.h:219
Distance data stores the distance request and the result given by distance algorithm.
Definition: default_broadphase_callbacks.h:76
void clear()
Clears the DistanceData.
Definition: default_broadphase_callbacks.h:89
DistanceResult result
Distance result.
Definition: default_broadphase_callbacks.h:83
bool done
Whether the distance iteration can stop.
Definition: default_broadphase_callbacks.h:86
DistanceData()
Definition: default_broadphase_callbacks.h:77
DistanceRequest request
Distance request.
Definition: default_broadphase_callbacks.h:80
request to the distance computation
Definition: collision_data.h:984
distance result
Definition: collision_data.h:1050
void clear()
clear the result
Definition: collision_data.h:1136