Merge branch 'master' of https://github.com/singularity-viewer/SingularityViewer.git
Conflicts: indra/newview/llnetmap.cpp
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
|
||||
#include "llmodel.h"
|
||||
#include "llmemory.h"
|
||||
#include "LLConvexDecomposition.h"
|
||||
#include "llconvexdecomposition.h"
|
||||
#include "llsdserialize.h"
|
||||
#include "llvector4a.h"
|
||||
#include "llmatrix4a.h"
|
||||
@@ -169,6 +169,7 @@ 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) || !pos_source )
|
||||
{
|
||||
llwarns << "Could not find dom sources for basic geo data; invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
|
||||
@@ -189,27 +190,78 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector<LLVolumeFace>& fa
|
||||
|
||||
LLVolumeFace::VertexMapData::PointMap point_map;
|
||||
|
||||
for (U32 i = 0; i < idx.getCount(); i += idx_stride)
|
||||
U32 index_count = idx.getCount();
|
||||
U32 vertex_count = pos_source ? v.getCount() : 0;
|
||||
U32 tc_count = tc_source ? tc.getCount() : 0;
|
||||
U32 norm_count = norm_source ? n.getCount() : 0;
|
||||
|
||||
for (U32 i = 0; i < index_count; i += idx_stride)
|
||||
{
|
||||
LLVolumeFace::VertexData cv;
|
||||
if (pos_source)
|
||||
{
|
||||
// guard against model data specifiying out of range indices or verts
|
||||
//
|
||||
if (((i + pos_offset) > index_count)
|
||||
|| ((idx[i+pos_offset]*3+2) > vertex_count))
|
||||
{
|
||||
llwarns << "Out of range index data; invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
|
||||
cv.setPosition(LLVector4a(v[idx[i+pos_offset]*3+0],
|
||||
v[idx[i+pos_offset]*3+1],
|
||||
v[idx[i+pos_offset]*3+2]));
|
||||
|
||||
if (!cv.getPosition().isFinite3())
|
||||
{
|
||||
llwarns << "Nan positional data, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
}
|
||||
|
||||
if (tc_source)
|
||||
{
|
||||
// guard against model data specifiying out of range indices or tcs
|
||||
//
|
||||
|
||||
if (((i + tc_offset) > index_count)
|
||||
|| ((idx[i+tc_offset]*2+1) > tc_count))
|
||||
{
|
||||
llwarns << "Out of range TC indices." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
|
||||
cv.mTexCoord.setVec(tc[idx[i+tc_offset]*2+0],
|
||||
tc[idx[i+tc_offset]*2+1]);
|
||||
|
||||
if (!cv.mTexCoord.isFinite())
|
||||
{
|
||||
llwarns << "Found NaN while loading tex coords from DAE-Model, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
}
|
||||
|
||||
if (norm_source)
|
||||
{
|
||||
// guard against model data specifiying out of range indices or norms
|
||||
//
|
||||
if (((i + norm_offset) > index_count)
|
||||
|| ((idx[i+norm_offset]*3+2) > norm_count))
|
||||
{
|
||||
llwarns << "Found out of range norm indices, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
|
||||
cv.setNormal(LLVector4a(n[idx[i+norm_offset]*3+0],
|
||||
n[idx[i+norm_offset]*3+1],
|
||||
n[idx[i+norm_offset]*3+2]));
|
||||
|
||||
if (!cv.getNormal().isFinite3())
|
||||
{
|
||||
llwarns << "Found NaN while loading normals from DAE-Model, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL found = FALSE;
|
||||
@@ -264,7 +316,7 @@ LLModel::EModelStatus load_face_from_dom_triangles(std::vector<LLVolumeFace>& fa
|
||||
LLVolumeFace& new_face = *face_list.rbegin();
|
||||
if (!norm_source)
|
||||
{
|
||||
//l_aligned_free_16(new_face.mNormals);
|
||||
//ll_aligned_free_16(new_face.mNormals);
|
||||
new_face.mNormals = NULL;
|
||||
}
|
||||
|
||||
@@ -336,6 +388,7 @@ 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))
|
||||
{
|
||||
llwarns << "Could not get DOM sources for basic geo data, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
|
||||
@@ -367,6 +420,11 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector<LLVolumeFace>& fac
|
||||
|
||||
LLVolumeFace::VertexMapData::PointMap point_map;
|
||||
|
||||
U32 index_count = idx.getCount();
|
||||
U32 vertex_count = pos_source ? v.getCount() : 0;
|
||||
U32 tc_count = tc_source ? tc.getCount() : 0;
|
||||
U32 norm_count = norm_source ? n.getCount() : 0;
|
||||
|
||||
U32 cur_idx = 0;
|
||||
for (U32 i = 0; i < vcount.getCount(); ++i)
|
||||
{ //for each polygon
|
||||
@@ -379,22 +437,68 @@ LLModel::EModelStatus load_face_from_dom_polylist(std::vector<LLVolumeFace>& fac
|
||||
|
||||
if (pos_source)
|
||||
{
|
||||
// guard against model data specifiying out of range indices or verts
|
||||
//
|
||||
if (((cur_idx + pos_offset) > index_count)
|
||||
|| ((idx[cur_idx+pos_offset]*3+2) > vertex_count))
|
||||
{
|
||||
llwarns << "Out of range position indices, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
|
||||
cv.getPosition().set(v[idx[cur_idx+pos_offset]*3+0],
|
||||
v[idx[cur_idx+pos_offset]*3+1],
|
||||
v[idx[cur_idx+pos_offset]*3+2]);
|
||||
|
||||
if (!cv.getPosition().isFinite3())
|
||||
{
|
||||
llwarns << "Found NaN while loading positions from DAE-Model, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (tc_source)
|
||||
{
|
||||
// guard against model data specifiying out of range indices or tcs
|
||||
//
|
||||
if (((cur_idx + tc_offset) > index_count)
|
||||
|| ((idx[cur_idx+tc_offset]*2+1) > tc_count))
|
||||
{
|
||||
llwarns << "Out of range TC indices, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
|
||||
cv.mTexCoord.setVec(tc[idx[cur_idx+tc_offset]*2+0],
|
||||
tc[idx[cur_idx+tc_offset]*2+1]);
|
||||
|
||||
if (!cv.mTexCoord.isFinite())
|
||||
{
|
||||
llwarns << "Found NaN while loading tex coords from DAE-Model, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
}
|
||||
|
||||
if (norm_source)
|
||||
{
|
||||
// guard against model data specifiying out of range indices or norms
|
||||
//
|
||||
if (((cur_idx + norm_offset) > index_count)
|
||||
|| ((idx[cur_idx+norm_offset]*3+2) > norm_count))
|
||||
{
|
||||
llwarns << "Out of range norm indices, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
|
||||
cv.getNormal().set(n[idx[cur_idx+norm_offset]*3+0],
|
||||
n[idx[cur_idx+norm_offset]*3+1],
|
||||
n[idx[cur_idx+norm_offset]*3+2]);
|
||||
|
||||
if (!cv.getNormal().isFinite3())
|
||||
{
|
||||
llwarns << "Found NaN while loading normals from DAE-Model, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
}
|
||||
|
||||
cur_idx += idx_stride;
|
||||
@@ -561,6 +665,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac
|
||||
domVertices* vertices = (domVertices*) elem.cast();
|
||||
if (!vertices)
|
||||
{
|
||||
llwarns << "Could not find vertex source, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
domInputLocal_Array& v_inp = vertices->getInput_array();
|
||||
@@ -574,6 +679,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac
|
||||
domSource* src = (domSource*) elem.cast();
|
||||
if (!src)
|
||||
{
|
||||
llwarns << "Could not find DOM source, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
v = &(src->getFloat_array()->getValue());
|
||||
@@ -589,6 +695,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac
|
||||
domSource* src = (domSource*) elem.cast();
|
||||
if (!src)
|
||||
{
|
||||
llwarns << "Could not find DOM source, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
n = &(src->getFloat_array()->getValue());
|
||||
@@ -601,6 +708,7 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac
|
||||
domSource* src = (domSource*) elem.cast();
|
||||
if (!src)
|
||||
{
|
||||
llwarns << "Could not find DOM source, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
t = &(src->getFloat_array()->getValue());
|
||||
@@ -635,6 +743,12 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac
|
||||
vert.getPosition().set(v->get(v_idx),
|
||||
v->get(v_idx+1),
|
||||
v->get(v_idx+2));
|
||||
|
||||
if (!vert.getPosition().isFinite3())
|
||||
{
|
||||
llwarns << "Found NaN while loading position data from DAE-Model, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
}
|
||||
|
||||
//bounds check n and t lookups because some FBX to DAE converters
|
||||
@@ -647,6 +761,12 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac
|
||||
vert.getNormal().set(n->get(n_idx),
|
||||
n->get(n_idx+1),
|
||||
n->get(n_idx+2));
|
||||
|
||||
if (!vert.getNormal().isFinite3())
|
||||
{
|
||||
llwarns << "Found NaN while loading normals from DAE-Model, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -660,6 +780,12 @@ LLModel::EModelStatus load_face_from_dom_polygons(std::vector<LLVolumeFace>& fac
|
||||
t_idx = llclamp(t_idx, (U32) 0, (U32) t->getCount());
|
||||
vert.mTexCoord.setVec(t->get(t_idx),
|
||||
t->get(t_idx+1));
|
||||
|
||||
if (!vert.mTexCoord.isFinite())
|
||||
{
|
||||
llwarns << "Found NaN while loading tex coords from DAE-Model, invalid model." << llendl;
|
||||
return LLModel::BAD_ELEMENT;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1592,6 +1718,7 @@ LLSD LLModel::writeModel(
|
||||
mdl[model_names[idx]][i]["TexCoord0Domain"]["Max"] = max_tc.getValue();
|
||||
mdl[model_names[idx]][i]["TexCoord0"] = tc;
|
||||
}
|
||||
|
||||
mdl[model_names[idx]][i]["TriangleList"] = indices;
|
||||
|
||||
if (skinning)
|
||||
|
||||
Reference in New Issue
Block a user