Added some debug functions

This commit is contained in:
MitchellHansen
2016-12-18 17:19:16 -08:00
parent 97545e6cec
commit 8a9237ce50
3 changed files with 42 additions and 8 deletions

View File

@@ -58,6 +58,11 @@ public:
// if not, allocate a new block and paste them at the bottom
// Make sure to reset the position
for (int i = 0; i < children.size(); i++) {
if (children.at(i) == 0)
abort();
}
// Copy the children on the stack, bottom up, first node to last
memcpy(&dat[stack_pos], children.data(), children.size() * sizeof(int64_t));
stack_pos -= children.size();
@@ -100,7 +105,12 @@ protected:
private:
// DEBUG
int counter = 0;
std::stringstream ss;
// !DEBUG
uint64_t generate_children(sf::Vector3i pos, int dim);
int cycle_counter = 0;

View File

@@ -6,6 +6,7 @@
#include <sstream>
#include "Vector4.hpp"
#include <bitset>
#include <string>
const double PI = 3.141592653589793238463;
const float PI_F = 3.14159265358979f;
@@ -172,6 +173,16 @@ inline std::string read_file(std::string file_name){
return buf.str();
}
inline void PrettyPrintUINT64(uint64_t i, std::stringstream* ss) {
*ss << "[" << std::bitset<15>(i) << "]";
*ss << "[" << std::bitset<1>(i >> 15) << "]";
*ss << "[" << std::bitset<8>(i >> 16) << "]";
*ss << "[" << std::bitset<8>(i >> 24) << "]";
*ss << "[" << std::bitset<32>(i >> 32) << "]";
}
inline void PrettyPrintUINT64(uint64_t i) {
std::cout << "[" << std::bitset<15>(i) << "]";
@@ -180,4 +191,15 @@ inline void PrettyPrintUINT64(uint64_t i) {
std::cout << "[" << std::bitset<8>(i >> 24) << "]";
std::cout << "[" << std::bitset<32>(i >> 32) << "]" << std::endl;
}
inline void DumpLog(std::stringstream* ss, std::string file_name) {
std::ofstream log_file;
log_file.open(file_name);
log_file << ss->str();
log_file.close();
}