Rename lod => lod_index

master
Marc Gilleron 2022-08-24 23:53:22 +01:00
parent c4b8a1e948
commit ca29cde90d
6 changed files with 13 additions and 14 deletions

View File

@ -472,7 +472,7 @@ void VoxelMesherBlocky::build(VoxelMesher::Output &output, const VoxelMesher::In
const VoxelBufferInternal &voxels = input.voxels;
#ifdef TOOLS_ENABLED
if (input.lod != 0) {
if (input.lod_index != 0) {
WARN_PRINT("VoxelMesherBlocky received lod != 0, it is not supported");
}
#endif

View File

@ -881,10 +881,10 @@ void VoxelMesherCubes::build(VoxelMesher::Output &output, const VoxelMesher::Inp
break;
}
if (input.lod > 0) {
if (input.lod_index > 0) {
// TODO This is very crude LOD, there will be cracks at the borders.
// One way would be to not cull faces on chunk borders if any neighbor face is air
const float lod_scale = 1 << input.lod;
const float lod_scale = 1 << input.lod_index;
for (unsigned int material_index = 0; material_index < cache.arrays_per_material.size(); ++material_index) {
Arrays &arrays = cache.arrays_per_material[material_index];
for (unsigned int i = 0; i < arrays.positions.size(); ++i) {

View File

@ -1471,7 +1471,7 @@ void VoxelMesherDMC::build(VoxelMesher::Output &output, const VoxelMesher::Input
if (root != nullptr) {
if (params.mesh_mode == MESH_DEBUG_OCTREE) {
surface = dmc::generate_debug_octree_mesh(root, 1 << input.lod);
surface = dmc::generate_debug_octree_mesh(root, 1 << input.lod_index);
} else {
time_before = Time::get_singleton()->get_ticks_usec();
@ -1483,7 +1483,7 @@ void VoxelMesherDMC::build(VoxelMesher::Output &output, const VoxelMesher::Input
stats.dualgrid_derivation_time = Time::get_singleton()->get_ticks_usec() - time_before;
if (params.mesh_mode == MESH_DEBUG_DUAL_GRID) {
surface = dmc::generate_debug_dual_grid_mesh(cache.dual_grid, 1 << input.lod);
surface = dmc::generate_debug_dual_grid_mesh(cache.dual_grid, 1 << input.lod_index);
} else {
time_before = Time::get_singleton()->get_ticks_usec();
@ -1507,8 +1507,8 @@ void VoxelMesherDMC::build(VoxelMesher::Output &output, const VoxelMesher::Input
if (surface.is_empty()) {
time_before = Time::get_singleton()->get_ticks_usec();
if (input.lod > 0) {
cache.mesh_builder.scale(1 << input.lod);
if (input.lod_index > 0) {
cache.mesh_builder.scale(1 << input.lod_index);
}
surface = cache.mesh_builder.commit(params.mesh_mode == MESH_WIREFRAME);
stats.commit_time = Time::get_singleton()->get_ticks_usec() - time_before;

View File

@ -232,16 +232,16 @@ void VoxelMesherTransvoxel::build(VoxelMesher::Output &output, const VoxelMesher
cell_infos = &transvoxel::tls_cell_infos;
}
if (_deep_sampling_enabled && input.generator != nullptr && input.data != nullptr && input.lod > 0) {
if (_deep_sampling_enabled && input.generator != nullptr && input.data != nullptr && input.lod_index > 0) {
const DeepSampler ds(*input.generator, *input.data, sdf_channel, input.origin_in_voxels);
// TODO Optimization: "area scope" feature on generators to optimize certain uses of `generate_single`.
// The idea is to call `begin_area(box)` and `end_area()`, so the generator can optimize random calls to
// `generate_single` in between, knowing they will all be done within the specified area.
default_texture_indices_data = transvoxel::build_regular_mesh(voxels, sdf_channel, input.lod,
default_texture_indices_data = transvoxel::build_regular_mesh(voxels, sdf_channel, input.lod_index,
static_cast<transvoxel::TexturingMode>(_texture_mode), tls_cache, mesh_arrays, &ds, cell_infos);
} else {
default_texture_indices_data = transvoxel::build_regular_mesh(voxels, sdf_channel, input.lod,
default_texture_indices_data = transvoxel::build_regular_mesh(voxels, sdf_channel, input.lod_index,
static_cast<transvoxel::TexturingMode>(_texture_mode), tls_cache, mesh_arrays, nullptr, cell_infos);
}
@ -272,7 +272,7 @@ void VoxelMesherTransvoxel::build(VoxelMesher::Output &output, const VoxelMesher
for (int dir = 0; dir < Cube::SIDE_COUNT; ++dir) {
ZN_PROFILE_SCOPE();
transvoxel::build_transition_mesh(voxels, sdf_channel, dir, input.lod,
transvoxel::build_transition_mesh(voxels, sdf_channel, dir, input.lod_index,
static_cast<transvoxel::TexturingMode>(_texture_mode), tls_cache, *combined_mesh_arrays,
default_texture_indices_data);
}

View File

@ -79,7 +79,7 @@ Ref<Mesh> VoxelMesher::build_mesh(
compute_normalmap(cell_iterator, to_span(mesh_arrays.vertices), to_span(mesh_arrays.normals),
to_span(mesh_arrays.indices), nm_data, virtual_texture_settings.tile_resolution_min,
*input.generator, nullptr, input.origin_in_voxels, input.lod,
*input.generator, nullptr, input.origin_in_voxels, input.lod_index,
virtual_texture_settings.octahedral_encoding_enabled);
const Vector3i block_size =

View File

@ -32,8 +32,7 @@ public:
// Origin of the block is required when doing deep sampling.
Vector3i origin_in_voxels;
// LOD index. 0 means highest detail. 1 means half detail etc.
// TODO Rename `lod_index`
uint8_t lod = 0;
uint8_t lod_index = 0;
// If true, collision information is required.
// Sometimes it doesn't change anything as the rendering mesh can be used as collider,
// but in other setups it can be different and will be returned in `collision_surface`.