//------------------------------------------------------------------------------ // addComponent() -- Add a new component to our list of components //------------------------------------------------------------------------------ bool Component::addComponent(Pair* const p) { PairStream* subcomponents = getComponents(); processComponents(subcomponents, typeid(Component), p); if (subcomponents != nullptr) subcomponents->unref(); return true; }
bool PhysicsManager::doUpdate(double dt) { // Add all components that came in before the last update processComponents(); processBehaviors(dt); auto state = std::make_shared<PhysicsManagerState>(); std::list<std::shared_ptr<PhysicsManagerState>> stateList(1, state); state->setRepresentations(m_representations); state->setCollisionRepresentations(m_collisionRepresentations); state->setConstraintComponents(m_constraintComponents); { boost::mutex::scoped_lock lock(m_excludedCollisionPairMutex); state->setExcludedCollisionPairs(m_excludedCollisionPairs); } for (const auto& computation : m_computations) { stateList.push_back(computation->update(dt, stateList.back())); } m_finalState.set(*(stateList.back())); return true; }
// setSlotComponent() -- Sets a single component bool Component::setSlotComponent(Component* const single) { // When a only one component ... make it a PairStream PairStream* tmp = new PairStream(); tmp->put( new Pair("1", single) ); // Process the new components list and swap processComponents(tmp, typeid(Component)); tmp->unref(); return true; }
//------------------------------------------------------------------------------ // build() -- build the table in our components list //------------------------------------------------------------------------------ void Table::build() { Basic::PairStream* newList = 0; if (rows > 0 && columns != 0) { newList = new Basic::PairStream(); // For each row: create a TableRow containing all the items in 'columns' for (unsigned int i = 1; i <= rows; i++) { // new row TableRow* row = new TableRow(); row->container(this); const Basic::List::Item* item = columns->getFirstItem(); while (item != 0) { const Basic::Pair* pair = static_cast<const Basic::Pair*>(item->getValue()); const Basic::Object* obj = pair->object(); if (obj->isClassType(typeid(BasicGL::Graphic))) { Basic::Pair* pp = pair->clone(); BasicGL::Graphic* gobj = static_cast<BasicGL::Graphic*>(pp->object()); gobj->container(row); row->put(pp); pp->unref(); } item = item->getNext(); } // put the row on our components list with a slotname equal to its row number { char cbuf[8]; sprintf(cbuf,"%d",i); Basic::Pair* pp = new Basic::Pair(cbuf,row); newList->put(pp); pp->unref(); } row->unref(); } // Position our subcomponents position(); } // These are new our subcomponents ... processComponents(newList,typeid(Basic::Component)); if (newList != 0) newList->unref(); }
// setSlotComponent() -- Sets a single component bool Component::setSlotComponent(Component* const single) { // When a only one component ... make it a PairStream const auto pairStream = new PairStream(); const auto pair = new Pair("1", single); pairStream->put( pair ); pair->unref(); // Process the new components list and swap processComponents(pairStream, typeid(Component)); pairStream->unref(); return true; }
// setSlotComponent() -- Sets a pairstream bool Component::setSlotComponent(PairStream* const multiple) { // Process the new components list and swap processComponents(multiple, typeid(Component)); return true; }