Skip to content

Commit

Permalink
Add sanity checks to lightmap unwrap texel size
Browse files Browse the repository at this point in the history
(cherry picked from commit d0fd5fd)
  • Loading branch information
JFonS authored and akien-mga committed Feb 24, 2022
1 parent 76de874 commit 0959ff2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/xatlas_unwrap/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver
xatlas::ChartOptions chart_options;
chart_options.fixWinding = true;

ERR_FAIL_COND_V_MSG(p_texel_size <= 0.0f, false, "Texel size must be greater than 0.");

xatlas::PackOptions pack_options;
pack_options.padding = 1;
pack_options.maxChartSize = 4094; // Lightmap atlassing needs 2 for padding between meshes, so 4096-2
Expand Down
1 change: 1 addition & 0 deletions scene/resources/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@ Error ArrayMesh::lightmap_unwrap(const Transform &p_base_transform, float p_texe
Error ArrayMesh::lightmap_unwrap_cached(int *&r_cache_data, unsigned int &r_cache_size, bool &r_used_cache, const Transform &p_base_transform, float p_texel_size) {
ERR_FAIL_COND_V(!array_mesh_lightmap_unwrap_callback, ERR_UNCONFIGURED);
ERR_FAIL_COND_V_MSG(blend_shapes.size() != 0, ERR_UNAVAILABLE, "Can't unwrap mesh with blend shapes.");
ERR_FAIL_COND_V_MSG(p_texel_size <= 0.0f, ERR_PARAMETER_RANGE_ERROR, "Texel size must be greater than 0.");

LocalVector<float> vertices;
LocalVector<float> normals;
Expand Down

0 comments on commit 0959ff2

Please sign in to comment.