Skip to content

Commit a4646ee

Browse files
committed
simplify tree "rebalancing"
We now unconditionally ensure that the graph is a tree (as it should), by always removing the parent from the target node, and reconnecting said node to the new transformation. The very complex implementation currently there did not seem to be needed.
1 parent 405114b commit a4646ee

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

src/TransformerGraph.cpp

+4-26
Original file line numberDiff line numberDiff line change
@@ -549,36 +549,14 @@ bool TransformerGraph::setTransformation(osg::Node &transformer,const std::strin
549549
}
550550
else if (target->getParent(0) != source)
551551
{
552-
if (target == &transformer || (source->getParent(0) == &transformer && target->getParent(0) != &transformer))
552+
if (target == &transformer)
553553
{
554554
invertOSGTransform(trans, quat, source, target, source_frame, target_frame);
555555
}
556556

557-
if (target->getParent(0) != &transformer)
558-
{
559-
std::set<osg::Node*> ancestors;
560-
osg::ref_ptr<osg::Node> sourceAncestor = source;
561-
while (sourceAncestor != &transformer)
562-
{
563-
ancestors.insert(sourceAncestor);
564-
if (sourceAncestor->getParent(0) == target)
565-
{
566-
target->removeChild(sourceAncestor);
567-
getTransform(&transformer)->addChild(sourceAncestor);
568-
ancestors.clear();
569-
break;
570-
}
571-
else
572-
sourceAncestor = sourceAncestor->getParent(0);
573-
}
574-
575-
::makeRoot(transformer, getTransform(target), ancestors);
576-
577-
}
578-
579-
osg::ref_ptr<osg::Node> node = target; //insures that node is not deleted
580-
removeFrame(transformer,target_frame);
581-
source->addChild(node);
557+
osg::ref_ptr<osg::Node> node = target; //insures that node is not deleted
558+
target->getParent(0)->removeChild(target);
559+
source->addChild(target);
582560
}
583561

584562
target->setAttitude(quat);

0 commit comments

Comments
 (0)