Optimized 16-bit voxel box copies (used when meshing)
This commit is contained in:
parent
069dc9dee3
commit
73aed51ea2
@ -5,6 +5,8 @@
|
||||
#endif
|
||||
|
||||
#include "../edition/voxel_tool_buffer.h"
|
||||
#include "../util/funcs.h"
|
||||
#include "../util/profiling.h"
|
||||
#include "voxel_buffer.h"
|
||||
|
||||
#include <core/func_ref.h>
|
||||
@ -550,7 +552,20 @@ void VoxelBuffer::copy_from(const VoxelBuffer &other, Vector3i src_min, Vector3i
|
||||
}
|
||||
}
|
||||
|
||||
} else if (channel.depth == DEPTH_16_BIT) {
|
||||
Vector3i pos;
|
||||
for (pos.z = 0; pos.z < area_size.z; ++pos.z) {
|
||||
for (pos.x = 0; pos.x < area_size.x; ++pos.x) {
|
||||
const unsigned int src_ri =
|
||||
2 * other.get_index(pos.x + src_min.x, pos.y + src_min.y, pos.z + src_min.z);
|
||||
const unsigned int dst_ri =
|
||||
2 * get_index(pos.x + dst_min.x, pos.y + dst_min.y, pos.z + dst_min.z);
|
||||
memcpy(&channel.data[dst_ri], &other_channel.data[src_ri], area_size.y * sizeof(uint16_t));
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
VOXEL_PROFILE_SCOPE();
|
||||
// TODO Optimized versions
|
||||
Vector3i pos;
|
||||
for (pos.z = 0; pos.z < area_size.z; ++pos.z) {
|
||||
@ -812,7 +827,6 @@ void VoxelBuffer::for_each_voxel_metadata_in_area(Ref<FuncRef> callback, Rect3i
|
||||
// TODO Can't provide detailed error because FuncRef doesn't give us access to the object
|
||||
// ERR_FAIL_COND_MSG(err.error != Variant::CallError::CALL_OK, false,
|
||||
// Variant::get_call_error_text(callback->get_object(), method_name, nullptr, 0, err));
|
||||
|
||||
}
|
||||
elem = elem->next();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user