diff options
Diffstat (limited to 'indra/newview/llfloatermodelpreview.cpp')
-rwxr-xr-x | indra/newview/llfloatermodelpreview.cpp | 80 |
1 files changed, 73 insertions, 7 deletions
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index ec905558aa..72c9170b06 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -732,6 +732,11 @@ void LLFloaterModelPreview::toggleGenarateNormals() { bool enabled = childGetValue("gen_normals").asBoolean(); childSetEnabled("crease_angle", enabled); + if(enabled) { + mModelPreview->generateNormals(); + } else { + mModelPreview->restoreNormals(); + } } //static @@ -2155,7 +2160,7 @@ bool LLModelLoader::loadFromSLM(const std::string& filename) S32 file_size = (S32) stat.st_size; - llifstream ifstream(filename, std::ifstream::in | std::ifstream::binary); + llifstream ifstream(filename.c_str(), std::ifstream::in | std::ifstream::binary); LLSD data; LLSDSerialize::fromBinary(data, ifstream, file_size); ifstream.close(); @@ -3513,7 +3518,7 @@ void LLModelPreview::saveUploadData(const std::string& filename, bool save_skinw data["instance"][i] = instance.asLLSD(); } - llofstream out(filename, std::ios_base::out | std::ios_base::binary); + llofstream out(filename.c_str(), std::ios_base::out | std::ios_base::binary); LLSDSerialize::toBinary(data, out); out.flush(); out.close(); @@ -3834,7 +3839,6 @@ void LLModelPreview::generateNormals() S32 which_lod = mPreviewLOD; - if (which_lod > 4 || which_lod < 0 || mModel[which_lod].empty()) { @@ -3849,19 +3853,81 @@ void LLModelPreview::generateNormals() if (which_lod == 3 && !mBaseModel.empty()) { - for (LLModelLoader::model_list::iterator iter = mBaseModel.begin(); iter != mBaseModel.end(); ++iter) + if(mBaseModelFacesCopy.empty()) + { + mBaseModelFacesCopy.reserve(mBaseModel.size()); + for (LLModelLoader::model_list::iterator it = mBaseModel.begin(), itE = mBaseModel.end(); it != itE; ++it) + { + v_LLVolumeFace_t faces; + (*it)->copyFacesTo(faces); + mBaseModelFacesCopy.push_back(faces); + } + } + + for (LLModelLoader::model_list::iterator it = mBaseModel.begin(), itE = mBaseModel.end(); it != itE; ++it) { - (*iter)->generateNormals(angle_cutoff); + (*it)->generateNormals(angle_cutoff); } mVertexBuffer[5].clear(); } - for (LLModelLoader::model_list::iterator iter = mModel[which_lod].begin(); iter != mModel[which_lod].end(); ++iter) + bool perform_copy = mModelFacesCopy[which_lod].empty(); + if(perform_copy) { + mModelFacesCopy[which_lod].reserve(mModel[which_lod].size()); + } + + for (LLModelLoader::model_list::iterator it = mModel[which_lod].begin(), itE = mModel[which_lod].end(); it != itE; ++it) + { + if(perform_copy) + { + v_LLVolumeFace_t faces; + (*it)->copyFacesTo(faces); + mModelFacesCopy[which_lod].push_back(faces); + } + + (*it)->generateNormals(angle_cutoff); + } + + mVertexBuffer[which_lod].clear(); + refresh(); + updateStatusMessages(); +} + +void LLModelPreview::restoreNormals() +{ + S32 which_lod = mPreviewLOD; + + if (which_lod > 4 || which_lod < 0 || + mModel[which_lod].empty()) + { + return; + } + + if(!mBaseModelFacesCopy.empty()) { - (*iter)->generateNormals(angle_cutoff); + llassert(mBaseModelFacesCopy.size() == mBaseModel.size()); + + vv_LLVolumeFace_t::const_iterator itF = mBaseModelFacesCopy.begin(); + for (LLModelLoader::model_list::iterator it = mBaseModel.begin(), itE = mBaseModel.end(); it != itE; ++it, ++itF) + { + (*it)->copyFacesFrom((*itF)); + } + + mBaseModelFacesCopy.clear(); } + + if(!mModelFacesCopy[which_lod].empty()) + { + vv_LLVolumeFace_t::const_iterator itF = mModelFacesCopy[which_lod].begin(); + for (LLModelLoader::model_list::iterator it = mModel[which_lod].begin(), itE = mModel[which_lod].end(); it != itE; ++it, ++itF) + { + (*it)->copyFacesFrom((*itF)); + } + mModelFacesCopy[which_lod].clear(); + } + mVertexBuffer[which_lod].clear(); refresh(); updateStatusMessages(); |