Unify macro prefixes

master
Marc Gilleron 2022-04-06 23:26:54 +01:00
parent 090d3485e5
commit 5519054c01
34 changed files with 117 additions and 117 deletions

View File

@ -148,7 +148,7 @@ In performance-critical areas which run a lot:
- In areas where performance matters, use the most direct APIs for the job. Especially, don't use nodes. See `RenderingServer` and `PhysicsServer`.
- Only expose a function to the script API if it is safe to use and guaranteed to remain present for a while
- When possible, use `memnew`, `memdelete`, `memalloc` and `memfree` so memory usage is counted within Godot monitors
- Don't leave random prints. For verbose mode you may also use `PRINT_VERBOSE()` instead of `print_verbose()`.
- Don't leave random prints. For verbose mode you may also use `ZN_PRINT_VERBOSE()` instead of `print_verbose()`.
- Use `int` as argument for functions exposed to scripts if they don't need to exceed 2^31, even if they are never negative, so errors are clearer if the user makes a mistake
### Namespaces

View File

@ -93,7 +93,7 @@ float VoxelTool::get_voxel_f(Vector3i pos) const {
void VoxelTool::set_voxel(Vector3i pos, uint64_t v) {
Box3i box(pos, Vector3i(1, 1, 1));
if (!is_area_editable(box)) {
PRINT_VERBOSE("Area not editable");
ZN_PRINT_VERBOSE("Area not editable");
return;
}
_set_voxel(pos, v);
@ -103,7 +103,7 @@ void VoxelTool::set_voxel(Vector3i pos, uint64_t v) {
void VoxelTool::set_voxel_f(Vector3i pos, float v) {
Box3i box(pos, Vector3i(1, 1, 1));
if (!is_area_editable(box)) {
PRINT_VERBOSE("Area not editable");
ZN_PRINT_VERBOSE("Area not editable");
return;
}
_set_voxel_f(pos, v);
@ -185,7 +185,7 @@ void VoxelTool::do_sphere(Vector3 center, float radius) {
Vector3iUtil::create(Math::ceil(radius) * 2));
if (!is_area_editable(box)) {
PRINT_VERBOSE("Area not editable");
ZN_PRINT_VERBOSE("Area not editable");
return;
}
@ -217,7 +217,7 @@ void VoxelTool::sdf_stamp_erase(Ref<gd::VoxelBuffer> stamp, Vector3i pos) {
const Box3i box(pos, stamp->get_buffer().get_size());
if (!is_area_editable(box)) {
PRINT_VERBOSE("Area not editable");
ZN_PRINT_VERBOSE("Area not editable");
return;
}
@ -239,7 +239,7 @@ void VoxelTool::do_box(Vector3i begin, Vector3i end) {
Box3i box = Box3i::from_min_max(begin, end + Vector3i(1, 1, 1));
if (!is_area_editable(box)) {
PRINT_VERBOSE("Area not editable");
ZN_PRINT_VERBOSE("Area not editable");
return;
}

View File

@ -228,7 +228,7 @@ void VoxelToolLodTerrain::do_sphere(Vector3 center, float radius) {
.clipped(_terrain->get_voxel_bounds());
if (!is_area_editable(box)) {
PRINT_VERBOSE("Area not editable");
ZN_PRINT_VERBOSE("Area not editable");
return;
}
@ -300,7 +300,7 @@ void VoxelToolLodTerrain::do_sphere_async(Vector3 center, float radius) {
.clipped(_terrain->get_voxel_bounds());
if (!is_area_editable(box)) {
PRINT_VERBOSE("Area not editable");
ZN_PRINT_VERBOSE("Area not editable");
return;
}

View File

@ -170,7 +170,7 @@ void VoxelToolTerrain::do_sphere(Vector3 center, float radius) {
Vector3iUtil::create(Math::ceil(radius) * 2));
if (!is_area_editable(box)) {
PRINT_VERBOSE("Area not editable");
ZN_PRINT_VERBOSE("Area not editable");
return;
}

View File

@ -143,7 +143,7 @@ const ThirdParty g_third_parties[] = {
"The contents of this file are protected by copyright and may not be publicly\n"
"reproduced without permission.\n" }
};
const unsigned int VOXEL_THIRD_PARTY_COUNT = VOXEL_ARRAY_LENGTH(g_third_parties);
const unsigned int VOXEL_THIRD_PARTY_COUNT = ZN_ARRAY_LENGTH(g_third_parties);
} // namespace
VoxelAboutWindow::VoxelAboutWindow() {

View File

@ -152,10 +152,10 @@ void VoxelGraphEditor::set_undo_redo(UndoRedo *undo_redo) {
void VoxelGraphEditor::set_voxel_node(VoxelNode *node) {
_voxel_node = node;
if (_voxel_node == nullptr) {
PRINT_VERBOSE("Reference node for VoxelGraph gizmos: null");
ZN_PRINT_VERBOSE("Reference node for VoxelGraph gizmos: null");
_debug_renderer.set_world(nullptr);
} else {
PRINT_VERBOSE(String("Reference node for VoxelGraph gizmos: {0}").format(varray(node->get_path())));
ZN_PRINT_VERBOSE(String("Reference node for VoxelGraph gizmos: {0}").format(varray(node->get_path())));
_debug_renderer.set_world(_voxel_node->get_world_3d().ptr());
}
}
@ -383,7 +383,7 @@ void VoxelGraphEditor::_on_graph_edit_connection_request(
//print("Connection attempt from ", from, ":", from_slot, " to ", to, ":", to_slot)
if (!_graph->is_valid_connection(src_node_id, from_slot, dst_node_id, to_slot)) {
PRINT_VERBOSE("Connection is invalid");
ZN_PRINT_VERBOSE("Connection is invalid");
return;
}
@ -473,7 +473,7 @@ void VoxelGraphEditor::_on_graph_edit_delete_nodes_request() {
const size_t param_count = VoxelGraphNodeDB::get_singleton()->get_type(node_type_id).params.size();
for (size_t j = 0; j < param_count; ++j) {
Variant param_value = _graph->get_node_param(node_id, j);
_undo_redo->add_undo_method(*_graph, "set_node_param", node_id, SIZE_T_TO_VARIANT(j), param_value);
_undo_redo->add_undo_method(*_graph, "set_node_param", node_id, ZN_SIZE_T_TO_VARIANT(j), param_value);
}
_undo_redo->add_undo_method(this, "create_node_gui", node_id);
@ -619,11 +619,11 @@ void VoxelGraphEditor::update_previews() {
}
uint64_t time_taken = Time::get_singleton()->get_ticks_usec() - time_before;
PRINT_VERBOSE(String("Previews generated in {0} us").format(varray(time_taken)));
ZN_PRINT_VERBOSE(String("Previews generated in {0} us").format(varray(time_taken)));
}
void VoxelGraphEditor::update_range_analysis_previews() {
PRINT_VERBOSE("Updating range analysis previews");
ZN_PRINT_VERBOSE("Updating range analysis previews");
ERR_FAIL_COND(_graph.is_null());
ERR_FAIL_COND(!_graph->is_good());
@ -681,7 +681,7 @@ void VoxelGraphEditor::update_range_analysis_gizmo() {
void VoxelGraphEditor::update_slice_previews() {
// TODO Use a thread?
PRINT_VERBOSE("Updating slice previews");
ZN_PRINT_VERBOSE("Updating slice previews");
ERR_FAIL_COND(!_graph->is_good());
struct PreviewInfo {

View File

@ -22,7 +22,7 @@ void VoxelGraphNodeInspectorWrapper::_get_property_list(List<PropertyInfo> *p_li
if (!graph->has_node(_node_id)) {
// Maybe got erased by the user?
#ifdef DEBUG_ENABLED
PRINT_VERBOSE("VoxelGeneratorGraph node was not found, from the graph inspector");
ZN_PRINT_VERBOSE("VoxelGeneratorGraph node was not found, from the graph inspector");
#endif
return;
}

View File

@ -195,7 +195,7 @@ bool make_single_voxel_grid(
const size_t volume = Vector3iUtil::get_volume(bounding_box.size);
ERR_FAIL_COND_V_MSG(volume > limit, false,
String("Vox data is too big to be meshed as a single mesh ({0}: {0} bytes)")
.format(varray(bounding_box.size, SIZE_T_TO_VARIANT(volume))));
.format(varray(bounding_box.size, ZN_SIZE_T_TO_VARIANT(volume))));
out_voxels.create(bounding_box.size + Vector3iUtil::create(VoxelMesherCubes::PADDING * 2));
out_voxels.set_channel_depth(VoxelBufferInternal::CHANNEL_COLOR, VoxelBufferInternal::DEPTH_8_BIT);

View File

@ -1023,7 +1023,7 @@ VoxelGraphRuntime::CompilationResult VoxelGeneratorGraph::compile() {
_runtime = r;
const int64_t time_spent = Time::get_singleton()->get_ticks_usec() - time_before;
PRINT_VERBOSE(String("Voxel graph compiled in {0} us").format(varray(time_spent)));
ZN_PRINT_VERBOSE(String("Voxel graph compiled in {0} us").format(varray(time_spent)));
return result;
}

View File

@ -658,9 +658,9 @@ VoxelGraphRuntime::CompilationResult VoxelGraphRuntime::_compile(const ProgramGr
_program.buffer_count = mem.next_address;
PRINT_VERBOSE(String("Compiled voxel graph. Program size: {0}b, buffers: {1}")
.format(varray(SIZE_T_TO_VARIANT(_program.operations.size() * sizeof(uint16_t)),
SIZE_T_TO_VARIANT(_program.buffer_count))));
ZN_PRINT_VERBOSE(String("Compiled voxel graph. Program size: {0}b, buffers: {1}")
.format(varray(ZN_SIZE_T_TO_VARIANT(_program.operations.size() * sizeof(uint16_t)),
ZN_SIZE_T_TO_VARIANT(_program.buffer_count))));
CompilationResult result;
result.success = true;

View File

@ -182,7 +182,7 @@ void VoxelBlockyLibrary::bake() {
generate_side_culling_matrix();
uint64_t time_spent = Time::get_singleton()->get_ticks_usec() - time_before;
PRINT_VERBOSE(String("Took {0} us to bake VoxelLibrary").format(varray(time_spent)));
ZN_PRINT_VERBOSE(String("Took {0} us to bake VoxelLibrary").format(varray(time_spent)));
}
void VoxelBlockyLibrary::generate_side_culling_matrix() {

View File

@ -36,7 +36,7 @@ bool VoxelBlockyModel::_set(const StringName &p_name, const Variant &p_value) {
// TODO Eventualy these could be Rect2 for maximum flexibility?
if (name.begins_with("cube_tiles/")) {
String s = name.substr(VOXEL_ARRAY_LENGTH("cube_tiles/") - 1, name.length());
String s = name.substr(ZN_ARRAY_LENGTH("cube_tiles/") - 1, name.length());
Cube::Side side = name_to_side(s);
if (side != Cube::SIDE_COUNT) {
Vector2 v = p_value;
@ -52,7 +52,7 @@ bool VoxelBlockyModel::_get(const StringName &p_name, Variant &r_ret) const {
String name = p_name;
if (name.begins_with("cube_tiles/")) {
String s = name.substr(VOXEL_ARRAY_LENGTH("cube_tiles/") - 1, name.length());
String s = name.substr(ZN_ARRAY_LENGTH("cube_tiles/") - 1, name.length());
Cube::Side side = name_to_side(s);
if (side != Cube::SIDE_COUNT) {
const Vector2f f = _cube_tiles[side];

View File

@ -147,18 +147,18 @@ void register_voxel_types() {
// Engine::get_singleton()->add_singleton(Engine::Singleton("SingletonName",singleton_instance));
// Reminders
PRINT_VERBOSE(String("Size of Variant: {0}").format(varray((int)sizeof(Variant))));
PRINT_VERBOSE(String("Size of Object: {0}").format(varray((int)sizeof(Object))));
PRINT_VERBOSE(String("Size of RefCounted: {0}").format(varray((int)sizeof(RefCounted))));
PRINT_VERBOSE(String("Size of Node: {0}").format(varray((int)sizeof(Node))));
PRINT_VERBOSE(String("Size of Node3D: {0}").format(varray((int)sizeof(Node3D))));
PRINT_VERBOSE(String("Size of gd::VoxelBuffer: {0}").format(varray((int)sizeof(gd::VoxelBuffer))));
PRINT_VERBOSE(String("Size of VoxelBufferInternal: {0}").format(varray((int)sizeof(VoxelBufferInternal))));
PRINT_VERBOSE(String("Size of VoxelMeshBlock: {0}").format(varray((int)sizeof(VoxelMeshBlock))));
PRINT_VERBOSE(String("Size of VoxelTerrain: {0}").format(varray((int)sizeof(VoxelTerrain))));
PRINT_VERBOSE(String("Size of VoxelLodTerrain: {0}").format(varray((int)sizeof(VoxelLodTerrain))));
PRINT_VERBOSE(String("Size of VoxelInstancer: {0}").format(varray((int)sizeof(VoxelInstancer))));
PRINT_VERBOSE(String("Size of VoxelDataMap: {0}").format(varray((int)sizeof(VoxelDataMap))));
ZN_PRINT_VERBOSE(String("Size of Variant: {0}").format(varray((int)sizeof(Variant))));
ZN_PRINT_VERBOSE(String("Size of Object: {0}").format(varray((int)sizeof(Object))));
ZN_PRINT_VERBOSE(String("Size of RefCounted: {0}").format(varray((int)sizeof(RefCounted))));
ZN_PRINT_VERBOSE(String("Size of Node: {0}").format(varray((int)sizeof(Node))));
ZN_PRINT_VERBOSE(String("Size of Node3D: {0}").format(varray((int)sizeof(Node3D))));
ZN_PRINT_VERBOSE(String("Size of gd::VoxelBuffer: {0}").format(varray((int)sizeof(gd::VoxelBuffer))));
ZN_PRINT_VERBOSE(String("Size of VoxelBufferInternal: {0}").format(varray((int)sizeof(VoxelBufferInternal))));
ZN_PRINT_VERBOSE(String("Size of VoxelMeshBlock: {0}").format(varray((int)sizeof(VoxelMeshBlock))));
ZN_PRINT_VERBOSE(String("Size of VoxelTerrain: {0}").format(varray((int)sizeof(VoxelTerrain))));
ZN_PRINT_VERBOSE(String("Size of VoxelLodTerrain: {0}").format(varray((int)sizeof(VoxelLodTerrain))));
ZN_PRINT_VERBOSE(String("Size of VoxelInstancer: {0}").format(varray((int)sizeof(VoxelInstancer))));
ZN_PRINT_VERBOSE(String("Size of VoxelDataMap: {0}").format(varray((int)sizeof(VoxelDataMap))));
#ifdef TOOLS_ENABLED
EditorPlugins::add_by_type<VoxelGraphEditorPlugin>();

View File

@ -48,7 +48,7 @@ void GenerateBlockTask::run(zylann::ThreadedTaskContext ctx) {
// TODO In some cases we dont want this to run all the time, do we?
// Like in full load mode, where non-edited blocks remain generated on the fly...
if (stream.is_valid() && stream->get_save_generator_output()) {
PRINT_VERBOSE(
ZN_PRINT_VERBOSE(
String("Requesting save of generator output for block {0} lod {1}").format(varray(position, lod)));
// TODO Optimization: `voxels` doesnt actually need to be shared
@ -105,7 +105,7 @@ void GenerateBlockTask::apply_result() {
} else {
// This can happen if the user removes the volume while requests are still about to return
PRINT_VERBOSE("Gemerated data request response came back but volume wasn't found");
ZN_PRINT_VERBOSE("Gemerated data request response came back but volume wasn't found");
}
// TODO We could complete earlier inside run() if we had access to the data structure to write the block into.

View File

@ -14,7 +14,7 @@ void LoadAllBlocksDataTask::run(zylann::ThreadedTaskContext ctx) {
stream->load_all_blocks(_result);
PRINT_VERBOSE(String("Loaded {0} blocks for volume {1}").format(varray(_result.blocks.size(), volume_id)));
ZN_PRINT_VERBOSE(String("Loaded {0} blocks for volume {1}").format(varray(_result.blocks.size(), volume_id)));
}
int LoadAllBlocksDataTask::get_priority() {
@ -52,7 +52,7 @@ void LoadAllBlocksDataTask::apply_result() {
} else {
// This can happen if the user removes the volume while requests are still about to return
PRINT_VERBOSE("Stream data request response came back but volume wasn't found");
ZN_PRINT_VERBOSE("Stream data request response came back but volume wasn't found");
}
}

View File

@ -139,7 +139,7 @@ void LoadBlockDataTask::apply_result() {
} else {
// This can happen if the user removes the volume while requests are still about to return
PRINT_VERBOSE("Stream data request response came back but volume wasn't found");
ZN_PRINT_VERBOSE("Stream data request response came back but volume wasn't found");
}
}

View File

@ -220,7 +220,7 @@ void MeshBlockTask::apply_result() {
} else {
// This can happen if the user removes the volume while requests are still about to return
PRINT_VERBOSE("Mesh request response came back but volume wasn't found");
ZN_PRINT_VERBOSE("Mesh request response came back but volume wasn't found");
}
}

View File

@ -76,8 +76,8 @@ void SaveBlockDataTask::run(zylann::ThreadedTaskContext ctx) {
// On the other hand, if we want to represent the fact that "everything was deleted here",
// this should not be null.
PRINT_VERBOSE(String("Saving instance block {0} lod {1} with data {2}")
.format(varray(_position, _lod, ptr2s(_instances.get()))));
ZN_PRINT_VERBOSE(String("Saving instance block {0} lod {1} with data {2}")
.format(varray(_position, _lod, ptr2s(_instances.get()))));
VoxelStream::InstancesQueryData instances_query{ std::move(_instances), _position, _lod };
stream->save_instance_blocks(Span<VoxelStream::InstancesQueryData>(&instances_query, 1));
@ -113,7 +113,7 @@ void SaveBlockDataTask::apply_result() {
} else {
// This can happen if the user removes the volume while requests are still about to return
PRINT_VERBOSE("Stream data request response came back but volume wasn't found");
ZN_PRINT_VERBOSE("Stream data request response came back but volume wasn't found");
}
}

View File

@ -39,7 +39,7 @@ VoxelServer::VoxelServer() {
CRASH_COND(ProjectSettings::get_singleton() == nullptr);
const int hw_threads_hint = std::thread::hardware_concurrency();
PRINT_VERBOSE(String("Voxel: HW threads hint: {0}").format(varray(hw_threads_hint)));
ZN_PRINT_VERBOSE(String("Voxel: HW threads hint: {0}").format(varray(hw_threads_hint)));
// Compute thread count for general pool.
// Note that the I/O thread counts as one used thread and will always be present.
@ -79,7 +79,7 @@ VoxelServer::VoxelServer() {
// `-1` is for the stream thread
const int thread_count_by_ratio = int(Math::round(float(threads_ratio) * hw_threads_hint)) - 1;
const int thread_count = math::clamp(thread_count_by_ratio, minimum_thread_count, maximum_thread_count);
PRINT_VERBOSE(String("Voxel: automatic thread count set to {0}").format(varray(thread_count)));
ZN_PRINT_VERBOSE(String("Voxel: automatic thread count set to {0}").format(varray(thread_count)));
if (thread_count > hw_threads_hint) {
WARN_PRINT("Configured thread count exceeds hardware thread count. Performance may not be optimal");
@ -102,9 +102,9 @@ VoxelServer::VoxelServer() {
// Init world
_world.shared_priority_dependency = gd_make_shared<PriorityDependency::ViewersData>();
PRINT_VERBOSE(String("Size of LoadBlockDataTask: {0}").format(varray((int)sizeof(LoadBlockDataTask))));
PRINT_VERBOSE(String("Size of SaveBlockDataTask: {0}").format(varray((int)sizeof(SaveBlockDataTask))));
PRINT_VERBOSE(String("Size of MeshBlockTask: {0}").format(varray((int)sizeof(MeshBlockTask))));
ZN_PRINT_VERBOSE(String("Size of LoadBlockDataTask: {0}").format(varray((int)sizeof(LoadBlockDataTask))));
ZN_PRINT_VERBOSE(String("Size of SaveBlockDataTask: {0}").format(varray((int)sizeof(SaveBlockDataTask))));
ZN_PRINT_VERBOSE(String("Size of MeshBlockTask: {0}").format(varray((int)sizeof(MeshBlockTask))));
}
VoxelServer::~VoxelServer() {
@ -340,7 +340,7 @@ void VoxelServer::request_block_generate(
}
void VoxelServer::request_all_stream_blocks(uint32_t volume_id) {
PRINT_VERBOSE(String("Request all blocks for volume {0}").format(varray(volume_id)));
ZN_PRINT_VERBOSE(String("Request all blocks for volume {0}").format(varray(volume_id)));
const Volume &volume = _world.volumes.get(volume_id);
ERR_FAIL_COND(volume.stream.is_null());
CRASH_COND(volume.stream_dependency == nullptr);
@ -581,8 +581,8 @@ Dictionary VoxelServer::Stats::to_dict() {
// This part is additional for scripts because VoxelMemoryPool is not exposed
Dictionary mem;
mem["voxel_total"] = SIZE_T_TO_VARIANT(VoxelMemoryPool::get_singleton()->debug_get_total_memory());
mem["voxel_used"] = SIZE_T_TO_VARIANT(VoxelMemoryPool::get_singleton()->debug_get_used_memory());
mem["voxel_total"] = ZN_SIZE_T_TO_VARIANT(VoxelMemoryPool::get_singleton()->debug_get_total_memory());
mem["voxel_used"] = ZN_SIZE_T_TO_VARIANT(VoxelMemoryPool::get_singleton()->debug_get_used_memory());
mem["block_count"] = VoxelMemoryPool::get_singleton()->debug_get_used_blocks();
Dictionary d;

View File

@ -10,7 +10,7 @@ namespace zylann::voxel {
bool g_updater_created = false;
VoxelServerUpdater::VoxelServerUpdater() {
PRINT_VERBOSE("Creating VoxelServerUpdater");
ZN_PRINT_VERBOSE("Creating VoxelServerUpdater");
set_process(true);
g_updater_created = true;
}
@ -46,7 +46,7 @@ void VoxelServerUpdater::_notification(int p_what) {
break;
case NOTIFICATION_PREDELETE:
PRINT_VERBOSE("Deleting VoxelServerUpdater");
ZN_PRINT_VERBOSE("Deleting VoxelServerUpdater");
break;
default:

View File

@ -51,7 +51,7 @@ public:
void set_modified(bool modified) {
#ifdef TOOLS_ENABLED
if (_modified == false && modified) {
PRINT_VERBOSE(String("Marking block {0} as modified").format(varray(position)));
ZN_PRINT_VERBOSE(String("Marking block {0} as modified").format(varray(position)));
}
#endif
_modified = modified;

View File

@ -190,8 +190,8 @@ VoxelDataBlock *VoxelDataMap::set_block_buffer(
block->set_voxels(buffer);
} else {
VOXEL_PROFILE_MESSAGE("Redundant data block");
PRINT_VERBOSE(String("Discarded block {0} lod {1}, there was already data and overwriting is not enabled")
.format(varray(bpos, _lod_index)));
ZN_PRINT_VERBOSE(String("Discarded block {0} lod {1}, there was already data and overwriting is not enabled")
.format(varray(bpos, _lod_index)));
}
return block;
}
@ -374,7 +374,7 @@ void preload_box(VoxelDataLodMap &data, Box3i voxel_box, VoxelGenerator *generat
for (uint8_t lod_index = 0; lod_index < data.lod_count; ++lod_index) {
const Box3i block_box = voxel_box.downscaled(data_block_size << lod_index);
PRINT_VERBOSE(
ZN_PRINT_VERBOSE(
String("Preloading box {0} at lod {1} synchronously").format(varray(block_box.to_string(), lod_index)));
VoxelDataLodMap::Lod &data_lod = data.lods[lod_index];

View File

@ -147,8 +147,8 @@ void VoxelMemoryPool::debug_print() {
Pool &pool = _pot_pools[pot];
MutexLock lock(pool.mutex);
print_line(String("Pool {0}: {1} blocks (capacity {2})")
.format(varray(pot, SIZE_T_TO_VARIANT(pool.blocks.size()),
SIZE_T_TO_VARIANT(pool.blocks.capacity()))));
.format(varray(pot, ZN_SIZE_T_TO_VARIANT(pool.blocks.size()),
ZN_SIZE_T_TO_VARIANT(pool.blocks.capacity()))));
}
}

View File

@ -559,7 +559,7 @@ bool RegionFile::save_header(FileAccess *f) {
}
bool RegionFile::migrate_from_v2_to_v3(FileAccess *f, RegionFormat &format) {
PRINT_VERBOSE(String("Migrating region file {0} from v2 to v3").format(varray(_file_path)));
ZN_PRINT_VERBOSE(String("Migrating region file {0} from v2 to v3").format(varray(_file_path)));
// We can migrate if we know in advance what format the file should contain.
ERR_FAIL_COND_V_MSG(format.block_size_po2 == 0, false, "Cannot migrate without knowing the correct format");
@ -664,7 +664,7 @@ void RegionFile::debug_check() {
const unsigned int block_begin = _blocks_begin_offset + sector_index * _header.format.sector_size;
if (block_begin >= file_len) {
print_line(String("ERROR: LUT {0} ({1}): offset {2} is larger than file size {3}")
.format(varray(lut_index, position, block_begin, SIZE_T_TO_VARIANT(file_len))));
.format(varray(lut_index, position, block_begin, ZN_SIZE_T_TO_VARIANT(file_len))));
continue;
}
f->seek(block_begin);
@ -673,8 +673,8 @@ void RegionFile::debug_check() {
const size_t remaining_size = file_len - pos;
if (block_data_size > remaining_size) {
print_line(String("ERROR: LUT {0} ({1}): block size at offset {2} is larger than remaining size {3}")
.format(varray(lut_index, position, SIZE_T_TO_VARIANT(block_data_size),
SIZE_T_TO_VARIANT(remaining_size))));
.format(varray(lut_index, position, ZN_SIZE_T_TO_VARIANT(block_data_size),
ZN_SIZE_T_TO_VARIANT(remaining_size))));
}
}
}

View File

@ -555,7 +555,7 @@ void VoxelStreamRegionFiles::_convert_files(Meta new_meta) {
// I wrote it because it would be too bad to loose large voxel worlds because of a setting change, so one day we may
// need it
PRINT_VERBOSE("Converting region files");
ZN_PRINT_VERBOSE("Converting region files");
// This can be a very long and slow operation. Better run this in a thread.
ERR_FAIL_COND(!_meta_saved);
@ -592,7 +592,7 @@ void VoxelStreamRegionFiles::_convert_files(Meta new_meta) {
}
old_stream->set_directory(old_dir);
PRINT_VERBOSE("Data backed up as " + old_dir);
ZN_PRINT_VERBOSE("Data backed up as " + old_dir);
}
struct PositionAndLod {
@ -663,7 +663,7 @@ void VoxelStreamRegionFiles::_convert_files(Meta new_meta) {
continue;
}
PRINT_VERBOSE(String("Converting region lod{0}/{1}").format(varray(region_info.lod, region_info.position)));
ZN_PRINT_VERBOSE(String("Converting region lod{0}/{1}").format(varray(region_info.lod, region_info.position)));
const unsigned int blocks_count = old_region->region.get_header_block_count();
for (unsigned int j = 0; j < blocks_count; ++j) {
@ -759,7 +759,7 @@ void VoxelStreamRegionFiles::_convert_files(Meta new_meta) {
close_all_regions();
PRINT_VERBOSE("Done converting region files");
ZN_PRINT_VERBOSE("Done converting region files");
}
Vector3i VoxelStreamRegionFiles::get_region_size() const {

View File

@ -583,17 +583,17 @@ thread_local std::vector<uint8_t> VoxelStreamSQLite::_temp_compressed_block_data
VoxelStreamSQLite::VoxelStreamSQLite() {}
VoxelStreamSQLite::~VoxelStreamSQLite() {
PRINT_VERBOSE("~VoxelStreamSQLite");
ZN_PRINT_VERBOSE("~VoxelStreamSQLite");
if (!_connection_path.is_empty() && _cache.get_indicative_block_count() > 0) {
PRINT_VERBOSE("~VoxelStreamSQLite flushy flushy");
ZN_PRINT_VERBOSE("~VoxelStreamSQLite flushy flushy");
flush_cache();
PRINT_VERBOSE("~VoxelStreamSQLite flushy done");
ZN_PRINT_VERBOSE("~VoxelStreamSQLite flushy done");
}
for (auto it = _connection_pool.begin(); it != _connection_pool.end(); ++it) {
delete *it;
}
_connection_pool.clear();
PRINT_VERBOSE("~VoxelStreamSQLite done");
ZN_PRINT_VERBOSE("~VoxelStreamSQLite done");
}
void VoxelStreamSQLite::set_database_path(String path) {
@ -820,8 +820,8 @@ void VoxelStreamSQLite::load_all_blocks(FullLoadingResult &result) {
Context *ctx = reinterpret_cast<Context *>(callback_data);
if (voxel_data.size() == 0 && instances_data.size() == 0) {
PRINT_VERBOSE(String("Unexpected empty voxel data and instances data at {0} lod {1}")
.format(varray(Vector3(location.x, location.y, location.z), location.lod)));
ZN_PRINT_VERBOSE(String("Unexpected empty voxel data and instances data at {0} lod {1}")
.format(varray(Vector3(location.x, location.y, location.z), location.lod)));
return;
}
@ -874,8 +874,8 @@ void VoxelStreamSQLite::flush_cache() {
// This function does not lock any mutex for internal use.
void VoxelStreamSQLite::flush_cache(VoxelStreamSQLiteInternal *con) {
VOXEL_PROFILE_SCOPE();
PRINT_VERBOSE(String("VoxelStreamSQLite: Flushing cache ({0} elements)")
.format(varray(_cache.get_indicative_block_count())));
ZN_PRINT_VERBOSE(String("VoxelStreamSQLite: Flushing cache ({0} elements)")
.format(varray(_cache.get_indicative_block_count())));
ERR_FAIL_COND(con == nullptr);
ERR_FAIL_COND(con->begin_transaction() == false);

View File

@ -146,7 +146,7 @@ static Basis parse_basis(uint8_t data) {
Vector3i magica_x, magica_y, magica_z;
transpose(x, y, z, magica_x, magica_y, magica_z);
// PRINT_VERBOSE(String("---\nX: {0}\nY: {1}\nZ: {2}")
// ZN_PRINT_VERBOSE(String("---\nX: {0}\nY: {1}\nZ: {2}")
// .format(varray(magica_x.to_vec3(), magica_y.to_vec3(), magica_z.to_vec3())));
magica_x = magica_to_opengl(magica_x);
magica_y = magica_to_opengl(magica_y);
@ -199,7 +199,7 @@ Error Data::_load_from_file(String fpath) {
// https://github.com/ephtracy/voxel-model/blob/master/MagicaVoxel-file-format-vox.txt
// https://github.com/ephtracy/voxel-model/blob/master/MagicaVoxel-file-format-vox-extension.txt
PRINT_VERBOSE(String("Loading ") + fpath);
ZN_PRINT_VERBOSE(String("Loading ") + fpath);
Error open_err;
FileAccessRef f_ref = FileAccess::open(fpath, FileAccess::READ, &open_err);
@ -228,8 +228,8 @@ Error Data::_load_from_file(String fpath) {
const uint32_t chunk_size = f.get_32();
f.get_32(); // child_chunks_size
PRINT_VERBOSE(String("Reading chunk {0} at {1}, size={2}")
.format(varray(chunk_id, SIZE_T_TO_VARIANT(f.get_position()), chunk_size)));
ZN_PRINT_VERBOSE(String("Reading chunk {0} at {1}, size={2}")
.format(varray(chunk_id, ZN_SIZE_T_TO_VARIANT(f.get_position()), chunk_size)));
if (strcmp(chunk_id, "SIZE") == 0) {
Vector3i size;
@ -315,7 +315,7 @@ Error Data::_load_from_file(String fpath) {
// It is 3 integers formatted as text
Vector<float> coords = t_it->second.split_floats(" ");
ERR_FAIL_COND_V(coords.size() < 3, ERR_PARSE_ERROR);
//PRINT_VERBOSE(String("Pos: {0}, {1}, {2}").format(varray(coords[0], coords[1], coords[2])));
//ZN_PRINT_VERBOSE(String("Pos: {0}, {1}, {2}").format(varray(coords[0], coords[1], coords[2])));
node.position = magica_to_opengl(Vector3i(coords[0], coords[1], coords[2]));
}
@ -472,7 +472,7 @@ Error Data::_load_from_file(String fpath) {
_materials.insert(std::make_pair(material_id, std::move(material_ptr)));
} else {
PRINT_VERBOSE(String("Skipping chunk ") + chunk_id);
ZN_PRINT_VERBOSE(String("Skipping chunk ") + chunk_id);
// Ignore chunk
f.seek(f.get_position() + chunk_size);
}
@ -552,7 +552,7 @@ Error Data::_load_from_file(String fpath) {
ERR_FAIL_COND_V_MSG(_root_node_id == -1, ERR_INVALID_DATA, "Root node not found");
}
PRINT_VERBOSE(String("Done loading ") + fpath);
ZN_PRINT_VERBOSE(String("Done loading ") + fpath);
return OK;
}

View File

@ -110,7 +110,7 @@ void serialize_metadata(uint8_t *p_dst, const VoxelBufferInternal &buffer, const
CRASH_COND_MSG(static_cast<size_t>(dst - p_dst) != metadata_size,
String("Written metadata doesn't match expected count (expected {0}, got {1})")
.format(varray(SIZE_T_TO_VARIANT(metadata_size), (int)(dst - p_dst))));
.format(varray(ZN_SIZE_T_TO_VARIANT(metadata_size), (int)(dst - p_dst))));
}
template <typename T>

View File

@ -32,7 +32,7 @@ VoxelTerrain::VoxelTerrain() {
void run(TimeSpreadTaskContext &ctx) override {
if (!VoxelServer::get_singleton()->is_volume_valid(volume_id)) {
// The node can have been destroyed while this task was still pending
PRINT_VERBOSE("Cancelling ApplyMeshUpdateTask, volume_id is invalid");
ZN_PRINT_VERBOSE("Cancelling ApplyMeshUpdateTask, volume_id is invalid");
return;
}
self->apply_mesh_update(data);
@ -70,7 +70,7 @@ VoxelTerrain::VoxelTerrain() {
}
VoxelTerrain::~VoxelTerrain() {
PRINT_VERBOSE("Destroying VoxelTerrain");
ZN_PRINT_VERBOSE("Destroying VoxelTerrain");
VoxelServer::get_singleton()->remove_volume(_volume_id);
}
@ -535,7 +535,7 @@ void VoxelTerrain::unview_data_block(Vector3i bpos) {
// The block isn't loaded
LoadingBlock *loading_block = _loading_blocks.getptr(bpos);
if (loading_block == nullptr) {
PRINT_VERBOSE("Request to unview a loading block that was never requested");
ZN_PRINT_VERBOSE("Request to unview a loading block that was never requested");
// Not expected, but fine I guess
return;
}
@ -893,15 +893,15 @@ void VoxelTerrain::send_block_data_requests() {
// Blocks to save
if (_stream.is_valid()) {
for (unsigned int i = 0; i < _blocks_to_save.size(); ++i) {
PRINT_VERBOSE(String("Requesting save of block {0}").format(varray(_blocks_to_save[i].position)));
ZN_PRINT_VERBOSE(String("Requesting save of block {0}").format(varray(_blocks_to_save[i].position)));
const BlockToSave b = _blocks_to_save[i];
// TODO Batch request
VoxelServer::get_singleton()->request_voxel_block_save(_volume_id, b.voxels, b.position, 0);
}
} else {
if (_blocks_to_save.size() > 0) {
PRINT_VERBOSE(String("Not saving {0} blocks because no stream is assigned")
.format(varray(SIZE_T_TO_VARIANT(_blocks_to_save.size()))));
ZN_PRINT_VERBOSE(String("Not saving {0} blocks because no stream is assigned")
.format(varray(ZN_SIZE_T_TO_VARIANT(_blocks_to_save.size()))));
}
}
@ -980,7 +980,7 @@ void VoxelTerrain::process_viewers() {
for (size_t i = 0; i < _paired_viewers.size(); ++i) {
PairedViewer &p = _paired_viewers[i];
if (!VoxelServer::get_singleton()->viewer_exists(p.id)) {
PRINT_VERBOSE("Detected destroyed viewer in VoxelTerrain");
ZN_PRINT_VERBOSE("Detected destroyed viewer in VoxelTerrain");
// Interpret removal as nullified view distance so the same code handling loading of blocks
// will be used to unload those viewed by this viewer.
// We'll actually remove unpaired viewers in a second pass.
@ -1171,7 +1171,7 @@ void VoxelTerrain::process_viewers() {
// We no longer need unpaired viewers.
for (size_t i = 0; i < unpaired_viewer_indexes.size(); ++i) {
PRINT_VERBOSE("Unpairing viewer from VoxelTerrain");
ZN_PRINT_VERBOSE("Unpairing viewer from VoxelTerrain");
// Iterating backward so indexes of paired viewers will not change because of the removal
const size_t vi = unpaired_viewer_indexes[unpaired_viewer_indexes.size() - i - 1];
_paired_viewers[vi] = _paired_viewers.back();
@ -1206,9 +1206,9 @@ void VoxelTerrain::apply_data_block_response(VoxelServer::BlockDataOutput &ob) {
if (ob.dropped) {
// That block was cancelled by the server, but we are still expecting it.
// We'll have to request it again.
PRINT_VERBOSE(String("Received a block loading drop while we were still expecting it: "
"lod{0} ({1}, {2}, {3}), re-requesting it")
.format(varray(ob.lod, ob.position.x, ob.position.y, ob.position.z)));
ZN_PRINT_VERBOSE(String("Received a block loading drop while we were still expecting it: "
"lod{0} ({1}, {2}, {3}), re-requesting it")
.format(varray(ob.lod, ob.position.x, ob.position.y, ob.position.z)));
++_stats.dropped_block_loads;
_blocks_pending_load.push_back(ob.position);
@ -1417,7 +1417,7 @@ void VoxelTerrain::apply_mesh_update(const VoxelServer::BlockMeshOutput &ob) {
if (ob.type == VoxelServer::BlockMeshOutput::TYPE_DROPPED) {
// That block is loaded, but its meshing request was dropped.
// TODO Not sure what to do in this case, the code sending update queries has to be tweaked
PRINT_VERBOSE("Received a block mesh drop while we were still expecting it");
ZN_PRINT_VERBOSE("Received a block mesh drop while we were still expecting it");
++_stats.dropped_block_meshs;
return;
}

View File

@ -1084,7 +1084,7 @@ void VoxelInstancer::save_block(Vector3i data_grid_pos, int lod_index) const {
VOXEL_PROFILE_SCOPE();
ERR_FAIL_COND(_library.is_null());
PRINT_VERBOSE(String("Requesting save of instance block {0} lod {1}").format(varray(data_grid_pos, lod_index)));
ZN_PRINT_VERBOSE(String("Requesting save of instance block {0} lod {1}").format(varray(data_grid_pos, lod_index)));
const Lod &lod = _lods[lod_index];

View File

@ -122,7 +122,7 @@ VoxelLodTerrain::VoxelLodTerrain() {
// Godot may create and destroy dozens of instances of all node types on startup,
// due to how ClassDB gets its default values.
PRINT_VERBOSE("Construct VoxelLodTerrain");
ZN_PRINT_VERBOSE("Construct VoxelLodTerrain");
_data = gd_make_shared<VoxelDataLodMap>();
_update_data = gd_make_shared<VoxelLodTerrainUpdateData>();
@ -143,7 +143,7 @@ VoxelLodTerrain::VoxelLodTerrain() {
void run(TimeSpreadTaskContext &ctx) override {
if (!VoxelServer::get_singleton()->is_volume_valid(volume_id)) {
// The node can have been destroyed while this task was still pending
PRINT_VERBOSE("Cancelling ApplyMeshUpdateTask, volume_id is invalid");
ZN_PRINT_VERBOSE("Cancelling ApplyMeshUpdateTask, volume_id is invalid");
return;
}
self->apply_mesh_update(data);
@ -182,7 +182,7 @@ VoxelLodTerrain::VoxelLodTerrain() {
}
VoxelLodTerrain::~VoxelLodTerrain() {
PRINT_VERBOSE("Destroy VoxelLodTerrain");
ZN_PRINT_VERBOSE("Destroy VoxelLodTerrain");
abort_async_edits();
VoxelServer::get_singleton()->remove_volume(_volume_id);
// Instancer can take care of itself
@ -1083,7 +1083,7 @@ inline bool check_block_sizes(int data_block_size, int mesh_block_size) {
// void VoxelLodTerrain::send_block_save_requests(Span<BlockToSave> blocks_to_save) {
// for (unsigned int i = 0; i < blocks_to_save.size(); ++i) {
// BlockToSave &b = blocks_to_save[i];
// PRINT_VERBOSE(String("Requesting save of block {0} lod {1}").format(varray(b.position, b.lod)));
// ZN_PRINT_VERBOSE(String("Requesting save of block {0} lod {1}").format(varray(b.position, b.lod)));
// VoxelServer::get_singleton()->request_voxel_block_save(_volume_id, b.voxels, b.position, b.lod);
// }
// }
@ -1214,7 +1214,7 @@ void VoxelLodTerrain::apply_main_thread_update_tasks() {
// If the block was removed for a different reason then it is unexpected
ERR_CONTINUE(debug_removed_blocks.find(tu.block_position) == debug_removed_blocks.end());
#endif
PRINT_VERBOSE(String("Skipping TransitionUpdate at {0} lod {1}, block not found")
ZN_PRINT_VERBOSE(String("Skipping TransitionUpdate at {0} lod {1}, block not found")
.format(varray(tu.block_position, lod_index)));
*/
continue;
@ -1283,8 +1283,8 @@ void VoxelLodTerrain::apply_data_block_response(VoxelServer::BlockDataOutput &ob
if (!ob.initial_load) {
if (!thread_safe_contains(lod.loading_blocks, ob.position, lod.loading_blocks_mutex)) {
// That block was not requested, or is no longer needed. drop it...
PRINT_VERBOSE(String("Ignoring block {0} lod {1}, it was not in loading blocks")
.format(varray(ob.position, ob.lod)));
ZN_PRINT_VERBOSE(String("Ignoring block {0} lod {1}, it was not in loading blocks")
.format(varray(ob.position, ob.lod)));
++_stats.dropped_block_loads;
return;
}
@ -1363,7 +1363,7 @@ void VoxelLodTerrain::apply_mesh_update(const VoxelServer::BlockMeshOutput &ob)
if (ob.type == VoxelServer::BlockMeshOutput::TYPE_DROPPED) {
// That block is loaded, but its meshing request was dropped.
// TODO Not sure what to do in this case, the code sending update queries has to be tweaked
PRINT_VERBOSE("Received a block mesh drop while we were still expecting it");
ZN_PRINT_VERBOSE("Received a block mesh drop while we were still expecting it");
++_stats.dropped_block_meshs;
return;
}

View File

@ -100,7 +100,7 @@ public:
void write_box(const Box3i &p_voxel_box, unsigned int channel, F action) {
const Box3i voxel_box = p_voxel_box.clipped(get_voxel_bounds());
if (is_full_load_mode_enabled() == false && !is_area_editable(voxel_box)) {
PRINT_VERBOSE("Area not editable");
ZN_PRINT_VERBOSE("Area not editable");
return;
}
Ref<VoxelGenerator> generator = _generator;
@ -122,7 +122,7 @@ public:
void write_box_2(const Box3i &p_voxel_box, unsigned int channel1, unsigned int channel2, F action) {
const Box3i voxel_box = p_voxel_box.clipped(get_voxel_bounds());
if (is_full_load_mode_enabled() == false && !is_area_editable(voxel_box)) {
PRINT_VERBOSE("Area not editable");
ZN_PRINT_VERBOSE("Area not editable");
return;
}
Ref<VoxelGenerator> generator = _generator;

View File

@ -1137,7 +1137,7 @@ void VoxelLodTerrainUpdateTask::send_block_save_requests(uint32_t volume_id,
BufferedTaskScheduler &task_scheduler) {
for (unsigned int i = 0; i < blocks_to_save.size(); ++i) {
VoxelLodTerrainUpdateData::BlockToSave &b = blocks_to_save[i];
PRINT_VERBOSE(String("Requesting save of block {0} lod {1}").format(varray(b.position, b.lod)));
ZN_PRINT_VERBOSE(String("Requesting save of block {0} lod {1}").format(varray(b.position, b.lod)));
request_voxel_block_save(
volume_id, b.voxels, b.position, b.lod, stream_dependency, data_block_size, task_scheduler);
}
@ -1264,7 +1264,7 @@ static std::shared_ptr<AsyncDependencyTracker> preload_boxes_async(VoxelLodTerra
const Box3i voxel_box = voxel_boxes[box_index];
const Box3i block_box = voxel_box.downscaled(data_block_size << lod_index);
// PRINT_VERBOSE(String("Preloading box {0} at lod {1}")
// ZN_PRINT_VERBOSE(String("Preloading box {0} at lod {1}")
// .format(varray(block_box.to_string(), lod_index)));
const VoxelDataLodMap::Lod &data_lod = data.lods[lod_index];
@ -1280,7 +1280,7 @@ static std::shared_ptr<AsyncDependencyTracker> preload_boxes_async(VoxelLodTerra
}
}
PRINT_VERBOSE(String("Preloading boxes with {1} tasks").format(varray(SIZE_T_TO_VARIANT(todo.size()))));
ZN_PRINT_VERBOSE(String("Preloading boxes with {1} tasks").format(varray(ZN_SIZE_T_TO_VARIANT(todo.size()))));
std::shared_ptr<AsyncDependencyTracker> tracker = nullptr;
@ -1333,7 +1333,7 @@ static void process_async_edits(VoxelLodTerrainUpdateData::State &state,
// Not sure if worth doing, I dont think tasks can be aborted before even being scheduled
if (edit.task_tracker->is_aborted()) {
PRINT_VERBOSE("Aborted async edit");
ZN_PRINT_VERBOSE("Aborted async edit");
memdelete(edit.task);
continue;
}

View File

@ -5,16 +5,16 @@
// print_verbose() is used everywhere in the engine, but its drawback is that even if you turn it off, strings
// you print are still allocated and formatted, to not be used. This macro avoids the string.
#define PRINT_VERBOSE(msg) \
#define ZN_PRINT_VERBOSE(msg) \
if (OS::get_singleton()->is_stdout_verbose()) { \
print_line(msg); \
}
// TODO Waiting for a fix, Variant() can't be constructed from `size_t` on JavaScript and OSX builds.
// See https://github.com/godotengine/godot/issues/36690
#define SIZE_T_TO_VARIANT(s) static_cast<int64_t>(s)
#define ZN_SIZE_T_TO_VARIANT(s) static_cast<int64_t>(s)
#define VOXEL_ARRAY_LENGTH(a) (sizeof(a) / sizeof(a[0]))
#define ZN_ARRAY_LENGTH(a) (sizeof(a) / sizeof(a[0]))
// Godot does not define the TTR macro for translation of messages in release builds. However, there are some non-editor
// code that can produce errors in this module, and we still want them to compile properly.