Beispiel #1
0
Action::ResultE DistanceLOD::intersect(Action *action)
{
    IntersectAction *ia  = dynamic_cast<IntersectAction *>(action);
    
#ifndef OSG_2_PREP
    const DynamicVolume &vol = ia->getActNode()->getVolume();
#else
    const BoxVolume     &vol = ia->getActNode()->getVolume();
#endif
    
    UInt32 numLevels = action->getNNodes();
    
    // early out: no children or lod set missed, cannot hit anything
    if (numLevels == 0 ||
    	vol.isValid() && !vol.intersect(ia->getLine()))
    {
        return Action::Skip;
    }

    const MFReal32 &range = (*getMFRange());
    UInt32 numRanges = range.size();
    UInt32 index = 0;
	
    if (numRanges > 0)
    {
        if (numRanges >= numLevels)
            numRanges = numLevels - 1;

        if (numRanges == 0)
        {
            index = 0;
        }
        else if (_lastDist >= range[numRanges - 1])
        {
            index = numRanges;
        }
        else
        {
            for (index = 0; index < numRanges; ++index)
            {
                if (_lastDist < range[index])
                    break;
            }
        }
    }
    
    const NodePtr nodePtr = action->getNode(index);
    
    ia->addNode(nodePtr);

    return Action::Continue;
}
ActionBase::ResultE Switch::intersect(Action *action)
{
    ActionBase::ResultE  returnValue = ActionBase::Continue;
    IntersectAction     *ia          = dynamic_cast<IntersectAction *>(action);

    if((getChoice()         >= 0              ) && 
       (UInt32(getChoice()) <  ia->getNNodes())   )
    {
        ia->useNodeList(                        );
        ia->addNode    (ia->getNode(getChoice()));
    }
    else if(getChoice() == ALL)
    {
        returnValue = ActionBase::Continue;
    }
    else
    {
        returnValue = ActionBase::Skip;
    }

    return returnValue;
}