projects
/
MicroTrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
InVoxel() for all Primitives, including fix for Triangle::CalcBounds()
[MicroTrace.git]
/
Triangle.cxx
diff --git
a/Triangle.cxx
b/Triangle.cxx
index
ed12db0
..
873f440
100644
(file)
--- a/
Triangle.cxx
+++ b/
Triangle.cxx
@@
-22,33
+22,33
@@
Triangle::Intersect(Ray& ray)
{
const Vec3f edge1 = m_b-m_a;
const Vec3f edge2 = m_c-m_a;
{
const Vec3f edge1 = m_b-m_a;
const Vec3f edge2 = m_c-m_a;
-
+
const Vec3f pvec = ray.direction().cross(edge2);
const Vec3f pvec = ray.direction().cross(edge2);
-
+
const float det = edge1.dot(pvec);
if (fabs(det) < Epsilon) return false;
const float det = edge1.dot(pvec);
if (fabs(det) < Epsilon) return false;
-
+
const float inv_det = 1.0f / det;
const float inv_det = 1.0f / det;
-
+
const Vec3f tvec = ray.origin()-m_a;
float lambda = tvec.dot( pvec );
lambda *= inv_det;
const Vec3f tvec = ray.origin()-m_a;
float lambda = tvec.dot( pvec );
lambda *= inv_det;
-
- if (lambda < 0.0f || lambda > 1.0f)
+
+ if (lambda < 0.0f || lambda > 1.0f)
return false;
const Vec3f qvec = tvec.cross(edge1);
float mue = ray.direction().dot(qvec);
mue *= inv_det;
return false;
const Vec3f qvec = tvec.cross(edge1);
float mue = ray.direction().dot(qvec);
mue *= inv_det;
-
- if (mue < 0.0f || mue+lambda > 1.0f)
+
+ if (mue < 0.0f || mue+lambda > 1.0f)
return false;
float f = edge2.dot(qvec);
f *= inv_det;
return false;
float f = edge2.dot(qvec);
f *= inv_det;
- if (ray.t() <= f || f < Epsilon )
+ if (ray.t() <= f || f < Epsilon )
return false;
return false;
-
+
ray.setT(f);
ray.setHit(this);
ray.setT(f);
ray.setHit(this);
@@
-64,11
+64,15
@@
Triangle::GetNormal(Ray& ray)
Box
Triangle::CalcBounds()
{
Box
Triangle::CalcBounds()
{
- return Box();
+ Box bounds;
+ bounds.Extend(m_a);
+ bounds.Extend(m_b);
+ bounds.Extend(m_c);
+ return bounds;
}
bool
Triangle::InVoxel(const Box& box)
{
}
bool
Triangle::InVoxel(const Box& box)
{
- return
false
;
+ return
CalcBounds().Overlaps(box)
;
}
}
This page took
0.023894 seconds
and
4
git commands to generate.