Subversion Repositories gelsvn

Rev

Rev 291 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
290 jrf 1
#include "AABox.h"
2
#include "BoundingINode.h"
3
 
4
using namespace std;
5
using namespace CGLA;
6
 
7
template<class BoxType>
8
void BoundingINode<BoxType>::draw(int l, int lmax) const
9
{
10
	if(l==lmax)
11
		{
12
			gl_draw(); 
13
			return;
14
		}
15
	left->draw(l+1,lmax);
16
	right->draw(l+1,lmax);
17
}
18
 
19
template<class BoxType>
20
int BoundingINode<BoxType>::intersect_cnt(const CGLA::Vec3f& p , 
21
																 const CGLA::Vec3f& dir) const
22
{
23
	if(!BoxType::intersect(p,dir))
24
		return 0;
25
 
26
	int li = left->intersect_cnt(p,dir);
27
	int ri = right->intersect_cnt(p,dir);
28
	return li + ri;
29
}
30
 
31
template<class BoxType>
32
bool BoundingINode<BoxType>::intersect(const CGLA::Vec3f& p , const CGLA::Vec3f& dir,
33
															float& tmin) const 
34
{
35
	if(!BoxType::intersect(p,dir))
36
		return false;
37
 
38
	float tminl=1e33, tminr=1e33;
39
	bool li = left->intersect(p,dir,tminl);
40
	bool ri = right->intersect(p,dir,tminr);
41
	if(li||ri)
42
		{
43
			tmin = min(tminl,tminr);
44
			return true;
45
		}
46
	return false;
47
}
48
 
49
 
50
 template BoundingINode<AABox>;
51
template BoundingINode<OBox>;