Text archives Help
- From: thiago@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r1979 - trunk/Model/Groups
- Date: Tue, 8 Jan 2008 11:51:14 -0700 (MST)
Author: thiago
Date: Tue Jan 8 11:51:14 2008
New Revision: 1979
Modified:
trunk/Model/Groups/ObjGroup.cc
Log:
Fixed seg fault that occured when obj had some triangles with vertex
normals and other triangles without.
Modified: trunk/Model/Groups/ObjGroup.cc
==============================================================================
--- trunk/Model/Groups/ObjGroup.cc (original)
+++ trunk/Model/Groups/ObjGroup.cc Tue Jan 8 11:51:14 2008
@@ -248,14 +248,12 @@
normal_indices.push_back(index-1);
}
else if (!vertexNormals.empty()) {
- //Not sure if this can happen in the obj spec, but just in
- //case...
- //we've already added in the vertices several lines
- //above, so we know enough to calculate a face normal.
- size_t vIndex = vertex_indices.size()-3;
- const Vector &n0 = vertices[vertex_indices[vIndex+0]];
- const Vector &n1 = vertices[vertex_indices[vIndex+1]];
- const Vector &n2 = vertices[vertex_indices[vIndex+2]];
+ //in case we are supposed to have vertex normals, but this
+ //triangle doesn't have any, we'll use the face normal for
+ //each of the vertex normals.
+ const Vector &n0 =
vertices[model->triangles[group->triangles[i]].vindices[0]-1];
+ const Vector &n1 =
vertices[model->triangles[group->triangles[i]].vindices[1]-1];
+ const Vector &n2 =
vertices[model->triangles[group->triangles[i]].vindices[2]-1];
const Vector normal = Cross(n1-n0, n2-n0);
normal_indices.push_back(vertexNormals.size());
vertexNormals.push_back(normal);
- [Manta] r1979 - trunk/Model/Groups, thiago, 01/08/2008
Archive powered by MHonArc 2.6.16.