diff --git a/include/Map.h b/include/Map.h index 2694f9f..1593491 100644 --- a/include/Map.h +++ b/include/Map.h @@ -70,10 +70,17 @@ public: return stack_pos; }; + + int get_idx(sf::Vector3i voxel_pos) { + + return 1; + + } + // 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::Vector2i position) { - + bool get_voxel(sf::Vector3i position) { + std::queue parent_stack; uint64_t head = stack.front()[stack_pos]; @@ -101,10 +108,13 @@ public: private: uint64_t cp_to_index(uint64_t descriptor) { - return descriptor >> 64 - 15; + + const uint64_t cp_mask = 0x0000000000007fff; + return descriptor & cp_mask; + }; - uint64_t is_leaf(uint64_t descriptor, ) + //uint64_t is_leaf(uint64_t descriptor, ) }; @@ -126,6 +136,8 @@ public: void setVoxel(sf::Vector3i position, int val); + char getVoxelFromOctree(sf::Vector3i position); + void moveLight(sf::Vector2f in); sf::Vector3f global_light; diff --git a/src/Map.cpp b/src/Map.cpp index f6cccec..b0c47b9 100644 --- a/src/Map.cpp +++ b/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{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)]; diff --git a/src/main.cpp b/src/main.cpp index 5832a8a..0d45553 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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);