Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1010 - trunk/Model/Groups
- Date: Fri, 21 Apr 2006 14:00:28 -0600 (MDT)
Author: bigler
Date: Fri Apr 21 14:00:27 2006
New Revision: 1010
Modified:
trunk/Model/Groups/KDTree2.cc
trunk/Model/Groups/KDTree2.h
Log:
Well, this code does work if you are using a new enough compiler. Per
Ingo's suggestion, I tried to make as many things as I could const.
Fixed a typo allocating the triangle indicies (it just allocated too
much memory).
Modified: trunk/Model/Groups/KDTree2.cc
==============================================================================
--- trunk/Model/Groups/KDTree2.cc (original)
+++ trunk/Model/Groups/KDTree2.cc Fri Apr 21 14:00:27 2006
@@ -39,8 +39,11 @@
#include <stack>
+#include <iostream>
+
using namespace Manta;
using namespace SCIRun;
+using namespace std;
KDTree2::KDTree2(Material* material_in)
: PrimitiveCommon( material_in ),
@@ -244,15 +247,16 @@
const float invDir[3] = { data->inverseDirection[0][which],
data->inverseDirection[1][which],
data->inverseDirection[2][which] };
- Node* node = start_node;
+ const Node* node = const_cast<const Node*>(start_node);
do {
while (node->type != 3 /* leaf */ ) {
- int axis = node->type;
- float dist = (node->split - origin[axis]) * invDir[axis];
+ const int axis = node->type;
+
+ const float dist = (node->split - origin[axis]) * invDir[axis];
- Node* nearChild = node->leftChild + ray_signs[axis];
- Node* farChild = node->leftChild + (1-ray_signs[axis]);
+ const Node* const nearChild = node->leftChild + ray_signs[axis];
+ const Node* const farChild = node->leftChild + (1-ray_signs[axis]);
if (dist > far) // if interval (far end) is infront of the plane
{
@@ -324,15 +328,11 @@
if ( mue < 0.f || mue + lambda > 1.f )
continue;
+ // Is this the nearest triangle?
if (f < minT) {
hit_tri = tri_indices[tri_index];
minT = f;
}
-// if (rays.hit(which, f, getMaterial(), this, getTexCoordMapper()))
{
-// // if (tri_index > 11)
-// // fprintf(stderr, "hit_tri = %d, tri_index = %d\n", hit_tri,
tri_index);
-// hit_tri = tri_indices[tri_index];
-// }
}
if (hit_tri >= 0) {
if (rays.hit(which, minT, getMaterial(), this, getTexCoordMapper()))
{
@@ -391,7 +391,7 @@
int
KDTree2::reserveTriangleIndices(unsigned int num_tri_indices_in) {
tri_indices =
- static_cast<unsigned int*>(malloc(num_tri_indices_in*sizeof(Triangle)));
+ static_cast<unsigned int*>(malloc(num_tri_indices_in*sizeof(unsigned
int)));
if (tri_indices) {
num_tri_indices = num_tri_indices_in;
return 0;
Modified: trunk/Model/Groups/KDTree2.h
==============================================================================
--- trunk/Model/Groups/KDTree2.h (original)
+++ trunk/Model/Groups/KDTree2.h Fri Apr 21 14:00:27 2006
@@ -127,7 +127,7 @@
float minDist, float maxDist) const;
struct Stack {
- Node* node;
+ const Node* node;
float far;
};
};
- [MANTA] r1010 - trunk/Model/Groups, bigler, 04/21/2006
Archive powered by MHonArc 2.6.16.