Skip to content

Commit

Permalink
hex
Browse files Browse the repository at this point in the history
  • Loading branch information
sellitforcache committed Apr 10, 2016
1 parent 06411d2 commit b1acaa7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
16 changes: 8 additions & 8 deletions benchmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ int main(int argc, char* argv[]){
bc = 1;
runtype = "criticality";
if(card0name.compare(argv[2])==0){
N = int(1e6);
N = int(1e5);
dev = 0;
}
else if(card1name.compare(argv[2])==0){
Expand Down Expand Up @@ -232,7 +232,7 @@ int main(int argc, char* argv[]){
bc = 2;
runtype = "criticality";
if(card0name.compare(argv[2])==0){
N = int(1e6);
N = int(1e5);
dev = 0;
}
else if(card1name.compare(argv[2])==0){
Expand Down Expand Up @@ -398,7 +398,7 @@ int main(int argc, char* argv[]){
bc = 1;
runtype = "fixed";
if(card0name.compare(argv[2])==0){
N = int(1e6);
N = int(1e5);
dev = 0;
}
else if(card1name.compare(argv[2])==0){
Expand Down Expand Up @@ -603,7 +603,7 @@ int main(int argc, char* argv[]){
bc = 1;
runtype = "criticality";
if(card0name.compare(argv[2])==0){
N = int(1e6);
N = int(1e5);
dev = 0;
}
else if(card1name.compare(argv[2])==0){
Expand Down Expand Up @@ -703,7 +703,7 @@ int main(int argc, char* argv[]){
bc = 1;
runtype = "criticality";
if(card0name.compare(argv[2])==0){
N = int(1e6);
N = int(1e5);
dev = 0;
}
else if(card1name.compare(argv[2])==0){
Expand Down Expand Up @@ -771,7 +771,7 @@ int main(int argc, char* argv[]){
bc = 1;
runtype = "fixed";
if(card0name.compare(argv[2])==0){
N = int(1e6);
N = int(1e5);
dev = 0;
}
else if(card1name.compare(argv[2])==0){
Expand Down Expand Up @@ -822,7 +822,7 @@ int main(int argc, char* argv[]){
geom.add_transform(prim_id,400,0,0,0,0,0);

//water
type=0;
type=2;
material=2;
mins[0]=-45.0;
mins[1]=-45.0;
Expand Down Expand Up @@ -924,7 +924,7 @@ int main(int argc, char* argv[]){
bc = 2;
runtype = "criticality";
if(card0name.compare(argv[2])==0){
N = int(1e6);
N = int(1e5);
dev = 0;
}
else if(card1name.compare(argv[2])==0){
Expand Down
17 changes: 11 additions & 6 deletions hex_mesh.cu
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ RT_PROGRAM void intersect(int object_dex)

// init
//float max_diff = 2.0*sqrtf(2.0*maxs.x*maxs.x+maxs.z*maxs.z); // BB chord, maxium difference possible in t values
float t0=-1e34, t1=1e34, sgn=1.0, this_t, t[8], new_t=0.0;
float t0=-1e34, t1=1e34, sgn=1.0, this_t, t[8], new_t=0.0, closest_xy_t=0.0;
int d[8], k=0;
float3 this_int, norm0, norm1, norms[8], pts[8];
bool report=true, check_second=true;
Expand Down Expand Up @@ -122,22 +122,27 @@ RT_PROGRAM void intersect(int object_dex)
pts[7] = make_float3( x2, 0.0 , maxs.z ); // 1

// calculate t for closest point in xy (this point is only good for xy!)
closest_xy_t = -(xformed_origin.x*ray.direction.x + xformed_origin.y*ray.direction.y)/sqrtf(ray.direction.x*ray.direction.x + ray.direction.y*ray.direction.y);
closest_xy_t = -(xformed_origin.x*ray.direction.x + xformed_origin.y*ray.direction.y) / sqrtf(ray.direction.x*ray.direction.x + ray.direction.y*ray.direction.y);

// get two xy points that are closest to origin
// t1 is nearest positive wrt closest_xy_t, t0 is nearest negative
// t1 is nearest positive w.r.t. closest_xy_t, t0 is nearest negative
k=0;
for (int i=2; i<8; i++) {
for (int i=0; i<8; i++) {
// calculate intersection t value
this_t = get_t(norms[i],ray.direction,(pts[i]-xformed_origin));
// calculate intersection point from t value
this_int = ray.direction * this_t + xformed_origin;
// find the nearest points to closest_xy_t
new_t = this_t - closest_xy_t;
if( new_t < 0.0) {
if(new_t > t0){t0=this_t;}
if(new_t > t0){
t0=this_t;
}
}
else{
if(new_t < t1){t1=this_t;}
if(new_t < t1){
t1=this_t;
}
}
}

Expand Down

0 comments on commit b1acaa7

Please sign in to comment.