diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llmeshoptimizer/llmeshoptimizer.h | 6 | ||||
-rw-r--r-- | indra/newview/llmodelpreview.cpp | 56 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_model_preview.xml | 24 |
3 files changed, 46 insertions, 40 deletions
diff --git a/indra/llmeshoptimizer/llmeshoptimizer.h b/indra/llmeshoptimizer/llmeshoptimizer.h index 2696733eb2..e881ec26c5 100644 --- a/indra/llmeshoptimizer/llmeshoptimizer.h +++ b/indra/llmeshoptimizer/llmeshoptimizer.h @@ -46,6 +46,7 @@ public: // returns amount of indices in destiantion // result_error returns how far from original the model is in % if not NULL + // Works with U32 indices (LLFace uses U16 indices) static U64 simplifyU32( U32 *destination, const U32 *indices, @@ -57,8 +58,9 @@ public: F32 target_error, F32* result_error); - // returns amount of indices in destiantion - // result_error returns how far from original the model is in % if not NULL + // Returns amount of indices in destiantion + // Result_error returns how far from original the model is in % if not NULL + // Meant for U16 indices (LLFace uses U16 indices) static U64 simplify( U16 *destination, const U16 *indices, diff --git a/indra/newview/llmodelpreview.cpp b/indra/newview/llmodelpreview.cpp index 3704cc2ea5..96eb9340f5 100644 --- a/indra/newview/llmodelpreview.cpp +++ b/indra/newview/llmodelpreview.cpp @@ -1840,7 +1840,9 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d LLModel* target_model = mModel[lod][mdl_idx]; - if (meshopt_mode == MESH_OPTIMIZER_COMBINE) + S32 model_meshopt_mode = meshopt_mode; + + if (model_meshopt_mode == MESH_OPTIMIZER_COMBINE) { // Figure out buffer size S32 size_indices = 0; @@ -1961,22 +1963,23 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d if (copy_triangle) { - if (idx >= U16_MAX) - { - // Shouldn't happen due to simplification? - // Todo: add a fallback? - LL_ERRS() << "Over triangle limit" << LL_ENDL; - break; - } - if (old_to_new_positions_map[idx] == -1) { // New position, need to copy it // Validate size if (buf_positions_copied >= U16_MAX) { - // Shouldn't happen due to simplification? - LL_ERRS() << "Over triangle limit" << LL_ENDL; + // Normally this shouldn't happen since the whole point is to reduce amount of vertices + // but it might happen if user tries to run optimization with too large triangle or error value + // so fallback to 'per face' mode or verify requested limits and copy base model as is. + LL_WARNS() << "Over triangle limit. Failed to optimize in 'per object' mode, falling back to per face variant for" + << " model " << target_model->mLabel + << " target Indices: " << target_indices + << " new Indices: " << new_indices + << " original count: " << size_indices + << " error treshold: " << lod_error_threshold + << LL_ENDL; + model_meshopt_mode = MESH_OPTIMIZER; break; } @@ -1999,6 +2002,11 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d } } + if (buf_positions_copied >= U16_MAX) + { + break; + } + LLVolumeFace &new_face = target_model->getVolumeFace(face_idx); //new_face = face; //temp @@ -2037,7 +2045,9 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d ll_aligned_free_32(buffer_indices); ll_aligned_free_32(combined_indices); } - else + + if (model_meshopt_mode == MESH_OPTIMIZER + || model_meshopt_mode == MESH_OPTIMIZER_SLOPPY) { // Run meshoptimizer for each face for (U32 face_idx = 0; face_idx < base->getNumVolumeFaces(); ++face_idx) @@ -2049,21 +2059,11 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d S32 size = (num_indices * sizeof(U16) + 0xF) & ~0xF; U16* output = (U16*)ll_aligned_malloc_16(size); - /* - generateShadowIndexBuffer appears to deform model - LLMeshOptimizer::generateShadowIndexBuffer( - &shadow[0], - face.mIndices, - num_indices, - &face.mPositions[0], - face.mNumVertices); - */ - S32 target_indices = 0; F32 result_code = 0; // how far from original the model is, 1 == 100% S32 new_indices = 0; - if (meshopt_mode == MESH_OPTIMIZER_SLOPPY) + if (model_meshopt_mode == MESH_OPTIMIZER_SLOPPY) { target_indices = llfloor(num_indices * indices_ratio); new_indices = LLMeshOptimizer::simplifySloppy( @@ -2078,7 +2078,7 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d &result_code); } - if (meshopt_mode == MESH_OPTIMIZER) + if (model_meshopt_mode == MESH_OPTIMIZER) { target_indices = llmax(3, llfloor(num_indices * indices_ratio)); // leave at least one triangle new_indices = LLMeshOptimizer::simplify( @@ -2100,7 +2100,9 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d << " of model " << target_model->mLabel << " target Indices: " << target_indices << " new Indices: " << new_indices - << " original count: " << num_indices << LL_ENDL; + << " original count: " << num_indices + << " error treshold: " << lod_error_threshold + << LL_ENDL; } LLVolumeFace &new_face = target_model->getVolumeFace(face_idx); @@ -2118,7 +2120,9 @@ void LLModelPreview::genMeshOptimizerLODs(S32 which_lod, S32 meshopt_mode, U32 d LL_INFOS() << "No indices generated by meshoptimizer for face " << face_idx << " of model " << target_model->mLabel << " target Indices: " << target_indices - << " original count: " << num_indices << LL_ENDL; + << " original count: " << num_indices + << " error treshold: " << lod_error_threshold + << LL_ENDL; } // Face got optimized away diff --git a/indra/newview/skins/default/xui/en/floater_model_preview.xml b/indra/newview/skins/default/xui/en/floater_model_preview.xml index 5c78ef55d1..cd67adf42a 100644 --- a/indra/newview/skins/default/xui/en/floater_model_preview.xml +++ b/indra/newview/skins/default/xui/en/floater_model_preview.xml @@ -178,15 +178,15 @@ value="Generate" /> <item name="MeshOpt" - label="MeshOpt" + label="Simplify per face" value="MeshOpt" /> <item name="MeshOptSloppy" - label="MeshOptSloppy" + label="Simplify sloppy" value="MeshOptSloppy" /> <item name="MeshOptCombine" - label="MeshOptCombine" + label="Simplify per object" value="MeshOptCombine" /> </combo_box> <line_editor @@ -319,15 +319,15 @@ value="Generate" /> <item name="MeshOpt" - label="MeshOpt" + label="Simplify per face" value="MeshOpt" /> <item name="MeshOptSloppy" - label="MeshOptSloppy" + label="Simplify sloppy" value="MeshOptSloppy" /> <item name="MeshOptCombine" - label="MeshOptCombine" + label="Simplify per object" value="MeshOptCombine" /> <item name="Use LoD above" @@ -464,15 +464,15 @@ value="Generate" /> <item name="MeshOpt" - label="MeshOpt" + label="Simplify per face" value="MeshOpt" /> <item name="MeshOptSloppy" - label="MeshOptSloppy" + label="Simplify sloppy" value="MeshOptSloppy" /> <item name="MeshOptCombine" - label="MeshOptCombine" + label="Simplify per object" value="MeshOptCombine" /> <item name="Use LoD above" @@ -609,15 +609,15 @@ value="Generate" /> <item name="MeshOpt" - label="MeshOpt" + label="Simplify per face" value="MeshOpt" /> <item name="MeshOptSloppy" - label="MeshOptSloppy" + label="Simplify sloppy" value="MeshOptSloppy" /> <item name="MeshOptCombine" - label="MeshOptCombine" + label="Simplify per object" value="MeshOptCombine" /> <item name="Use LoD above" |