Bullet Collision Detection & Physics Library
btMultiBodyLinkCollider.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16#ifndef BT_FEATHERSTONE_LINK_COLLIDER_H
17#define BT_FEATHERSTONE_LINK_COLLIDER_H
18
20
21#include "btMultiBody.h"
22
24{
25//protected:
26public:
27
29 int m_link;
30
31
34 m_link(link)
35 {
36 m_checkCollideWith = true;
37 //we need to remove the 'CF_STATIC_OBJECT' flag, otherwise links/base doesn't merge islands
38 //this means that some constraints might point to bodies that are not in the islands, causing crashes
39 //if (link>=0 || (multiBody && !multiBody->hasFixedBase()))
40 {
42 }
43 // else
44 //{
45 // m_collisionFlags |= (btCollisionObject::CF_STATIC_OBJECT);
46 //}
47
49 }
51 {
54 return 0;
55 }
57 {
60 return 0;
61 }
62
64 {
66 if (!other)
67 return true;
68 if (other->m_multiBody != this->m_multiBody)
69 return true;
71 return false;
72
73 //check if 'link' has collision disabled
74 if (m_link>=0)
75 {
76 const btMultibodyLink& link = m_multiBody->getLink(this->m_link);
78 {
80 while (1)
81 {
82 if (parent_of_this==-1)
83 break;
85 if (parent_of_this==other->m_link)
86 {
87 return false;
88 }
89 }
90 }
92 {
93 if ( link.m_parent == other->m_link)
94 return false;
95 }
96
97 }
98
99 if (other->m_link>=0)
100 {
101 const btMultibodyLink& otherLink = other->m_multiBody->getLink(other->m_link);
103 {
104 int parent_of_other = other->m_link;
105 while (1)
106 {
107 if (parent_of_other==-1)
108 break;
110 if (parent_of_other==this->m_link)
111 return false;
112 }
113 }
115 {
116 if (otherLink.m_parent == this->m_link)
117 return false;
118 }
119 }
120 return true;
121 }
122};
123
124#endif //BT_FEATHERSTONE_LINK_COLLIDER_H
125
const T & btMax(const T &a, const T &b)
Definition btMinMax.h:29
btCollisionObject can be used to manage collision detection objects.
int m_checkCollideWith
If some object should have elaborate collision filtering by sub-classes.
int m_internalType
m_internalType is reserved to distinguish Bullet's btCollisionObject, btRigidBody,...
btMultiBodyLinkCollider(btMultiBody *multiBody, int link)
static const btMultiBodyLinkCollider * upcast(const btCollisionObject *colObj)
static btMultiBodyLinkCollider * upcast(btCollisionObject *colObj)
virtual bool checkCollideWithOverride(const btCollisionObject *co) const
bool hasSelfCollision() const
const btMultibodyLink & getLink(int index) const