Thankfully it wasn't a problem with the data format, I was passing the

address of a ptr, not the address contained by the ptr. With that,
preliminary GPU octree interaction works perfectly
This commit is contained in:
MitchellHansen
2017-09-24 17:48:06 -07:00
parent 7c86c60f9f
commit 305ef917e0
6 changed files with 28 additions and 12 deletions

View File

@@ -2,7 +2,7 @@
#include "Logger.h"
Map::Map(uint32_t dimensions) {
Map::Map(uint32_t dimensions, Old_Map* array_map) {
if ((int)pow(2, (int)log2(dimensions)) != dimensions)
@@ -12,12 +12,26 @@ Map::Map(uint32_t dimensions) {
// randomly set the voxel data for testing
for (uint64_t i = 0; i < dimensions * dimensions * dimensions; i++) {
if (i % 2 == 0)
if (rand() % 10000 < 3)
voxel_data[i] = 1;
else
voxel_data[i] = 0;
}
char* char_array = array_map->get_voxel_data();
sf::Vector3i arr_dimensions = array_map->getDimensions();
for (int x = 0; x < dimensions; x++) {
for (int y = 0; y < dimensions; y++) {
for (int z = 0; z < dimensions; z++) {
char v = char_array[x + arr_dimensions.x * (y + arr_dimensions.z * z)];
if (v)
voxel_data[x + dimensions * (y + dimensions * z)] = 1;
}
}
}
sf::Vector3i dim3(dimensions, dimensions, dimensions);
Logger::log("Generating Octree", Logger::LogLevel::INFO);