coal/broadphase/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 
117 bool defaultCollisionFunction(CollisionObject* o1, CollisionObject* o2,
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 
191 bool defaultDistanceFunction(CollisionObject* o1, CollisionObject* o2,
192  void* data, CoalScalar& dist);
193 
199  void init() { data.clear(); }
200 
201  bool collide(CollisionObject* o1, CollisionObject* o2);
202 
204 
206 };
207 
213  void init() { data.clear(); }
214 
215  bool distance(CollisionObject* o1, CollisionObject* o2, CoalScalar& dist);
216 
218 
220 };
221 
224  typedef std::pair<CollisionObject*, CollisionObject*> CollisionPair;
225 
227  CollisionCallBackCollect(const size_t max_size);
228 
229  bool collide(CollisionObject* o1, CollisionObject* o2);
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
collision.h
coal::CollisionCallBackDefault
Default collision callback to check collision between collision objects.
Definition: coal/broadphase/default_broadphase_callbacks.h:196
coal::DistanceData::clear
void clear()
Clears the DistanceData.
Definition: coal/broadphase/default_broadphase_callbacks.h:89
coal::DistanceData
Distance data stores the distance request and the result given by distance algorithm.
Definition: coal/broadphase/default_broadphase_callbacks.h:76
coal::CollisionCallBackCollect::~CollisionCallBackCollect
virtual ~CollisionCallBackCollect()
Definition: coal/broadphase/default_broadphase_callbacks.h:246
coal::CollisionData::result
CollisionResult result
Collision result.
Definition: coal/broadphase/default_broadphase_callbacks.h:62
coal::CollisionCallBackCollect::CollisionPair
std::pair< CollisionObject *, CollisionObject * > CollisionPair
Definition: coal/broadphase/default_broadphase_callbacks.h:224
data
data
coal
Main namespace.
Definition: coal/broadphase/broadphase_bruteforce.h:44
coal::CollisionCallBackDefault::~CollisionCallBackDefault
virtual ~CollisionCallBackDefault()
Definition: coal/broadphase/default_broadphase_callbacks.h:205
coal::DistanceCallBackDefault::~DistanceCallBackDefault
virtual ~DistanceCallBackDefault()
Definition: coal/broadphase/default_broadphase_callbacks.h:219
coal::CollisionCallBackDefault::data
CollisionData data
Definition: coal/broadphase/default_broadphase_callbacks.h:203
coal::distance
COAL_DLLAPI CoalScalar distance(const Matrix3s &R0, const Vec3s &T0, const kIOS &b1, const kIOS &b2, Vec3s *P=NULL, Vec3s *Q=NULL)
Approximate distance between two kIOS bounding volumes.
Definition: kIOS.cpp:180
coal::CollisionCallBackCollect
Collision callback to collect collision pairs potentially in contacts.
Definition: coal/broadphase/default_broadphase_callbacks.h:223
coal::DistanceData::DistanceData
DistanceData()
Definition: coal/broadphase/default_broadphase_callbacks.h:77
coal::DistanceCallBackDefault
Default distance callback to check collision between collision objects.
Definition: coal/broadphase/default_broadphase_callbacks.h:210
coal::DistanceRequest
request to the distance computation
Definition: coal/collision_data.h:985
coal::CollisionResult::clear
void clear()
clear the results obtained
Definition: coal/collision_data.h:483
coal::defaultCollisionFunction
bool defaultCollisionFunction(CollisionObject *o1, CollisionObject *o2, void *data)
Provides a simple callback for the collision query in the BroadPhaseCollisionManager....
Definition: default_broadphase_callbacks.cpp:42
coal::DistanceCallBackDefault::init
void init()
Initialize the callback. Clears the distance result and sets the done boolean to false.
Definition: coal/broadphase/default_broadphase_callbacks.h:213
coal::CollisionCallBackDefault::init
void init()
Initialize the callback. Clears the collision result and sets the done boolean to false.
Definition: coal/broadphase/default_broadphase_callbacks.h:199
coal::CollisionResult
collision result
Definition: coal/collision_data.h:390
coal::DistanceData::done
bool done
Whether the distance iteration can stop.
Definition: coal/broadphase/default_broadphase_callbacks.h:86
coal::CollisionRequest
request to the collision algorithm
Definition: coal/collision_data.h:311
distance.h
coal::DistanceCallBackBase
Base callback class for distance queries. This class can be supersed by child classes to provide desi...
Definition: coal/broadphase/broadphase_callbacks.h:72
coal::DistanceResult
distance result
Definition: coal/collision_data.h:1051
coal::CollisionObject
the object for collision or distance computation, contains the geometry and the transform information
Definition: coal/collision_object.h:214
coal::DistanceData::request
DistanceRequest request
Distance request.
Definition: coal/broadphase/default_broadphase_callbacks.h:80
coal::DistanceCallBackDefault::data
DistanceData data
Definition: coal/broadphase/default_broadphase_callbacks.h:217
coal::defaultDistanceFunction
bool defaultDistanceFunction(CollisionObject *o1, CollisionObject *o2, void *data, CoalScalar &dist)
Collision data for use with the DefaultContinuousCollisionFunction. It stores the collision request a...
Definition: default_broadphase_callbacks.cpp:66
coal::CollisionData::clear
void clear()
Clears the CollisionData.
Definition: coal/broadphase/default_broadphase_callbacks.h:68
coal::CollisionData::CollisionData
CollisionData()
Definition: coal/broadphase/default_broadphase_callbacks.h:56
coal::CollisionCallBackCollect::max_size
size_t max_size
Definition: coal/broadphase/default_broadphase_callbacks.h:250
broadphase_callbacks.h
coal::collide
COAL_DLLAPI std::size_t collide(const CollisionObject *o1, const CollisionObject *o2, const CollisionRequest &request, CollisionResult &result)
Main collision interface: given two collision objects, and the requirements for contacts,...
Definition: src/collision.cpp:61
coal::CollisionData
Collision data stores the collision request and the result given by collision algorithm.
Definition: coal/broadphase/default_broadphase_callbacks.h:55
coal::CollisionData::request
CollisionRequest request
Collision request.
Definition: coal/broadphase/default_broadphase_callbacks.h:59
coal::CollisionCallBackBase
Base callback class for collision queries. This class can be supersed by child classes to provide des...
Definition: coal/broadphase/broadphase_callbacks.h:49
coal::CollisionData::done
bool done
Whether the collision iteration can stop.
Definition: coal/broadphase/default_broadphase_callbacks.h:65
coal::DistanceData::result
DistanceResult result
Distance result.
Definition: coal/broadphase/default_broadphase_callbacks.h:83
coal::CoalScalar
double CoalScalar
Definition: coal/data_types.h:76
coal::DistanceResult::clear
void clear()
clear the result
Definition: coal/collision_data.h:1139


hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:57