Added a struct to pass away from get_voxel
This commit is contained in:
@@ -29,6 +29,18 @@ struct XYZHasher {
|
||||
}
|
||||
};
|
||||
|
||||
struct oct_state {
|
||||
|
||||
int parent_stack_position = 0;
|
||||
uint64_t parent_stack[32] = { 0 };
|
||||
|
||||
uint8_t scale = 0;
|
||||
uint8_t idx_stack[32] = { 0 };
|
||||
|
||||
uint64_t current_descriptor;
|
||||
|
||||
};
|
||||
|
||||
class Octree {
|
||||
public:
|
||||
Octree();
|
||||
@@ -36,6 +48,7 @@ public:
|
||||
|
||||
uint64_t *blob = new uint64_t[100000];
|
||||
|
||||
uint64_t root_index = 0;
|
||||
uint64_t stack_pos = 0x8000;
|
||||
uint64_t global_pos = 0;
|
||||
|
||||
@@ -98,23 +111,10 @@ private:
|
||||
std::stringstream output_stream;
|
||||
// =========================
|
||||
|
||||
|
||||
uint64_t generate_children(sf::Vector3i pos, int dim);
|
||||
|
||||
char* voxel_data = new char[OCT_DIM * OCT_DIM * OCT_DIM];
|
||||
|
||||
double* height_map;
|
||||
|
||||
// 2^k
|
||||
int chunk_radius = 6;
|
||||
|
||||
sf::Vector3i world_to_chunk(sf::Vector3i world_coords) {
|
||||
return sf::Vector3i(
|
||||
world_coords.x / CHUNK_DIM + 1,
|
||||
world_coords.y / CHUNK_DIM + 1,
|
||||
world_coords.z / CHUNK_DIM + 1
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -125,7 +125,6 @@ inline sf::Vector3f FixOrigin(sf::Vector3f base, sf::Vector3f head) {
|
||||
return head - base;
|
||||
}
|
||||
|
||||
|
||||
inline sf::Vector3f Normalize(sf::Vector3f in) {
|
||||
|
||||
float multiplier = sqrt(in.x * in.x + in.y * in.y + in.z * in.z);
|
||||
@@ -138,7 +137,6 @@ inline sf::Vector3f Normalize(sf::Vector3f in) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline float DotProduct(sf::Vector3f a, sf::Vector3f b){
|
||||
return a.x * b.x + a.y * b.y + a.z * b.z;
|
||||
}
|
||||
@@ -208,61 +206,6 @@ inline void DumpLog(std::stringstream* ss, std::string file_name) {
|
||||
|
||||
}
|
||||
|
||||
inline std::string sfml_get_input(sf::RenderWindow *window) {
|
||||
|
||||
std::stringstream ss;
|
||||
|
||||
sf::Event event;
|
||||
while (window->pollEvent(event)) {
|
||||
if (event.type == sf::Event::TextEntered) {
|
||||
ss << event.text.unicode;
|
||||
}
|
||||
|
||||
else if (event.type == sf::Event::KeyPressed) {
|
||||
if (event.key.code == sf::Keyboard::Return) {
|
||||
return ss.str();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline std::vector<float> sfml_get_float_input(sf::RenderWindow *window) {
|
||||
|
||||
std::stringstream ss;
|
||||
|
||||
sf::Event event;
|
||||
while (true) {
|
||||
|
||||
if (window->pollEvent(event)) {
|
||||
|
||||
if (event.type == sf::Event::TextEntered) {
|
||||
if (event.text.unicode > 47 && event.text.unicode < 58 || event.text.unicode == 32)
|
||||
ss << static_cast<char>(event.text.unicode);
|
||||
}
|
||||
|
||||
else if (event.type == sf::Event::KeyPressed) {
|
||||
|
||||
if (event.key.code == sf::Keyboard::Return) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::istream_iterator<std::string> begin(ss);
|
||||
std::istream_iterator<std::string> end;
|
||||
std::vector<std::string> vstrings(begin, end);
|
||||
|
||||
std::vector<float> ret;
|
||||
|
||||
for (auto i: vstrings) {
|
||||
ret.push_back(std::stof(i));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include <intrin.h>
|
||||
# define __builtin_popcount _mm_popcnt_u32
|
||||
|
||||
Reference in New Issue
Block a user