Subversion Repositories gelsvn

Rev

Rev 290 | Rev 299 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 290 Rev 291
Line 3... Line 3...
3
 
3
 
4
#include "BoundingNode.h"
4
#include "BoundingNode.h"
5
 
5
 
6
#define USE_LEAF_BOXES 1
6
#define USE_LEAF_BOXES 1
7
 
7
 
-
 
8
namespace Geometry
-
 
9
{
-
 
10
 
8
/// Leaf node of a bounding box tree. References triangle.
11
/// Leaf node of a bounding box tree. References triangle.
9
template<class BoxType>
12
template<class BoxType>
10
class BoundingLNode: public BoundingNode<BoxType>
13
class BoundingLNode: public BoundingNode<BoxType>
11
{
14
{
12
	Triangle tri;
15
	Triangle tri;
Line 24... Line 27...
24
	bool intersect(const CGLA::Vec3f&,const CGLA::Vec3f&,float&) const;
27
	bool intersect(const CGLA::Vec3f&,const CGLA::Vec3f&,float&) const;
25
	int intersect_cnt(const CGLA::Vec3f&,const CGLA::Vec3f&) const;
28
	int intersect_cnt(const CGLA::Vec3f&,const CGLA::Vec3f&) const;
26
 
29
 
27
	void sq_distance(const CGLA::Vec3f&, float&, float&, float&) const;
30
	void sq_distance(const CGLA::Vec3f&, float&, float&, float&) const;
28
 
31
 
29
	void draw(int l, int lmax) const
-
 
30
		{
-
 
31
#if USE_LEAF_BOXES
-
 
32
 			gl_draw(); 
-
 
33
#endif
-
 
34
		}
-
 
35
 
-
 
36
	virtual bool is_leaf() const {return true;}
32
	virtual bool is_leaf() const {return true;}
37
 
33
 
38
	const Triangle& get_tri() const {return tri;}
34
	const Triangle& get_tri() const {return tri;}
39
};
35
};
40
 
36
 
Line 56... Line 52...
56
template<class BoxType>
52
template<class BoxType>
57
inline int BoundingLNode<BoxType>::intersect_cnt(const CGLA::Vec3f& p, 
53
inline int BoundingLNode<BoxType>::intersect_cnt(const CGLA::Vec3f& p, 
58
																								 const CGLA::Vec3f& dir) const
54
																								 const CGLA::Vec3f& dir) const
59
{
55
{
60
#if USE_LEAF_BOXES
56
#if USE_LEAF_BOXES
61
	float tmin=1e33;
57
	float tmin=1.0e33f;
62
	if(BoxType::intersect(p,dir) && 
58
	if(BoxType::intersect(p,dir) && 
63
		 tri.intersect(p,dir,tmin) &&
59
		 tri.intersect(p,dir,tmin) &&
64
		 tmin > 0)
60
		 tmin > 0)
65
		return 1;
61
		return 1;
66
	return 0;
62
	return 0;
Line 82... Line 78...
82
	if(!did_work) std::cout << dmax << std::endl;
78
	if(!did_work) std::cout << dmax << std::endl;
83
	assert(did_work);
79
	assert(did_work);
84
 	dmin = dmax; 
80
 	dmin = dmax; 
85
}
81
}
86
 
82
 
87
 
83
}
88
#endif
84
#endif