From 14e792766ebc00e1af6070ae27013ac29bf4eab8 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Fri, 1 Apr 2022 00:33:51 +0300 Subject: SL-17121 Adjust uploader for possible 0 input. --- indra/newview/llmodelpreview.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp index 8bf88cb5e8..00613b1d80 100644 --- a/indra/newview/llmodelpreview.cpp +++ b/indra/newview/llmodelpreview.cpp @@ -1286,7 +1286,14 @@ F32 LLModelPreview::genMeshOptimizerPerModel(LLModel *base_model, LLModel *targe F32 result_error = 0; // how far from original the model is, 1 == 100% S32 new_indices = 0; - target_indices = llclamp(llfloor(size_indices / indices_decimator), 3, (S32)size_indices); // leave at least one triangle + if (indices_decimator > 0) + { + target_indices = llclamp(llfloor(size_indices / indices_decimator), 3, (S32)size_indices); // leave at least one triangle + } + else // indices_decimator can be zero for error_threshold based calculations + { + target_indices = 3; + } new_indices = LLMeshOptimizer::simplifyU32( output_indices, combined_indices, @@ -1490,7 +1497,14 @@ F32 LLModelPreview::genMeshOptimizerPerFace(LLModel *base_model, LLModel *target F32 result_error = 0; // how far from original the model is, 1 == 100% S32 new_indices = 0; - target_indices = llclamp(llfloor(size_indices / indices_decimator), 3, (S32)size_indices); // leave at least one triangle + if (indices_decimator > 0) + { + target_indices = llclamp(llfloor(size_indices / indices_decimator), 3, (S32)size_indices); // leave at least one triangle + } + else + { + target_indices = 3; + } new_indices = LLMeshOptimizer::simplify( output, face.mIndices, @@ -1627,7 +1641,8 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d } // meshoptimizer doesn't use triangle limit, it uses indices limit, so convert it to aproximate ratio - indices_decimator = (F32)base_triangle_count / triangle_limit; + // triangle_limit can be 0. + indices_decimator = (F32)base_triangle_count / llmax(triangle_limit, 1.f); } else { -- cgit v1.2.3