Subversion Repositories gelsvn

Rev

Rev 291 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#include "AABox.h"
#include "BoundingINode.h"

using namespace std;
using namespace CGLA;

template<class BoxType>
void BoundingINode<BoxType>::draw(int l, int lmax) const
{
        if(l==lmax)
                {
                        gl_draw(); 
                        return;
                }
        left->draw(l+1,lmax);
        right->draw(l+1,lmax);
}

template<class BoxType>
int BoundingINode<BoxType>::intersect_cnt(const CGLA::Vec3f& p , 
                                                                                                                                 const CGLA::Vec3f& dir) const
{
        if(!BoxType::intersect(p,dir))
                return 0;

        int li = left->intersect_cnt(p,dir);
        int ri = right->intersect_cnt(p,dir);
        return li + ri;
}

template<class BoxType>
bool BoundingINode<BoxType>::intersect(const CGLA::Vec3f& p , const CGLA::Vec3f& dir,
                                                                                                                        float& tmin) const 
{
        if(!BoxType::intersect(p,dir))
                return false;

        float tminl=1e33, tminr=1e33;
        bool li = left->intersect(p,dir,tminl);
        bool ri = right->intersect(p,dir,tminr);
        if(li||ri)
                {
                        tmin = min(tminl,tminr);
                        return true;
                }
        return false;
}


 template BoundingINode<AABox>;
template BoundingINode<OBox>;