From a9fff9a868b3e4d889ed758702637149b452122a Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Thu, 10 Dec 2015 23:21:56 +0200 Subject: Backed out changeset: de52f1d38f3c --- indra/llprimitive/lldaeloader.cpp | 57 +++++++-------------------------------- indra/llprimitive/lldaeloader.h | 9 +++---- 2 files changed, 13 insertions(+), 53 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp index afc88fc861..688fd6f1b5 100644 --- a/indra/llprimitive/lldaeloader.cpp +++ b/indra/llprimitive/lldaeloader.cpp @@ -821,8 +821,7 @@ LLDAELoader::LLDAELoader( opaque_userdata, jointMap, jointsFromNodes), -mGeneratedModelLimit(modelLimit), -mForceIdNaming(false) +mGeneratedModelLimit(modelLimit) { } @@ -945,32 +944,6 @@ bool LLDAELoader::OpenFile(const std::string& filename) mTransform.condition(); - mForceIdNaming = false; - std::vector checkNames; - for (daeInt idx = 0; idx < count; ++idx) - { - domMesh* mesh = NULL; - db->getElement((daeElement**)&mesh, idx, NULL, COLLADA_TYPE_MESH); - - if (mesh) - { - std::string name = getLodlessLabel(mesh, false); - - std::vector::iterator it; - it = std::find(checkNames.begin(), checkNames.end(), name); - if (it != checkNames.end()) - { - LL_WARNS() << "document has duplicate names, using IDs instead" << LL_ENDL; - mForceIdNaming = true; - break; - } - else - { - checkNames.push_back(name); - } - } - } - U32 submodel_limit = count > 0 ? mGeneratedModelLimit/count : 0; for (daeInt idx = 0; idx < count; ++idx) { //build map of domEntities to LLModel @@ -1971,7 +1944,7 @@ void LLDAELoader::processElement( daeElement* element, bool& badElement, DAE* da if (model->mLabel.empty()) { - label = getLodlessLabel(instance_geo, mForceIdNaming); + label = getLodlessLabel(instance_geo); llassert(!label.empty()); @@ -2186,17 +2159,12 @@ LLImportMaterial LLDAELoader::profileToMaterial(domProfile_COMMON* material, DAE return mat; } -std::string LLDAELoader::getElementLabel(daeElement *element) -{ - return getElementLabel(element, mForceIdNaming); -} - // try to get a decent label for this element -std::string LLDAELoader::getElementLabel(daeElement *element, bool forceIdNaming) +std::string LLDAELoader::getElementLabel(daeElement *element) { // if we have a name attribute, use it std::string name = element->getAttribute("name"); - if (name.length() && !forceIdNaming) + if (name.length()) { return name; } @@ -2219,7 +2187,7 @@ std::string LLDAELoader::getElementLabel(daeElement *element, bool forceIdNaming // if parent has a name or ID, use it std::string name = parent->getAttribute("name"); - if (!name.length() || forceIdNaming) + if (!name.length()) { name = std::string(parent->getID()); } @@ -2262,9 +2230,9 @@ size_t LLDAELoader::getSuffixPosition(std::string label) } // static -std::string LLDAELoader::getLodlessLabel(daeElement *element, bool forceIdNaming) +std::string LLDAELoader::getLodlessLabel(daeElement *element) { - std::string label = getElementLabel(element, forceIdNaming); + std::string label = getElementLabel(element); size_t ext_pos = getSuffixPosition(label); if (ext_pos != -1) { @@ -2335,13 +2303,8 @@ bool LLDAELoader::addVolumeFacesFromDomMesh(LLModel* pModel,domMesh* mesh) return (status == LLModel::NO_ERRORS); } -LLModel* LLDAELoader::loadModelFromDomMesh(domMesh *mesh) -{ - return loadModelFromDomMesh(mesh, mForceIdNaming); -} - //static -LLModel* LLDAELoader::loadModelFromDomMesh(domMesh *mesh, bool forceIdNaming) +LLModel* LLDAELoader::loadModelFromDomMesh(domMesh *mesh) { LLVolumeParams volume_params; volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE); @@ -2349,7 +2312,7 @@ LLModel* LLDAELoader::loadModelFromDomMesh(domMesh *mesh, bool forceIdNaming) createVolumeFacesFromDomMesh(ret, mesh); if (ret->mLabel.empty()) { - ret->mLabel = getElementLabel(mesh, forceIdNaming); + ret->mLabel = getElementLabel(mesh); } return ret; } @@ -2367,7 +2330,7 @@ bool LLDAELoader::loadModelsFromDomMesh(domMesh* mesh, std::vector& mo LLModel* ret = new LLModel(volume_params, 0.f); - std::string model_name = getLodlessLabel(mesh, mForceIdNaming); + std::string model_name = getLodlessLabel(mesh); ret->mLabel = model_name + lod_suffix[mLod]; llassert(!ret->mLabel.empty()); diff --git a/indra/llprimitive/lldaeloader.h b/indra/llprimitive/lldaeloader.h index 3ababd3156..7d91a6063b 100644 --- a/indra/llprimitive/lldaeloader.h +++ b/indra/llprimitive/lldaeloader.h @@ -89,22 +89,19 @@ protected: static bool addVolumeFacesFromDomMesh(LLModel* model, domMesh* mesh); static bool createVolumeFacesFromDomMesh(LLModel* model, domMesh *mesh); - static LLModel* loadModelFromDomMesh(domMesh* mesh, bool forceIdNaming); - LLModel* loadModelFromDomMesh(domMesh* mesh); + static LLModel* loadModelFromDomMesh(domMesh* mesh); // Loads a mesh breaking it into one or more models as necessary // to get around volume face limitations while retaining >8 materials // bool loadModelsFromDomMesh(domMesh* mesh, std::vector& models_out, U32 submodel_limit); - static std::string getElementLabel(daeElement *element, bool forceIdNaming); - std::string getElementLabel(daeElement *element); + static std::string getElementLabel(daeElement *element); static size_t getSuffixPosition(std::string label); - static std::string getLodlessLabel(daeElement *element, bool forceIdNaming = false); + static std::string getLodlessLabel(daeElement *element); private: U32 mGeneratedModelLimit; // Attempt to limit amount of generated submodels - bool mForceIdNaming; }; #endif // LL_LLDAELLOADER_H -- cgit v1.2.3 From dca797c3db34d119ccdc2d6f24c7742df75ff9c6 Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Tue, 8 Dec 2015 02:52:15 +0200 Subject: MAINT-5678 [Importer] materials with spaces in name import with truncated names --- indra/llprimitive/lldaeloader.cpp | 44 +++++++++++++++++++++++++++++++++++++-- indra/llprimitive/lldaeloader.h | 2 ++ 2 files changed, 44 insertions(+), 2 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp index 688fd6f1b5..f84b49873b 100644 --- a/indra/llprimitive/lldaeloader.cpp +++ b/indra/llprimitive/lldaeloader.cpp @@ -62,6 +62,9 @@ #include "glh/glh_linear.h" #include "llmatrix4a.h" +#include +#include + std::string colladaVersion[VERSIONTYPE_COUNT+1] = { "1.4.0", @@ -845,7 +848,9 @@ bool LLDAELoader::OpenFile(const std::string& filename) { //no suitable slm exists, load from the .dae file DAE dae; - domCOLLADA* dom = dae.open(filename); + + std::string fileURI = "from memory"; // set to a null device + domCOLLADA* dom = dae.openFromMemory(fileURI, preprocessDAE(filename).c_str()); if (!dom) { @@ -873,7 +878,7 @@ bool LLDAELoader::OpenFile(const std::string& filename) daeInt count = db->getElementCount(NULL, COLLADA_TYPE_MESH); - daeDocument* doc = dae.getDoc(mFilename); + daeDocument* doc = dae.getDoc(fileURI); if (!doc) { LL_WARNS() << "can't find internal doc" << LL_ENDL; @@ -1051,6 +1056,41 @@ bool LLDAELoader::OpenFile(const std::string& filename) return true; } +std::string LLDAELoader::preprocessDAE(std::string filename) +{ + // Open a DAE file for some preprocessing (like removing space characters in IDs), see MAINT-5678 + std::ifstream inFile; + inFile.open(filename); + std::stringstream strStream; + strStream << inFile.rdbuf(); + std::string buffer = strStream.str(); + + LL_INFOS() << "Preprocessing dae file to remove spaces from the names, ids, etc." << LL_ENDL; + + try + { + std::regex re("\"[\\w\\.@#$-]*(\\s[\\w\\.@#$-]*)+\""); + std::sregex_iterator next(buffer.begin(), buffer.end(), re); + std::sregex_iterator end; + while (next != end) + { + std::smatch match = *next; + std::string s = match.str(); + LL_INFOS() << s << " found" << LL_ENDL; + boost::replace_all(s, " ", "_"); + LL_INFOS() << "Replacing with " << s << LL_ENDL; + boost::replace_all(buffer, match.str(), s); + next++; + } + } + catch (std::regex_error &) + { + LL_INFOS() << "Regex error" << LL_ENDL; + } + + return buffer; +} + void LLDAELoader::processDomModel(LLModel* model, DAE* dae, daeElement* root, domMesh* mesh, domSkin* skin) { llassert(model && dae && mesh && skin); diff --git a/indra/llprimitive/lldaeloader.h b/indra/llprimitive/lldaeloader.h index 7d91a6063b..19a85a5339 100644 --- a/indra/llprimitive/lldaeloader.h +++ b/indra/llprimitive/lldaeloader.h @@ -100,6 +100,8 @@ protected: static size_t getSuffixPosition(std::string label); static std::string getLodlessLabel(daeElement *element); + static std::string preprocessDAE(std::string filename); + private: U32 mGeneratedModelLimit; // Attempt to limit amount of generated submodels -- cgit v1.2.3 From 97dbd3768af3a1dfd888f3eda39224e52d20e74f Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Fri, 11 Dec 2015 20:17:59 +0200 Subject: MAINT-5678 [Importer] Buildfix for Linux and OSX --- indra/llprimitive/lldaeloader.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp index f84b49873b..4d8acb2808 100644 --- a/indra/llprimitive/lldaeloader.cpp +++ b/indra/llprimitive/lldaeloader.cpp @@ -62,7 +62,7 @@ #include "glh/glh_linear.h" #include "llmatrix4a.h" -#include +#include #include std::string colladaVersion[VERSIONTYPE_COUNT+1] = @@ -1060,7 +1060,7 @@ std::string LLDAELoader::preprocessDAE(std::string filename) { // Open a DAE file for some preprocessing (like removing space characters in IDs), see MAINT-5678 std::ifstream inFile; - inFile.open(filename); + inFile.open(filename.c_str(), std::ios_base::in); std::stringstream strStream; strStream << inFile.rdbuf(); std::string buffer = strStream.str(); @@ -1069,12 +1069,12 @@ std::string LLDAELoader::preprocessDAE(std::string filename) try { - std::regex re("\"[\\w\\.@#$-]*(\\s[\\w\\.@#$-]*)+\""); - std::sregex_iterator next(buffer.begin(), buffer.end(), re); - std::sregex_iterator end; + boost::regex re("\"[\\w\\.@#$-]*(\\s[\\w\\.@#$-]*)+\""); + boost::sregex_iterator next(buffer.begin(), buffer.end(), re); + boost::sregex_iterator end; while (next != end) { - std::smatch match = *next; + boost::smatch match = *next; std::string s = match.str(); LL_INFOS() << s << " found" << LL_ENDL; boost::replace_all(s, " ", "_"); @@ -1083,7 +1083,7 @@ std::string LLDAELoader::preprocessDAE(std::string filename) next++; } } - catch (std::regex_error &) + catch (boost::regex_error &) { LL_INFOS() << "Regex error" << LL_ENDL; } -- cgit v1.2.3 From 18f4ad27b6b18f3ea32f610136858b64a816cc85 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 10 Dec 2015 19:28:26 +0200 Subject: MAINT-5956 FIXED Certain dae will not upload with the new importer code --- indra/llprimitive/lldaeloader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp index 4d8acb2808..9a1f8d09e8 100644 --- a/indra/llprimitive/lldaeloader.cpp +++ b/indra/llprimitive/lldaeloader.cpp @@ -239,7 +239,10 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector& fa // Don't share verts within the same tri, degenerate // - if ((indices.size() % 3) && (indices[indices.size()-1] != shared_index)) + U32 indx_size = indices.size(); + U32 verts_new_tri = indx_size % 3; + if ((verts_new_tri < 1 || indices[indx_size - 1] != shared_index) + && (verts_new_tri < 2 || indices[indx_size - 2] != shared_index)) { found = true; indices.push_back(shared_index); -- cgit v1.2.3 From 72685fe1cb6faffa648cc46259699097033a31e3 Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Wed, 17 Feb 2016 02:40:58 +0200 Subject: MAINT-6132 Fixed error on uploading models with texture --- indra/llprimitive/lldaeloader.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp index 9a1f8d09e8..9ce17ef276 100644 --- a/indra/llprimitive/lldaeloader.cpp +++ b/indra/llprimitive/lldaeloader.cpp @@ -851,9 +851,7 @@ bool LLDAELoader::OpenFile(const std::string& filename) { //no suitable slm exists, load from the .dae file DAE dae; - - std::string fileURI = "from memory"; // set to a null device - domCOLLADA* dom = dae.openFromMemory(fileURI, preprocessDAE(filename).c_str()); + domCOLLADA* dom = dae.openFromMemory(filename, preprocessDAE(filename).c_str()); if (!dom) { @@ -881,7 +879,7 @@ bool LLDAELoader::OpenFile(const std::string& filename) daeInt count = db->getElementCount(NULL, COLLADA_TYPE_MESH); - daeDocument* doc = dae.getDoc(fileURI); + daeDocument* doc = dae.getDoc(filename); if (!doc) { LL_WARNS() << "can't find internal doc" << LL_ENDL; -- cgit v1.2.3 From 8920beabc4b01dfdbd8eb3bbe33deefe03896f7d Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Wed, 17 Feb 2016 03:01:04 +0200 Subject: MAINT-5678 Improvement: ImporterPreprocessDAE debug setting to disable DAE preprocessing when needed --- indra/llprimitive/lldaeloader.cpp | 17 ++++++++++++++--- indra/llprimitive/lldaeloader.h | 4 +++- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'indra/llprimitive') diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp index 9ce17ef276..720986a411 100644 --- a/indra/llprimitive/lldaeloader.cpp +++ b/indra/llprimitive/lldaeloader.cpp @@ -816,7 +816,8 @@ LLDAELoader::LLDAELoader( void* opaque_userdata, JointTransformMap& jointMap, JointSet& jointsFromNodes, - U32 modelLimit) + U32 modelLimit, + bool preprocess) : LLModelLoader( filename, lod, @@ -827,7 +828,8 @@ LLDAELoader::LLDAELoader( opaque_userdata, jointMap, jointsFromNodes), -mGeneratedModelLimit(modelLimit) +mGeneratedModelLimit(modelLimit), +mPreprocessDAE(preprocess) { } @@ -851,7 +853,16 @@ bool LLDAELoader::OpenFile(const std::string& filename) { //no suitable slm exists, load from the .dae file DAE dae; - domCOLLADA* dom = dae.openFromMemory(filename, preprocessDAE(filename).c_str()); + domCOLLADA* dom; + if (mPreprocessDAE) + { + dom = dae.openFromMemory(filename, preprocessDAE(filename).c_str()); + } + else + { + LL_INFOS() << "Skipping dae preprocessing" << LL_ENDL; + dom = dae.open(filename); + } if (!dom) { diff --git a/indra/llprimitive/lldaeloader.h b/indra/llprimitive/lldaeloader.h index 19a85a5339..27db5326d5 100644 --- a/indra/llprimitive/lldaeloader.h +++ b/indra/llprimitive/lldaeloader.h @@ -56,7 +56,8 @@ public: void* opaque_userdata, JointTransformMap& jointMap, JointSet& jointsFromNodes, - U32 modelLimit); + U32 modelLimit, + bool preprocess); virtual ~LLDAELoader() ; virtual bool OpenFile(const std::string& filename); @@ -104,6 +105,7 @@ protected: private: U32 mGeneratedModelLimit; // Attempt to limit amount of generated submodels + bool mPreprocessDAE; }; #endif // LL_LLDAELLOADER_H -- cgit v1.2.3