/*! The SLRefGroup::shapeInit checks the validity of the referenced node. To avoid endless loops a refShape node is not allowed to refShape its ancestors. An ancestor of a refShape node is group node followed along the previous pointers with lower depth than the depth of the refShape node. */ void SLRefGroup::shapeInit(SLSceneView* sv) { // cummulate wm with referenced wm SLShape* ref = (SLShape*)_refGroup; _wm *= ref->m(); _wmI.setMatrix(_wm.inverse()); _wmN.setMatrix(_wmI.mat3()); _wmN.transpose(); // check circular references SLNode* parent = this->parent(); while (parent) { if (parent==_refGroup) SL_EXIT_MSG("Reference node produces a never ending loop."); parent = parent->parent(); } // set transparency flag _aabb.hasAlpha(((SLShape*)_refGroup)->aabb()->hasAlpha()); // delete all child references if (_first) deleteAll(); // loop through the referenced group and add a SLRefShape or SLRefGroup SLNode* current = ((SLGroup*)_refGroup)->first(); while (current) { if (typeid(*current)==typeid(SLGroup)) addNode(new SLRefGroup((SLGroup*)current, name()+"_"+current->name())); else addNode(new SLRefShape((SLShape*)current, name()+"_"+current->name())); ((SLShape*)_last)->wm(_wm); ((SLShape*)_last)->depth(depth()+1); ((SLShape*)_last)->shapeInit(sv); current = current->next(); } }
/*! The SLRefShape::shapeInit checks the validity of the referenced node. To avoid endless loops a refShape node is not allowed to refShape its ancestors. An ancestor of a refShape node is group node followed along the previous pointers with lower depth than the depth of the refShape node. Do not initialize the referenced shape twice. */ void SLRefShape::shapeInit(SLSceneView* sv) { (void)sv; // avoid unused parameter warning // cummulate my wm with referenced object transform (m) SLShape* ref = (SLShape*)_refShape; _wm *= ref->m(); _wmI.setMatrix(_wm.inverse()); _wmN.setMatrix(_wmI.mat3()); _wmN.transpose(); // set transparency flag _aabb.hasAlpha(((SLShape*)_refShape)->aabb()->hasAlpha()); // check circular references SLNode* parent = this->parent(); while (parent) { if (parent==_refShape) SL_EXIT_MSG("Reference node produces a never ending loop."); parent = parent->parent(); } }