add: delete act;
context: void keyboard(unsigned char k, int x, int y){    switch(k)    {        case 27:            {            OSG::osgExit();            exit(0);        }        break;        case ' ':   // send a ray through the clicked pixel                /*                    Intersection testing for rays is done using an                    IntersectAction. The ray itself is calculated by the                    SimpleSceneManager, given the clicked pixel.                                        It needs to be set up with the line that is to be                    intersected. A line is a semi-infinite ray which has a                    starting point and a direction, and extends in the                    direction to infinity.                                        To do the actual test the Action's apply() method is used.                                        The results can be received from the Action. The main                    difference is if something was hit or not, which is                    returned in didHit().                                        If an intersection did occur, the other data elements are                    valid, otherwise they are undefined.                                        The information that is stored in the action is the object                    which was hit, the triangle of the object that was hit (in                    the form of its index) and the actual hit position.                             */                {                Line l;                                l = mgr->calcViewRay(x, y);                std::cerr << "From "  << l.getPosition ()                           << ", dir " << l.getDirection() << std::endl;                    IntersectAction *act = IntersectAction::create();                                act->setLine(l);                act->apply(fileroot);                            beginEditCP(isectPoints);                isectPoints->setValue(l.getPosition(), 0);                isectPoints->setValue(l.getPosition() + l.getDirection(), 1);                            // did we hit something?                if (act->didHit())                {                    // yes!! print and highlight it                    std::cerr << " object " << act->getHitObject  ()                               << " tri "    << act->getHitTriangle()                               << " at "     << act->getHitPoint   ();                                        mgr->setHighlight(act->getHitObject());                                        // stop the ray on the hit surface                    isectPoints->setValue(l.getPosition() +                             l.getDirection() * act->getHitT(), 1);                                        // find the triangle that was hit                    TriangleIterator it(act->getHitObject());                    it.seek(act->getHitTriangle());                                        // calculate its vertex positions in world space                    Matrix m;                    act->getHitObject()->getToWorld(m);                                // and turn them into a triangle                    Pnt3f p = it.getPosition(0);                    m.multMatrixPnt(p);                    isectPoints->setValue(p, 2);                    p = it.getPosition(1);                    m.multMatrixPnt(p);                    isectPoints->setValue(p, 3);                    p = it.getPosition(2);                    m.multMatrixPnt(p);                    isectPoints->setValue(p, 4);                }                else                {                    // no, get rid of the triangle and highlight.                    isectPoints->setValue(Pnt3f(0,0,0), 2);                    isectPoints->setValue(Pnt3f(0,0,0), 3);                    isectPoints->setValue(Pnt3f(0,0,0), 4);                                        mgr->setHighlight(NullFC);                }                endEditCP(isectPoints);                            // the geometry won't notice automatically, tell it that the                // points changed                beginEditCP(testgeocore, Geometry::PositionsFieldMask);                endEditCP  (testgeocore, Geometry::PositionsFieldMask);                                std::cerr << std::endl;                                glutPostRedisplay();                           }                break;    }}