godotengine / godotengine/godot
Unhelpful error message when ArrayMesh has a shadow_mesh with a different number of surfaces
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Initially found in 4.2.2 (Steam buildid 14084462).
Reproducible in 4.0-stable (after removing type hints on loops).
Reproducible in 4.1-stable (after removing type hints on loops).
Reproducible in 4.3-beta3.
### System information
Godot v4.2.2.stable - Debian GNU/Linux trixie/sid trixie - Wayland - Vulkan (Forward+) - integrated Intel(R) Graphics (RPL-P) () - 13th Gen Intel(R) Core(TM) i7-1360P (16 Threads)
### Issue description
The repro project spams the following errors in the output window:
```
ERROR: Index p_surface_index = 1 is out of bounds (mesh->surface_count = 1).
at: mesh_get_surface (./servers/rendering/renderer_rd/storage_rd/mesh_storage.h:382)
ERROR: Index p_surface_index = 2 is out of bounds (mesh->surface_count = 1).
at: mesh_get_surface (./servers/rendering/renderer_rd/storage_rd/mesh_storage.h:382)
ERROR: Index p_surface_index = 1 is out of bounds (mesh->surface_count = 1).
at: mesh_get_surface (./servers/rendering/renderer_rd/storage_rd/mesh_storage.h:382)
ERROR: Index p_surface_index = 2 is out of bounds (mesh->surface_count = 1).
at: mesh_get_surface (./servers/rendering/renderer_rd/storage_rd/mesh_storage.h:382)
```
There does not appear to be anything wrong visually, but obviously there is something wrong if it's spamming error messages.
### Steps to reproduce
1. Open project
2. Observe output window
If the code in `res://code/terrain/terrain_mesh.gd` is removed, the error still occurs, but only once.
### Minimal reproduction project (MRP)
[voxel.zip](https://github.com/user-attachments/files/16365065/voxel.zip)
Contributor guide
Research direction
Reproduce the output spam with the linked voxel project, then inspect mesh_get_surface in servers/rendering/renderer_rd/storage_rd/mesh_storage.h and the shadow_mesh surface handling. Trace why surface indices exceed the shadow mesh surface count, and make the resulting diagnostic identify the mismatched surface configuration; verify the repro no longer emits unhelpful repeated errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics, game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100