# HG changeset patch # User Radek Brich # Date 1196755085 -3600 # Node ID 7e258561a6901ed6fe3b7a96f939acbd77ab09b3 # Parent 76b7bd51d64aa8569cc4c52fa59c8a54f45dc19a fix a bug in KdNode::subdivide and remove some extra variables realtime.cc - use SW surface diff -r 76b7bd51d64a -r 7e258561a690 ccdemos/realtime.cc --- a/ccdemos/realtime.cc Mon Dec 03 01:49:23 2007 +0100 +++ b/ccdemos/realtime.cc Tue Dec 04 08:58:05 2007 +0100 @@ -53,7 +53,7 @@ atexit(SDL_Quit); - screen = SDL_SetVideoMode(w, h, 32, SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE); + screen = SDL_SetVideoMode(w, h, 32, SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_RESIZABLE); if ( screen == NULL ) { fprintf(stderr, "Unable to set video mode: %s\n", SDL_GetError()); exit(1); diff -r 76b7bd51d64a -r 7e258561a690 src/kdtree.cc --- a/src/kdtree.cc Mon Dec 03 01:49:23 2007 +0100 +++ b/src/kdtree.cc Tue Dec 04 08:58:05 2007 +0100 @@ -186,7 +186,6 @@ const Float K = 1.4; // constant, K = cost of traversal / cost of ray-triangle intersection Float SAV = 2*(bbox.w()*bbox.h() + bbox.w()*bbox.d() + bbox.h()*bbox.d()); // surface area of node Float cost = SAV * (K + shapes->size()); // initial cost = non-split cost - SplitPos *splitpos = NULL; bool leaf = true; BBox lbb = bbox; BBox rbb = bbox; @@ -203,7 +202,7 @@ { leaf = false; cost = splitcost; - splitpos = &*spl; + split = spl->pos; } } @@ -236,10 +235,6 @@ f += 4; #endif - split = splitpos->pos; - Float lnum = splitpos->lnum; - Float rnum = splitpos->rnum; - // split this node delete shapes; children = new KdNode[2]; @@ -279,13 +274,13 @@ if (split - bbox.L.cell[axis] < bbox.H.cell[axis] - split) { // left subcell is smaller -> if not empty, put shape here - if (lnum) + if (children[0].shapes->size()) children[0].addShape(sh->shape); else children[1].addShape(sh->shape); } else { // right subcell is smaller - if (rnum) + if (children[1].shapes->size()) children[1].addShape(sh->shape); else children[0].addShape(sh->shape);