still puzzling over how to do the voxel traversal
This commit is contained in:
33
src/Map.cpp
33
src/Map.cpp
@@ -122,9 +122,6 @@ uint64_t Map::generate_children(sf::Vector3i pos, int dim) {
|
||||
}
|
||||
else {
|
||||
|
||||
// 2339 is the iterative anomoly
|
||||
// 30454 is the stack anomoly
|
||||
|
||||
uint64_t tmp = 0;
|
||||
uint64_t child = 0;
|
||||
|
||||
@@ -171,12 +168,33 @@ uint64_t Map::generate_children(sf::Vector3i pos, int dim) {
|
||||
|
||||
void Map::generate_octree() {
|
||||
|
||||
generate_children(sf::Vector3i(0, 0, 0), OCT_DIM/2);
|
||||
// Launch the recursive generator at (0,0,0) as the first point
|
||||
// and the octree dimension as the initial block size
|
||||
uint64_t root_node = generate_children(sf::Vector3i(0, 0, 0), OCT_DIM/2);
|
||||
uint64_t tmp = 0;
|
||||
|
||||
PrettyPrintUINT64(root_node, &ss);
|
||||
ss << " " << OCT_DIM << " " << counter++ << std::endl;
|
||||
|
||||
if (IsLeaf(root_node)) {
|
||||
if (CheckLeafSign(root_node))
|
||||
SetBit(0 + 16, &tmp);
|
||||
|
||||
SetBit(0 + 16 + 8, &tmp);
|
||||
}
|
||||
|
||||
else {
|
||||
SetBit(0 + 16, &tmp);
|
||||
|
||||
}
|
||||
|
||||
tmp |= a.copy_to_stack(std::vector<uint64_t>{root_node});
|
||||
|
||||
DumpLog(&ss, "raw_output.txt");
|
||||
|
||||
a.print_block(0);
|
||||
|
||||
a.get_voxel(sf::Vector2i(0, 0));
|
||||
//a.get_voxel(sf::Vector2i(0, 0));
|
||||
}
|
||||
|
||||
void Map::load_unload(sf::Vector3i world_position) {
|
||||
@@ -229,6 +247,11 @@ void Map::setVoxel(sf::Vector3i world_position, int val) {
|
||||
|
||||
}
|
||||
|
||||
char Map::getVoxelFromOctree(sf::Vector3i position)
|
||||
{
|
||||
return a.get_voxel(position);
|
||||
}
|
||||
|
||||
char Map::getVoxel(sf::Vector3i pos){
|
||||
|
||||
return voxel_data[pos.x + OCT_DIM * (pos.y + OCT_DIM * pos.z)];
|
||||
|
||||
@@ -89,9 +89,11 @@ int main() {
|
||||
// =============================
|
||||
Map _map(sf::Vector3i(0, 0, 0));
|
||||
_map.generate_octree();
|
||||
|
||||
_map.a.get_voxel(sf::Vector3i(0, 0, 0));
|
||||
// =============================
|
||||
|
||||
return 0;
|
||||
//return 0;
|
||||
|
||||
/*GL_Testing t;
|
||||
t.compile_shader("../shaders/passthrough.frag", GL_Testing::Shader_Type::FRAGMENT);
|
||||
|
||||
Reference in New Issue
Block a user