Skip to content

Commit

Permalink
Remove unnecessary prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zylann committed Jun 9, 2024
1 parent e04ce22 commit d382330
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions terrain/instancing/generate_instances_block_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ void GenerateInstancesBlockTask::run(ThreadedTaskContext &ctx) {

{
MutexLock mlock(output_queue->mutex);
output_queue->results.push_back(VoxelInstanceLoadingTaskOutput());
VoxelInstanceLoadingTaskOutput &o = output_queue->results.back();
output_queue->results.push_back(InstanceLoadingTaskOutput());
InstanceLoadingTaskOutput &o = output_queue->results.back();
o.layer_id = layer_id;
o.edited_mask = edited_mask;
o.render_block_position = mesh_block_grid_position;
Expand Down
2 changes: 1 addition & 1 deletion terrain/instancing/generate_instances_block_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class GenerateInstancesBlockTask : public IThreadedTask {
Ref<VoxelInstanceGenerator> generator;
// Can be pre-populated by edited transforms
StdVector<Transform3f> transforms;
std::shared_ptr<VoxelInstancerTaskOutputQueue> output_queue;
std::shared_ptr<InstancerTaskOutputQueue> output_queue;

const char *get_debug_name() const override {
return "GenerateInstancesBlock";
Expand Down
8 changes: 4 additions & 4 deletions terrain/instancing/load_instance_block_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
namespace zylann::voxel {

LoadInstanceChunkTask::LoadInstanceChunkTask( //
std::shared_ptr<VoxelInstancerTaskOutputQueue> output_queue, //
std::shared_ptr<InstancerTaskOutputQueue> output_queue, //
Ref<VoxelStream> stream, //
std::shared_ptr<VoxelInstancerQuickReloadingCache> quick_reload_cache,
std::shared_ptr<InstancerQuickReloadingCache> quick_reload_cache,
Ref<VoxelInstanceLibrary> library, //
Array mesh_arrays, //
Vector3i grid_position, //
uint8_t lod_index, //
uint8_t instance_block_size, //
uint8_t data_block_size, //
UpMode up_mode //
) :
) :
//
_output_queue(output_queue), //
_stream(stream), //
Expand Down Expand Up @@ -251,7 +251,7 @@ void LoadInstanceChunkTask::run(ThreadedTaskContext &ctx) {

// Post results
for (Layer &layer : layers) {
VoxelInstanceLoadingTaskOutput o;
InstanceLoadingTaskOutput o;
o.layer_id = layer.id;
// Will normally be full
o.edited_mask = layer.edited_mask;
Expand Down
10 changes: 5 additions & 5 deletions terrain/instancing/load_instance_block_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

namespace zylann::voxel {

struct VoxelInstancerQuickReloadingCache;
struct InstancerQuickReloadingCache;

// Loads all instances of all layers of a specific LOD in a specific chunk
class LoadInstanceChunkTask : public IThreadedTask {
public:
LoadInstanceChunkTask( //
std::shared_ptr<VoxelInstancerTaskOutputQueue> output_queue, //
std::shared_ptr<InstancerTaskOutputQueue> output_queue, //
Ref<VoxelStream> stream, //
std::shared_ptr<VoxelInstancerQuickReloadingCache> quick_reload_cache,
std::shared_ptr<InstancerQuickReloadingCache> quick_reload_cache,
Ref<VoxelInstanceLibrary> library, //
Array mesh_arrays, //
Vector3i grid_position, //
Expand All @@ -38,9 +38,9 @@ class LoadInstanceChunkTask : public IThreadedTask {
void run(ThreadedTaskContext &ctx) override;

private:
std::shared_ptr<VoxelInstancerTaskOutputQueue> _output_queue;
std::shared_ptr<InstancerTaskOutputQueue> _output_queue;
Ref<VoxelStream> _stream;
std::shared_ptr<VoxelInstancerQuickReloadingCache> _quick_reload_cache;
std::shared_ptr<InstancerQuickReloadingCache> _quick_reload_cache;
Ref<VoxelInstanceLibrary> _library;
Array _mesh_arrays;
Vector3i _render_grid_position;
Expand Down
12 changes: 6 additions & 6 deletions terrain/instancing/voxel_instancer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ StdVector<Transform3f> &get_tls_transform_cache() {
VoxelInstancer::VoxelInstancer() {
set_notify_transform(true);
set_process_internal(true);
_loading_results = make_shared_instance<VoxelInstancerTaskOutputQueue>();
_loading_results = make_shared_instance<InstancerTaskOutputQueue>();
fill(_mesh_lod_distances, 0.f);
}

Expand Down Expand Up @@ -222,8 +222,8 @@ void VoxelInstancer::process() {

void VoxelInstancer::process_task_results() {
ZN_PROFILE_SCOPE();
static thread_local StdVector<VoxelInstanceLoadingTaskOutput> tls_results;
StdVector<VoxelInstanceLoadingTaskOutput> &results = tls_results;
static thread_local StdVector<InstanceLoadingTaskOutput> tls_results;
StdVector<InstanceLoadingTaskOutput> &results = tls_results;
#ifdef DEBUG_ENABLED
if (results.size()) {
ZN_PRINT_ERROR("Results were not cleaned up?");
Expand All @@ -232,7 +232,7 @@ void VoxelInstancer::process_task_results() {
{
MutexLock mlock(_loading_results->mutex);
// Copy results to temporary buffer
StdVector<VoxelInstanceLoadingTaskOutput> &src = _loading_results->results;
StdVector<InstanceLoadingTaskOutput> &src = _loading_results->results;
results.resize(src.size());
for (unsigned int i = 0; i < src.size(); ++i) {
results[i] = std::move(src[i]);
Expand All @@ -254,7 +254,7 @@ void VoxelInstancer::process_task_results() {
const int mesh_block_size_base = (1 << _parent_mesh_block_size_po2);
const int render_to_data_factor = mesh_block_size_base / data_block_size_base;

for (VoxelInstanceLoadingTaskOutput &output : results) {
for (InstanceLoadingTaskOutput &output : results) {
auto layer_it = _layers.find(output.layer_id);
if (layer_it == _layers.end()) {
// Layer was removed since?
Expand Down Expand Up @@ -1613,7 +1613,7 @@ SaveBlockDataTask *VoxelInstancer::save_block(
UniquePtr<InstanceBlockData> saving_cache = make_unique_instance<InstanceBlockData>();
block_data->copy_to(*saving_cache);
if (lod_mutable.quick_reload_cache == nullptr) {
lod_mutable.quick_reload_cache = make_shared_instance<VoxelInstancerQuickReloadingCache>();
lod_mutable.quick_reload_cache = make_shared_instance<InstancerQuickReloadingCache>();
}
{
MutexLock mlock(lod_mutable.quick_reload_cache->mutex);
Expand Down
8 changes: 4 additions & 4 deletions terrain/instancing/voxel_instancer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class VoxelTool;
class SaveBlockDataTask;
class BufferedTaskScheduler;
struct InstanceBlockData;
struct VoxelInstancerQuickReloadingCache;
struct VoxelInstancerTaskOutputQueue;
struct InstancerQuickReloadingCache;
struct InstancerTaskOutputQueue;
struct InstanceLibraryMultiMeshItemSettings;

// Note: a large part of this node could be made generic to support the sole idea of instancing within octants?
Expand Down Expand Up @@ -293,7 +293,7 @@ class VoxelInstancer : public Node3D, public IInstanceLibraryItemListener {
// Keys follows the data block coordinate system.
StdUnorderedSet<Vector3i> edited_data_blocks;

std::shared_ptr<VoxelInstancerQuickReloadingCache> quick_reload_cache;
std::shared_ptr<InstancerQuickReloadingCache> quick_reload_cache;

// FixedArray<MeshLodDistances, VoxelInstanceLibraryMultiMeshItem::MAX_MESH_LODS> mesh_lod_distances;
};
Expand All @@ -318,7 +318,7 @@ class VoxelInstancer : public Node3D, public IInstanceLibraryItemListener {
// float _mesh_lod_update_camera_threshold_distance = 8.f;
unsigned int _mesh_lod_time_sliced_block_index = 0;

std::shared_ptr<VoxelInstancerTaskOutputQueue> _loading_results;
std::shared_ptr<InstancerTaskOutputQueue> _loading_results;

#ifdef TOOLS_ENABLED
zylann::godot::DebugRenderer _debug_renderer;
Expand Down
2 changes: 1 addition & 1 deletion terrain/instancing/voxel_instancer_quick_reloading_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct InstanceBlockData;
// If chunks need to be loaded again before saving has completed or even started, they will be picked from this cache
// instead. Without this, chunks could be reloaded before getting saved, leading to loss of data. As confusing as it
// sounds, this can happen because saving and loading is multi-threaded.
struct VoxelInstancerQuickReloadingCache {
struct InstancerQuickReloadingCache {
StdUnorderedMap<Vector3i, UniquePtr<InstanceBlockData>> map;
Mutex mutex;
};
Expand Down
6 changes: 3 additions & 3 deletions terrain/instancing/voxel_instancer_task_output_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace zylann::voxel {

struct VoxelInstanceLoadingTaskOutput {
struct InstanceLoadingTaskOutput {
Vector3i render_block_position;
uint8_t layer_id;
// Tells which parts of the block contain edited data (non-generated).
Expand All @@ -18,8 +18,8 @@ struct VoxelInstanceLoadingTaskOutput {
StdVector<Transform3f> transforms;
};

struct VoxelInstancerTaskOutputQueue {
StdVector<VoxelInstanceLoadingTaskOutput> results;
struct InstancerTaskOutputQueue {
StdVector<InstanceLoadingTaskOutput> results;
Mutex mutex;
};

Expand Down

0 comments on commit d382330

Please sign in to comment.