Skip to content

Commit

Permalink
Try fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkashin committed Dec 19, 2024
1 parent 558b3e0 commit 8552ee3
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions src/main_lbvh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,28 +981,18 @@ int findSplit(const std::vector<morton_t> &codes, int i_begin, int i_end, int bi
return -1;
}

int start_bit = getBit(codes[i_begin], bit_index);
int end_bit = getBit(codes[i_end-1], bit_index);
int l = i_begin, r = i_end;
while (l != r) {
int m = (l + r) / 2;

if (start_bit == end_bit) {
return -1;
}

int low = i_begin + 1;
int high = i_end;
int first_split = -1;
while (low < high) {
int mid = (low + high) / 2;
int bit = getBit(codes[mid], bit_index);
if (bit != start_bit) {
first_split = mid;
high = mid;
if (getBit(codes[m], bit_index)) {
r = m;
} else {
low = mid + 1;
l = m + 1;
}
}

return first_split;
return l;
}

void buildLBVHRecursive(std::vector<Node> &nodes, const std::vector<morton_t> &codes, const std::vector<Point> &points, int i_begin, int i_end, int bit_index)
Expand Down

0 comments on commit 8552ee3

Please sign in to comment.