|
|
@ -42,6 +42,8 @@ public:
|
|
|
|
for (int i = 0; i < 0x8000; i++) {
|
|
|
|
for (int i = 0; i < 0x8000; i++) {
|
|
|
|
block_stack.back()[i] = 0;
|
|
|
|
block_stack.back()[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
~Octree() {};
|
|
|
|
~Octree() {};
|
|
|
@ -81,17 +83,49 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This might need to be a recursive function. But it needs to be easily ported to
|
|
|
|
|
|
|
|
// OpenCL C. Might spend some time thinking about how to do this in a linear algorithm
|
|
|
|
|
|
|
|
bool get_voxel(sf::Vector3i position) {
|
|
|
|
bool get_voxel(sf::Vector3i position) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Init the parent stack and push the head node
|
|
|
|
std::queue<uint64_t> parent_stack;
|
|
|
|
std::queue<uint64_t> parent_stack;
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t head = block_stack.front()[stack_pos];
|
|
|
|
uint64_t head = block_stack.front()[stack_pos];
|
|
|
|
|
|
|
|
|
|
|
|
parent_stack.push(head);
|
|
|
|
parent_stack.push(head);
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t index = cp_to_index(head);
|
|
|
|
// Get the index of the first child of the head node
|
|
|
|
|
|
|
|
uint64_t index = head & child_pointer_mask;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Init the idx stack
|
|
|
|
|
|
|
|
std::vector<std::bitset<3>> scale_stack(log2(OCT_DIM));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set our initial dimension and the position we use to keep track what oct were in
|
|
|
|
|
|
|
|
int dimension = OCT_DIM;
|
|
|
|
|
|
|
|
sf::Vector3i quad_position(0, 0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (dimension > 1) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Do the logic steps to find which sub oct we step down into
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (position.x >= (dimension / 2) + quad_position.x) {
|
|
|
|
|
|
|
|
quad_position.x += (dimension / 2);
|
|
|
|
|
|
|
|
scale_stack.at(log2(OCT_DIM) - log2(dimension)).set(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (position.y >= (dimension / 2) + quad_position.y) {
|
|
|
|
|
|
|
|
quad_position.y += (dimension / 2);
|
|
|
|
|
|
|
|
scale_stack.at(log2(OCT_DIM) - log2(dimension)).set(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (position.z >= (dimension / 2) + quad_position.z) {
|
|
|
|
|
|
|
|
quad_position.z += (dimension / 2);
|
|
|
|
|
|
|
|
scale_stack.at(log2(OCT_DIM) - log2(dimension)).set(2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set the new dimension
|
|
|
|
|
|
|
|
dimension /= 2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t child1 = block_stack.front()[index];
|
|
|
|
uint64_t child1 = block_stack.front()[index];
|
|
|
|
uint64_t child2 = block_stack.front()[index+1];
|
|
|
|
uint64_t child2 = block_stack.front()[index+1];
|
|
|
@ -114,14 +148,14 @@ public:
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t cp_to_index(uint64_t descriptor) {
|
|
|
|
const uint64_t child_pointer_mask = 0x0000000000007fff;
|
|
|
|
|
|
|
|
const uint64_t far_bit_mask = 0x8000;
|
|
|
|
|
|
|
|
const uint64_t valid_mask = 0xFF0000;
|
|
|
|
|
|
|
|
const uint64_t leaf_mask = 0xFF000000;
|
|
|
|
|
|
|
|
const uint64_t contour_pointer_mask = 0xFFFFFF00000000;
|
|
|
|
|
|
|
|
const uint64_t contour_mask = 0xFF00000000000000;
|
|
|
|
|
|
|
|
|
|
|
|
const uint64_t cp_mask = 0x0000000000007fff;
|
|
|
|
|
|
|
|
return descriptor & cp_mask;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//uint64_t is_leaf(uint64_t descriptor, )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|