DART  6.10.1
CollisionFilter.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2021, The DART development contributors
3  * All rights reserved.
4  *
5  * The list of contributors can be found at:
6  * https://github.com/dartsim/dart/blob/master/LICENSE
7  *
8  * This file is provided under the following "BSD-style" License:
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
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  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef DART_COLLISION_COLLISIONFILTER_HPP_
34 #define DART_COLLISION_COLLISIONFILTER_HPP_
35 
38 
39 namespace dart {
40 
41 namespace dynamics {
42 class BodyNode;
43 } // namespace dynamics
44 
45 namespace collision {
46 
47 class CollisionObject;
48 
50 {
51 public:
53  virtual ~CollisionFilter();
54 
60  DART_DEPRECATED(6.3)
61  bool needCollision(
62  const CollisionObject* object1, const CollisionObject* object2) const;
63 
66  virtual bool ignoresCollision(
67  const CollisionObject* object1, const CollisionObject* object2) const = 0;
68 };
69 
71 {
72 public:
74  void addCollisionFilter(const CollisionFilter* filter);
75 
77  void removeCollisionFilter(const CollisionFilter* filter);
78 
81 
82  // Documentation inherited
83  bool ignoresCollision(
84  const CollisionObject* object1,
85  const CollisionObject* object2) const override;
86 
87 protected:
89  std::unordered_set<const CollisionFilter*> mFilters;
90 };
91 
93 {
94 public:
97  const dynamics::BodyNode* bodyNode1, const dynamics::BodyNode* bodyNode2);
98 
101  const dynamics::BodyNode* bodyNode1, const dynamics::BodyNode* bodyNode2);
102 
105 
106  // Documentation inherited
107  bool ignoresCollision(
108  const CollisionObject* object1,
109  const CollisionObject* object2) const override;
110 
111 private:
114  bool areAdjacentBodies(
115  const dynamics::BodyNode* bodyNode1,
116  const dynamics::BodyNode* bodyNode2) const;
117 
120 };
121 
122 } // namespace collision
123 } // namespace dart
124 
125 #endif // DART_COLLISION_COLLISIONFILTER_HPP_
#define DART_DEPRECATED(version)
Definition: Deprecated.hpp:51
Definition: CollisionFilter.hpp:93
void addBodyNodePairToBlackList(const dynamics::BodyNode *bodyNode1, const dynamics::BodyNode *bodyNode2)
Add a BodyNode pair to the blacklist.
Definition: CollisionFilter.cpp:91
bool ignoresCollision(const CollisionObject *object1, const CollisionObject *object2) const override
Returns true if the given two CollisionObjects should be checked by the collision detector,...
Definition: CollisionFilter.cpp:111
void removeAllBodyNodePairsFromBlackList()
Remove all the BodyNode pairs from the blacklist.
Definition: CollisionFilter.cpp:105
detail::UnorderedPairs< dynamics::BodyNode > mBodyNodeBlackList
List of pairs to be ignored in the collision detection.
Definition: CollisionFilter.hpp:119
void removeBodyNodePairFromBlackList(const dynamics::BodyNode *bodyNode1, const dynamics::BodyNode *bodyNode2)
Remove a BodyNode pair from the blacklist.
Definition: CollisionFilter.cpp:98
bool areAdjacentBodies(const dynamics::BodyNode *bodyNode1, const dynamics::BodyNode *bodyNode2) const
Returns true if the two BodyNodes are adjacent BodyNodes (i.e., the two BodyNodes are connected by a ...
Definition: CollisionFilter.cpp:163
Definition: CollisionFilter.hpp:50
virtual ~CollisionFilter()
Destructor.
Definition: CollisionFilter.cpp:42
bool needCollision(const CollisionObject *object1, const CollisionObject *object2) const
Returns true if the given two CollisionObjects should be checked by the collision detector,...
Definition: CollisionFilter.cpp:48
virtual bool ignoresCollision(const CollisionObject *object1, const CollisionObject *object2) const =0
Returns true if the given two CollisionObjects should be checked by the collision detector,...
Definition: CollisionObject.hpp:45
Definition: CollisionFilter.hpp:71
void addCollisionFilter(const CollisionFilter *filter)
Adds a collision filter to this CompositeCollisionFilter.
Definition: CollisionFilter.cpp:55
bool ignoresCollision(const CollisionObject *object1, const CollisionObject *object2) const override
Returns true if the given two CollisionObjects should be checked by the collision detector,...
Definition: CollisionFilter.cpp:78
void removeAllCollisionFilters()
Removes all the collision filters from this CompositeCollisionFilter.
Definition: CollisionFilter.cpp:72
void removeCollisionFilter(const CollisionFilter *filter)
Removes a collision filter from this CompositeCollisionFilter.
Definition: CollisionFilter.cpp:65
std::unordered_set< const CollisionFilter * > mFilters
Collision filters.
Definition: CollisionFilter.hpp:89
Definition: UnorderedPairs.hpp:45
BodyNode class represents a single node of the skeleton.
Definition: BodyNode.hpp:79
::fcl::CollisionObject CollisionObject
Definition: BackwardCompatibility.hpp:161
Definition: BulletCollisionDetector.cpp:65