Support setting up mesh LODs from a scene with name `LODx` suffixes
parent
2a36f3fd1c
commit
fefb014637
|
@ -22,6 +22,7 @@ Godot 4 is required from this version.
|
|||
- `VoxelToolLodTerrain`: added *experimental* `do_sphere_async`, an alternative version of `do_sphere` which defers the task on threads to reduce stutter if the affected area is big.
|
||||
- `VoxelInstancer`: Allow to dump VoxelInstancer as scene for debug inspection
|
||||
- `VoxelInstancer`: Editor: instance chunks are shown when the node is selected
|
||||
- `VoxelInstanceLibraryMultiMeshItem`: Support setting up mesh LODs from a scene with name `LODx` suffixes
|
||||
|
||||
- Fixes
|
||||
- `VoxelBuffer`: frequently creating buffers with always different sizes no longer wastes memory
|
||||
|
@ -41,6 +42,8 @@ Godot 4 is required from this version.
|
|||
- `Voxel` was renamed `VoxelBlockyModel`
|
||||
- `VoxelLibrary` was renamed `VoxelBlockyLibrary`
|
||||
- `VoxelVoxImporter` was renamed `VoxelVoxSceneImporter`
|
||||
- `VoxelInstanceLibraryItem` was renamed `VoxelInstanceLibraryMultiMeshItem`
|
||||
- `VoxelInstanceLibraryItemBase` was renamed `VoxelInstanceLibraryItem`
|
||||
|
||||
- Known issues
|
||||
- Some nodes and resources no longer start with predefined properties due to a warning introduced in Godot4 when properties are resources.
|
||||
|
|
|
@ -104,7 +104,10 @@ This conversion process expects your scene to follow a specific structure:
|
|||
|
||||
```
|
||||
- PhysicsBody (StaticBody, RigidBody...)
|
||||
- MeshInstance
|
||||
- MeshInstance_LOD0 <-- "LOD" suffixes are optional but allow to specify the 4 LODs if needed
|
||||
- MeshInstance_LOD1
|
||||
- MeshInstance_LOD2
|
||||
- MeshInstance_LOD3
|
||||
- CollisionShape1
|
||||
- CollisionShape2
|
||||
- ...
|
||||
|
|
|
@ -98,6 +98,24 @@ static RenderingServer::ShadowCastingSetting node_to_visual_server_enum(Geometry
|
|||
}
|
||||
|
||||
void VoxelInstanceLibraryMultiMeshItem::setup_from_template(Node *root) {
|
||||
struct L {
|
||||
static unsigned int get_lod_index_from_name(const String &name) {
|
||||
if (name.ends_with("LOD0")) {
|
||||
return 0;
|
||||
}
|
||||
if (name.ends_with("LOD1")) {
|
||||
return 1;
|
||||
}
|
||||
if (name.ends_with("LOD2")) {
|
||||
return 2;
|
||||
}
|
||||
if (name.ends_with("LOD3")) {
|
||||
return 3;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
ERR_FAIL_COND(root == nullptr);
|
||||
|
||||
_collision_shapes.clear();
|
||||
|
@ -111,9 +129,9 @@ void VoxelInstanceLibraryMultiMeshItem::setup_from_template(Node *root) {
|
|||
for (int i = 0; i < root->get_child_count(); ++i) {
|
||||
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(root->get_child(i));
|
||||
if (mi != nullptr) {
|
||||
// TODO Support LODs
|
||||
_mesh_lods[0] = mi->get_mesh();
|
||||
_mesh_lod_count = 1;
|
||||
const unsigned int lod_index = L::get_lod_index_from_name(mi->get_name());
|
||||
_mesh_lods[lod_index] = mi->get_mesh();
|
||||
_mesh_lod_count = math::max(lod_index + 1, _mesh_lod_count);
|
||||
_material_override = mi->get_material_override();
|
||||
_shadow_casting_setting = node_to_visual_server_enum(mi->get_cast_shadows_setting());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue