From 0c9ef2ae6ad2a4ffe513948a6e74ab8cf9ab8327 Mon Sep 17 00:00:00 2001 From: MitchellHansen Date: Mon, 20 Feb 2017 22:49:41 -0800 Subject: [PATCH] It seems that the octree has been built correctly. Going to use bitset to count children, not sure how I'm going to determine what quadrants they lie in. Perhaps masks? --- include/Map.h | 9 ++++++++- include/util.hpp | 23 ----------------------- src/Map.cpp | 5 ----- src/main.cpp | 8 +++++--- 4 files changed, 13 insertions(+), 32 deletions(-) diff --git a/include/Map.h b/include/Map.h index 7c730c5..4dc7019 100644 --- a/include/Map.h +++ b/include/Map.h @@ -29,6 +29,10 @@ struct XYZHasher { } }; + + + + class Octree { public: Octree() { @@ -89,8 +93,11 @@ public: uint64_t index = cp_to_index(head); - uint64_t child = block_stack.front()[index]; + uint64_t child1 = block_stack.front()[index]; + uint64_t child2 = block_stack.front()[index+1]; + std::bitset<64> t(index); + auto val = t.count(); return true; } diff --git a/include/util.hpp b/include/util.hpp index 28015d4..4be91fd 100644 --- a/include/util.hpp +++ b/include/util.hpp @@ -272,26 +272,3 @@ inline std::vector sfml_get_float_input(sf::RenderWindow *window) { } -//struct Light { -// sf::Vector4f rgbi; -// -// // I believe that Vector3's get padded to Vector4's. Give them a non-garbage value -// sf::Vector3f position; -// -// sf::Vector3f direction_cartesian; -// -// void look_at_center() { -// direction_cartesian = SphereToCart(CartToNormalizedSphere(sf::Vector3f(256, 256, 256) - position)); -// }; -// -// void orbit_around_center(double time) { -// position = sf::Vector3f( -// position.x * cos(time/1000) - position.y * sin(time/1000), -// position.x * sin(time/1000) + position.y * cos(time/1000), -// position.z -// ); -// -// look_at_center(); -// }; -//}; - diff --git a/src/Map.cpp b/src/Map.cpp index b0c47b9..3432a74 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -1,11 +1,6 @@ #include "Map.h" -int BitCount(unsigned int u) { - unsigned int uCount; - uCount = u - ((u >> 1) & 033333333333) - ((u >> 2) & 011111111111); - return ((uCount + (uCount >> 3)) & 030707070707) % 63; -} void SetBit(int position, char* c) { *c |= (uint64_t)1 << position; diff --git a/src/main.cpp b/src/main.cpp index 0d45553..8f454ee 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -83,8 +83,7 @@ int main() { // Currently just close it right away for debug ni.stop_listening_for_clients(); - sf::RenderWindow window(sf::VideoMode(WINDOW_X, WINDOW_Y), "SFML"); - window.setMouseCursorVisible(false); + // ============================= Map _map(sf::Vector3i(0, 0, 0)); @@ -93,7 +92,10 @@ int main() { _map.a.get_voxel(sf::Vector3i(0, 0, 0)); // ============================= - //return 0; + return 0; + + sf::RenderWindow window(sf::VideoMode(WINDOW_X, WINDOW_Y), "SFML"); + window.setMouseCursorVisible(false); /*GL_Testing t; t.compile_shader("../shaders/passthrough.frag", GL_Testing::Shader_Type::FRAGMENT);