Beispiel #1
0
ActionBase::ResultE Joint::intersectEnter(Action *action)
{
    // Use parent class for trivial reject
    if(Inherited::intersect(action) == Action::Skip)
        return Action::Skip;
    
    // Need to check children
    IntersectAction *ia = dynamic_cast<IntersectAction *>(action);
    Matrix           m  = this->getMatrix();

    m.mult(this->getJointTransformation());
    m.invert();
    
    Pnt3f pos;
    Vec3f dir;

    m.multFull(ia->getLine().getPosition (), pos);
    m.mult    (ia->getLine().getDirection(), dir);
    
    Real32 length = dir.length();

    if(length < TypeTraits<Real32>::getDefaultEps())
        SWARNING << "Joint::intersectEnter: Near-zero scale!" << std::endl;

    ia->setLine(Line(pos, dir), ia->getMaxDist());
    ia->scale  (length                          );
    
    return ActionBase::Continue; 
}
Action::ResultE transformLeave(CNodePtr& node, Action * action) 
{ 
    IntersectAction * ia = dynamic_cast<IntersectAction*>(action);
    NodePtr n( node );
    Transform* core =  dynamic_cast<Transform*>(get_pointer(n->getCore()));
    Matrix &m = core->editMatrix();
    
    Pnt3f pos;
    Vec3f dir;
    m.multFull(ia->getLine().getPosition (), pos);
    m.mult    (ia->getLine().getDirection(), dir);
    
    ia->setLine( Line( pos, dir ), ia->getMaxDist() );
    return Action::Continue; 
}
Action::ResultE InverseTransform::intersectLeave(Action *action)
{
    IntersectAction *ia = dynamic_cast<IntersectAction *>(action);
    Matrix           m(_invWorld);

    Pnt3f pos;
    Vec3f dir;

    m.multFull(ia->getLine().getPosition (), pos);
    m.mult    (ia->getLine().getDirection(), dir);

    ia->setLine(Line(pos, dir), ia->getMaxDist());
    ia->scale(dir.length());

    return Action::Continue;
}
Beispiel #4
0
ActionBase::ResultE Joint::intersectLeave(Action *action)
{
    IntersectAction *ia = dynamic_cast<IntersectAction *>(action);
    Matrix           m  = this->getMatrix();
    m.mult(this->getJointTransformation());
    
    Pnt3f pos;
    Vec3f dir;

    m.multFull(ia->getLine().getPosition (), pos);
    m.mult    (ia->getLine().getDirection(), dir);
    
    ia->setLine(Line(pos, dir), ia->getMaxDist());
    ia->scale(dir.length());

    return ActionBase::Continue;
}
Action::ResultE SkeletonBlendedGeometry::intersectEnter(Action *action)
{
    IntersectAction *ia = dynamic_cast<IntersectAction *>(action);
    Matrix           m(_invWorld);

    m.invert();

    Pnt3f pos;
    Vec3f dir;

    m.multFull(ia->getLine().getPosition (), pos);
    m.mult    (ia->getLine().getDirection(), dir);

    ia->setLine(Line(pos, dir), ia->getMaxDist());
    ia->scale(dir.length());

    return Inherited::intersectEnter(action);
}
Action::ResultE ScreenGroup::intersectEnter(Action *action)
{
    IntersectAction *ia = dynamic_cast<IntersectAction *>(action);
    Matrix           m(_camTransform);

    m.invert();

    Pnt3f pos;
    Vec3f dir;

    m.multFull(ia->getLine().getPosition (), pos);
    m.mult    (ia->getLine().getDirection(), dir);

    ia->setLine(Line(pos, dir), ia->getMaxDist());
    ia->scale(dir.length());

    return Action::Continue;
}
/* virtual */ Action::ResultE
KDTreeIntersectProxyAttachment::intersectEnter(Node *node, Action *action)
{
    Action::ResultE  res  = Inherited::intersectEnter(node, action);
    IntersectAction *iact =
        boost::polymorphic_downcast<IntersectAction *>(action);

    Real32 closestHitT = iact->didHit() ? iact->getHitT() : iact->getMaxDist();
    Vec3f  hitNormal;
    UInt32 hitTriangle;

    if(_mfTreeNodes.empty() == false)
    {
        UInt32 numTris = 0;
        bool hit = intersectIntersectKDTree(iact->getLine(),
                                            node->getVolume(),
                                            _sfGeometry.getValue(),
                                            &_mfTreeNodes,
                                            &_mfTriIndices,
                                            closestHitT,
                                            hitNormal,
                                            hitTriangle,
                                            &numTris    );

        if(hit == true)
        {
            iact->setHit(closestHitT,
                         node,
                         hitTriangle,
                         hitNormal, 0);
        }

        iact->getStatCollector()->getElem(
            IntersectAction::statNTriangles)->add(numTris);
    }
    else
    {
        // tree was empty - skip this proxy and use conventional
        // intersect
        res = Action::Continue;
    }

    return res;
}