Text archives Help
- From: knolla@sci.utah.edu
- To: rtrt@sci.utah.edu
- Subject: [MANTA] r300 - trunk/Model/Primitives
- Date: Thu, 12 May 2005 17:04:40 -0600 (MDT)
Author: knolla
Date: Thu May 12 17:04:38 2005
New Revision: 300
Modified:
trunk/Model/Primitives/Triangle.cc
Log:
Triangle now checks for precomputed normals and hitposition in computeNormals
Modified: trunk/Model/Primitives/Triangle.cc
==============================================================================
--- trunk/Model/Primitives/Triangle.cc (original)
+++ trunk/Model/Primitives/Triangle.cc Thu May 12 17:04:38 2005
@@ -66,12 +66,26 @@
void Triangle::computeNormal(const RenderContext&, RayPacket& rays) const
{
- rays.computeHitPositions();
- int nrays = rays.getSize();
- for(int i=0; i<nrays; i++) {
- RayPacket::Element& e = rays.get(i);
- e.normal = Cross((c-a),(b-a));
- e.normal.normalize();
+ if (rays.getFlags() & RayPacket::HaveHitPositions)
+ rays.computeHitPositions();
+
+ if (rays.getFlags() & RayPacket::HaveNormals){
+ if (rays.getFlags() & RayPacket::HaveUnitNormals)
+ return;
+
+ int nrays = rays.getSize();
+ for(int i=0; i<nrays; i++){
+ rays.get(i).normal.normalize();
+ }
}
+ else{
+ int nrays = rays.getSize();
+ for(int i=0; i<nrays; i++) {
+ RayPacket::Element& e = rays.get(i);
+ e.normal = Cross((c-a),(b-a));
+ e.normal.normalize();
+ }
+ }
+
}
- [MANTA] r300 - trunk/Model/Primitives, knolla, 05/12/2005
Archive powered by MHonArc 2.6.16.