Text archives Help
- From: sparker@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r813 - in branches/vertical: Interface Model Model/MiscObjects Model/Primitives
- Date: Tue, 3 Jan 2006 17:44:04 -0700 (MST)
Author: sparker
Date: Tue Jan 3 17:44:00 2006
New Revision: 813
Modified:
branches/vertical/Interface/RayPacket.h
branches/vertical/Model/CMakeLists.txt
branches/vertical/Model/MiscObjects/CMakeLists.txt
branches/vertical/Model/MiscObjects/CuttingPlane.cc
branches/vertical/Model/MiscObjects/Difference.cc
branches/vertical/Model/MiscObjects/Intersection.cc
branches/vertical/Model/Primitives/CMakeLists.txt
branches/vertical/Model/Primitives/Cone.cc
branches/vertical/Model/Primitives/Cone.h
branches/vertical/Model/Primitives/Cube.cc
branches/vertical/Model/Primitives/Disk.cc
branches/vertical/Model/Primitives/Disk.h
branches/vertical/Model/Primitives/HeavyTriangle.cc
branches/vertical/Model/Primitives/Heightfield.cc
branches/vertical/Model/Primitives/Hemisphere.cc
branches/vertical/Model/Primitives/ParticleBVH.cc
branches/vertical/Model/Primitives/PrimitiveCommon.h
Log:
More progress toward vertical raypackets
Modified: branches/vertical/Interface/RayPacket.h
==============================================================================
--- branches/vertical/Interface/RayPacket.h (original)
+++ branches/vertical/Interface/RayPacket.h Tue Jan 3 17:44:00 2006
@@ -41,6 +41,7 @@
Real hitPosition[3][Size];
Real minT[Size];
Real texCoords[3][Size];
+ Real inverseDirection[3][Size];
// Color-based arrays
Color::ComponentType color[Color::NumComponents][Size];
@@ -48,6 +49,7 @@
// Int-based arrays
int whichEye[Size];
+ int sign[3][Size];
// Char-based arrays
char scratchpad_data[Size][MaxScratchpadSize];
@@ -158,6 +160,13 @@
for(int i=0;i<3;i++)
data->direction[i][which] = direction[i];
}
+ void setRay(int which, const Ray& ray)
+ {
+ for(int i=0;i<3;i++)
+ data->origin[i][which] = ray.origin()[i];
+ for(int i=0;i<3;i++)
+ data->direction[i][which] = ray.direction()[i];
+ }
Ray getRay(int which) const
{
return Ray(Point(data->origin[0][which], data->origin[1][which],
data->origin[2][which]),
@@ -176,6 +185,10 @@
{
return Vector(data->direction[0][which], data->direction[1][which],
data->direction[2][which]);
}
+ Vector getInverseDirection(int which) const
+ {
+ return Vector(data->inverseDirection[0][which],
data->inverseDirection[1][which], data->inverseDirection[2][which]);
+ }
void normalizeDirections()
{
if(flags & NormalizedDirections)
@@ -206,7 +219,33 @@
flags |= NormalizedDirections;
flags &= ~HaveInverseDirections;
}
-
+ void computeInverseDirections()
+ {
+ if(flags & HaveInverseDirections)
+ return;
+ for(int i=rayBegin;i<rayEnd;i++)
+ for(int j=0;j<3;j++)
+ data->inverseDirection[j][i] = 1./data->direction[j][i];
+ flags |= HaveInverseDirections;
+ }
+ void computeSigns()
+ {
+ if(flags & HaveSigns)
+ return;
+ for(int i=rayBegin;i<rayEnd;i++)
+ for(int j = 0; j < 3; j++)
+ data->sign[j][i] = data->direction[j][i] < 0;
+ flags |= HaveSigns;
+ flags &= ~ConstantSigns;
+ int sign[3];
+ for(int j=0;j<3;j++)
+ sign[j] = data->sign[j][rayBegin];
+ for(int i=rayBegin+1; i < rayEnd; i++)
+ for(int j = 0; j < 3; j++)
+ if(data->sign[j][i] != sign[j])
+ return;
+ flags |= ConstantSigns;
+ }
// Hit information
void resetHits() {
Modified: branches/vertical/Model/CMakeLists.txt
==============================================================================
--- branches/vertical/Model/CMakeLists.txt (original)
+++ branches/vertical/Model/CMakeLists.txt Tue Jan 3 17:44:00 2006
@@ -7,7 +7,7 @@
INCLUDE (Materials/CMakeLists.txt)
INCLUDE (Primitives/CMakeLists.txt)
INCLUDE (TexCoordMappers/CMakeLists.txt)
-INCLUDE (Instances/CMakeLists.txt)
+#INCLUDE (Instances/CMakeLists.txt)
INCLUDE (MiscObjects/CMakeLists.txt)
INCLUDE (Readers/CMakeLists.txt)
INCLUDE (Intersections/CMakeLists.txt)
Modified: branches/vertical/Model/MiscObjects/CMakeLists.txt
==============================================================================
--- branches/vertical/Model/MiscObjects/CMakeLists.txt (original)
+++ branches/vertical/Model/MiscObjects/CMakeLists.txt Tue Jan 3 17:44:00
2006
@@ -3,6 +3,6 @@
MiscObjects/Difference.cc
MiscObjects/Intersection.h
MiscObjects/Intersection.cc
- MiscObjects/CuttingPlane.h
- MiscObjects/CuttingPlane.cc
-)
\ No newline at end of file
+ #MiscObjects/CuttingPlane.h
+ #MiscObjects/CuttingPlane.cc
+)
Modified: branches/vertical/Model/MiscObjects/CuttingPlane.cc
==============================================================================
--- branches/vertical/Model/MiscObjects/CuttingPlane.cc (original)
+++ branches/vertical/Model/MiscObjects/CuttingPlane.cc Tue Jan 3 17:44:00
2006
@@ -7,142 +7,142 @@
using namespace Manta;
-void CuttingPlane::movePlaneAlongNormal( Real distance ) {
-
- plane_point = initial_point + (plane_normal * distance * 100.0);
+void CuttingPlane::movePlaneAlongNormal( Real distance )
+{
+ plane_point = initial_point + (plane_normal * distance * 100.0);
}
// Preprocess the internal object and compute its bounds.
-void CuttingPlane::preprocess( const PreprocessContext &context ) {
-
- // Call preprocess on the object.
- internal_object->preprocess( context );
-
- // Compute its bounds.
- internal_object->computeBounds( context, bounds );
-
- // Determine how far away the edges of the bounding box are from the
- // initial point.
- movement_scale = bounds.diagonal().length() * (Real)0.5;
+void CuttingPlane::preprocess( const PreprocessContext &context )
+{
+ // Call preprocess on the object.
+ internal_object->preprocess( context );
+
+ // Compute its bounds.
+ internal_object->computeBounds( context, bounds );
+
+ // Determine how far away the edges of the bounding box are from the
+ // initial point.
+ movement_scale = bounds.diagonal().length() * (Real)0.5;
}
void CuttingPlane::intersect(const RenderContext& context, RayPacket& rays)
const {
- // Send a new ray packet with new ray origins.
- RayPacketData new_data;
- RayPacket new_rays( new_data, rays.begin(), rays.end(),
rays.getDepth(), rays.getAllFlags());
-
- rays.normalizeDirections();
- rays.computeInverseDirections();
- rays.computeSigns();
+ // Send a new ray packet with new ray origins.
+ RayPacketData new_data;
+ RayPacket new_rays( new_data, rays.begin(), rays.end(),
rays.getDepth(), rays.getAllFlags());
+
+ rays.normalizeDirections();
+ rays.computeInverseDirections();
+ rays.computeSigns();
- // Map between rays in original packet and new packet in case some
rays are skipped.
- int packet_map[RayPacket::MaxSize];
+ // Map between rays in original packet and new packet in case some rays
are skipped.
+ int packet_map[RayPacket::MaxSize];
- // Keep track of which new rays intersect the front face of the plane.
- bool front_facing[RayPacket::MaxSize];
+ // Keep track of which new rays intersect the front face of the plane.
+ bool front_facing[RayPacket::MaxSize];
- // Keep track of the plane_t offset for each ray.
- Real plane_t[RayPacket::MaxSize];
+ // Keep track of the plane_t offset for each ray.
+ Real plane_t[RayPacket::MaxSize];
-
/////////////////////////////////////////////////////////////////////////////
- // Create the new rays.
- int new_i = 0, i;
- for (i=0;i<rays.getSize();++i) {
- RayPacket::Element &e = rays.get( i );
-
- Real box_min, box_max;
-
- // Check to see if the ray intersects the bounding box.
- if (Intersection::intersectAaBox( bounds, box_min, box_max,
-
e.ray, e.sign, e.inverseDirection )) {
-
- // Intersect the ray with the plane.
- Intersection::intersectPlane( plane_point,
plane_normal, plane_t[new_i], e.ray );
-
- RayPacket::Element &n = new_rays.get( new_i );
-
- // Record which original ray this new ray maps to.
- packet_map[new_i] = i;
-
- // Check to see if the ray origin is on the front or
back facing side of
- // the cutting plane (the front facing side is cut
away).
- if (front_facing[new_i] = (Dot(plane_normal,
(e.ray.origin()-plane_point)) > 0.0)) {
-
- // If plane_t is negative, the ray
can't possibly hit the cut model.
- // because the ray is pointing away
from the plane.
- if (plane_t[new_i] > 0.0) {
-
- // If front facing, move the
new ray to the cutting plane.
-
n.ray.set(e.ray.origin()+(e.ray.direction()*plane_t[new_i]),e.ray.direction());
-
new_rays.resetFlag(RayPacket::ConstantOrigin);
-
-
- // Subtract the distance from
the hit t.
- n.hitInfo.reset(
e.hitInfo.minT() - plane_t[new_i] );
-
- ++new_i;
- }
- }
- else {
-
- // Otherwise if back facing, move the hit t
in the hit record to the plane
- // (it will need to be moved back afterwards)
- n.ray = e.ray;
- //n.hitInfo.reset( plane_t[new_i] );
- n.hitInfo.reset( e.hitInfo.minT() );
-
- ++new_i;
- }
-
-
- }
- }
-
- // Check to see if all of the rays miss the bounds.
- if (new_i == 0) {
- return;
- }
-
- // Specify the number of new rays.
- new_rays.resize( new_i );
-
-
/////////////////////////////////////////////////////////////////////////////
- // Intersect the new ray packet with the internal object.
- internal_object->intersect( context, new_rays );
-
-
/////////////////////////////////////////////////////////////////////////////
- // Map the results back to the old rays.
- for (new_i=rays.begin(); new_i<new_rays.end(); ++new_i) {
-
- RayPacket::Element &n = new_rays.get(new_i);
-
- // Check to see if the new ray hit something.
- if (n.hitInfo.wasHit()) {
-
- // Determine which old ray this maps to.
- RayPacket::Element &e = rays.get( packet_map[new_i] );
-
- // Check to see if the old ray is front or back
facing.
- if (front_facing[new_i]) {
- // If so, then translate the hit t back into
the old hit record.
- if (e.hitInfo.hit(
n.hitInfo.minT()+plane_t[new_i],
-
n.hitInfo.hitMaterial(),
-
n.hitInfo.hitPrimitive(),
-
n.hitInfo.hitTexCoordMapper() ))
- e.hitInfo.copyScratchpad( n.hitInfo );
- }
- else {
- // Otherwise, if the original ray is back
facing check to see if the hit
- // is closer then the cutting plane.
- if ((plane_t[new_i] < 0.0) ||
(n.hitInfo.minT() < plane_t[new_i])) {
- if (e.hitInfo.hit( n.hitInfo.minT(),
-
n.hitInfo.hitMaterial(),
-
n.hitInfo.hitPrimitive(),
-
n.hitInfo.hitTexCoordMapper() ))
- e.hitInfo.copyScratchpad(
n.hitInfo );
- }
- }
- }
- }
+
/////////////////////////////////////////////////////////////////////////////
+ // Create the new rays.
+ int new_i = 0, i;
+ for (i=rays.begin();i<rays.end();++i) {
+ RayPacket::Element &e = rays.get( i );
+
+ Real box_min, box_max;
+
+ // Check to see if the ray intersects the bounding box.
+ if (Intersection::intersectAaBox( bounds, box_min, box_max,
+ e.ray, e.sign, e.inverseDirection )) {
+
+ // Intersect the ray with the plane.
+ Intersection::intersectPlane( plane_point, plane_normal,
plane_t[new_i], e.ray );
+
+ RayPacket::Element &n = new_rays.get( new_i );
+
+ // Record which original ray this new ray maps to.
+ packet_map[new_i] = i;
+
+ // Check to see if the ray origin is on the front or back facing side
of
+ // the cutting plane (the front facing side is cut away).
+ if (front_facing[new_i] = (Dot(plane_normal,
(e.ray.origin()-plane_point)) > 0.0)) {
+
+ // If plane_t is negative, the ray can't possibly hit the cut model.
+ // because the ray is pointing away from the plane.
+ if (plane_t[new_i] > 0.0) {
+
+ // If front facing, move the new ray to the cutting plane.
+
n.ray.set(e.ray.origin()+(e.ray.direction()*plane_t[new_i]),e.ray.direction());
+ new_rays.resetFlag(RayPacket::ConstantOrigin);
+
+
+ // Subtract the distance from the hit t.
+ n.hitInfo.reset( e.hitInfo.minT() - plane_t[new_i] );
+
+ ++new_i;
+ }
+ }
+ else {
+
+ // Otherwise if back facing, move the hit t in the hit record to the
plane
+ // (it will need to be moved back afterwards)
+ n.ray = e.ray;
+ //n.hitInfo.reset( plane_t[new_i] );
+ n.hitInfo.reset( e.hitInfo.minT() );
+
+ ++new_i;
+ }
+
+
+ }
+ }
+
+ // Check to see if all of the rays miss the bounds.
+ if (new_i == 0) {
+ return;
+ }
+
+ // Specify the number of new rays.
+ new_rays.resize( new_i );
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Intersect the new ray packet with the internal object.
+ internal_object->intersect( context, new_rays );
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Map the results back to the old rays.
+ for (new_i=rays.begin(); new_i<new_rays.end(); ++new_i) {
+
+ RayPacket::Element &n = new_rays.get(new_i);
+
+ // Check to see if the new ray hit something.
+ if (n.hitInfo.wasHit()) {
+
+ // Determine which old ray this maps to.
+ RayPacket::Element &e = rays.get( packet_map[new_i] );
+
+ // Check to see if the old ray is front or back facing.
+ if (front_facing[new_i]) {
+ // If so, then translate the hit t back into the old hit record.
+ if (e.hitInfo.hit( n.hitInfo.minT()+plane_t[new_i],
+ n.hitInfo.hitMaterial(),
+ n.hitInfo.hitPrimitive(),
+ n.hitInfo.hitTexCoordMapper() ))
+ e.hitInfo.copyScratchpad( n.hitInfo );
+ }
+ else {
+ // Otherwise, if the original ray is back facing check to see if the
hit
+ // is closer then the cutting plane.
+ if ((plane_t[new_i] < 0.0) || (n.hitInfo.minT() < plane_t[new_i])) {
+ if (e.hitInfo.hit( n.hitInfo.minT(),
+ n.hitInfo.hitMaterial(),
+ n.hitInfo.hitPrimitive(),
+ n.hitInfo.hitTexCoordMapper() ))
+ e.hitInfo.copyScratchpad( n.hitInfo );
+ }
+ }
+ }
+ }
}
Modified: branches/vertical/Model/MiscObjects/Difference.cc
==============================================================================
--- branches/vertical/Model/MiscObjects/Difference.cc (original)
+++ branches/vertical/Model/MiscObjects/Difference.cc Tue Jan 3 17:44:00
2006
@@ -37,13 +37,10 @@
rays.getAllFlags());
for(int i = rays.begin();i<rays.end();i++){
- RayPacket::Element& e = rays.get(i);
- RayPacket::Element& e1 = object1_rays.get(i);
- RayPacket::Element& e2 = object2_rays.get(i);
- e1.ray = e.ray;
- e2.ray = e.ray;
- e1.hitInfo.reset(e.hitInfo.minT());
- e2.hitInfo.reset(e.hitInfo.minT());
+ object1_rays.setRay(i, rays.getRay(i));
+ object2_rays.setRay(i, rays.getRay(i));
+ object1_rays.resetHit(i, rays.getMinT(i));
+ object2_rays.resetHit(i, rays.getMinT(i));
}
object1->intersect(context, object1_rays);
object2->intersect(context, object2_rays);
Modified: branches/vertical/Model/MiscObjects/Intersection.cc
==============================================================================
--- branches/vertical/Model/MiscObjects/Intersection.cc (original)
+++ branches/vertical/Model/MiscObjects/Intersection.cc Tue Jan 3 17:44:00
2006
@@ -40,26 +40,24 @@
rays.getAllFlags());
for(int i = rays.begin();i<rays.end();i++){
- RayPacket::Element& e = rays.get(i);
- RayPacket::Element& e1 = object1_rays.get(i);
- RayPacket::Element& e2 = object2_rays.get(i);
- e1.ray = e.ray;
- e2.ray = e.ray;
- e1.hitInfo.reset(e.hitInfo.minT());
- e2.hitInfo.reset(e.hitInfo.minT());
+ object1_rays.setRay(i, rays.getRay(i));
+ object2_rays.setRay(i, rays.getRay(i));
+ object1_rays.resetHit(i, rays.getMinT(i));
+ object2_rays.resetHit(i, rays.getMinT(i));
}
object1->intersect(context, object1_rays);
object2->intersect(context, object2_rays);
for(int i=rays.begin();i<rays.end();i++){
- RayPacket::Element& e = rays.get(i);
- RayPacket::Element& e1 = object1_rays.get(i);
- RayPacket::Element& e2 = object2_rays.get(i);
- if(e1.hitInfo.minT() > e2.hitInfo.minT()){
- e.hitInfo.hit(e1.hitInfo.minT(), e1.hitInfo.hitMaterial(),
- e1.hitInfo.hitPrimitive(),
e1.hitInfo.hitTexCoordMapper());
+ if(object1_rays.getMinT(i) > object2_rays.getMinT(i)){
+ rays.hit(i, object1_rays.getMinT(i),
+ object1_rays.getHitMaterial(i),
+ object1_rays.getHitPrimitive(i),
+ object1_rays.getHitTexCoordMapper(i));
} else {
- e.hitInfo.hit(e2.hitInfo.minT(), e2.hitInfo.hitMaterial(),
- e2.hitInfo.hitPrimitive(),
e2.hitInfo.hitTexCoordMapper());
+ rays.hit(i, object2_rays.getMinT(i),
+ object2_rays.getHitMaterial(i),
+ object2_rays.getHitPrimitive(i),
+ object2_rays.getHitTexCoordMapper(i));
}
}
}
Modified: branches/vertical/Model/Primitives/CMakeLists.txt
==============================================================================
--- branches/vertical/Model/Primitives/CMakeLists.txt (original)
+++ branches/vertical/Model/Primitives/CMakeLists.txt Tue Jan 3 17:44:00
2006
@@ -2,37 +2,37 @@
SET (Manta_Primitives_SRCS
#Primitives/BvhTriangleMesh.cc
#Primitives/BvhTriangleMesh.h
- #Primitives/Cone.cc
- #Primitives/Cone.h
+ Primitives/Cone.cc
+ Primitives/Cone.h
#Primitives/Cube.cc
#Primitives/Cube.h
#Primitives/Disk.cc
#Primitives/Disk.h
- #Primitives/HeavyTriangle.cc
- #Primitives/HeavyTriangle.h
- #Primitives/Heightfield.cc
- #Primitives/Heightfield.h
+ Primitives/HeavyTriangle.cc
+ Primitives/HeavyTriangle.h
+ Primitives/Heightfield.cc
+ Primitives/Heightfield.h
#Primitives/Hemisphere.cc
#Primitives/Hemisphere.h
Primitives/Parallelogram.cc
Primitives/Parallelogram.h
- #Primitives/ParticleBVH.cc
- #Primitives/ParticleBVH.h
+ Primitives/ParticleBVH.cc
+ Primitives/ParticleBVH.h
Primitives/Plane.cc
Primitives/Plane.h
Primitives/PrimitiveCommon.cc
Primitives/PrimitiveCommon.h
- #Primitives/Ring.cc
- #Primitives/Ring.h
+ Primitives/Ring.cc
+ Primitives/Ring.h
Primitives/Sphere.cc
Primitives/Sphere.h
- #Primitives/SuperEllipsoid.cc
- #Primitives/SuperEllipsoid.h
- #Primitives/TexTriangle.cc
- #Primitives/TexTriangle.h
- #Primitives/Triangle.cc
- #Primitives/Triangle.h
- #Primitives/VertexColoredTriangle.cc
- #Primitives/VertexColoredTriangle.h
+ Primitives/SuperEllipsoid.cc
+ Primitives/SuperEllipsoid.h
+ Primitives/TexTriangle.cc
+ Primitives/TexTriangle.h
+ Primitives/Triangle.cc
+ Primitives/Triangle.h
+ Primitives/VertexColoredTriangle.cc
+ Primitives/VertexColoredTriangle.h
)
Modified: branches/vertical/Model/Primitives/Cone.cc
==============================================================================
--- branches/vertical/Model/Primitives/Cone.cc (original)
+++ branches/vertical/Model/Primitives/Cone.cc Tue Jan 3 17:44:00 2006
@@ -28,7 +28,6 @@
void Cone::intersect(const RenderContext&, RayPacket& rays) const
{
if(rays.getFlag(RayPacket::ConstantOrigin)) {
- RayPacket::Element& e0 = rays.get(0);
Point Pa = bottom + Rb * (top - bottom) / (Rb-Rt);
Real btx = (top.x()-bottom.x())*(top.x()-bottom.x());
Real bty = (top.y()-bottom.y())*(top.y()-bottom.y());
@@ -43,11 +42,10 @@
Real sinA = lbt/hyp;
Real cosA2 = cosA*cosA;
Real sinA2 = sinA*sinA;
- Point P(xform * e0.ray.origin());
+ Point P(xform * rays.getOrigin(rays.begin()));
Vector dP(P - Pa);
- for(int i=0; i<rays.getSize(); i++) {
- RayPacket::Element& e = rays.get(i);
- Vector V(xform * e.ray.direction());
+ for(int i=rays.begin(); i<rays.end(); i++) {
+ Vector V(xform * rays.getDirection(i));
Vector tv = V;
Real dist_scale = tv.normalize();
Real a = ((cosA2*Dot(V-Dot(V,Va)*Va, V-Dot(V,Va)*Va))-
@@ -73,10 +71,10 @@
Real z1 = P.z()+t1*V.z();
Real z2 = P.z()+t2*V.z();
if(t1>0 && z1 > 0 && z1 < 1) {
- e.hitInfo.hit(t1/dist_scale, getMaterial(), this,
getTexCoordMapper());
+ rays.hit(i, t1/dist_scale, getMaterial(), this,
getTexCoordMapper());
}
if(t2>0 && z2 > 0 && z2 < 1) {
- e.hitInfo.hit(t2/dist_scale, getMaterial(), this,
getTexCoordMapper());
+ rays.hit(i, t2/dist_scale, getMaterial(), this,
getTexCoordMapper());
}
}
}
@@ -96,11 +94,10 @@
Real sinA = lbt/hyp;
Real cosA2 = cosA*cosA;
Real sinA2 = sinA*sinA;
- for(int i=0; i<rays.getSize(); i++) {
- RayPacket::Element& e = rays.get(i);
- Point P(xform * e.ray.origin());
+ for(int i=rays.begin(); i<rays.end(); i++) {
+ Point P(xform * rays.getOrigin(i));
Vector dP(P - Pa);
- Vector V(xform * e.ray.direction());
+ Vector V(xform * rays.getDirection(i));
Vector tv = V;
Real dist_scale = tv.normalize();
Real a = ((cosA2*Dot(V-Dot(V,Va)*Va, V-Dot(V,Va)*Va))-
@@ -125,10 +122,10 @@
Real z1 = P.z()+t1*V.z();
Real z2 = P.z()+t2*V.z();
if(t1>0 && z1 > 0 && z1 < 1) {
- e.hitInfo.hit(t1/dist_scale, getMaterial(), this,
getTexCoordMapper());
+ rays.hit(i, t1/dist_scale, getMaterial(), this,
getTexCoordMapper());
}
if(t2>0 && z2 > 0 && z2 < 1) {
- e.hitInfo.hit(t2/dist_scale, getMaterial(), this,
getTexCoordMapper());
+ rays.hit(i, t2/dist_scale, getMaterial(), this,
getTexCoordMapper());
}
}
}
@@ -139,8 +136,7 @@
void Cone::computeNormal(const RenderContext&, RayPacket& rays) const
{
rays.computeHitPositions();
- for(int i=0; i<rays.getSize(); i++) {
- RayPacket::Element& e = rays.get(i);
+ for(int i=rays.begin(); i<rays.end(); i++) {
#if 0
Vector xn(xform.project(e.hitPosition).asVector());
xn.z(0);
@@ -156,19 +152,15 @@
void Cone::computeTexCoords2(const RenderContext&,
RayPacket& rays) const
{
- for(int i=0;i<rays.getSize();i++){
- RayPacket::Element& e = rays.get(i);
- e.texCoords = e.hitInfo.scratchpad<Point>();
- }
+ for(int i=rays.begin();i<rays.end();i++)
+ rays.setTexCoords(i, rays.scratchpad<Point>(i));
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
void Cone::computeTexCoords3(const RenderContext&,
RayPacket& rays) const
{
- for(int i=0;i<rays.getSize();i++){
- RayPacket::Element& e = rays.get(i);
- e.texCoords = e.hitInfo.scratchpad<Point>();
- }
+ for(int i=rays.begin();i<rays.end();i++)
+ rays.setTexCoords(i, rays.scratchpad<Point>(i));
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
Modified: branches/vertical/Model/Primitives/Cone.h
==============================================================================
--- branches/vertical/Model/Primitives/Cone.h (original)
+++ branches/vertical/Model/Primitives/Cone.h Tue Jan 3 17:44:00 2006
@@ -9,7 +9,6 @@
namespace Manta
{
-
class Cone : public PrimitiveCommon, public TexCoordMapper {
public:
Cone(Material* mat, const Point& bottom, const Point& top, Real Rb, Real
Rt);
Modified: branches/vertical/Model/Primitives/Cube.cc
==============================================================================
--- branches/vertical/Model/Primitives/Cube.cc (original)
+++ branches/vertical/Model/Primitives/Cube.cc Tue Jan 3 17:44:00 2006
@@ -172,23 +172,21 @@
void Cube::computeNormal(const RenderContext&, RayPacket& rays) const
{
rays.computeHitPositions();
- for(int i=0; i<rays.getSize(); i++) {
-
- RayPacket::Element& e = rays.get(i);
-
- if (Abs(e.hitPosition.x() - bbox[0][0]) < 0.0001)
+ for(int i=rays.begin(); i<rays.end(); i++) {
+ Point hp = rays.getHitPosition(i);
+ if (Abs(hp.x() - bbox[0][0]) < 0.0001)
e.normal = Vector(-1, 0, 0 );
- else if (Abs(e.hitPosition.x() - bbox[1][0]) < 0.0001)
+ else if (Abs(hp.x() - bbox[1][0]) < 0.0001)
e.normal = Vector( 1, 0, 0 );
- else if (Abs(e.hitPosition.y() - bbox[0][1]) < 0.0001)
+ else if (Abs(hp.y() - bbox[0][1]) < 0.0001)
e.normal = Vector( 0,-1, 0 );
- else if (Abs(e.hitPosition.y() - bbox[1][1]) < 0.0001)
+ else if (Abs(hp.y() - bbox[1][1]) < 0.0001)
e.normal = Vector( 0, 1, 0 );
- else if (Abs(e.hitPosition.z() - bbox[0][2]) < 0.0001)
+ else if (Abs(hp.z() - bbox[0][2]) < 0.0001)
e.normal = Vector( 0, 0,-1 );
else
Modified: branches/vertical/Model/Primitives/Disk.cc
==============================================================================
--- branches/vertical/Model/Primitives/Disk.cc (original)
+++ branches/vertical/Model/Primitives/Disk.cc Tue Jan 3 17:44:00 2006
@@ -5,19 +5,28 @@
using namespace Manta;
using namespace std;
-Disk::Disk(Material* mat, const Point& center, const Vector& n, Real radius,
const Vector& axis) : PrimitiveCommon(mat, this), _c(center), _n(n),
_r(radius), _partial(false), _minTheta(0.0), _maxTheta(2.0 * M_PI) {
+Disk::Disk(Material* mat, const Point& center, const Vector& n,
+ Real radius, const Vector& axis)
+ : PrimitiveCommon(mat, this), _c(center), _n(n), _r(radius),
+ _partial(false), _minTheta(0.0), _maxTheta(2.0 * M_PI)
+{
_n.normalize();
_d = -Dot(_n, _c);
setupAxes(axis);
}
-Disk::Disk(Material* mat, const Point& center, const Vector& n, Real radius,
const Vector& axis, Real minTheta, Real maxTheta) : PrimitiveCommon(mat,
this), _c(center), _n(n), _r(radius), _partial(true), _minTheta(minTheta),
_maxTheta(maxTheta) {
+Disk::Disk(Material* mat, const Point& center, const Vector& n,
+ Real radius, const Vector& axis, Real minTheta, Real maxTheta)
+ : PrimitiveCommon(mat, this), _c(center), _n(n), _r(radius),
+ _partial(true), _minTheta(minTheta), _maxTheta(maxTheta)
+{
_n.normalize();
_d = -Dot(_n, _c);
setupAxes(axis);
}
-Disk::~Disk() {
+Disk::~Disk()
+{
}
void Disk::computeBounds(const PreprocessContext& /*context*/,
@@ -26,40 +35,33 @@
bbox.extendByDisc(_c, _n, _r);
}
-void Disk::intersect(const RenderContext& /*context*/, RayPacket& rays)
const {
- int i, numRays(rays.getSize());
- static const Real EPSILON(1.0e-6);
- Point rayO;
- Vector rayD;
- Real denom, t;
-
+void Disk::intersect(const RenderContext& /*context*/, RayPacket& rays) const
+{
if (rays.getFlag(RayPacket::ConstantOrigin)) {
- rayO = rays.get(0).ray.origin();
+ Point rayO = rays.getOrigin(rays.begin());
Real nDotO(Dot(_n, rayO));
- for (i = 0; i < numRays; i++) {
- RayPacket::Element& e(rays.get(i));
- rayD = e.ray.direction();
- denom = Dot(_n, rayD);
+ for (int i = rays.begin(); i < rays.end(); i++) {
+ Vector rayD = rays.getDirection(i);
+ Real denom = Dot(_n, rayD);
if ((denom < -EPSILON) || (denom > EPSILON)) {
- t = -(_d + nDotO) / denom;
+ Real t = -(_d + nDotO) / denom;
if (checkBounds(rayO + t * rayD)) {
- e.hitInfo.hit(t, getMaterial(), this, getTexCoordMapper());
+ rays.hit(i, t, getMaterial(), this, getTexCoordMapper());
}
}
}
} else {
- for (i = 0; i < numRays; i++) {
- RayPacket::Element& e(rays.get(i));
- rayD = e.ray.direction();
- rayO = e.ray.origin();
- denom = Dot(_n, rayD);
+ for (int i = rays.begin(); i < rays.end(); i++) {
+ Point rayD = rays.getDirection(i);
+ Vector rayO = rays.getOrigin(i);
+ Real denom = Dot(_n, rayD);
if ((denom < -EPSILON) || (denom > EPSILON)) {
- t = -(_d + Dot(_n, rayO)) / denom;
+ Real t = -(_d + Dot(_n, rayO)) / denom;
if (checkBounds(rayO + t * rayD)) {
- e.hitInfo.hit(t, getMaterial(), this, getTexCoordMapper());
+ rays.hit(i, t, getMaterial(), this, getTexCoordMapper());
}
}
}
@@ -68,37 +70,34 @@
void Disk::computeNormal(const RenderContext& /*context*/,
- RayPacket& rays) const {
- int i, numRays(rays.getSize());
-
- for (i = 0; i < numRays; i++) {
- RayPacket::Element& e(rays.get(i));
- e.normal = _n;
- }
+ RayPacket& rays) const
+{
+ for (int i = rays.begin(); i < rays.end(); i++)
+ rays.setNormal(i, _n);
// set flags to indicate packet now has unit normals
rays.setFlag(RayPacket::HaveNormals & RayPacket::HaveUnitNormals);
}
void Disk::computeTexCoords2(const RenderContext& /*context*/,
- RayPacket& rays) const {
- int i, numRays(rays.getSize());
- Point p;
-
+ RayPacket& rays) const
+{
// compute hit locations if necessary
- if (!(rays.getFlag(RayPacket::HaveHitPositions)))
- rays.computeHitPositions();
+ rays.computeHitPositions();
// set 2-d texture coordinates as returned by getTexCoords()
- for (i = 0; i < numRays; i++) {
- RayPacket::Element& e(rays.get(i));
- p = e.hitPosition;
- getTexCoords(p);
- e.texCoords = p;
+ for (int i = rays.begin(); i < rays.end(); i++) {
+ Point p = rays.getHitPosition(i);
+ Vector dir = p - _c;
+ Real dist = dir.normalize();
+ Real theta = Atan2(Dot(_v, dir), Dot(_u, dir));
+ if(theta < 0)
+ theta += ??PI;
+ rays.setTexCoords(i, dist/_r, (theta - minTheta) / (_maxTheta -
minTheta), 0);
}
// set flag to show texcoords have been computed
- rays.setFlag(RayPacket::HaveTexture2);
+ rays.setFlag(RayPacket::HaveTexture2 | RayPacket::HaveTexture3);
}
void Disk::computeTexCoords3(const RenderContext& /*context*/,
@@ -112,12 +111,17 @@
// set 3-d texture coordinates to be the hit locations
for (i = 0; i < numRays; i++) {
- RayPacket::Element& e(rays.get(i));
- e.texCoords = e.hitPosition;
+ Point p = rays.getHitPosition(i);
+ Vector dir = p - _c;
+ Real dist = dir.normalize();
+ Real theta = Atan2(Dot(_v, dir), Dot(_u, dir));
+ if(theta < 0)
+ theta += ??PI;
+ rays.setTexCoords(i, dist/_r, (theta - minTheta) / (_maxTheta -
minTheta), 0);
}
// set flag to show texcoords have been computed
- rays.setFlag(RayPacket::HaveTexture3);
+ rays.setFlag(RayPacket::HaveTexture3 | RayPacket::HaveTexture3);
}
/**
@@ -155,7 +159,8 @@
* close to the direction of the normal, then the z-axis is used instead of
the
* given vector.
**/
-void Disk::setupAxes(const Vector& axis) {
+void Disk::setupAxes(const Vector& axis)
+{
static const Real EPSILON(1.0e-6);
_u = axis;
@@ -172,22 +177,3 @@
_v.normalize();
_u = Cross(_v, _n);
}
-
-/**
- * getTexCoords(p)
- *
- * Assumes the point p lies within the disk. Returns the 2-D texture
- * coordinates in the disk in p.
- **/
-void Disk::getTexCoords(Point& p) const {
- Vector dir(p - _c);
- Real dist(dir.normalize()), theta;
-
- theta = atan2(Dot(_v, dir), Dot(_u, dir));
- if (theta < 0.0)
- theta = 2 * (Real)M_PI + theta;
-
- p = Point(dist / _r, (theta - _minTheta) / (_maxTheta - _minTheta), 0);
-}
-
-
Modified: branches/vertical/Model/Primitives/Disk.h
==============================================================================
--- branches/vertical/Model/Primitives/Disk.h (original)
+++ branches/vertical/Model/Primitives/Disk.h Tue Jan 3 17:44:00 2006
@@ -9,8 +9,10 @@
namespace Manta {
class Disk : public PrimitiveCommon, public TexCoordMapper {
public:
- Disk(Material* mat, const Point& center, const Vector& n, Real radius,
const Vector& axis);
- Disk(Material* mat, const Point& center, const Vector& n, Real radius,
const Vector& axis, Real minTheta, Real maxTheta);
+ Disk(Material* mat, const Point& center, const Vector& n,
+ Real radius, const Vector& axis);
+ Disk(Material* mat, const Point& center, const Vector& n,
+ Real radius, const Vector& axis, Real minTheta, Real maxTheta);
virtual ~Disk();
virtual void computeBounds(const PreprocessContext& context, BBox& bbox)
const;
Modified: branches/vertical/Model/Primitives/HeavyTriangle.cc
==============================================================================
--- branches/vertical/Model/Primitives/HeavyTriangle.cc (original)
+++ branches/vertical/Model/Primitives/HeavyTriangle.cc Tue Jan 3 17:44:00
2006
@@ -48,14 +48,14 @@
{
rays.normalizeDirections();
- for(int i=0; i<rays.getSize(); i++) {
- RayPacket::Element& e = rays.get(i);
+ for(int i=rays.begin(); i<rays.end(); i++) {
Real t, u, v;
- if (Intersection::intersectTriangleEdge( t, u, v, e.ray, edge[0],
edge[1], point ) &&
- e.hitInfo.hit( t, getMaterial(), this, getTexCoordMapper() )) {
+ if (Intersection::intersectTriangleEdge( t, u, v, rays.getRay(i),
+ edge[0], edge[1], point ) &&
+ rays.hit(i, t, getMaterial(), this, getTexCoordMapper() )) {
- TriangleHit& th = e.hitInfo.scratchpad<TriangleHit>();
+ TriangleHit& th = rays.scratchpad<TriangleHit>(i);
th.a = u;
th.b = v;
th.ptr = getTexCoordMapper();
@@ -74,18 +74,16 @@
}
else {
- for(int i=0; i<rays.getSize(); i++) {
-
- RayPacket::Element &e = rays.get(i);
-
- TriangleHit& th = e.hitInfo.scratchpad<TriangleHit>();
+ for(int i=rays.begin(); i<rays.end(); i++) {
+ TriangleHit& th = rays.scratchpad<TriangleHit>(i);
Real a = th.a;
Real b = th.b;
Real c = (1.0 - th.a - th.b);
- e.normal = (n[1]*a) + (n[2]*b) + (n[0]*c);
- e.normal.normalize();
+ Vector normal = (n[1]*a) + (n[2]*b) + (n[0]*c);
+ normal.normalize();
+ rays.setNormal(i, normal);
}
rays.setFlag(RayPacket::HaveUnitNormals);
@@ -93,8 +91,8 @@
}
-void HeavyTriangle::computeBounds(const PreprocessContext& context, BBox&
bbox) const {
-
+void HeavyTriangle::computeBounds(const PreprocessContext& context, BBox&
bbox) const
+{
bbox.extendByPoint( point );
bbox.extendByPoint( point+edge[0] );
bbox.extendByPoint( point+edge[1] );
Modified: branches/vertical/Model/Primitives/Heightfield.cc
==============================================================================
--- branches/vertical/Model/Primitives/Heightfield.cc (original)
+++ branches/vertical/Model/Primitives/Heightfield.cc Tue Jan 3 17:44:00
2006
@@ -2,6 +2,7 @@
#include <Model/Primitives/Heightfield.h>
#include <Interface/RayPacket.h>
#include <Core/Geometry/BBox.h>
+#include <Core/Math/Expon.h>
#include <Core/Math/MiscMath.h>
#include <Core/Math/MinMax.h>
#include <Core/Geometry/PointVector.h>
@@ -10,7 +11,7 @@
using namespace Manta;
using namespace std;
-
+using SCIRun::Sqrt;
#define ALLOCATE2DARRAY(array, nx, ny, type) \
{ \
@@ -82,22 +83,18 @@
Real tnear, tfar, zenter, texit, zexit;
bool validtcells[2];
- if (!(rays.getFlag(RayPacket::NormalizedDirections)))
- {
- rays.normalizeDirections();
- rays.setFlag(RayPacket::NormalizedDirections);
- }
+ rays.normalizeDirections();
+ rays.computeInverseDirections();
- for(int i=0; i<rays.getSize(); i++)
+ for(int i=rays.begin(); i<rays.end(); i++)
{
- RayPacket::Element & e = rays.get(i);
- Ray & ray = e.ray;
+ Ray ray = rays.getRay(i);
using Manta::Min;
using Manta::Max;
- rays.computeInverseDirections();
- Vector t1 = (m_Box.getMin() - ray.origin()) * e.inverseDirection;
- Vector t2 = (m_Box.getMax() - ray.origin()) * e.inverseDirection;
+ Vector id = rays.getInverseDirection(i);
+ Vector t1 = (m_Box.getMin() - ray.origin()) * id;
+ Vector t2 = (m_Box.getMax() - ray.origin()) * id;
Vector tn = Min(t1, t2);
Vector tf = Max(t1, t2);
tnear = tn.maxComponent();
@@ -108,8 +105,12 @@
using SCIRun::Min;
using SCIRun::Max;
- if (m_Box.getMin().x() < ray.origin().x() && m_Box.getMin().y() <
ray.origin().y() && m_Box.getMin().z() < ray.origin().z() &&
- m_Box.getMax().x() > ray.origin().x() && m_Box.getMax().y() >
ray.origin().y() && m_Box.getMax().z() < ray.origin().z() )
+ if (m_Box.getMin().x() < ray.origin().x()
+ && m_Box.getMin().y() < ray.origin().y()
+ && m_Box.getMin().z() < ray.origin().z()
+ && m_Box.getMax().x() > ray.origin().x()
+ && m_Box.getMax().y() > ray.origin().y()
+ && m_Box.getMax().z() < ray.origin().z() )
tnear = 0.0;
diagonal = m_Box.diagonal();
@@ -189,8 +190,8 @@
if (tcell > T_EPSILON && tcell < texit && u > 0.0 && u < 1.0 && v
>
0.0 && v < 1.0)
{
- if (e.hitInfo.hit(tnear + tcell, getMaterial(), this,
getTexCoordMapper()))
- e.hitInfo.scratchpad<Vector>() = Vector(- (z[1] + v*z[3]) /
cellSize[0], - (z[2] + u*z[3]) / cellSize[1], 1.0);
+ if (rays.hit(i, tnear + tcell, getMaterial(), this,
getTexCoordMapper()))
+ rays.scratchpad<Vector>(i) = Vector(- (z[1] + v*z[3]) /
cellSize[0], - (z[2] + u*z[3]) / cellSize[1], 1.0);
break;
}
}
@@ -201,7 +202,7 @@
{
Real tcells[2], a2, u, v, tcell;
- delta = sqrt(delta);
+ delta = Sqrt(delta);
a2 = 2 * a;
tcells[0] = (-b - delta) / a2;
@@ -221,8 +222,8 @@
v = sy + tcell * dy;
if (u > 0.0 && u < 1.0 && v > 0.0 && v < 1.0)
{
- if (e.hitInfo.hit(tnear + tcell, getMaterial(), this,
getTexCoordMapper()))
- e.hitInfo.scratchpad<Vector>() = Vector( - (z[1] + v*z[3])
/ cellSize[0], - (z[2] + u*z[3]) / cellSize[1], 1.0);
+ if (rays.hit(i, tnear + tcell, getMaterial(), this,
getTexCoordMapper()))
+ rays.scratchpad<Vector>(i) = Vector( - (z[1] + v*z[3]) /
cellSize[0], - (z[2] + u*z[3]) / cellSize[1], 1.0);
break;
}
}
@@ -248,17 +249,9 @@
void Heightfield::computeNormal(const RenderContext& /*context*/,
RayPacket& rays) const
{
- int i, numRays(rays.getSize());
-
- for (i=0; i<numRays; i++)
- {
- RayPacket::Element & e(rays.get(i));
- e.normal = e.hitInfo.scratchpad<Vector>();
- e.normal.normalize();
- }
-
- // set flags to indicate packet now has unit normals
- rays.setFlag(RayPacket::HaveNormals | RayPacket::HaveUnitNormals);
+ for (int i=rays.begin(); i<rays.end(); i++)
+ rays.setNormal(i, rays.scratchpad<Vector>(i));
+ rays.setFlag(RayPacket::HaveNormals);
}
Modified: branches/vertical/Model/Primitives/Hemisphere.cc
==============================================================================
--- branches/vertical/Model/Primitives/Hemisphere.cc (original)
+++ branches/vertical/Model/Primitives/Hemisphere.cc Tue Jan 3 17:44:00
2006
@@ -22,12 +22,6 @@
}
void Hemisphere::intersect(const RenderContext&, RayPacket& rays) const {
- int i, numRays(rays.getSize()),
- rpFlags(rays.getAllFlags() & (RayPacket::ConstantOrigin |
RayPacket::NormalizedDirections));
- Real a, b, c, disc, r, t;
- Point rayO;
- Vector rayD, tRayO;
-
if (rpFlags == (RayPacket::ConstantOrigin |
RayPacket::NormalizedDirections)) {
// Rays all have the same origin and unit-length directions
rayO = rays.get(0).ray.origin();
Modified: branches/vertical/Model/Primitives/ParticleBVH.cc
==============================================================================
--- branches/vertical/Model/Primitives/ParticleBVH.cc (original)
+++ branches/vertical/Model/Primitives/ParticleBVH.cc Tue Jan 3 17:44:00
2006
@@ -114,16 +114,17 @@
bound[ 0 ] = box.getMin().x(); bound[ 1 ] = box.getMax().x();
bound[ 2 ] = box.getMin().y(); bound[ 3 ] = box.getMax().y();
bound[ 4 ] = box.getMin().z(); bound[ 5 ] = box.getMax().z();
- for ( int ray = 0; ray < rays.getSize(); ++ray ) {
- RayPacket::Element &element( rays.get( ray ) );
+ for ( int ray = rays.begin(); ray < rays.end(); ++ray ) {
double maximum_minimum = T_EPSILON;
double minimum_maximum = element.hitInfo.minT();
- double x_minimum = ( bound[ element.sign[ 0 ] ] -
element.ray.origin().x() ) * element.inverseDirection.x();
- double x_maximum = ( bound[ 1 - element.sign[ 0 ] ] -
element.ray.origin().x() ) * element.inverseDirection.x();
- double y_minimum = ( bound[ 2 + element.sign[ 1 ] ] -
element.ray.origin().y() ) * element.inverseDirection.y();
- double y_maximum = ( bound[ 3 - element.sign[ 1 ] ] -
element.ray.origin().y() ) * element.inverseDirection.y();
- double z_minimum = ( bound[ 4 + element.sign[ 2 ] ] -
element.ray.origin().z() ) * element.inverseDirection.z();
- double z_maximum = ( bound[ 5 - element.sign[ 2 ] ] -
element.ray.origin().z() ) * element.inverseDirection.z();
+ Point O = rays.getOrigin(i);
+ Vector id = rays.getInverseDirection(i);
+ double x_minimum = ( bound[ element.sign[ 0 ] ] - O.x() ) *
element.inverseDirection.x();
+ double x_maximum = ( bound[ 1 - element.sign[ 0 ] ] - O.x() ) *
element.inverseDirection.x();
+ double y_minimum = ( bound[ 2 + element.sign[ 1 ] ] - O.y() ) *
element.inverseDirection.y();
+ double y_maximum = ( bound[ 3 - element.sign[ 1 ] ] - O.y() ) *
element.inverseDirection.y();
+ double z_minimum = ( bound[ 4 + element.sign[ 2 ] ] - O.z() ) *
element.inverseDirection.z();
+ double z_maximum = ( bound[ 5 - element.sign[ 2 ] ] - O.z() ) *
element.inverseDirection.z();
if ( minimum_maximum < x_minimum ||
maximum_minimum > x_maximum )
continue;
Modified: branches/vertical/Model/Primitives/PrimitiveCommon.h
==============================================================================
--- branches/vertical/Model/Primitives/PrimitiveCommon.h (original)
+++ branches/vertical/Model/Primitives/PrimitiveCommon.h Tue Jan 3
17:44:00 2006
@@ -9,11 +9,12 @@
class PrimitiveCommon : public Primitive {
public:
PrimitiveCommon(Material* material, const TexCoordMapper* tex = 0);
- PrimitiveCommon() { }; // Empty default constructor (used
for an array of some primitive)
+ // Empty default constructor (used for an array of some primitive)
+ PrimitiveCommon() { };
virtual ~PrimitiveCommon();
- // Note that this preprocess method sets up the activeLights
for the associated
- // material (not sure what happens for shared materials)
+ // Note that this preprocess method sets up the activeLights for the
associated
+ // material (not sure what happens for shared materials)
virtual void preprocess(const PreprocessContext&);
// Accessors.
@@ -22,7 +23,6 @@
void setMaterial( Material *material_ ) { material = material; }
Material *getMaterial() const { return material; }
-
private:
Material* material;
- [MANTA] r813 - in branches/vertical: Interface Model Model/MiscObjects Model/Primitives, sparker, 01/03/2006
Archive powered by MHonArc 2.6.16.