equal
deleted
inserted
replaced
105 const Float K = 1.4f; // constant, K = cost of traversal / cost of ray-triangle intersection |
105 const Float K = 1.4f; // constant, K = cost of traversal / cost of ray-triangle intersection |
106 Float SAV = (bounds.w()*bounds.h() + // surface area of node |
106 Float SAV = (bounds.w()*bounds.h() + // surface area of node |
107 bounds.w()*bounds.d() + bounds.h()*bounds.d()); |
107 bounds.w()*bounds.d() + bounds.h()*bounds.d()); |
108 Float cost = SAV * (K + shapes->size()); // initial cost = non-split cost |
108 Float cost = SAV * (K + shapes->size()); // initial cost = non-split cost |
109 |
109 |
110 vector<ShapeBound>::iterator edge, splitedge = edges[0].end(); |
|
111 int axis = 0; |
110 int axis = 0; |
|
111 vector<ShapeBound>::iterator edge, splitedge = edges[axis].end(); |
112 for (int ax = 0; ax < 3; ax++) |
112 for (int ax = 0; ax < 3; ax++) |
113 { |
113 { |
114 int lnum = 0, rnum = (int)shapes->size(); |
114 int lnum = 0, rnum = (int)shapes->size(); |
115 BBox lbb = bounds; |
115 BBox lbb = bounds; |
116 BBox rbb = bounds; |
116 BBox rbb = bounds; |
136 if (!edge->end) |
136 if (!edge->end) |
137 lnum++; |
137 lnum++; |
138 } |
138 } |
139 } |
139 } |
140 |
140 |
141 // we actually need to compare with edges[0].end(), but |
|
142 // MSVC does not allow comparison of iterators from differen instances of vector |
|
143 // it's OK this way, because axis will be zero if no good split was found |
|
144 if (splitedge == edges[axis].end()) |
141 if (splitedge == edges[axis].end()) |
145 { |
142 { |
146 node->setLeaf(); |
143 node->setLeaf(); |
147 return; |
144 return; |
148 } |
145 } |
554 } |
551 } |
555 |
552 |
556 void KdTree::recursive_load(istream &st, KdNode *node) |
553 void KdTree::recursive_load(istream &st, KdNode *node) |
557 { |
554 { |
558 string s; |
555 string s; |
559 istringstream is; |
|
560 |
556 |
561 getline(st, s, ','); |
557 getline(st, s, ','); |
562 trim(s); |
558 trim(s); |
563 |
559 |
564 if (s.compare("(s") == 0) |
560 if (s.compare("(s") == 0) |