Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r822 - branches/vertical/Model/Instances
- Date: Thu, 5 Jan 2006 12:41:57 -0700 (MST)
Author: bigler
Date: Thu Jan 5 12:41:56 2006
New Revision: 822
Modified:
branches/vertical/Model/Instances/Instance.cc
branches/vertical/Model/Instances/InstanceRST.cc
branches/vertical/Model/Instances/InstanceRT.cc
branches/vertical/Model/Instances/InstanceST.cc
branches/vertical/Model/Instances/InstanceT.cc
Log:
Instance.cc
Shouldn't be scaling the normals. With arbitrary transformations,
there isn't an easy way to "fix" the normals after the transformation.
InstanceRST.cc
InstanceRT.cc
InstanceST.cc
InstanceT.cc
Keep track of the primitives passing back unit normals. If all the
normals were of unit length, set the flag of the parent RayPacket.
InstanceRT.cc
Fixed a stupid copy paste error that was transforming the normals in
the computeTex{2,3} functions.
Modified: branches/vertical/Model/Instances/Instance.cc
==============================================================================
--- branches/vertical/Model/Instances/Instance.cc (original)
+++ branches/vertical/Model/Instances/Instance.cc Thu Jan 5 12:41:56
2006
@@ -127,8 +127,7 @@
rays.setRay(i, old_rays[i]);
rays.overrideMinT(i, old_minT[i]);
- Real scale = rays.scratchpad<MPTscale>(i).scale;
- rays.setNormal(i, transpose_mult(transform_inv,rays.getNormal(i)) *
scale);
+ rays.setNormal(i, transpose_mult(transform_inv,rays.getNormal(i)));
}
rays.resetFlag(RayPacket::HaveHitPositions);
}
Modified: branches/vertical/Model/Instances/InstanceRST.cc
==============================================================================
--- branches/vertical/Model/Instances/InstanceRST.cc (original)
+++ branches/vertical/Model/Instances/InstanceRST.cc Thu Jan 5 12:41:56
2006
@@ -115,6 +115,8 @@
// Try to create a ray packet that all use the same child primitive
// to compute normals.
+ bool HaveUnitNormals = true; // Used to pass along if the normals
+ // were normalized.
for(int i=rays.begin();i<rays.end();){
const Primitive* prim = rays.scratchpad<MPT>(i).primitive;
int end = i+1;
@@ -122,8 +124,13 @@
end++;
RayPacket subPacket(rays, i, end);
prim->computeNormal(context, subPacket);
+ // If we ever encounter a case where the normals aren't normalized
+ // turn the flag off.
+ HaveUnitNormals &= subPacket.getFlag(RayPacket::HaveUnitNormals);
i = end;
}
+ // If all the normals were unit length set the parent RayPacket's flag.
+ if (HaveUnitNormals) rays.setFlag(RayPacket::HaveUnitNormals);
// Put the rays and minT back, scale normal
for(int i=rays.begin();i<rays.end();i++){
Modified: branches/vertical/Model/Instances/InstanceRT.cc
==============================================================================
--- branches/vertical/Model/Instances/InstanceRT.cc (original)
+++ branches/vertical/Model/Instances/InstanceRT.cc Thu Jan 5 12:41:56
2006
@@ -108,6 +108,8 @@
}
rays.resetFlag(RayPacket::HaveHitPositions);
+ bool HaveUnitNormals = true; // Used to pass along if the normals
+ // were normalized.
for(int i=rays.begin();i<rays.end();){
const Primitive* prim = rays.scratchpad<MPT>(i).primitive;
int end = i+1;
@@ -115,8 +117,13 @@
end++;
RayPacket subPacket(rays, i, end);
prim->computeNormal(context, subPacket);
+ // If we ever encounter a case where the normals aren't normalized
+ // turn the flag off.
+ HaveUnitNormals &= subPacket.getFlag(RayPacket::HaveUnitNormals);
i = end;
}
+ // If all the normals were unit length set the parent RayPacket's flag.
+ if (HaveUnitNormals) rays.setFlag(RayPacket::HaveUnitNormals);
// Put the rays back and fix the normals
for(int i=rays.begin();i<rays.end();i++){
@@ -174,7 +181,6 @@
// Put the rays back and fix the normals
for(int i=rays.begin();i<rays.end();i++){
rays.setRay(i, old_rays[i]);
- rays.setNormal(i, transpose_mult(transform_inv,rays.getNormal(i)));
}
rays.resetFlag(RayPacket::HaveHitPositions);
}
@@ -208,7 +214,6 @@
// Put the rays back and fix the normals
for(int i=rays.begin();i<rays.end();i++){
rays.setRay(i, old_rays[i]);
- rays.setNormal(i, transpose_mult(transform_inv,rays.getNormal(i)));
}
rays.resetFlag(RayPacket::HaveHitPositions);
}
Modified: branches/vertical/Model/Instances/InstanceST.cc
==============================================================================
--- branches/vertical/Model/Instances/InstanceST.cc (original)
+++ branches/vertical/Model/Instances/InstanceST.cc Thu Jan 5 12:41:56
2006
@@ -148,6 +148,8 @@
}
rays.resetFlag(RayPacket::HaveHitPositions);
+ bool HaveUnitNormals = true; // Used to pass along if the normals
+ // were normalized.
for(int i=rays.begin();i<rays.end();){
const Primitive* prim = rays.scratchpad<MPT>(i).primitive;
int end = i+1;
@@ -155,6 +157,9 @@
end++;
RayPacket subPacket(rays, i, end);
prim->computeNormal(context, subPacket);
+ // If we ever encounter a case where the normals aren't normalized
+ // turn the flag off.
+ HaveUnitNormals &= subPacket.getFlag(RayPacket::HaveUnitNormals);
i = end;
}
@@ -164,12 +169,14 @@
rays.setOrigin(i, old_origins[i]);
rays.overrideMinT(i, old_minT[i]);
}
+ // If all the normals were unit length set the parent RayPacket's flag.
+ if (HaveUnitNormals) rays.setFlag(RayPacket::HaveUnitNormals);
} else {
// Put the origins and minT back, scale normal
for(int i=rays.begin();i<rays.end();i++){
rays.setRay(i, old_rays[i]);
rays.overrideMinT(i, old_minT[i]);
- rays.setNormal(i, (rays.getNormal(i) * inv_scale).normal());
+ rays.setNormal(i, rays.getNormal(i) * inv_scale);
}
}
rays.resetFlag(RayPacket::HaveHitPositions);
Modified: branches/vertical/Model/Instances/InstanceT.cc
==============================================================================
--- branches/vertical/Model/Instances/InstanceT.cc (original)
+++ branches/vertical/Model/Instances/InstanceT.cc Thu Jan 5 12:41:56
2006
@@ -75,6 +75,8 @@
}
rays.resetFlag(RayPacket::HaveHitPositions);
+ bool HaveUnitNormals = true; // Used to pass along if the normals
+ // were normalized.
for(int i=rays.begin();i<rays.end();){
const Primitive* prim = rays.scratchpad<MPT>(i).primitive;
int end = i+1;
@@ -82,8 +84,13 @@
end++;
RayPacket subPacket(rays, i, end);
prim->computeNormal(context, subPacket);
+ // If we ever encounter a case where the normals aren't normalized
+ // turn the flag off.
+ HaveUnitNormals &= subPacket.getFlag(RayPacket::HaveUnitNormals);
i = end;
}
+ // If all the normals were unit length set the parent RayPacket's flag.
+ if (HaveUnitNormals) rays.setFlag(RayPacket::HaveUnitNormals);
// Put the origins back
for(int i=rays.begin();i<rays.end();i++){
- [MANTA] r822 - branches/vertical/Model/Instances, bigler, 01/05/2006
Archive powered by MHonArc 2.6.16.