Subversion Repositories gelsvn

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
688 khor 1
/* ----------------------------------------------------------------------- *
2
 * This file is part of GEL, http://www.imm.dtu.dk/GEL
3
 * Copyright (C) the authors and DTU Informatics
4
 * For license and list of authors, see ../../doc/intro.pdf
5
 * ----------------------------------------------------------------------- */
6
 
7
#include "AABox.h"
8
#include "BoundingINode.h"
9
 
10
using namespace std;
11
using namespace CGLA;
12
 
13
namespace Geometry
14
{
15
 
16
template<class BoxType>
17
int BoundingINode<BoxType>::intersect_cnt(const CGLA::Vec3f& p , 
18
																 const CGLA::Vec3f& dir) const
19
{
20
	if(!BoxType::intersect(p,dir))
21
		return 0;
22
 
23
	int li = left->intersect_cnt(p,dir);
24
	int ri = right->intersect_cnt(p,dir);
25
	return li + ri;
26
}
27
 
28
template<class BoxType>
29
void BoundingINode<BoxType>::intersect(Ray& r) const 
30
{
31
	if(BoxType::intersect(r.origin,r.direction))
32
	{
33
			left->intersect(r);
34
			right->intersect(r);
35
	}
36
}
37
 
38
template<class BoxType>
39
bool BoundingINode<BoxType>::intersect(const CGLA::Vec3f& p , const CGLA::Vec3f& dir,
40
															float& tmin) const 
41
{
42
	if(!BoxType::intersect(p,dir))
43
		return false;
44
 
45
	float tminl=1e33f, tminr=1e33f;
46
	bool li = left->intersect(p,dir,tminl);
47
	bool ri = right->intersect(p,dir,tminr);
48
	if(li||ri)
49
		{
50
			tmin = min(tminl,tminr);
51
			return true;
52
		}
53
	return false;
54
}
55
 
56
template class BoundingINode<AABox>;
57
template class BoundingINode<OBox>;
58
 
59
}