summaryrefslogtreecommitdiff
path: root/indra/llprimitive/lldaeloader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llprimitive/lldaeloader.cpp')
-rw-r--r--indra/llprimitive/lldaeloader.cpp90
1 files changed, 83 insertions, 7 deletions
diff --git a/indra/llprimitive/lldaeloader.cpp b/indra/llprimitive/lldaeloader.cpp
index dfa29fb539..73a0b3d673 100644
--- a/indra/llprimitive/lldaeloader.cpp
+++ b/indra/llprimitive/lldaeloader.cpp
@@ -149,7 +149,12 @@ bool get_dom_sources(const domInputLocalOffset_Array& inputs, S32& pos_offset, S
return true;
}
-LLModel::EModelStatus load_face_from_dom_triangles(std::vector<LLVolumeFace>& face_list, std::vector<std::string>& materials, domTrianglesRef& tri)
+LLModel::EModelStatus load_face_from_dom_triangles(
+ std::vector<LLVolumeFace>& face_list,
+ std::vector<std::string>& materials,
+ domTrianglesRef& tri,
+ bool &generated_additional_faces,
+ LLSD& log_msg)
{
LLVolumeFace face;
std::vector<LLVolumeFace::VertexData> verts;
@@ -169,12 +174,18 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector<LLVolumeFace>& fa
if ( !get_dom_sources(inputs, pos_offset, tc_offset, norm_offset, idx_stride, pos_source, tc_source, norm_source))
{
+ LLSD args;
+ args["Message"] = "ParsingErrorBadElement";
+ log_msg.append(args);
return LLModel::BAD_ELEMENT;
}
if (!pos_source || !pos_source->getFloat_array())
{
LL_WARNS() << "Unable to process mesh without position data; invalid model; invalid model." << LL_ENDL;
+ LLSD args;
+ args["Message"] = "ParsingErrorPositionInvalidModel";
+ log_msg.append(args);
return LLModel::BAD_ELEMENT;
}
@@ -282,6 +293,8 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector<LLVolumeFace>& fa
if (indices.size()%3 == 0 && verts.size() >= 65532)
{
+ generated_additional_faces = true;
+
std::string material;
if (tri->getMaterial())
@@ -343,7 +356,12 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector<LLVolumeFace>& fa
return LLModel::NO_ERRORS ;
}
-LLModel::EModelStatus load_face_from_dom_polylist(std::vector<LLVolumeFace>& face_list, std::vector<std::string>& materials, domPolylistRef& poly, LLSD& log_msg)
+LLModel::EModelStatus load_face_from_dom_polylist(
+ std::vector<LLVolumeFace>& face_list,
+ std::vector<std::string>& materials,
+ domPolylistRef& poly,
+ bool& generated_additional_faces,
+ LLSD& log_msg)
{
domPRef p = poly->getP();
domListOfUInts& idx = p->getValue();
@@ -370,6 +388,10 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector<LLVolumeFace>& fac
if (!get_dom_sources(inputs, pos_offset, tc_offset, norm_offset, idx_stride, pos_source, tc_source, norm_source))
{
+ LL_WARNS() << "Bad element." << LL_ENDL;
+ LLSD args;
+ args["Message"] = "ParsingErrorBadElement";
+ log_msg.append(args);
return LLModel::BAD_ELEMENT;
}
@@ -421,6 +443,9 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector<LLVolumeFace>& fac
if (!cv.getPosition().isFinite3())
{
LL_WARNS() << "Found NaN while loading position data from DAE-Model, invalid model." << LL_ENDL;
+ LLSD args;
+ args["Message"] = "PositionNaN";
+ log_msg.append(args);
return LLModel::BAD_ELEMENT;
}
}
@@ -453,6 +478,10 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector<LLVolumeFace>& fac
if (!cv.getNormal().isFinite3())
{
LL_WARNS() << "Found NaN while loading normals from DAE-Model, invalid model." << LL_ENDL;
+ LLSD args;
+ args["Message"] = "NormalsNaN";
+ log_msg.append(args);
+
return LLModel::BAD_ELEMENT;
}
}
@@ -545,6 +574,8 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector<LLVolumeFace>& fac
if (indices.size()%3 == 0 && indices.size() >= 65532)
{
+ generated_additional_faces = true;
+
std::string material;
if (poly->getMaterial())
@@ -770,6 +801,9 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac
}
}
+ // Viewer can only fit U16 vertices, shouldn't we do some checks here and return overflow if result has more?
+ llassert(vert_idx.size() < U16_MAX);
+
//build vertex array from map
std::vector<LLVolumeFace::VertexData> new_verts;
new_verts.resize(vert_idx.size());
@@ -787,7 +821,12 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac
for (U32 i = 0; i < verts.size(); ++i)
{
indices[i] = vert_idx[verts[i]];
- llassert(!i || (indices[i-1] != indices[i]));
+ if (i % 3 != 0) // assumes GL_TRIANGLES, compare 0-1, 1-2, 3-4, 4-5 but not 2-3 or 5-6
+ {
+ // A faulty degenerate triangle detection (triangle with 0 area),
+ // probably should be a warning and not an assert
+ llassert(!i || (indices[i-1] != indices[i]));
+ }
}
// DEBUG just build an expanded triangle list
@@ -907,6 +946,9 @@ bool LLDAELoader::OpenFile(const std::string& filename)
if (!dom)
{
LL_INFOS() <<" Error with dae - traditionally indicates a corrupt file."<<LL_ENDL;
+ LLSD args;
+ args["Message"] = "ParsingErrorCorrupt";
+ mWarningsArray.append(args);
setLoadState( ERROR_PARSING );
return false;
}
@@ -934,6 +976,9 @@ bool LLDAELoader::OpenFile(const std::string& filename)
if (!doc)
{
LL_WARNS() << "can't find internal doc" << LL_ENDL;
+ LLSD args;
+ args["Message"] = "ParsingErrorNoDoc";
+ mWarningsArray.append(args);
return false;
}
@@ -941,6 +986,9 @@ bool LLDAELoader::OpenFile(const std::string& filename)
if (!root)
{
LL_WARNS() << "document has no root" << LL_ENDL;
+ LLSD args;
+ args["Message"] = "ParsingErrorNoRoot";
+ mWarningsArray.append(args);
return false;
}
@@ -956,6 +1004,9 @@ bool LLDAELoader::OpenFile(const std::string& filename)
if (!result)
{
LL_INFOS() << "Could not verify controller" << LL_ENDL;
+ LLSD args;
+ args["Message"] = "ParsingErrorBadElement";
+ mWarningsArray.append(args);
setLoadState( ERROR_PARSING );
return true;
}
@@ -1089,6 +1140,9 @@ bool LLDAELoader::OpenFile(const std::string& filename)
if (!scene)
{
LL_WARNS() << "document has no visual_scene" << LL_ENDL;
+ LLSD args;
+ args["Message"] = "ParsingErrorNoScene";
+ mWarningsArray.append(args);
setLoadState( ERROR_PARSING );
return true;
}
@@ -1097,11 +1151,14 @@ bool LLDAELoader::OpenFile(const std::string& filename)
bool badElement = false;
- processElement( scene, badElement, &dae );
+ processElement( scene, badElement, &dae);
if ( badElement )
{
LL_INFOS()<<"Scene could not be parsed"<<LL_ENDL;
+ LLSD args;
+ args["Message"] = "ParsingErrorCantParseScene";
+ mWarningsArray.append(args);
setLoadState( ERROR_PARSING );
}
@@ -1940,7 +1997,7 @@ daeElement* LLDAELoader::getChildFromElement( daeElement* pElement, std::string
return NULL;
}
-void LLDAELoader::processElement( daeElement* element, bool& badElement, DAE* dae )
+void LLDAELoader::processElement( daeElement* element, bool& badElement, DAE* dae)
{
LLMatrix4 saved_transform;
bool pushed_mat = false;
@@ -2034,6 +2091,11 @@ void LLDAELoader::processElement( daeElement* element, bool& badElement, DAE* da
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;
}
@@ -2057,6 +2119,10 @@ void LLDAELoader::processElement( daeElement* element, bool& badElement, DAE* da
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;
}
@@ -2098,6 +2164,9 @@ void LLDAELoader::processElement( daeElement* element, bool& badElement, DAE* da
else
{
LL_INFOS()<<"Unable to resolve geometry URL."<<LL_ENDL;
+ LLSD args;
+ args["Message"] = "CantResolveGeometryUrl";
+ mWarningsArray.append(args);
badElement = true;
}
@@ -2384,11 +2453,13 @@ bool LLDAELoader::addVolumeFacesFromDomMesh(LLModel* pModel,domMesh* mesh, LLSD&
LLModel::EModelStatus status = LLModel::NO_ERRORS;
domTriangles_Array& tris = mesh->getTriangles_array();
+ pModel->mHasGeneratedFaces = false;
+
for (U32 i = 0; i < tris.getCount(); ++i)
{
domTrianglesRef& tri = tris.get(i);
- status = load_face_from_dom_triangles(pModel->getVolumeFaces(), pModel->getMaterialList(), tri);
+ status = load_face_from_dom_triangles(pModel->getVolumeFaces(), pModel->getMaterialList(), tri, pModel->mHasGeneratedFaces, log_msg);
pModel->mStatus = status;
if(status != LLModel::NO_ERRORS)
{
@@ -2401,7 +2472,7 @@ bool LLDAELoader::addVolumeFacesFromDomMesh(LLModel* pModel,domMesh* mesh, LLSD&
for (U32 i = 0; i < polys.getCount(); ++i)
{
domPolylistRef& poly = polys.get(i);
- status = load_face_from_dom_polylist(pModel->getVolumeFaces(), pModel->getMaterialList(), poly, log_msg);
+ status = load_face_from_dom_polylist(pModel->getVolumeFaces(), pModel->getMaterialList(), poly, pModel->mHasGeneratedFaces, log_msg);
if(status != LLModel::NO_ERRORS)
{
@@ -2415,6 +2486,10 @@ bool LLDAELoader::addVolumeFacesFromDomMesh(LLModel* pModel,domMesh* mesh, LLSD&
for (U32 i = 0; i < polygons.getCount(); ++i)
{
domPolygonsRef& poly = polygons.get(i);
+
+ // Due to how poligons work, assume that face was 'generated' by default
+ pModel->mHasGeneratedFaces = true;
+
status = load_face_from_dom_polygons(pModel->getVolumeFaces(), pModel->getMaterialList(), poly);
if(status != LLModel::NO_ERRORS)
@@ -2514,6 +2589,7 @@ bool LLDAELoader::loadModelsFromDomMesh(domMesh* mesh, std::vector<LLModel*>& mo
{
LLModel* next = new LLModel(volume_params, 0.f);
next->mSubmodelID = ++submodelID;
+ next->mHasGeneratedFaces = ret->mHasGeneratedFaces;
next->mLabel = model_name + (char)((int)'a' + next->mSubmodelID) + lod_suffix[mLod];
next->getVolumeFaces() = remainder;
next->mNormalizedScale = ret->mNormalizedScale;