diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2024-11-22 00:17:46 +0200 |
---|---|---|
committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2024-11-22 15:38:53 +0200 |
commit | 934833ba97f3f8e9323fdab4c3e96e392beeeb4e (patch) | |
tree | 85d6c3176805cfc17bf740ed1b13ea833d570929 | |
parent | 7ff7de0f067d4d579143180ae21063d041f5d74a (diff) |
viewer#3126 Crash at LLDAELoader::processElement
-rw-r--r-- | indra/llprimitive/lldaeloader.cpp | 122 |
1 files changed, 63 insertions, 59 deletions
diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp index 7fa4230237..0759447902 100644 --- a/indra/llprimitive/lldaeloader.cpp +++ b/indra/llprimitive/lldaeloader.cpp @@ -2080,79 +2080,83 @@ void LLDAELoader::processElement( daeElement* element, bool& badElement, DAE* da { if (domMesh* mesh = daeSafeCast<domMesh>(geo->getDescendant(daeElement::matchType(domMesh::ID())))) { - for (LLModel* model : mModelsMap.find(mesh)->second) + dae_model_map::iterator it = mModelsMap.find(mesh); + if (it != mModelsMap.end()) { - LLMatrix4 transformation = mTransform; + for (LLModel* model : it->second) + { + LLMatrix4 transformation = mTransform; - if (mTransform.determinant() < 0) - { //negative scales are not supported - LL_INFOS() << "Negative scale detected, unsupported transform. domInstance_geometry: " << getElementLabel(instance_geo) << LL_ENDL; - LLSD args; - args["Message"] = "NegativeScaleTrans"; - args["LABEL"] = getElementLabel(instance_geo); - mWarningsArray.append(args); + if (mTransform.determinant() < 0) + { //negative scales are not supported + LL_INFOS() << "Negative scale detected, unsupported transform. domInstance_geometry: " << getElementLabel(instance_geo) << LL_ENDL; + LLSD args; + args["Message"] = "NegativeScaleTrans"; + args["LABEL"] = getElementLabel(instance_geo); + mWarningsArray.append(args); - badElement = true; - } + badElement = true; + } - LLModelLoader::material_map materials = getMaterials(model, instance_geo, dae); - - // adjust the transformation to compensate for mesh normalization - LLVector3 mesh_scale_vector; - LLVector3 mesh_translation_vector; - model->getNormalizedScaleTranslation(mesh_scale_vector, mesh_translation_vector); - - LLMatrix4 mesh_translation; - mesh_translation.setTranslation(mesh_translation_vector); - mesh_translation *= transformation; - transformation = mesh_translation; - - LLMatrix4 mesh_scale; - mesh_scale.initScale(mesh_scale_vector); - mesh_scale *= transformation; - transformation = mesh_scale; - - if (transformation.determinant() < 0) - { //negative scales are not supported - LL_INFOS() << "Negative scale detected, unsupported post-normalization transform. domInstance_geometry: " << getElementLabel(instance_geo) << LL_ENDL; - LLSD args; - args["Message"] = "NegativeScaleNormTrans"; - args["LABEL"] = getElementLabel(instance_geo); - mWarningsArray.append(args); - badElement = true; - } + LLModelLoader::material_map materials = getMaterials(model, instance_geo, dae); + + // adjust the transformation to compensate for mesh normalization + LLVector3 mesh_scale_vector; + LLVector3 mesh_translation_vector; + model->getNormalizedScaleTranslation(mesh_scale_vector, mesh_translation_vector); + + LLMatrix4 mesh_translation; + mesh_translation.setTranslation(mesh_translation_vector); + mesh_translation *= transformation; + transformation = mesh_translation; + + LLMatrix4 mesh_scale; + mesh_scale.initScale(mesh_scale_vector); + mesh_scale *= transformation; + transformation = mesh_scale; + + if (transformation.determinant() < 0) + { //negative scales are not supported + LL_INFOS() << "Negative scale detected, unsupported post-normalization transform. domInstance_geometry: " << getElementLabel(instance_geo) << LL_ENDL; + LLSD args; + args["Message"] = "NegativeScaleNormTrans"; + args["LABEL"] = getElementLabel(instance_geo); + mWarningsArray.append(args); + badElement = true; + } - std::string label; + std::string label; - if (model->mLabel.empty()) - { - label = getLodlessLabel(instance_geo); + if (model->mLabel.empty()) + { + label = getLodlessLabel(instance_geo); - llassert(!label.empty()); + llassert(!label.empty()); - if (model->mSubmodelID) - { - label += (char)((int)'a' + model->mSubmodelID); - } + if (model->mSubmodelID) + { + label += (char)((int)'a' + model->mSubmodelID); + } - model->mLabel = label + lod_suffix[mLod]; - } - else - { - // Don't change model's name if possible, it will play havoc with scenes that already use said model. - size_t ext_pos = getSuffixPosition(model->mLabel); - if (ext_pos != -1) - { - label = model->mLabel.substr(0, ext_pos); + model->mLabel = label + lod_suffix[mLod]; } else { - label = model->mLabel; + // Don't change model's name if possible, it will play havoc with scenes that already use said model. + size_t ext_pos = getSuffixPosition(model->mLabel); + if (ext_pos != -1) + { + label = model->mLabel.substr(0, ext_pos); + } + else + { + label = model->mLabel; + } } - } - mScene[transformation].push_back(LLModelInstance(model, label, transformation, materials)); - stretch_extents(model, transformation); + mScene[transformation].push_back(LLModelInstance(model, label, transformation, materials)); + stretch_extents(model, transformation); + } } } } |