bool ComposedEntity::linkToBase(PositionableEntity *p) { if(p==0)return false; //if linked... do nothing if(p->location.getBase())return false; //else directly link p->location.linkTo(getReferenciableLocation()); computeBoundingBox(); return true; }
//Methods //protected method, it is responsible of the posible propagation of //belonging to a set for entities that include other entities //the basic one is just a "set" method void PositionableEntity::setOwner(EntitySet *w){ if(w==0)return; //tal vez hay que plantearse que hacer para desagregar :S if(owner)return; if(w->hasObject(this)==false)w->addObject(this); owner=w; //the owner have to be propagated to all the dependent systems whose owner is 0 //it is not posible to have an owner at this point ReferenceSystem *outputLocation=getReferenciableLocation(); int i,n=outputLocation->getNumberOfDependents(); PositionableEntity *aux; for(i=0;i<n;i++){ aux=(outputLocation->getDependent(i))->getOwner(); if(aux==this)aux->setOwner(w); //reference system associated into the same object (e.g.: joints) if(aux->owner==0)aux->setOwner(w); } }