From 32e58d516aff06539d01554b7df9345807f5dd21 Mon Sep 17 00:00:00 2001 From: MitchellHansen Date: Thu, 29 Jun 2017 01:52:30 -0700 Subject: [PATCH] bringing up to date --- src/main.cpp | 6 +++--- src/map/Map.cpp | 13 +++++++------ src/map/Octree.cpp | 21 ++++++++++++--------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 33201ac..d3a8055 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -92,10 +92,10 @@ int main() { // ============================= Map _map(32); - _map.test(); + //_map.test(); _map.dump_logs(); - //std::cin.get(); - //return 0; + std::cin.get(); + return 0; // ============================= sf::RenderWindow window(sf::VideoMode(WINDOW_X, WINDOW_Y), "SFML"); diff --git a/src/map/Map.cpp b/src/map/Map.cpp index f5f0b7c..3129d5e 100644 --- a/src/map/Map.cpp +++ b/src/map/Map.cpp @@ -29,13 +29,13 @@ uint64_t Map::generate_children(sf::Vector3i pos, int voxel_scale) { // The 8 subvoxel coords starting from the 1th direction, the direction of the origin of the 3d grid // XY, Z++, XY std::vector v = { - sf::Vector3i(pos.x , pos.y , pos.z), - sf::Vector3i(pos.x + voxel_scale, pos.y , pos.z), - sf::Vector3i(pos.x , pos.y + voxel_scale, pos.z), + sf::Vector3i(pos.x , pos.y , pos.z), + sf::Vector3i(pos.x + voxel_scale, pos.y , pos.z), + sf::Vector3i(pos.x , pos.y + voxel_scale, pos.z), sf::Vector3i(pos.x + voxel_scale, pos.y + voxel_scale, pos.z), - sf::Vector3i(pos.x , pos.y , pos.z + voxel_scale), - sf::Vector3i(pos.x + voxel_scale, pos.y , pos.z + voxel_scale), - sf::Vector3i(pos.x , pos.y + voxel_scale, pos.z + voxel_scale), + sf::Vector3i(pos.x , pos.y , pos.z + voxel_scale), + sf::Vector3i(pos.x + voxel_scale, pos.y , pos.z + voxel_scale), + sf::Vector3i(pos.x , pos.y + voxel_scale, pos.z + voxel_scale), sf::Vector3i(pos.x + voxel_scale, pos.y + voxel_scale, pos.z + voxel_scale) }; @@ -66,6 +66,7 @@ uint64_t Map::generate_children(sf::Vector3i pos, int voxel_scale) { uint64_t child_descriptor = 0; std::vector descriptor_array; + std::vector index_array; // Generate down the recursion, returning the descriptor of the current node for (int i = 0; i < v.size(); i++) { diff --git a/src/map/Octree.cpp b/src/map/Octree.cpp index d53791e..9728677 100644 --- a/src/map/Octree.cpp +++ b/src/map/Octree.cpp @@ -13,16 +13,19 @@ Octree::Octree() { // Copy to stack enables the hybrid depth-breadth first tree by taking // a list of valid non-leaf child descriptors contained under a common parent. +// It takes the list of children, and the current level in the voxel hierarchy. +// It returns the index to the first element of the + uint64_t Octree::copy_to_stack(std::vector children, unsigned int voxel_scale) { - //// Check for the 15 bit boundry - //if (stack_pos - children.size() > stack_pos) { - // global_pos = stack_pos; - // stack_pos = 0x8000; - //} - //else { - // stack_pos -= children.size(); - //} + // Check for the 15 bit boundry + if (stack_pos - children.size() > stack_pos) { + global_pos = stack_pos; + stack_pos = 0x8000; + } + else { + stack_pos -= children.size(); + } // Copy to stack needs to keep track of an "anchor_stack" which will hopefully facilitate // relative pointer generation for items being copied to the stack @@ -35,7 +38,7 @@ uint64_t Octree::copy_to_stack(std::vector children, unsigned int voxe - stack_pos -= children.size(); + //stack_pos -= children.size(); memcpy(&descriptor_buffer[stack_pos + global_pos], children.data(), children.size() * sizeof(uint64_t)); // Return the bitmask encoding the index of that value