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

Generated by GNU Enscript 1.6.6.
-
 
63
 
-
 
64
 
-
 
65