33 #ifndef DART_COLLISION_COLLISIONGROUP_HPP_
34 #define DART_COLLISION_COLLISIONGROUP_HPP_
36 #include <unordered_set>
37 #include <unordered_map>
73 const std::vector<const dynamics::ShapeFrame*>& shapeFrames);
83 template <
typename... Others>
85 const Others*... others);
88 template <
typename... Others>
90 const std::vector<const dynamics::ShapeFrame*>& shapeFrames,
91 const Others*... others);
95 template <
typename... Others>
97 const Others*... others);
101 template <
typename... Others>
103 const Others*... others);
107 template <
typename... Others>
109 const Others*... others);
120 template <
typename... Others>
123 const Others&... others);
134 template <
typename... Others>
137 const Others&... others);
151 const std::vector<const dynamics::ShapeFrame*>& shapeFrames);
161 template <
typename... Others>
163 const Others*... others);
166 template <
typename... Others>
168 const std::vector<const dynamics::ShapeFrame*>& shapeFrames,
169 const Others*... others);
176 template <
typename... Others>
178 const Others*... others);
185 template <
typename... Others>
187 const Others*... others);
194 template <
typename... Others>
196 const Others*... others);
207 template <
typename... Others>
210 const Others*... others);
214 template <
typename... Others>
217 const Others*... others);
311 const std::vector<CollisionObject*>& collObjects) = 0;
444 template <
typename Source,
typename Child =
void>
454 std::unordered_map<const dynamics::ShapeFrame*, ObjectInfo*>
mObjects;
464 std::unordered_set<const dynamics::ShapeFrame*>
mFrames;
const CollisionOption & option
Collision option of DART.
Definition: FCLCollisionDetector.cpp:154
CollisionResult * result
Collision result of DART.
Definition: FCLCollisionDetector.cpp:157
std::size_t index
Definition: SkelParser.cpp:1617
This class watches when ShapeFrames get deleted so that they can be safely removes from the Collision...
Definition: CollisionGroup.hpp:392
void removeShapeFrame(const dynamics::ShapeFrame *shapeFrame)
Remove a shape frame from this observer.
Definition: CollisionGroup.cpp:307
void handleDestructionNotification(const common::Subject *subject) override
This will be called each time an observed shape frame is deleted.
Definition: CollisionGroup.cpp:321
std::unordered_set< const dynamics::ShapeFrame * > mDeletedFrames
Whenever an observed shape frame gets deleted, its pointer will be added to this set.
Definition: CollisionGroup.hpp:407
void addShapeFrame(const dynamics::ShapeFrame *shapeFrame)
Add a shape frame to this observer.
Definition: CollisionGroup.cpp:298
std::unordered_map< const common::Subject *, const dynamics::ShapeFrame * > mMap
A map from a subject pointer to its corresponding ShapeFrame pointer.
Definition: CollisionGroup.hpp:420
void removeAllShapeFrames()
Remove all shape frames from this observer.
Definition: CollisionGroup.cpp:315
Definition: CollisionGroup.hpp:51
std::unordered_map< const dynamics::MetaSkeleton *, SkeletonSource > SkeletonSources
Definition: CollisionGroup.hpp:492
ShapeFrameObserver mObserver
The object that observes the Shape Frames that this group cares about.
Definition: CollisionGroup.hpp:518
virtual void addCollisionObjectToEngine(CollisionObject *object)=0
Add CollisionObject to the collision detection engine.
void addShapeFramesOf()
Do nothing.
Definition: CollisionGroup.cpp:80
bool collide(const CollisionOption &option=CollisionOption(false, 1u, nullptr), CollisionResult *result=nullptr)
Perform collision check within this CollisionGroup.
Definition: CollisionGroup.cpp:180
std::unordered_map< const dynamics::BodyNode *, BodyNodeSource > BodyNodeSources
Definition: CollisionGroup.hpp:497
bool mUpdateAutomatically
Set this to true to have this CollisionGroup check for updates automatically.
Definition: CollisionGroup.hpp:439
void subscribeTo()
Do nothing.
Definition: CollisionGroup.cpp:86
bool updateSkeletonSource(SkeletonSources::value_type &entry)
Internal function called to update a Skeleton source.
Definition: CollisionGroup.cpp:395
bool updateBodyNodeSource(BodyNodeSources::value_type &entry)
Internal function called to update a BodyNode source.
Definition: CollisionGroup.cpp:526
CollisionDetectorPtr mCollisionDetector
Collision detector.
Definition: CollisionGroup.hpp:326
void removeShapeFrames(const std::vector< const dynamics::ShapeFrame * > &shapeFrames)
Remove ShapeFrames from this CollisionGroup.
Definition: CollisionGroup.cpp:130
virtual void initializeEngineData()=0
Initialize the collision detection engine data such as broadphase algorithm.
void addShapeFrames(const std::vector< const dynamics::ShapeFrame * > &shapeFrames)
Add ShapeFrames to this CollisionGroup.
Definition: CollisionGroup.cpp:72
double distance(const DistanceOption &option=DistanceOption(false, 0.0, nullptr), DistanceResult *result=nullptr)
Get the minimum signed distance between the Shape pairs in this CollisionGroup.
Definition: CollisionGroup.cpp:202
SkeletonSources mSkeletonSources
Skeleton sources that this group is subscribed to.
Definition: CollisionGroup.hpp:512
bool updateShapeFrame(ObjectInfo *object)
Internal function called to update a ShapeFrame.
Definition: CollisionGroup.cpp:591
virtual void removeAllCollisionObjectsFromEngine()=0
Remove all the CollisionObjects from the collision detection engine.
void unsubscribeFrom(const dynamics::BodyNode *bodyNode, const Others *... others)
Unsubscribe from bodyNode.
Definition: CollisionGroup.hpp:255
void removeDeletedShapeFrames()
Remove any ShapeFrames that have been deleted.
Definition: CollisionGroup.cpp:248
ObjectInfo * addShapeFrameImpl(const dynamics::ShapeFrame *shapeFrame, const void *source)
Implementation of addShapeFrame.
Definition: CollisionGroup.cpp:329
void removeAllShapeFrames()
Remove all the ShapeFrames in this CollisionGroup.
Definition: CollisionGroup.cpp:144
void addShapeFrame(const dynamics::ShapeFrame *shapeFrame)
Add a ShapeFrame to this CollisionGroup.
Definition: CollisionGroup.cpp:66
virtual void updateCollisionGroupEngineData()=0
Update the collision detection engine data such as broadphase algorithm.
void removeShapeFrame(const dynamics::ShapeFrame *shapeFrame)
Remove a ShapeFrame from this CollisionGroup.
Definition: CollisionGroup.cpp:92
virtual void addCollisionObjectsToEngine(const std::vector< CollisionObject * > &collObjects)=0
Add CollisionObjects to the collision detection engine.
void updateEngineData()
Update engine data.
Definition: CollisionGroup.cpp:289
virtual void removeCollisionObjectFromEngine(CollisionObject *object)=0
Remove CollisionObject from the collision detection engine.
void update()
Check whether this CollisionGroup's subscriptions or any of its objects need an update,...
Definition: CollisionGroup.cpp:236
bool getAutomaticUpdate() const
Get whether this CollisionGroup is set to automatically check for updates.
Definition: CollisionGroup.cpp:230
virtual ~CollisionGroup()=default
Destructor.
bool hasShapeFrame(const dynamics::ShapeFrame *shapeFrame) const
Return true if this CollisionGroup contains shapeFrame.
Definition: CollisionGroup.cpp:153
void setAutomaticUpdate(bool automatic=true)
Set whether this CollisionGroup will automatically check for updates.
Definition: CollisionGroup.cpp:224
CollisionGroup(const CollisionDetectorPtr &collisionDetector)
Constructor.
Definition: CollisionGroup.cpp:46
std::size_t getNumShapeFrames() const
Return number of ShapeFrames added to this CollisionGroup.
Definition: CollisionGroup.cpp:163
void removeShapeFramesOf()
Do nothing.
Definition: CollisionGroup.cpp:138
std::vector< std::unique_ptr< ObjectInfo > > ObjectInfoList
Definition: CollisionGroup.hpp:360
void removeShapeFrameInternal(const dynamics::ShapeFrame *shapeFrame, const void *source)
Internal version of removeShapeFrame.
Definition: CollisionGroup.cpp:368
CollisionDetectorPtr getCollisionDetector()
Return collision detection engine associated with this CollisionGroup.
Definition: CollisionGroup.cpp:54
ObjectInfoList mObjectInfoList
Information about ShapeFrames and CollisionObjects that have been added to this CollisionGroup.
Definition: CollisionGroup.hpp:364
const dynamics::ShapeFrame * getShapeFrame(std::size_t index) const
Get the ShapeFrame corresponding to the given index.
Definition: CollisionGroup.cpp:169
BodyNodeSources mBodyNodeSources
BodyNode sources that this group is susbscribed to.
Definition: CollisionGroup.hpp:515
Definition: CollisionObject.hpp:45
Definition: CollisionResult.hpp:52
The Observer class should be inherited by any class that wants to respond in a customized way to the ...
Definition: Observer.hpp:52
The Subject class is a base class for any object that wants to report when it gets destroyed.
Definition: Subject.hpp:58
BodyNode class represents a single node of the skeleton.
Definition: BodyNode.hpp:78
Definition: ShapeFrame.hpp:164
class Skeleton
Definition: Skeleton.hpp:59
TemplateBodyNodePtr is a templated class that enables users to create a reference-counting BodyNodePt...
Definition: BodyNodePtr.hpp:111
std::shared_ptr< const CollisionDetector > ConstCollisionDetectorPtr
Definition: SmartPointer.hpp:41
std::shared_ptr< CollisionDetector > CollisionDetectorPtr
Definition: SmartPointer.hpp:41
std::shared_ptr< CollisionObject > CollisionObjectPtr
Definition: SmartPointer.hpp:45
std::shared_ptr< const Skeleton > ConstSkeletonPtr
Definition: SmartPointer.hpp:60
Definition: BulletCollisionDetector.cpp:63
This is information pertaining to a child of the source.
Definition: CollisionGroup.hpp:459
ChildInfo(const std::size_t version)
A constructor that simply accepts a last known version number.
Definition: CollisionGroup.hpp:468
std::size_t mLastKnownVersion
Last known version of this child.
Definition: CollisionGroup.hpp:461
std::unordered_set< const dynamics::ShapeFrame * > mFrames
Last known set of frames attached to this child.
Definition: CollisionGroup.hpp:464
This struct is used to store sources of ShapeFrames that the CollisionGroup is subscribed to,...
Definition: CollisionGroup.hpp:446
std::unordered_map< const Child *, ChildInfo > mChildren
The last known versions of the children related to this source.
Definition: CollisionGroup.hpp:477
std::unordered_map< const dynamics::ShapeFrame *, ObjectInfo * > mObjects
The set of objects that pertain to this source.
Definition: CollisionGroup.hpp:454
Source mSource
The source of ShapeFrames.
Definition: CollisionGroup.hpp:448
CollisionSource(const Source &source, std::size_t lastKnownVersion)
Constructor.
Definition: CollisionGroup.hpp:480
std::size_t mLastKnownVersion
The last known version of that source.
Definition: CollisionGroup.hpp:451
Information on a collision object belonging to this group.
Definition: CollisionGroup.hpp:337
std::size_t mLastKnownVersion
The last known version of the last known shape that was held by the shape frame.
Definition: CollisionGroup.hpp:349
std::unordered_set< const void * > mSources
The set of all sources that indicate that this object should be in this group.
Definition: CollisionGroup.hpp:357
CollisionObjectPtr mObject
The CollisionObject that was generated by the CollisionDetector.
Definition: CollisionGroup.hpp:342
const dynamics::ShapeFrame * mFrame
The ShapeFrame for this object.
Definition: CollisionGroup.hpp:339
std::size_t mLastKnownShapeID
The ID of that last known shape that was held by the shape frame.
Definition: CollisionGroup.hpp:345
Definition: CollisionOption.hpp:45
Definition: DistanceOption.hpp:45
Definition: DistanceResult.hpp:47