Subversion Repositories gelsvn

Rev

Rev 291 | Rev 309 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 291 Rev 299
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
namespace Geometry
7
namespace Geometry
8
{
8
{
9
 
9
 
10
template<class BoxType>
10
template<class BoxType>
11
int BoundingINode<BoxType>::intersect_cnt(const CGLA::Vec3f& p , 
11
int BoundingINode<BoxType>::intersect_cnt(const CGLA::Vec3f& p , 
12
																 const CGLA::Vec3f& dir) const
12
																 const CGLA::Vec3f& dir) const
13
{
13
{
14
	if(!BoxType::intersect(p,dir))
14
	if(!BoxType::intersect(p,dir))
15
		return 0;
15
		return 0;
16
 
16
 
17
	int li = left->intersect_cnt(p,dir);
17
	int li = left->intersect_cnt(p,dir);
18
	int ri = right->intersect_cnt(p,dir);
18
	int ri = right->intersect_cnt(p,dir);
19
	return li + ri;
19
	return li + ri;
20
}
20
}
21
 
21
 
22
template<class BoxType>
22
template<class BoxType>
23
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,
24
															float& tmin) const 
24
															float& tmin) const 
25
{
25
{
26
	if(!BoxType::intersect(p,dir))
26
	if(!BoxType::intersect(p,dir))
27
		return false;
27
		return false;
28
 
28
 
29
	float tminl=1.0e33f, tminr=1.0e33f;
29
	float tminl=1.0e33f, tminr=1.0e33f;
30
	bool li = left->intersect(p,dir,tminl);
30
	bool li = left->intersect(p,dir,tminl);
31
	bool ri = right->intersect(p,dir,tminr);
31
	bool ri = right->intersect(p,dir,tminr);
32
	if(li||ri)
32
	if(li||ri)
33
		{
33
		{
34
			tmin = min(tminl,tminr);
34
			tmin = min(tminl,tminr);
35
			return true;
35
			return true;
36
		}
36
		}
37
	return false;
37
	return false;
38
}
38
}
39
 
39
 
40
 
40
 
41
 template BoundingINode<AABox>;
41
 template BoundingINode<AABox>;
42
template BoundingINode<OBox>;
42
template BoundingINode<OBox>;
43
 
43
 
44
}
44
}
45
 
45
 
46

Generated by GNU Enscript 1.6.6.
46

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