i think all the old logging is replaced
parent
deacad5358
commit
78a4ad9f39
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
include(cmake/color.cmake)
|
include(cmake/color.cmake)
|
||||||
set(BLT_VERSION 5.2.6)
|
set(BLT_VERSION 5.2.7)
|
||||||
|
|
||||||
set(BLT_TARGET BLT)
|
set(BLT_TARGET BLT)
|
||||||
|
|
||||||
|
|
|
@ -305,7 +305,7 @@ namespace blt::nbt {
|
||||||
auto& tag = t[i];
|
auto& tag = t[i];
|
||||||
T t;
|
T t;
|
||||||
if (tag->getType() != t.getType()) {
|
if (tag->getType() != t.getType()) {
|
||||||
BLT_WARN("Expected tag of type %d but got tag of type %d", (char)t.getType(), (char)tag->getType());
|
BLT_WARN("Expected tag of type {:d} but got tag of type {:d}", (char)t.getType(), (char)tag->getType());
|
||||||
throw std::runtime_error("Requested Tag does not match stored type!");
|
throw std::runtime_error("Requested Tag does not match stored type!");
|
||||||
}
|
}
|
||||||
return dynamic_cast<T*>(tag);
|
return dynamic_cast<T*>(tag);
|
||||||
|
@ -342,7 +342,7 @@ namespace blt::nbt {
|
||||||
auto& tag = t[name];
|
auto& tag = t[name];
|
||||||
T t;
|
T t;
|
||||||
if (tag->getType() != t.getType()) {
|
if (tag->getType() != t.getType()) {
|
||||||
BLT_WARN("Expected tag of type %d but got tag of type %d", (char)t.getType(), (char)tag->getType());
|
BLT_WARN("Expected tag of type {:d} but got tag of type {:d}", (char)t.getType(), (char)tag->getType());
|
||||||
throw std::runtime_error("Requested Tag does not match stored type!");
|
throw std::runtime_error("Requested Tag does not match stored type!");
|
||||||
}
|
}
|
||||||
return dynamic_cast<T*>(tag);
|
return dynamic_cast<T*>(tag);
|
||||||
|
@ -409,7 +409,7 @@ namespace blt::nbt {
|
||||||
auto& tag = root->get()[name];
|
auto& tag = root->get()[name];
|
||||||
T t;
|
T t;
|
||||||
if (tag->getType() != t.getType()) {
|
if (tag->getType() != t.getType()) {
|
||||||
BLT_WARN("Expected tag of type %d but got tag of type %d", (char)t.getType(), (char)tag->getType());
|
BLT_WARN("Expected tag of type {:d} but got tag of type {:d}", (char)t.getType(), (char)tag->getType());
|
||||||
throw std::runtime_error("Requested Tag does not match stored type!");
|
throw std::runtime_error("Requested Tag does not match stored type!");
|
||||||
}
|
}
|
||||||
return dynamic_cast<T*>(tag);
|
return dynamic_cast<T*>(tag);
|
||||||
|
|
|
@ -149,7 +149,7 @@ namespace blt
|
||||||
*/
|
*/
|
||||||
inline void allocate_block()
|
inline void allocate_block()
|
||||||
{
|
{
|
||||||
//BLT_INFO("Allocating a new block of size %d", BLOCK_SIZE);
|
//BLT_INFO("Allocating a new block of size {:d}", BLOCK_SIZE);
|
||||||
auto* blk = new block_storage();
|
auto* blk = new block_storage();
|
||||||
blk->data = static_cast<pointer>(malloc(sizeof(T) * BLOCK_SIZE));
|
blk->data = static_cast<pointer>(malloc(sizeof(T) * BLOCK_SIZE));
|
||||||
blocks.push_back(blk);
|
blocks.push_back(blk);
|
||||||
|
@ -572,13 +572,13 @@ namespace blt
|
||||||
if constexpr (WARN_ON_FAIL)
|
if constexpr (WARN_ON_FAIL)
|
||||||
{
|
{
|
||||||
if (((size_t) buffer & (HUGE_PAGE_SIZE - 1)) != 0)
|
if (((size_t) buffer & (HUGE_PAGE_SIZE - 1)) != 0)
|
||||||
BLT_ERROR("Pointer is not aligned! %p", buffer);
|
BLT_ERROR("Pointer is not aligned! {:#x}", buffer);
|
||||||
}
|
}
|
||||||
auto* ptr = static_cast<void*>(buffer);
|
auto* ptr = static_cast<void*>(buffer);
|
||||||
auto ptr_size = reinterpret_cast<blt::size_t>(ptr);
|
auto ptr_size = reinterpret_cast<blt::size_t>(ptr);
|
||||||
buffer = static_cast<T*>(std::align(BLOCK_SIZE, BLOCK_SIZE, ptr, bytes));
|
buffer = static_cast<T*>(std::align(BLOCK_SIZE, BLOCK_SIZE, ptr, bytes));
|
||||||
if constexpr (WARN_ON_FAIL)
|
if constexpr (WARN_ON_FAIL)
|
||||||
BLT_ERROR("Offset by %ld pages, resulting: %p", (reinterpret_cast<blt::size_t>(buffer) - ptr_size) / 4096, buffer);
|
BLT_ERROR("Offset by {} pages, resulting: {:#x}", (reinterpret_cast<blt::size_t>(buffer) - ptr_size) / 4096, buffer);
|
||||||
}
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
#endif
|
#endif
|
||||||
|
@ -839,7 +839,7 @@ namespace blt
|
||||||
#endif
|
#endif
|
||||||
// if (deletes.contains(p))
|
// if (deletes.contains(p))
|
||||||
// {
|
// {
|
||||||
// BLT_FATAL("pointer %p has already been freed", p);
|
// BLT_FATAL("pointer {:#x} has already been freed", p);
|
||||||
// throw std::bad_alloc();
|
// throw std::bad_alloc();
|
||||||
// }else
|
// }else
|
||||||
// deletes.insert(static_cast<void*>(p));
|
// deletes.insert(static_cast<void*>(p));
|
||||||
|
@ -848,7 +848,7 @@ namespace blt
|
||||||
blk->metadata.allocated_objects--;
|
blk->metadata.allocated_objects--;
|
||||||
if (blk->metadata.allocated_objects == 0)
|
if (blk->metadata.allocated_objects == 0)
|
||||||
{
|
{
|
||||||
//BLT_INFO("Deallocating block from %p in (1) %p current head %p, based: %p", p, blk, head, base);
|
//BLT_INFO("Deallocating block from {:#x} in (1) {:#x} current head {:#x}, based: {:#x}", p, blk, head, base);
|
||||||
if (blk == base)
|
if (blk == base)
|
||||||
{
|
{
|
||||||
base = base->metadata.next;
|
base = base->metadata.next;
|
||||||
|
@ -860,7 +860,7 @@ namespace blt
|
||||||
else if (blk->metadata.prev != nullptr) // finally if it wasn't the head we need to bridge the gap in the list
|
else if (blk->metadata.prev != nullptr) // finally if it wasn't the head we need to bridge the gap in the list
|
||||||
blk->metadata.prev->metadata.next = blk->metadata.next;
|
blk->metadata.prev->metadata.next = blk->metadata.next;
|
||||||
|
|
||||||
//BLT_INFO("Deallocating block from %p in (2) %p current head %p, based: %p", p, blk, head, base);
|
//BLT_INFO("Deallocating block from {:#x} in (2) {:#x} current head {:#x}, based: {:#x}", p, blk, head, base);
|
||||||
delete_block(blk);
|
delete_block(blk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,8 +82,8 @@ std::string blt::fs::getFile(std::string_view path)
|
||||||
file_contents = file_stream.str();
|
file_contents = file_stream.str();
|
||||||
} catch (std::ifstream::failure& e)
|
} catch (std::ifstream::failure& e)
|
||||||
{
|
{
|
||||||
BLT_WARN("Unable to read file '%s'!\n", std::string(path).c_str());
|
BLT_WARN("Unable to read file '{}'!\n", std::string(path).c_str());
|
||||||
BLT_WARN("Exception: %s", e.what());
|
BLT_WARN("Exception: {}", e.what());
|
||||||
BLT_THROW(std::runtime_error("Failed to read file!\n"));
|
BLT_THROW(std::runtime_error("Failed to read file!\n"));
|
||||||
}
|
}
|
||||||
return file_contents;
|
return file_contents;
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace blt::nbt {
|
||||||
char t;
|
char t;
|
||||||
reader.read(&t, 1);
|
reader.read(&t, 1);
|
||||||
if (t != (char)nbt_tag::COMPOUND) {
|
if (t != (char)nbt_tag::COMPOUND) {
|
||||||
BLT_WARN("Found %d", t);
|
BLT_WARN("Found {:d}", t);
|
||||||
throw std::runtime_error("Incorrectly formatted NBT data! Root tag must be a compound tag!");
|
throw std::runtime_error("Incorrectly formatted NBT data! Root tag must be a compound tag!");
|
||||||
}
|
}
|
||||||
root = new tag_compound;
|
root = new tag_compound;
|
||||||
|
|
|
@ -196,7 +196,7 @@ namespace blt
|
||||||
printUsage();
|
printUsage();
|
||||||
std::cout << getProgramName() << ": error: flag '" << flag << "' expected " << properties.a_nargs.args
|
std::cout << getProgramName() << ": error: flag '" << flag << "' expected " << properties.a_nargs.args
|
||||||
<< " argument(s) but found '" << tokenizer.get() << "' instead!\n";
|
<< " argument(s) but found '" << tokenizer.get() << "' instead!\n";
|
||||||
//BLT_WARN("Expected %d arguments, found flag instead!", properties.a_nargs.args);
|
//BLT_WARN("Expected {:d} arguments, found flag instead!", properties.a_nargs.args);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// get the value and advance
|
// get the value and advance
|
||||||
|
|
|
@ -30,226 +30,227 @@
|
||||||
|
|
||||||
namespace blt::parse
|
namespace blt::parse
|
||||||
{
|
{
|
||||||
class char_tokenizer
|
class char_tokenizer
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string_view string;
|
std::string_view string;
|
||||||
std::size_t current_pos = 0;
|
std::size_t current_pos = 0;
|
||||||
public:
|
|
||||||
explicit char_tokenizer(std::string_view view): string(view)
|
public:
|
||||||
{}
|
explicit char_tokenizer(std::string_view view): string(view)
|
||||||
|
{}
|
||||||
inline char advance()
|
|
||||||
{
|
inline char advance()
|
||||||
return string[current_pos++];
|
{
|
||||||
}
|
return string[current_pos++];
|
||||||
|
}
|
||||||
inline bool has_next(size_t offset = 0)
|
|
||||||
{
|
inline bool has_next(size_t offset = 0)
|
||||||
return current_pos + offset < string.size();
|
{
|
||||||
}
|
return current_pos + offset < string.size();
|
||||||
|
}
|
||||||
inline std::string_view read_fully()
|
|
||||||
{
|
inline std::string_view read_fully()
|
||||||
return blt::string::trim(string.substr(current_pos));
|
{
|
||||||
}
|
return blt::string::trim(string.substr(current_pos));
|
||||||
};
|
}
|
||||||
|
};
|
||||||
template<typename T = float>
|
|
||||||
T get(std::string_view str)
|
template <typename T = float>
|
||||||
{
|
T get(std::string_view str)
|
||||||
T x;
|
{
|
||||||
// TODO: GCC version. C++17 supports from_chars but GCC8.5 doesn't have floating point.
|
T x;
|
||||||
#if __cplusplus >= BLT_CPP20
|
// TODO: GCC version. C++17 supports from_chars but GCC8.5 doesn't have floating point.
|
||||||
|
#if __cplusplus >= BLT_CPP20
|
||||||
const auto [ptr, ec] = std::from_chars(str.data(), str.data() + str.size(), x);
|
const auto [ptr, ec] = std::from_chars(str.data(), str.data() + str.size(), x);
|
||||||
#else
|
#else
|
||||||
auto ec = std::errc();
|
auto ec = std::errc();
|
||||||
if constexpr (std::is_floating_point_v<T>)
|
if constexpr (std::is_floating_point_v<T>)
|
||||||
{
|
{
|
||||||
x = static_cast<T>(std::stod(std::string(str)));
|
x = static_cast<T>(std::stod(std::string(str)));
|
||||||
} else if constexpr (std::is_integral_v<T>)
|
} else if constexpr (std::is_integral_v<T>)
|
||||||
{
|
{
|
||||||
x = static_cast<T>(std::stoll(std::string(str)));
|
x = static_cast<T>(std::stoll(std::string(str)));
|
||||||
} else
|
} else
|
||||||
static_assert(
|
static_assert(
|
||||||
"You are using a c++ version which does not support the required std::from_chars, manual conversion has failed to find a type!");
|
"You are using a c++ version which does not support the required std::from_chars, manual conversion has failed to find a type!");
|
||||||
#endif
|
#endif
|
||||||
// probably not needed.
|
// probably not needed.
|
||||||
if (ec != std::errc())
|
if (ec != std::errc())
|
||||||
{
|
{
|
||||||
// int i;
|
// int i;
|
||||||
// const auto [ptr2, ec2] = std::from_chars(str.data(), str.data() + str.size(), i);
|
// const auto [ptr2, ec2] = std::from_chars(str.data(), str.data() + str.size(), i);
|
||||||
// if (ec2 == std::errc())
|
// if (ec2 == std::errc())
|
||||||
// {
|
// {
|
||||||
// x = static_cast<float>(i);
|
// x = static_cast<float>(i);
|
||||||
// } else
|
// } else
|
||||||
// {
|
// {
|
||||||
BLT_WARN("Unable to parse string '%s' into number!", std::string(str).c_str());
|
BLT_WARN("Unable to parse string '{}' into number!", std::string(str).c_str());
|
||||||
x = 0;
|
x = 0;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void obj_loader::parse_vertex_line(char_tokenizer& tokenizer)
|
void obj_loader::parse_vertex_line(char_tokenizer& tokenizer)
|
||||||
{
|
{
|
||||||
char type = tokenizer.advance();
|
char type = tokenizer.advance();
|
||||||
|
|
||||||
if (type == 'p')
|
if (type == 'p')
|
||||||
{
|
{
|
||||||
BLT_WARN("Unexpected type '%c' (not supported)", type);
|
BLT_WARN("Unexpected type '{:c}' (not supported)", type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto elements = string::split(tokenizer.read_fully(), " ");
|
auto elements = string::split(tokenizer.read_fully(), " ");
|
||||||
BLT_ASSERT(elements.size() >= 2 && "Current line doesn't have enough arguments to process!");
|
BLT_ASSERT(elements.size() >= 2 && "Current line doesn't have enough arguments to process!");
|
||||||
float x = get(elements[0]), y = get(elements[1]);
|
float x = get(elements[0]), y = get(elements[1]);
|
||||||
BLT_DEBUG("Loaded value of ({}, {})", x, y);
|
BLT_DEBUG("Loaded value of ({}, {})", x, y);
|
||||||
if (elements.size() < 3)
|
if (elements.size() < 3)
|
||||||
{
|
{
|
||||||
if (type == 't')
|
if (type == 't')
|
||||||
uvs.push_back(uv_t{x, y});
|
uvs.push_back(uv_t{x, y});
|
||||||
else
|
else
|
||||||
BLT_ERROR("Unable to parse line '{}' type '{:c}' not recognized for arg count", tokenizer.read_fully(), type);
|
BLT_ERROR("Unable to parse line '{}' type '{:c}' not recognized for arg count", tokenizer.read_fully(), type);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
float z = get(elements[2]);
|
float z = get(elements[2]);
|
||||||
BLT_DEBUG(" with z: {}", z);
|
BLT_DEBUG(" with z: {}", z);
|
||||||
if (!handle_vertex_and_normals(x, y, z, type))
|
if (!handle_vertex_and_normals(x, y, z, type))
|
||||||
BLT_ERROR("Unable to parse line '{}' type '{:c}' not recognized", tokenizer.read_fully(), type);
|
BLT_ERROR("Unable to parse line '{}' type '{:c}' not recognized", tokenizer.read_fully(), type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool obj_loader::handle_vertex_and_normals(float x, float y, float z, char type)
|
bool obj_loader::handle_vertex_and_normals(float x, float y, float z, char type)
|
||||||
{
|
{
|
||||||
if (std::isspace(type))
|
if (std::isspace(type))
|
||||||
{
|
{
|
||||||
vertices.push_back(vertex_t{x, y, z});
|
vertices.push_back(vertex_t{x, y, z});
|
||||||
} else if (type == 'n')
|
} else if (type == 'n')
|
||||||
{
|
{
|
||||||
normals.push_back(normal_t{x, y, z});
|
normals.push_back(normal_t{x, y, z});
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj_model_t quick_load(std::string_view file)
|
obj_model_t quick_load(std::string_view file)
|
||||||
{
|
{
|
||||||
return obj_loader().parseFile(file);
|
return obj_loader().parseFile(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
obj_model_t obj_loader::parseFile(std::string_view file)
|
obj_model_t obj_loader::parseFile(std::string_view file)
|
||||||
{
|
{
|
||||||
auto lines = blt::fs::getLinesFromFile(std::string(file));
|
auto lines = blt::fs::getLinesFromFile(std::string(file));
|
||||||
for (const auto& [index, line] : blt::enumerate(lines))
|
for (const auto& [index, line] : blt::enumerate(lines))
|
||||||
{
|
{
|
||||||
current_line = index;
|
current_line = index;
|
||||||
char_tokenizer token(line);
|
char_tokenizer token(line);
|
||||||
if (!token.has_next() || token.read_fully().empty())
|
if (!token.has_next() || token.read_fully().empty())
|
||||||
continue;
|
continue;
|
||||||
switch (token.advance())
|
switch (token.advance())
|
||||||
{
|
{
|
||||||
case '#':
|
case '#':
|
||||||
continue;
|
continue;
|
||||||
case 'f':
|
case 'f':
|
||||||
parse_face(token);
|
parse_face(token);
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
parse_vertex_line(token);
|
parse_vertex_line(token);
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
{
|
{
|
||||||
current_object.object_names.emplace_back(token.read_fully());
|
current_object.object_names.emplace_back(token.read_fully());
|
||||||
BLT_TRACE("Setting object '%s'", std::string(current_object.object_name).c_str());
|
BLT_TRACE("Setting object '{}'", std::string(current_object.object_name).c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'm':
|
case 'm':
|
||||||
{
|
{
|
||||||
while (token.has_next() && token.advance() != ' ')
|
while (token.has_next() && token.advance() != ' ')
|
||||||
{}
|
{}
|
||||||
BLT_WARN("Material '%s' needs to be loaded!", std::string(token.read_fully()).c_str());
|
BLT_WARN("Material '{}' needs to be loaded!", std::string(token.read_fully()).c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'u':
|
case 'u':
|
||||||
{
|
{
|
||||||
if (!current_object.indices.empty())
|
if (!current_object.indices.empty())
|
||||||
data.push_back(current_object);
|
data.push_back(current_object);
|
||||||
current_object = {};
|
current_object = {};
|
||||||
while (token.has_next() && token.advance() != ' ')
|
while (token.has_next() && token.advance() != ' ')
|
||||||
{}
|
{}
|
||||||
current_object.material = token.read_fully();
|
current_object.material = token.read_fully();
|
||||||
//BLT_WARN("Using material '%s'", std::string(token.read_fully()).c_str());
|
//BLT_WARN("Using material '{}'", std::string(token.read_fully()).c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 's':
|
case 's':
|
||||||
//BLT_WARN("Using shading: %s", std::string(token.read_fully()).c_str());
|
//BLT_WARN("Using shading: {}", std::string(token.read_fully()).c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
data.push_back(current_object);
|
data.push_back(current_object);
|
||||||
return {std::move(vertex_data), std::move(data), std::move(materials)};
|
return {std::move(vertex_data), std::move(data), std::move(materials)};
|
||||||
}
|
}
|
||||||
|
|
||||||
void obj_loader::parse_face(char_tokenizer& tokenizer)
|
void obj_loader::parse_face(char_tokenizer& tokenizer)
|
||||||
{
|
{
|
||||||
auto faces = blt::string::split(std::string(tokenizer.read_fully()), ' ');
|
auto faces = blt::string::split(std::string(tokenizer.read_fully()), ' ');
|
||||||
if (faces.size() == 3)
|
if (faces.size() == 3)
|
||||||
{
|
{
|
||||||
triangle_t triangle{};
|
triangle_t triangle{};
|
||||||
handle_face_vertex(faces, triangle.v);
|
handle_face_vertex(faces, triangle.v);
|
||||||
current_object.indices.push_back(triangle);
|
current_object.indices.push_back(triangle);
|
||||||
} else if (faces.size() == 4)
|
} else if (faces.size() == 4)
|
||||||
{
|
{
|
||||||
quad_t quad{};
|
quad_t quad{};
|
||||||
handle_face_vertex(faces, quad.v);
|
handle_face_vertex(faces, quad.v);
|
||||||
triangle_t t1{};
|
triangle_t t1{};
|
||||||
triangle_t t2{};
|
triangle_t t2{};
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
t1.v[i] = quad.v[i];
|
t1.v[i] = quad.v[i];
|
||||||
t2.v[0] = quad.v[0];
|
t2.v[0] = quad.v[0];
|
||||||
t2.v[1] = quad.v[2];
|
t2.v[1] = quad.v[2];
|
||||||
t2.v[2] = quad.v[3];
|
t2.v[2] = quad.v[3];
|
||||||
|
|
||||||
current_object.indices.push_back(t1);
|
current_object.indices.push_back(t1);
|
||||||
current_object.indices.push_back(t2);
|
current_object.indices.push_back(t2);
|
||||||
} else
|
} else
|
||||||
BLT_WARN("Unsupported face vertex count of %d on line %d!", faces.size(), current_line);
|
BLT_WARN("Unsupported face vertex count of {:d} on line {:d}!", faces.size(), current_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
void obj_loader::handle_face_vertex(const std::vector<std::string>& face_list, int32_t* arr)
|
void obj_loader::handle_face_vertex(const std::vector<std::string>& face_list, int32_t* arr)
|
||||||
{
|
{
|
||||||
for (const auto& [e_index, value] : blt::enumerate(face_list))
|
for (const auto& [e_index, value] : blt::enumerate(face_list))
|
||||||
{
|
{
|
||||||
auto indices = blt::string::split(value, '/');
|
auto indices = blt::string::split(value, '/');
|
||||||
BLT_ASSERT(indices.size() == 3 && "Must have vertex, uv, and normal indices!!");
|
BLT_ASSERT(indices.size() == 3 && "Must have vertex, uv, and normal indices!!");
|
||||||
|
|
||||||
auto vi = get<std::int32_t>(indices[0]) - 1;
|
auto vi = get<std::int32_t>(indices[0]) - 1;
|
||||||
auto ui = get<std::int32_t>(indices[1]) - 1;
|
auto ui = get<std::int32_t>(indices[1]) - 1;
|
||||||
auto ni = get<std::int32_t>(indices[2]) - 1;
|
auto ni = get<std::int32_t>(indices[2]) - 1;
|
||||||
|
|
||||||
BLT_DEBUG("Found vertex: %d, UV: %d, and normal: %d", vi, ui, ni);
|
BLT_DEBUG("Found vertex: {:d}, UV: {:d}, and normal: {:d}", vi, ui, ni);
|
||||||
|
|
||||||
face_t face{vi, ui, ni};
|
face_t face{vi, ui, ni};
|
||||||
|
|
||||||
auto loc = vertex_map.find(face);
|
auto loc = vertex_map.find(face);
|
||||||
if (loc == vertex_map.end())
|
if (loc == vertex_map.end())
|
||||||
{
|
{
|
||||||
BLT_DEBUG("DID NOT FIND FACE!");
|
BLT_DEBUG("DID NOT FIND FACE!");
|
||||||
auto index = static_cast<std::int32_t>(vertex_data.size());
|
auto index = static_cast<std::int32_t>(vertex_data.size());
|
||||||
vertex_data.push_back({vertices[vi], uvs[ui], normals[ni]});
|
vertex_data.push_back({vertices[vi], uvs[ui], normals[ni]});
|
||||||
BLT_DEBUG("Vertex: (%f, %f, %f), UV: (%f, %f), Normal: (%f, %f, %f)", vertices[vi].x(), vertices[vi].y(), vertices[vi].z(),
|
BLT_DEBUG("Vertex: ({.4f}, {.4f}, {.4f}), UV: ({.4f}, {.4f}), Normal: ({.4f}, {.4f}, {:.4f})", vertices[vi].x(), vertices[vi].y(),
|
||||||
uvs[ui].x(), uvs[ui].y(), normals[ni].x(), normals[ni].y(), normals[ni].z());
|
vertices[vi].z(), uvs[ui].x(), uvs[ui].y(), normals[ni].x(), normals[ni].y(), normals[ni].z());
|
||||||
vertex_map.insert({face, index});
|
vertex_map.insert({face, index});
|
||||||
arr[e_index] = index;
|
arr[e_index] = index;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
BLT_TRACE("Using cached data; %d; map size: %d", loc->second, vertex_data.size());
|
BLT_TRACE("Using cached data; {:d}; map size: {:d}", loc->second, vertex_data.size());
|
||||||
//const auto& d = vertex_data[loc->second];
|
//const auto& d = vertex_data[loc->second];
|
||||||
BLT_TRACE("Vertex: (%f, %f, %f), UV: (%f, %f), Normal: (%f, %f, %f)", d.vertex.x(), d.vertex.y(), d.vertex.z(),
|
BLT_TRACE("Vertex: ({.4f}, {.4f}, {.4f}), UV: ({.4f}, {.4f}), Normal: ({.4f}, {.4f}, {:.4f})", d.vertex.x(), d.vertex.y(),
|
||||||
d.uv.x(), d.uv.y(), d.normal.x(), d.normal.y(), d.normal.z());
|
d.vertex.z(), d.uv.x(), d.uv.y(), d.normal.x(), d.normal.y(), d.normal.z());
|
||||||
arr[e_index] = loc->second;
|
arr[e_index] = loc->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,7 +275,7 @@ namespace blt
|
||||||
values.push_back(b1 ^ b2);
|
values.push_back(b1 ^ b2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BLT_WARN("Unexpected token '%s'", std::string(next.token).c_str());
|
BLT_WARN("Unexpected token '{}'", std::string(next.token).c_str());
|
||||||
return blt::unexpected(template_parser_failure_t::BOOL_TYPE_NOT_FOUND);
|
return blt::unexpected(template_parser_failure_t::BOOL_TYPE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace blt
|
||||||
#ifdef IS_GNU_BACKTRACE
|
#ifdef IS_GNU_BACKTRACE
|
||||||
BLT_STACK_TRACE(50);
|
BLT_STACK_TRACE(50);
|
||||||
|
|
||||||
BLT_ERROR("An exception '%s' has occurred in file '%s:%d'", what, path, line);
|
BLT_ERROR("An exception '{}' has occurred in file '{}:{:d}'", what, path, line);
|
||||||
BLT_ERROR("Stack Trace:");
|
BLT_ERROR("Stack Trace:");
|
||||||
printStacktrace(messages, size, path, line);
|
printStacktrace(messages, size, path, line);
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ namespace blt
|
||||||
#ifdef IS_GNU_BACKTRACE
|
#ifdef IS_GNU_BACKTRACE
|
||||||
BLT_STACK_TRACE(50);
|
BLT_STACK_TRACE(50);
|
||||||
|
|
||||||
BLT_ERROR("The assertion '%s' has failed in file '%s:%d'", expression, path, line);
|
BLT_ERROR("The assertion '{}' has failed in file '{}:{:d}'", expression, path, line);
|
||||||
if (msg != nullptr)
|
if (msg != nullptr)
|
||||||
BLT_ERROR(msg);
|
BLT_ERROR(msg);
|
||||||
BLT_ERROR("Stack Trace:");
|
BLT_ERROR("Stack Trace:");
|
||||||
|
@ -175,8 +175,8 @@ namespace blt
|
||||||
BLT_STACK_TRACE(50);
|
BLT_STACK_TRACE(50);
|
||||||
#endif
|
#endif
|
||||||
BLT_FATAL("----{BLT ABORT}----");
|
BLT_FATAL("----{BLT ABORT}----");
|
||||||
BLT_FATAL("\tWhat: %s", what);
|
BLT_FATAL("\tWhat: {}", what);
|
||||||
BLT_FATAL("\tCalled from %s:%d", path, line);
|
BLT_FATAL("\tCalled from {}:{:d}", path, line);
|
||||||
#ifdef IS_GNU_BACKTRACE
|
#ifdef IS_GNU_BACKTRACE
|
||||||
printStacktrace(messages, size, path, line);
|
printStacktrace(messages, size, path, line);
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ namespace blt
|
||||||
if (GetProcessTimes(GetCurrentProcess(),
|
if (GetProcessTimes(GetCurrentProcess(),
|
||||||
&starttime, &exittime, &kerneltime, &usertime) == 0)
|
&starttime, &exittime, &kerneltime, &usertime) == 0)
|
||||||
{
|
{
|
||||||
BLT_WARN("Unable to get process resource usage, error: %d", GetLastError());
|
BLT_WARN("Unable to get process resource usage, error: {:d}", GetLastError());
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ namespace blt
|
||||||
#else
|
#else
|
||||||
if (getrusage(who, (struct rusage*) &usage) != 0)
|
if (getrusage(who, (struct rusage*) &usage) != 0)
|
||||||
{
|
{
|
||||||
BLT_ERROR("Failed to get rusage %d", errno);
|
BLT_ERROR("Failed to get rusage {:d}", errno);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -181,6 +181,7 @@ int main()
|
||||||
BLT_WARN("This is a warning!");
|
BLT_WARN("This is a warning!");
|
||||||
BLT_ERROR("This is an error!");
|
BLT_ERROR("This is an error!");
|
||||||
BLT_FATAL("This is a fatal error!");
|
BLT_FATAL("This is a fatal error!");
|
||||||
|
BLT_TRACE("This is a pointer {:f}", &charCount);
|
||||||
|
|
||||||
/*std::cout << "\033[2J";
|
/*std::cout << "\033[2J";
|
||||||
constexpr int totalRows = 24;
|
constexpr int totalRows = 24;
|
||||||
|
|
Loading…
Reference in New Issue