Subversion Repositories gelsvn

Rev

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

Rev 299 Rev 309
Line 1... Line 1...
1
#ifndef __BOUNDINGLNODE_H
1
#ifndef __BOUNDINGLNODE_H
2
#define __BOUNDINGLNODE_H
2
#define __BOUNDINGLNODE_H
3
 
3
 
-
 
4
#include "Ray.h"
4
#include "BoundingNode.h"
5
#include "BoundingNode.h"
5
 
6
 
6
#define USE_LEAF_BOXES 1
7
#define USE_LEAF_BOXES 1
7
 
8
 
8
namespace Geometry
9
namespace Geometry
Line 23... Line 24...
23
#endif
24
#endif
24
 
25
 
25
	~BoundingLNode() {}
26
	~BoundingLNode() {}
26
 
27
 
27
	bool intersect(const CGLA::Vec3f&,const CGLA::Vec3f&,float&) const;
28
	bool intersect(const CGLA::Vec3f&,const CGLA::Vec3f&,float&) const;
-
 
29
	void intersect(Ray&r) const;
28
	int intersect_cnt(const CGLA::Vec3f&,const CGLA::Vec3f&) const;
30
	int intersect_cnt(const CGLA::Vec3f&,const CGLA::Vec3f&) const;
29
 
31
 
30
	void sq_distance(const CGLA::Vec3f&, float&, float&, float&) const;
32
	void sq_distance(const CGLA::Vec3f&, float&, float&, float&) const;
31
 
33
 
32
	virtual bool is_leaf() const {return true;}
34
	virtual bool is_leaf() const {return true;}
Line 48... Line 50...
48
#endif
50
#endif
49
 
51
 
50
}
52
}
51
 
53
 
52
template<class BoxType>
54
template<class BoxType>
-
 
55
inline void BoundingLNode<BoxType>::intersect(Ray& r) const
-
 
56
{
-
 
57
		CGLA::Vec3f p = r.origin;
-
 
58
		CGLA::Vec3f d = r.direction;
-
 
59
		float t = FLT_MAX;
-
 
60
		if(tri.intersect(p,d,t) && t < r.dist)
-
 
61
		{
-
 
62
				r.has_hit = true;
-
 
63
				r.dist = t;
-
 
64
				r.hit_pos = p + t*d;
-
 
65
				r.hit_normal = tri.get_face_norm();
-
 
66
		}
-
 
67
}
-
 
68
 
-
 
69
template<class BoxType>
53
inline int BoundingLNode<BoxType>::intersect_cnt(const CGLA::Vec3f& p, 
70
inline int BoundingLNode<BoxType>::intersect_cnt(const CGLA::Vec3f& p, 
54
																								 const CGLA::Vec3f& dir) const
71
																								 const CGLA::Vec3f& dir) const
55
{
72
{
56
#if USE_LEAF_BOXES
73
#if USE_LEAF_BOXES
57
	float tmin=1.0e33f;
74
	float tmin=1.0e33f;