Cleaned up and pulled out some code into Map.cpp in order to start working on the meat of the *Correct* voxel traversal method as explained in the paper.
This commit is contained in:
@@ -11,6 +11,49 @@
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
|
||||
class Map {
|
||||
public:
|
||||
|
||||
Map(uint32_t dimensions);
|
||||
|
||||
// Sets a voxel in the 3D char dataset
|
||||
void setVoxel(sf::Vector3i position, int val);
|
||||
|
||||
// Gets a voxel at the 3D position in the octree
|
||||
char getVoxel(sf::Vector3i pos);
|
||||
|
||||
std::vector<std::tuple<sf::Vector3i, char>> Map::CastRayOctree(
|
||||
Octree *octree,
|
||||
sf::Vector3i* map_dim,
|
||||
sf::Vector2f* cam_dir,
|
||||
sf::Vector3f* cam_pos
|
||||
);
|
||||
|
||||
std::vector<std::tuple<sf::Vector3i, char>> Map::CastRayCharArray(
|
||||
char *map,
|
||||
sf::Vector3i* map_dim,
|
||||
sf::Vector2f* cam_dir,
|
||||
sf::Vector3f* cam_pos
|
||||
);
|
||||
|
||||
// Octree handles all basic octree operations
|
||||
Octree octree;
|
||||
|
||||
private:
|
||||
|
||||
// ======= DEBUG ===========
|
||||
int counter = 0;
|
||||
std::stringstream output_stream;
|
||||
|
||||
// The 3D char dataset that is generated at runtime. This will be replaced by two different interactions.
|
||||
// The first a file loading function that loads binary octree data.
|
||||
// The second being an import tool which will allow Any -> Octree transformation.
|
||||
char* voxel_data;
|
||||
// =========================
|
||||
|
||||
};
|
||||
|
||||
// Might possibly use this struct for hashing XYZ chunk values into a dict for storage and loading
|
||||
struct XYZHasher {
|
||||
std::size_t operator()(const sf::Vector3i& k) const {
|
||||
return ((std::hash<int>()(k.x)
|
||||
@@ -18,29 +61,3 @@ struct XYZHasher {
|
||||
^ (std::hash<int>()(k.z) << 1);
|
||||
}
|
||||
};
|
||||
|
||||
class Map {
|
||||
public:
|
||||
|
||||
Map(uint32_t dimensions);
|
||||
|
||||
void setVoxel(sf::Vector3i position, int val);
|
||||
bool getVoxelFromOctree(sf::Vector3i position);
|
||||
bool getVoxel(sf::Vector3i pos);
|
||||
|
||||
Octree octree;
|
||||
|
||||
bool test();
|
||||
|
||||
private:
|
||||
|
||||
// ======= DEBUG ===========
|
||||
int counter = 0;
|
||||
std::stringstream output_stream;
|
||||
// =========================
|
||||
|
||||
char* voxel_data;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user