Subversion Repositories gelsvn

Rev

Rev 290 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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

Generated by GNU Enscript 1.6.6.
-
 
47
 
-
 
48
 
-
 
49