Text archives Help
- From: roni@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r1996 - trunk/Model/Primitives
- Date: Thu, 17 Jan 2008 17:42:49 -0700 (MST)
Author: roni
Date: Thu Jan 17 17:42:48 2008
New Revision: 1996
Modified:
trunk/Model/Primitives/ConvexQuad.cc
trunk/Model/Primitives/ConvexQuad.h
Log:
Commented out coplanarity test (doesn't properly account for floating
point error). Added some extra error output to convexity test.
Modified: trunk/Model/Primitives/ConvexQuad.cc
==============================================================================
--- trunk/Model/Primitives/ConvexQuad.cc (original)
+++ trunk/Model/Primitives/ConvexQuad.cc Thu Jan 17 17:42:48 2008
@@ -7,6 +7,7 @@
#include <Model/Primitives/Plane.h>
#include <iostream>
+#include <sstream>
using namespace Manta;
@@ -14,10 +15,6 @@
const Vector& v0, const Vector& v1, const Vector& v2,
const Vector& v3)
: PrimitiveCommon(mat)
{
- // Compute the bounding box.
- bbox[0] = Min(v0, Min(v1, Min(v2, v3)));
- bbox[1] = Max(v0, Max(v1, Max(v2, v3)));
-
// Store the vertices, as they will be needed in the intersect
// routine.
v[0] = v0;
@@ -30,16 +27,28 @@
normal.normalize();
// Clearly, v0, v1, and v3 belong to the plane; check if v2 does too.
- // TODO: what is the correct value to use instead of 1e-5?
- if(Abs(Dot(v[2]-v[0], normal)) > 1e-5)
- throw BadPrimitive("ConvexQuad vertices are not co-planar");
+ // TODO: what is the correct value to use for eps?
+// const Real eps = 1e-3;
+// const Real value = Abs(Dot(v[2]-v[0], normal));
+// if(value > eps){
+// std::cerr << "value: " << value << std::endl;
+// std::cerr << v[0] << std::endl
+// << v[1] << std::endl
+// << v[2] << std::endl
+// << v[3] << std::endl;
+// throw BadPrimitive("ConvexQuad vertices are not co-planar");
+// }
// Check that the quad is convex.
for(int i=0; i<4; i++){
int j = (i+1) % 4;
int k = (i+2) % 4;
- if(Dot(Cross(v[j]-v[i], v[k]-v[j]), normal) < 0)
- throw BadPrimitive("ConvexQuad vertices do not specify a convex
region");
+ if(Dot(Cross(v[j]-v[i], v[k]-v[j]), normal) < 0){
+ std::stringstream s;
+ s << "ConvexQuad vertices (" << v[0] << ", " << v[1] << ", " << v[2]
<< ", " << v[3] << ") do not specify a convex region";
+ //throw BadPrimitive("ConvexQuad vertices do not specify a convex
region");
+ throw BadPrimitive(s.str().c_str());
+ }
}
}
@@ -49,8 +58,10 @@
void ConvexQuad::computeBounds(const PreprocessContext& context,
BBox& bbox_) const {
- bbox_.extendByPoint(bbox[0]);
- bbox_.extendByPoint(bbox[1]);
+ bbox_.extendByPoint(v[0]);
+ bbox_.extendByPoint(v[1]);
+ bbox_.extendByPoint(v[2]);
+ bbox_.extendByPoint(v[3]);
}
void ConvexQuad::intersect(const RenderContext& context,
Modified: trunk/Model/Primitives/ConvexQuad.h
==============================================================================
--- trunk/Model/Primitives/ConvexQuad.h (original)
+++ trunk/Model/Primitives/ConvexQuad.h Thu Jan 17 17:42:48 2008
@@ -25,7 +25,6 @@
RayPacket& rays) const;
private:
- BBox bbox;
Vector v[4];
Vector normal;
};
- [Manta] r1996 - trunk/Model/Primitives, roni, 01/17/2008
Archive powered by MHonArc 2.6.16.