diff options
Diffstat (limited to 'indra/llprimitive/llmodel.cpp')
-rw-r--r-- | indra/llprimitive/llmodel.cpp | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp index 82765c740f..ae17996956 100644 --- a/indra/llprimitive/llmodel.cpp +++ b/indra/llprimitive/llmodel.cpp @@ -120,7 +120,7 @@ void load_face_from_dom_inputs(LLVolumeFace& face, const domInputLocalOffset_Arr { LLVector4a* norm = (LLVector4a*) face.mNormals + (j-min_idx); norm->set(n[j*3+0], n[j*3+1], n[j*3+2]); - norm->normalize3fast(); + norm->normalize3(); } } else if (strcmp(COMMON_PROFILE_INPUT_TEXCOORD, inputs[j]->getSemantic()) == 0) @@ -662,12 +662,18 @@ void load_face_from_dom_polygons(std::vector<LLVolumeFace>& face_list, std::vect } } + if (cur_idx != vert_idx.size()) + { + llerrs << "WTF?" << llendl; + } + //build vertex array from map - verts.resize(vert_idx.size()); + std::vector<LLVolumeFace::VertexData> new_verts; + new_verts.resize(vert_idx.size()); for (std::map<LLVolumeFace::VertexData, U32>::iterator iter = vert_idx.begin(); iter != vert_idx.end(); ++iter) { - verts[iter->second] = iter->first; + new_verts[iter->second] = iter->first; update_min_max(face.mExtents[0], face.mExtents[1], iter->first.getPosition()); } @@ -679,8 +685,14 @@ void load_face_from_dom_polygons(std::vector<LLVolumeFace>& face_list, std::vect indices[i] = vert_idx[verts[i]]; } + // DEBUG just build an expanded triangle list + /*for (U32 i = 0; i < verts.size(); ++i) + { + indices.push_back((U16) i); + update_min_max(face.mExtents[0], face.mExtents[1], verts[i].getPosition()); + }*/ - if (!verts.empty()) + if (!new_verts.empty()) { std::string material; @@ -691,7 +703,7 @@ void load_face_from_dom_polygons(std::vector<LLVolumeFace>& face_list, std::vect materials.push_back(material); face_list.push_back(face); - face_list.rbegin()->fillFromLegacyData(verts, indices); + face_list.rbegin()->fillFromLegacyData(new_verts, indices); } } @@ -1029,6 +1041,12 @@ void LLModel::smoothNormals(F32 angle_cutoff) { LLVolumeFace& vol_face = mVolumeFaces[j]; + if (vol_face.mNumIndices > 65535) + { + llwarns << "Too many vertices for normal generation to work." << llendl; + continue; + } + //create faceted copy of current face with no texture coordinates (step 1) LLVolumeFace faceted; @@ -1036,16 +1054,16 @@ void LLModel::smoothNormals(F32 angle_cutoff) //LLVector4a* src_norm = (LLVector4a*) vol_face.mNormals; - //bake out triangles into temporary face, clearing normals and texture coordinates + faceted.resizeVertices(vol_face.mNumIndices); + faceted.resizeIndices(vol_face.mNumIndices); + //bake out triangles into temporary face, clearing texture coordinates for (U32 i = 0; i < vol_face.mNumIndices; ++i) { U32 idx = vol_face.mIndices[i]; - LLVolumeFace::VertexData v; - v.setPosition(src_pos[idx]); - v.getNormal().clear(); - v.mTexCoord.clear(); - faceted.pushVertex(v); - faceted.pushIndex(i); + + faceted.mPositions[i] = src_pos[idx]; + faceted.mTexCoords[i] = LLVector2(0,0); + faceted.mIndices[i] = i; } //generate normals for temporary face @@ -1068,7 +1086,7 @@ void LLModel::smoothNormals(F32 angle_cutoff) rhs.setSub(p2, p0); n0.setCross3(lhs, rhs); - n0.normalize3fast(); + n0.normalize3(); n1 = n0; n2 = n0; } @@ -1114,7 +1132,7 @@ void LLModel::smoothNormals(F32 angle_cutoff) for (U32 i = 0; i < faceted.mNumVertices; ++i) { - faceted.mNormals[i].normalize3fast(); + faceted.mNormals[i].normalize3(); LLVolumeFace::VertexMapData v; v.setPosition(faceted.mPositions[i]); @@ -1127,16 +1145,17 @@ void LLModel::smoothNormals(F32 angle_cutoff) LLVolumeFace new_face; //bake out triangles into new face + new_face.resizeIndices(vol_face.mNumIndices); + new_face.resizeVertices(vol_face.mNumIndices); + for (U32 i = 0; i < vol_face.mNumIndices; ++i) { U32 idx = vol_face.mIndices[i]; LLVolumeFace::VertexData v; - v.setPosition(vol_face.mPositions[idx]); - v.setNormal(vol_face.mNormals[idx]); - v.mTexCoord = vol_face.mTexCoords[idx]; - - new_face.pushVertex(v); - new_face.pushIndex(i); + new_face.mPositions[i] = vol_face.mPositions[idx]; + new_face.mNormals[i].clear(); + new_face.mTexCoords[i] = vol_face.mTexCoords[idx]; + new_face.mIndices[i] = i; } //generate normals for new face @@ -1159,7 +1178,7 @@ void LLModel::smoothNormals(F32 angle_cutoff) rhs.setSub(p2, p0); n0.setCross3(lhs, rhs); - n0.normalize3fast(); + n0.normalize3(); n1 = n0; n2 = n0; } |