DART  6.6.2
CollisionGroup.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2018, 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_DETAIL_COLLISIONGROUP_HPP_
34 #define DART_COLLISION_DETAIL_COLLISIONGROUP_HPP_
35 
37 
40 
41 namespace dart {
42 namespace collision {
43 
44 //==============================================================================
45 template <typename... Others>
47  const dynamics::ShapeFrame* shapeFrame, const Others*... others)
48 {
49  addShapeFrame(shapeFrame);
50 
51  addShapeFramesOf(others...);
52 }
53 
54 //==============================================================================
55 template <typename... Others>
57  const std::vector<const dynamics::ShapeFrame*>& shapeFrames,
58  const Others*... others)
59 {
60  addShapeFrames(shapeFrames);
61 
62  addShapeFramesOf(others...);
63 }
64 
65 //==============================================================================
66 template <typename... Others>
68  const CollisionGroup* otherGroup, const Others*... others)
69 {
70  assert(otherGroup);
71 
72  if (otherGroup && this != otherGroup)
73  {
74  for (const auto& pair : otherGroup->mShapeFrameMap)
75  addShapeFrame(pair.first);
76  }
77 
78  addShapeFramesOf(others...);
79 }
80 
81 //==============================================================================
82 template <typename... Others>
84  const dynamics::BodyNode* bodyNode, const Others*... others)
85 {
86  assert(bodyNode);
87 
88  auto collisionShapeNodes
90 
91  for (auto& shapeNode : collisionShapeNodes)
92  addShapeFrame(shapeNode);
93 
94  addShapeFramesOf(others...);
95 }
96 
97 //==============================================================================
98 template <typename... Others>
100  const dynamics::MetaSkeleton* skel, const Others*... others)
101 {
102  assert(skel);
103 
104  auto numBodyNodes = skel->getNumBodyNodes();
105  for (auto i = 0u; i < numBodyNodes; ++i)
106  addShapeFramesOf(skel->getBodyNode(i));
107 
108  addShapeFramesOf(others...);
109 }
110 
111 //==============================================================================
112 template <typename... Others>
114  const dynamics::ShapeFrame* shapeFrame, const Others*... others)
115 {
116  removeShapeFrame(shapeFrame);
117 
118  removeShapeFramesOf(others...);
119 }
120 
121 //==============================================================================
122 template <typename... Others>
124  const std::vector<const dynamics::ShapeFrame*>& shapeFrames,
125  const Others*... others)
126 {
127  removeShapeFrames(shapeFrames);
128 
129  removeShapeFramesOf(others...);
130 }
131 
132 //==============================================================================
133 template <typename... Others>
135  const CollisionGroup* otherGroup, const Others*... others)
136 {
137  assert(otherGroup);
138 
139  if (otherGroup)
140  {
141  if (this == otherGroup)
142  {
144  return;
145  }
146 
147  for (const auto& pair : otherGroup->mShapeFrameMap)
148  removeShapeFrame(pair.first);
149  }
150 
151  removeShapeFramesOf(others...);
152 }
153 
154 //==============================================================================
155 template <typename... Others>
157  const dynamics::BodyNode* bodyNode, const Others*... others)
158 {
159  assert(bodyNode);
160 
161  auto collisionShapeNodes
163 
164  for (auto& shapeNode : collisionShapeNodes)
165  removeShapeFrame(shapeNode);
166 
167  removeShapeFramesOf(others...);
168 }
169 
170 //==============================================================================
171 template <typename... Others>
173  const dynamics::MetaSkeleton* skel, const Others*... others)
174 {
175  assert(skel);
176 
177  auto numBodyNodes = skel->getNumBodyNodes();
178  for (auto i = 0u; i < numBodyNodes; ++i)
180 
181  removeShapeFramesOf(others...);
182 }
183 
184 } // namespace collision
185 } // namespace dart
186 
187 #endif // DART_COLLISION_DETAIL_COLLISIONGROUP_HPP_
Definition: CollisionGroup.hpp:49
std::vector< std::pair< const dynamics::ShapeFrame *, CollisionObjectPtr > > mShapeFrameMap
ShapeFrames and CollisionOjbects added to this CollisionGroup.
Definition: CollisionGroup.hpp:254
void addShapeFramesOf()
Do nothing.
Definition: CollisionGroup.cpp:89
void removeShapeFrames(const std::vector< const dynamics::ShapeFrame * > &shapeFrames)
Remove ShapeFrames from this CollisionGroup.
Definition: CollisionGroup.cpp:115
void addShapeFrames(const std::vector< const dynamics::ShapeFrame * > &shapeFrames)
Add ShapeFrames to this CollisionGroup.
Definition: CollisionGroup.cpp:81
void removeAllShapeFrames()
Remove all the ShapeFrames in this CollisionGroup.
Definition: CollisionGroup.cpp:129
void addShapeFrame(const dynamics::ShapeFrame *shapeFrame)
Add a ShapeFrame to this CollisionGroup.
Definition: CollisionGroup.cpp:65
void removeShapeFrame(const dynamics::ShapeFrame *shapeFrame)
Remove a ShapeFrame from this CollisionGroup.
Definition: CollisionGroup.cpp:95
void removeShapeFramesOf()
Do nothing.
Definition: CollisionGroup.cpp:123
void addShapeFramesOf(const dynamics::MetaSkeleton *skeleton, const Others *... others)
Add ShapeFrames of MetaSkeleton, and also add another ShapeFrames of other various objects.
Definition: CollisionGroup.hpp:99
BodyNode class represents a single node of the skeleton.
Definition: BodyNode.hpp:78
const std::vector< ShapeNode * > getShapeNodesWith()
Return the list of ShapeNodes containing given Aspect.
Definition: BodyNode.hpp:217
Definition: ShapeFrame.hpp:119
MetaSkeleton is a pure abstract base class that provides a common interface for obtaining data (such ...
Definition: MetaSkeleton.hpp:62
virtual std::size_t getNumBodyNodes() const =0
Get number of body nodes.
virtual BodyNode * getBodyNode(std::size_t _idx)=0
Get BodyNode whose index is _idx.
Definition: ShapeFrame.hpp:164
Definition: BulletCollisionDetector.cpp:63