From b97c47c19cff4f33c6172bd18fd8b48063007a37 Mon Sep 17 00:00:00 2001 From: prep linden Date: Fri, 1 Apr 2011 12:57:45 -0400 Subject: Removed unused variable --- indra/newview/llfloatermodelpreview.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 21c9fca164..66d80e3bc3 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -384,8 +384,6 @@ BOOL LLFloaterModelPreview::postBuild() LLFloaterModelPreview::~LLFloaterModelPreview() { sInstance = NULL; - - const LLModelLoader *model_loader = mModelPreview->mModelLoader; if ( mModelPreview && mModelPreview->getResetJointFlag() ) { -- cgit v1.2.3 From f0c70a4ee3739c34b1da2ce384bfcf420f8c6c72 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 1 Apr 2011 10:58:34 -0600 Subject: fix for SH-1176: A Mesh That Crashes Client on Upload Attempt (due to triangle number overflowing) --- indra/llprimitive/llmodel.cpp | 71 ++++++++++++++++++---- indra/llprimitive/llmodel.h | 10 +++ indra/newview/llfloatermodelpreview.cpp | 27 ++++++-- indra/newview/llfloatermodelpreview.h | 2 +- .../skins/default/xui/en/floater_model_preview.xml | 1 + .../skins/default/xui/en/floater_model_wizard.xml | 1 + 6 files changed, 95 insertions(+), 17 deletions(-) (limited to 'indra') diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 0a4ed6b638..03b893de29 100755 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -57,7 +57,7 @@ const int MODEL_NAMES_LENGTH = sizeof(model_names) / sizeof(std::string); LLModel::LLModel(LLVolumeParams& params, F32 detail) : LLVolume(params, detail), mNormalizedScale(1,1,1), mNormalizedTranslation(0,0,0) - , mPelvisOffset( 0.0f ) + , mPelvisOffset( 0.0f ), mStatus(NO_ERRORS) { mDecompID = -1; mLocalID = -1; @@ -209,7 +209,7 @@ void get_dom_sources(const domInputLocalOffset_Array& inputs, S32& pos_offset, S idx_stride += 1; } -void load_face_from_dom_triangles(std::vector& face_list, std::vector& materials, domTrianglesRef& tri) +LLModel::EModelStatus load_face_from_dom_triangles(std::vector& face_list, std::vector& materials, domTrianglesRef& tri) { LLVolumeFace face; std::vector verts; @@ -304,7 +304,8 @@ void load_face_from_dom_triangles(std::vector& face_list, std::vec verts.push_back(cv); if (verts.size() >= 65535) { - llerrs << "Attempted to write model exceeding 16-bit index buffer limitation." << llendl; + //llerrs << "Attempted to write model exceeding 16-bit index buffer limitation." << llendl; + return LLModel::VERTEX_NUMBER_OVERFLOW ; } U16 index = (U16) (verts.size()-1); indices.push_back(index); @@ -349,16 +350,17 @@ void load_face_from_dom_triangles(std::vector& face_list, std::vec face_list.rbegin()->fillFromLegacyData(verts, indices); } + return LLModel::NO_ERRORS ; } -void load_face_from_dom_polylist(std::vector& face_list, std::vector& materials, domPolylistRef& poly) +LLModel::EModelStatus load_face_from_dom_polylist(std::vector& face_list, std::vector& materials, domPolylistRef& poly) { domPRef p = poly->getP(); domListOfUInts& idx = p->getValue(); if (idx.getCount() == 0) { - return; + return LLModel::NO_ERRORS ; } const domInputLocalOffset_Array& inputs = poly->getInput_array(); @@ -479,7 +481,8 @@ void load_face_from_dom_polylist(std::vector& face_list, std::vect verts.push_back(cv); if (verts.size() >= 65535) { - llerrs << "Attempted to write model exceeding 16-bit index buffer limitation." << llendl; + //llerrs << "Attempted to write model exceeding 16-bit index buffer limitation." << llendl; + return LLModel::VERTEX_NUMBER_OVERFLOW ; } U16 index = (U16) (verts.size()-1); @@ -539,9 +542,11 @@ void load_face_from_dom_polylist(std::vector& face_list, std::vect face_list.push_back(face); face_list.rbegin()->fillFromLegacyData(verts, indices); } + + return LLModel::NO_ERRORS ; } -void load_face_from_dom_polygons(std::vector& face_list, std::vector& materials, domPolygonsRef& poly) +LLModel::EModelStatus load_face_from_dom_polygons(std::vector& face_list, std::vector& materials, domPolygonsRef& poly) { LLVolumeFace face; std::vector indices; @@ -654,7 +659,7 @@ void load_face_from_dom_polygons(std::vector& face_list, std::vect if (verts.empty()) { - return; + return LLModel::NO_ERRORS; } face.mExtents[0] = verts[0].getPosition(); @@ -716,6 +721,27 @@ void load_face_from_dom_polygons(std::vector& face_list, std::vect face_list.push_back(face); face_list.rbegin()->fillFromLegacyData(new_verts, indices); } + + return LLModel::NO_ERRORS ; +} + +//static +std::string LLModel::getStatusString(U32 status) +{ + const static std::string status_strings[(S32)INVALID_STATUS] = {"status_no_error", "status_vertex_number_overflow"}; + + if(status < INVALID_STATUS) + { + if(status_strings[status] == std::string()) + { + llerrs << "No valid status string for this status: " << (U32)status << llendl ; + } + return status_strings[status] ; + } + + llerrs << "Invalid model status: " << (U32)status << llendl ; + + return std::string() ; } void LLModel::addVolumeFacesFromDomMesh(domMesh* mesh) @@ -726,7 +752,14 @@ void LLModel::addVolumeFacesFromDomMesh(domMesh* mesh) { domTrianglesRef& tri = tris.get(i); - load_face_from_dom_triangles(mVolumeFaces, mMaterialList, tri); + mStatus = load_face_from_dom_triangles(mVolumeFaces, mMaterialList, tri); + + if(mStatus != NO_ERRORS) + { + mVolumeFaces.clear() ; + mMaterialList.clear() ; + return ; //abort + } } domPolylist_Array& polys = mesh->getPolylist_array(); @@ -734,7 +767,14 @@ void LLModel::addVolumeFacesFromDomMesh(domMesh* mesh) { domPolylistRef& poly = polys.get(i); - load_face_from_dom_polylist(mVolumeFaces, mMaterialList, poly); + mStatus = load_face_from_dom_polylist(mVolumeFaces, mMaterialList, poly); + + if(mStatus != NO_ERRORS) + { + mVolumeFaces.clear() ; + mMaterialList.clear() ; + return ; //abort + } } domPolygons_Array& polygons = mesh->getPolygons_array(); @@ -742,7 +782,14 @@ void LLModel::addVolumeFacesFromDomMesh(domMesh* mesh) { domPolygonsRef& poly = polygons.get(i); - load_face_from_dom_polygons(mVolumeFaces, mMaterialList, poly); + mStatus = load_face_from_dom_polygons(mVolumeFaces, mMaterialList, poly); + + if(mStatus != NO_ERRORS) + { + mVolumeFaces.clear() ; + mMaterialList.clear() ; + return ; //abort + } } } @@ -755,7 +802,7 @@ BOOL LLModel::createVolumeFacesFromDomMesh(domMesh* mesh) mMaterialList.clear(); addVolumeFacesFromDomMesh(mesh); - + if (getNumVolumeFaces() > 0) { optimizeVolumeFaces(); diff --git a/indra/llprimitive/llmodel.h b/indra/llprimitive/llmodel.h index 962e422a26..23f4b5cb42 100755 --- a/indra/llprimitive/llmodel.h +++ b/indra/llprimitive/llmodel.h @@ -69,6 +69,13 @@ public: NUM_LODS }; + enum EModelStatus + { + NO_ERRORS = 0, + VERTEX_NUMBER_OVERFLOW, //vertex number is >= 65535. + INVALID_STATUS + } ; + //convex_hull_decomposition is a vector of convex hulls //each convex hull is a set of points typedef std::vector > convex_hull_decomposition; @@ -138,6 +145,8 @@ public: static LLModel* loadModelFromDomMesh(domMesh* mesh); static std::string getElementLabel(daeElement* element); std::string getName() const; + EModelStatus getStatus() const {return mStatus;} + static std::string getStatusString(U32 status) ; void appendFaces(LLModel* model, LLMatrix4& transform, LLMatrix4& normal_transform); void appendFace(const LLVolumeFace& src_face, std::string src_material, LLMatrix4& mat, LLMatrix4& norm_mat); @@ -237,6 +246,7 @@ public: Decomposition mPhysics; + EModelStatus mStatus ; protected: void addVolumeFacesFromDomMesh(domMesh* mesh); virtual BOOL createVolumeFacesFromDomMesh(domMesh *mesh); diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 21c9fca164..f2fa891bca 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -579,7 +579,14 @@ void LLFloaterModelPreview::draw() if (!mModelPreview->mLoading) { - childSetTextArg("status", "[STATUS]", getString("status_idle")); + if ( mModelPreview->getLoadState() > LLModelLoader::ERROR_PARSING ) + { + childSetTextArg("status", "[STATUS]", getString(LLModel::getStatusString(mModelPreview->getLoadState() - LLModelLoader::ERROR_PARSING))); + } + else + { + childSetTextArg("status", "[STATUS]", getString("status_idle")); + } } childSetTextArg("prim_cost", "[PRIM_COST]", llformat("%d", mModelPreview->mResourceCost)); @@ -1285,6 +1292,12 @@ bool LLModelLoader::doLoadModel() { LLPointer model = LLModel::loadModelFromDomMesh(mesh); + if(model->getStatus() != LLModel::NO_ERRORS) + { + setLoadState(ERROR_PARSING + model->getStatus()) ; + return true ; //abort + } + if (model.notNull() && validate_model(model)) { mModelList.push_back(model); @@ -2502,7 +2515,7 @@ U32 LLModelPreview::calcResourceCost() if (mFMP && mModelLoader) { - if ( getLoadState() != LLModelLoader::ERROR_PARSING ) + if ( getLoadState() < LLModelLoader::ERROR_PARSING ) { mFMP->childEnable("ok_btn"); } @@ -2856,7 +2869,7 @@ void LLModelPreview::loadModel(std::string filename, S32 lod) setPreviewLOD(lod); - if ( getLoadState() == LLModelLoader::ERROR_PARSING ) + if ( getLoadState() >= LLModelLoader::ERROR_PARSING ) { mFMP->childDisable("ok_btn"); } @@ -2938,8 +2951,14 @@ void LLModelPreview::loadModelCallback(S32 lod) LLMutexLock lock(this); if (!mModelLoader) { + mLoading = false ; return; } + if(getLoadState() >= LLModelLoader::ERROR_PARSING) + { + mLoading = false ; + return ; + } mModelLoader->loadTextures() ; @@ -3675,7 +3694,7 @@ void LLModelPreview::updateStatusMessages() } } - bool errorStateFromLoader = getLoadState() == LLModelLoader::ERROR_PARSING ? true : false; + bool errorStateFromLoader = getLoadState() >= LLModelLoader::ERROR_PARSING ? true : false; bool skinAndRigOk = true; bool uploadingSkin = mFMP->childGetValue("upload_skin").asBoolean(); diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h index 3fcc1b3e57..dabe3c613d 100644 --- a/indra/newview/llfloatermodelpreview.h +++ b/indra/newview/llfloatermodelpreview.h @@ -66,7 +66,7 @@ public: GENERATING_VERTEX_BUFFERS, GENERATING_LOD, DONE, - ERROR_PARSING, //basically loading failed + ERROR_PARSING //basically loading failed } eLoadState; U32 mState; 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 0053be4f67..7be6165a0d 100644 --- a/indra/newview/skins/default/xui/en/floater_model_preview.xml +++ b/indra/newview/skins/default/xui/en/floater_model_preview.xml @@ -6,6 +6,7 @@ Idle Loading... Generating Meshes... + Error: Vertex number is more than 65534, aborted! High Medium Low diff --git a/indra/newview/skins/default/xui/en/floater_model_wizard.xml b/indra/newview/skins/default/xui/en/floater_model_wizard.xml index 93740007ee..54ef4695f0 100644 --- a/indra/newview/skins/default/xui/en/floater_model_wizard.xml +++ b/indra/newview/skins/default/xui/en/floater_model_wizard.xml @@ -1026,6 +1026,7 @@ Advanced users familiar with 3d content creation tools may prefer to use the [se Idle Loading... Generating Meshes... + Error: Vertex number is more than 65534, aborted! High Medium Low -- cgit v1.2.3