Clamp VoxelGI extents to reasonable values to avoid breaking baking

This also prevents crashes when resizing a VoxelGI's extents to 0
on any axis.
This commit is contained in:
Hugo Locurcio 2022-07-05 18:30:56 +02:00
parent 5f386fecf0
commit aa9403bcda
No known key found for this signature in database
GPG Key ID: 39E8F8BE30B0A49C
2 changed files with 3 additions and 1 deletions

View File

@ -37,6 +37,7 @@
</member>
<member name="extents" type="Vector3" setter="set_extents" getter="get_extents" default="Vector3(10, 10, 10)">
The size of the area covered by the [VoxelGI]. If you make the extents larger without increasing the subdivisions with [member subdiv], the size of each cell will increase and result in lower detailed lighting.
[b]Note:[/b] Extents are clamped to 1.0 unit or more on each axis.
</member>
<member name="subdiv" type="int" setter="set_subdiv" getter="get_subdiv" enum="VoxelGI.Subdiv" default="1">
Number of times to subdivide the grid that the [VoxelGI] operates on. A higher number results in finer detail and thus higher visual quality, while lower numbers result in better performance.

View File

@ -272,7 +272,8 @@ VoxelGI::Subdiv VoxelGI::get_subdiv() const {
}
void VoxelGI::set_extents(const Vector3 &p_extents) {
extents = p_extents;
// Prevent very small extents as these break baking if other extents are set very high.
extents = Vector3(MAX(1.0, p_extents.x), MAX(1.0, p_extents.y), MAX(1.0, p_extents.z));
update_gizmos();
}