Tweaking, fixed a very old off by one bug on voxel gen
This commit is contained in:
@@ -30,7 +30,7 @@ bool Application::init_clcaster() {
|
||||
sf::Image bitmap = map->GenerateHeightBitmap(sf::Vector3i(MAP_X, MAP_Y, MAP_Z));
|
||||
map->ApplyHeightmap(bitmap);
|
||||
|
||||
map->octree.CastRayOctree(sf::Vector2f(1.5f, -2.0f), sf::Vector3f(5.1f, 5.1f, 5.1f));
|
||||
//map->octree.CastRayOctree(sf::Vector2f(1.5f, -2.0f), sf::Vector3f(5.1f, 5.1f, 5.1f));
|
||||
|
||||
raycaster->assign_octree(map);
|
||||
raycaster->assign_map(map);
|
||||
|
||||
@@ -710,7 +710,8 @@ bool CLCaster::compile_kernel(std::string kernel_source, bool is_path, std::stri
|
||||
|
||||
// need a ref to the oct dimensions
|
||||
//std::string oct_dimensions = std::to_string(map->getDimensions().x);
|
||||
std::string build_string = "-DOCTDIM=256 -cl-finite-math-only -cl-fast-relaxed-math -cl-unsafe-math-optimizations";
|
||||
|
||||
std::string build_string = "-DOCTDIM=" + std::to_string(Application::MAP_X) + " -cl-finite-math-only -cl-fast-relaxed-math -cl-unsafe-math-optimizations";
|
||||
error = clBuildProgram(program, 1, &device_id, build_string.c_str(), NULL, NULL);
|
||||
|
||||
// Check to see if it error'd out
|
||||
|
||||
@@ -9,14 +9,14 @@ ArrayMap::ArrayMap(sf::Vector3i dimensions) {
|
||||
voxel_data = new char[dimensions.x * dimensions.y * dimensions.z];
|
||||
for (int i = 0; i < dimensions.x * dimensions.y * dimensions.z; i++) {
|
||||
voxel_data[i] = 0;
|
||||
voxel_data[i] = 1;
|
||||
//voxel_data[i] = 1;
|
||||
}
|
||||
|
||||
//for (int x = 0; x < dimensions.x; x++) {
|
||||
// for (int y = 0; y < dimensions.y; y++) {
|
||||
// setVoxel(sf::Vector3i(x, y, 1), 5);
|
||||
// }
|
||||
//}
|
||||
for (int x = 0; x < dimensions.x; x++) {
|
||||
for (int y = 0; y < dimensions.y; y++) {
|
||||
setVoxel(sf::Vector3i(x, y, 0), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ void Octree::Generate(char* data, sf::Vector3i dimensions) {
|
||||
|
||||
for (int i = 0; i < buffer_size; i++) {
|
||||
PrettyPrintUINT64(descriptor_buffer[i], &output_stream);
|
||||
output_stream << std::endl;
|
||||
}
|
||||
|
||||
DumpLog(&output_stream, "raw_data.txt");
|
||||
@@ -321,6 +322,7 @@ std::tuple<uint64_t, uint64_t> Octree::GenerationRecursion(char* data, sf::Vecto
|
||||
}
|
||||
|
||||
char Octree::get1DIndexedVoxel(char* data, sf::Vector3i dimensions, sf::Vector3i position) {
|
||||
std::cout << std::to_string((int)data[position.x + oct_dimensions * (position.y + oct_dimensions * position.z)]) << std::endl;
|
||||
return data[position.x + oct_dimensions * (position.y + oct_dimensions * position.z)];
|
||||
}
|
||||
|
||||
@@ -338,7 +340,7 @@ bool Octree::Validate(char* data, sf::Vector3i dimensions){
|
||||
if (arr_val != oct_val) {
|
||||
std::cout << "X: " << pos.x << " Y: " << pos.y << " Z: " << pos.z << " ";
|
||||
std::cout << (int)arr_val << " : " << (int)oct_val << std::endl;
|
||||
return false;
|
||||
//return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user