Subversion Repositories gelsvn

Rev

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

Rev Author Line No. Line
290 jrf 1
#include <GL/gl.h>
2
 
3
#include "BoundingNode.h"
4
#include "BoundingINode.h"
5
#include "BoundingLNode.h"
6
 
7
 
8
using namespace std;
9
using namespace CGLA;
10
 
11
template<class BoxType>
12
void BoundingNode<BoxType>::sq_distance(const Vec3f& p, 
13
																				float& dmin, float& dmax,
14
																				float& s) const
15
{
16
	minmax_sq_dist(p, dmin, dmax);
17
	s = 0;
18
}
19
 
20
template<class BoxType>
21
BoundingNode<BoxType>* 
22
BoundingNode<BoxType>::build(std::vector<Triangle>& triangles)
23
{
24
	int N = triangles.size();
25
	if(N==1)
26
		{
27
			const Triangle& t = triangles[0];
28
#if USE_LEAF_BOXES
29
			return new BoundingLNode<BoxType>(BoxType::box_triangle(t), t);
30
#else
31
			return new BoundingLNode<BoxType>(t);
32
#endif
33
 
34
		}
35
	else
36
		{
37
			std::vector<Triangle> triangles_left;
38
			std::vector<Triangle> triangles_right;
39
 
40
			BoxType box = 
41
				BoxType::box_and_split(triangles, triangles_left, triangles_right);
42
 
43
			BoundingNode* left  = build(triangles_left);
44
			BoundingNode* right = build(triangles_right);
45
 
46
			BoundingNode<BoxType>* bn = new BoundingINode<BoxType>(box, left, right);
47
			return bn;
48
		}
49
}
50
 
51
template BoundingNode<AABox>;
52
template BoundingNode<AABox>* 
53
BoundingNode<AABox>::build(std::vector<Triangle>& triangles);
54
 
55
template BoundingNode<OBox>;
56
template BoundingNode<OBox>* 
57
BoundingNode<OBox>::build(std::vector<Triangle>& triangles);