diff options
author | andreykproductengine <akleshchev@productengine.com> | 2015-02-04 19:25:55 +0200 |
---|---|---|
committer | andreykproductengine <akleshchev@productengine.com> | 2015-02-04 19:25:55 +0200 |
commit | cf5a5a0e9727cbcc8ea9dd8d0ea25d5ba03c93e7 (patch) | |
tree | c3f9612b831dff06dfea05eeed0d82c9e0208dc3 /indra/newview/llfloatermodelpreview.cpp | |
parent | 0939bf4063ffe494e0a5f108636b9469d387dfb4 (diff) |
MAINT-4806 sub-models fix
Diffstat (limited to 'indra/newview/llfloatermodelpreview.cpp')
-rwxr-xr-x | indra/newview/llfloatermodelpreview.cpp | 88 |
1 files changed, 74 insertions, 14 deletions
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 27c2a1ed42..a672d05760 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -1554,20 +1554,6 @@ void LLModelPreview::rebuildUploadData() setLoadState( LLModelLoader::ERROR_MATERIALS ); mFMP->childDisable( "calculate_btn" ); } - else - { - if (mBaseModel.size() == mModel[i].size()) - { - for (U32 idx = 0; idx < mBaseModel.size(); ++idx) - { - if (mModel[i][idx] && !mModel[i][idx]->matchMaterialOrder(mBaseModel[idx], refFaceCnt, modelFaceCnt ) ) - { - setLoadState( LLModelLoader::ERROR_MATERIALS ); - mFMP->childDisable( "calculate_btn" ); - } - } - } - } } } instance.mTransform = mat; @@ -1575,6 +1561,79 @@ void LLModelPreview::rebuildUploadData() } } + // Since sub-models affect verification, we need to know number of original/primary models + U32 base_primary_count = 0; + U32 base_total_count = mBaseModel.size(); + for (U32 base_ind = 0; base_ind < base_total_count; ++base_ind) + { + if (mBaseModel[base_ind] && !mBaseModel[base_ind]->mSubmodelID) + { + base_primary_count++; + } + } + + //reorder materials to match mBaseModel + for (U32 i = 0; i < LLModel::NUM_LODS-1; i++) + { + int refFaceCnt = 0; + int modelFaceCnt = 0; + + U32 model_primary_count = 0; + U32 model_total_count = mModel[i].size(); + for (U32 model_ind = 0; model_ind < model_total_count; ++model_ind) + { + if (mModel[i][model_ind] && !mModel[i][model_ind]->mSubmodelID) + { + model_primary_count++; + } + } + + // Since we don't have a reliable method to check sub-models, check only original/primary models + // + // Note: we can matchMaterialOrder() for sub-models if they have same id and same label, + // but since sub-models are leftovers from original models with random material order, we + // can't warranty that checking sub-models is valid. + // Original model retains full material list, so we should get ERROR_MATERIALS even + // if we don't check sub-models. See LLDAELoader::loadModelsFromDomMesh() + if (base_primary_count == model_primary_count) + { + U32 model_ind = 0; + U32 base_ind = 0; + U32 models_matched = 0; + + while (models_matched < base_primary_count) + { + // filter out sub-models + while (mModel[i][model_ind] + && mModel[i][model_ind]->mSubmodelID + && model_ind < model_primary_count) + { + model_ind++; + } + while (mBaseModel[base_ind] + && mBaseModel[base_ind]->mSubmodelID + && base_ind < base_total_count) + { + base_ind++; + } + if (model_ind >= model_total_count || base_ind >= base_total_count) + { + // Safeguard, shouldn't happen unless something is wrong with models in the list + LL_WARNS() << "Materials of some models were not verified and reordered" << LL_ENDL; + break; + } + if (mModel[i][model_ind] && !mModel[i][model_ind]->matchMaterialOrder(mBaseModel[base_ind], refFaceCnt, modelFaceCnt ) ) + { + setLoadState( LLModelLoader::ERROR_MATERIALS ); + mFMP->childDisable( "calculate_btn" ); + } + models_matched++; + model_ind++; + base_ind++; + } + } + } + F32 max_import_scale = (DEFAULT_MAX_PRIM_SCALE-0.1f)/max_scale; F32 max_axis = llmax(mPreviewScale.mV[0], mPreviewScale.mV[1]); @@ -1901,6 +1960,7 @@ void LLModelPreview::loadModelCallback(S32 loaded_lod) } mModel[lod][idx] = list_iter->mModel; + mModel[lod][idx]->mLabel = list_iter->mLabel; if (!list_iter->mModel->mSkinWeights.empty()) { skin_weights = true; |