瀏覽代碼

Merge pull request #58496 from JFonS/fix_lm_crash

Rémi Verschelde 3 年之前
父節點
當前提交
4dc8214831
共有 2 個文件被更改,包括 3 次插入0 次删除
  1. 2 0
      modules/xatlas_unwrap/register_types.cpp
  2. 1 0
      scene/resources/mesh.cpp

+ 2 - 0
modules/xatlas_unwrap/register_types.cpp

@@ -120,6 +120,8 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver
 		xatlas::ChartOptions chart_options;
 		xatlas::ChartOptions chart_options;
 		chart_options.fixWinding = true;
 		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;
 		xatlas::PackOptions pack_options;
 		pack_options.padding = 1;
 		pack_options.padding = 1;
 		pack_options.maxChartSize = 4094; // Lightmap atlassing needs 2 for padding between meshes, so 4096-2
 		pack_options.maxChartSize = 4094; // Lightmap atlassing needs 2 for padding between meshes, so 4096-2

+ 1 - 0
scene/resources/mesh.cpp

@@ -1684,6 +1684,7 @@ Error ArrayMesh::lightmap_unwrap(const Transform3D &p_base_transform, float p_te
 Error ArrayMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform, float p_texel_size, const Vector<uint8_t> &p_src_cache, Vector<uint8_t> &r_dst_cache, bool p_generate_cache) {
 Error ArrayMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform, float p_texel_size, const Vector<uint8_t> &p_src_cache, Vector<uint8_t> &r_dst_cache, bool p_generate_cache) {
 	ERR_FAIL_COND_V(!array_mesh_lightmap_unwrap_callback, ERR_UNCONFIGURED);
 	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(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> vertices;
 	LocalVector<float> normals;
 	LocalVector<float> normals;