29 #include "BulletSoftBody/btSoftRigidDynamicsWorld.h"
41 tgRigidAutoCompound::tgRigidAutoCompound(std::vector<tgRigidInfo*> rigids)
43 m_rigids.insert(m_rigids.end(), rigids.begin(), rigids.end());
46 tgRigidAutoCompound::tgRigidAutoCompound(std::deque<tgRigidInfo*> rigids) : m_rigids(rigids)
49 std::vector< tgRigidInfo* > tgRigidAutoCompound::execute() {
58 for(
int i=0; i < m_groups.size(); i++) {
61 setRigidInfoForGroup(m_compounded[i], m_groups[i]);
69 void tgRigidAutoCompound::setRigidBodyForGroup(btCollisionObject* body, std::deque<tgRigidInfo*>& group) {
70 for(
int i = 0; i < group.size(); i++) {
71 group[i]->setCollisionObject(body);
75 void tgRigidAutoCompound::setRigidInfoForGroup(
tgRigidInfo* rigidInfo, std::deque<tgRigidInfo*>& group) {
76 for(
int i = 0; i < group.size(); i++) {
77 group[i]->setRigidInfoGroup(rigidInfo);
81 void tgRigidAutoCompound::groupRigids()
83 std::deque<tgRigidInfo*> ungrouped = std::deque<tgRigidInfo*>(m_rigids);
85 while(ungrouped.size() > 0) {
91 std::deque<tgRigidInfo*> group = findGroup(elem, ungrouped);
94 m_groups.push_back(group);
100 std::deque<tgRigidInfo*> tgRigidAutoCompound::findGroup(
tgRigidInfo* rigid, std::deque<tgRigidInfo*>& ungrouped) {
102 std::deque<tgRigidInfo*> group;
105 group.push_back(rigid);
108 ungrouped.erase(std::remove(ungrouped.begin(), ungrouped.end(), rigid), ungrouped.end());
112 while(i < ungrouped.size()) {
115 std::deque<tgRigidInfo*> links = findGroup(other, ungrouped);
116 group.insert(group.end(), links.begin(), links.end());
126 void tgRigidAutoCompound::createCompounds() {
127 for(
int i=0; i < m_groups.size(); i++) {
128 std::deque<tgRigidInfo*>& group = m_groups[i];
129 if(group.size() == 1) {
131 m_compounded.push_back(group[0]);
134 m_compounded.push_back(compound);
139 tgRigidInfo* tgRigidAutoCompound::createCompound(std::deque<tgRigidInfo*> rigids) {
141 for(
int i = 0; i < rigids.size(); i++) {
147 bool tgRigidAutoCompound::rigidBelongsIn(
tgRigidInfo* rigid, std::deque<tgRigidInfo*> group) {
148 for(
int i = 0; i < group.size(); i++) {
virtual bool sharesNodesWith(const tgRigidInfo &other) const
Definition of class tgCompoundRigidInfo.
void addRigid(tgRigidInfo &rigid)
Contains the definition of class tgUtil and overloaded operator<<() free functions.
Definition of class tgRigidAutoCompound.