From: Braden M. <br...@us...> - 2007-05-31 07:59:34
|
Update of /cvsroot/openvrml/openvrml/src/libopenvrml-gl/openvrml/gl In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv24779/src/libopenvrml-gl/openvrml/gl Modified Files: viewer.cpp Log Message: Ensure indices into coordinate, normal, and color data are valid before using them in the renderer. Index: viewer.cpp =================================================================== RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml-gl/openvrml/gl/viewer.cpp,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** viewer.cpp 6 Mar 2007 07:24:02 -0000 1.61 --- viewer.cpp 31 May 2007 07:59:32 -0000 1.62 *************** *** 209,213 **** const std::vector<openvrml::vec2f> & texCoord; const std::vector<openvrml::int32> & texCoordIndex; ! int *texAxes; float *texParams; size_t nf, i; --- 209,213 ---- const std::vector<openvrml::vec2f> & texCoord; const std::vector<openvrml::int32> & texCoordIndex; ! int (&texAxes)[2]; float *texParams; size_t nf, i; *************** *** 222,226 **** const std::vector<openvrml::vec2f> & texCoord, const std::vector<openvrml::int32> & texCoordIndex, ! int * texAxes, float * texParams, size_t nf, size_t i); }; --- 222,226 ---- const std::vector<openvrml::vec2f> & texCoord, const std::vector<openvrml::int32> & texCoordIndex, ! int (&texAxes)[2], float * texParams, size_t nf, size_t i); }; *************** *** 234,238 **** const std::vector<openvrml::vec2f> & texCoord, const std::vector<openvrml::int32> & texCoordIndex, ! int * texAxes, float * texParams, size_t nf, --- 234,238 ---- const std::vector<openvrml::vec2f> & texCoord, const std::vector<openvrml::int32> & texCoordIndex, ! int (&texAxes)[2], float * texParams, size_t nf, *************** *** 2802,2811 **** // Per-face attributes ! if (!s->color.empty() ! && !(s->mask & viewer::mask_color_per_vertex)) { ! const size_t index = !s->colorIndex.empty() ! ? s->colorIndex[nf] ! : nf; ! glColor3fv(&s->color[index][0]); } --- 2802,2811 ---- // Per-face attributes ! const size_t color_index = (nf < s->colorIndex.size()) ! ? s->colorIndex[nf] ! : nf; ! if (color_index < s->color.size() ! && !(s->mask & viewer::mask_color_per_vertex)) { ! glColor3fv(&s->color[color_index][0]); } *************** *** 2814,2822 **** ? 0 : i + 1; ! if (!s->normal.empty()) { ! const size_t index = !s->normalIndex.empty() ! ? s->normalIndex[nf] ! : nf; ! glNormal3fv(&s->normal[index][0]); } else if (i < s->coordIndex.size() - 4 && s->coordIndex[i1] >= 0 --- 2814,2822 ---- ? 0 : i + 1; ! const size_t normal_index = (nf < s->normalIndex.size()) ! ? s->normalIndex[nf] ! : nf; ! if (normal_index < s->normal.size()) { ! glNormal3fv(&s->normal[normal_index][0]); } else if (i < s->coordIndex.size() - 4 && s->coordIndex[i1] >= 0 *************** *** 2839,2856 **** if (s->coordIndex[i] >= 0) { // Per-vertex attributes ! if (!s->color.empty() ! && (s->mask & viewer::mask_color_per_vertex)) { ! const size_t index = !s->colorIndex.empty() ! ? s->colorIndex[i] ! : s->coordIndex[i]; ! glColor3fv(&s->color[index][0]); } if (s->mask & viewer::mask_normal_per_vertex) { ! if (!s->normal.empty()) { ! const size_t index = !s->normalIndex.empty() ! ? s->normalIndex[i] ! : s->coordIndex[i]; ! glNormal3fv(&s->normal[index][0]); } else { ; // Generate per-vertex normal here... --- 2839,2856 ---- if (s->coordIndex[i] >= 0) { // Per-vertex attributes ! const size_t color_index = (i < s->colorIndex.size()) ! ? s->colorIndex[i] ! : s->coordIndex[i]; ! if (color_index < s->color.size() ! && (s->mask & viewer::mask_color_per_vertex)) { ! glColor3fv(&s->color[color_index][0]); } if (s->mask & viewer::mask_normal_per_vertex) { ! const size_t normal_index = (i < s->normalIndex.size()) ! ? s->normalIndex[i] ! : s->coordIndex[i]; ! if (normal_index < s->normal.size()) { ! glNormal3fv(&s->normal[normal_index][0]); } else { ; // Generate per-vertex normal here... *************** *** 2859,2867 **** const vec3f & v = s->coord[s->coordIndex[i]]; ! if (!s->texCoord.empty()) { ! const size_t index = !s->texCoordIndex.empty() ! ? s->texCoordIndex[i] ! : s->coordIndex[i]; ! glTexCoord2fv(&s->texCoord[index][0]); } else { float c0, c1; --- 2859,2867 ---- const vec3f & v = s->coord[s->coordIndex[i]]; ! const size_t tex_coord_index = (i < s->texCoordIndex.size()) ! ? s->texCoordIndex[i] ! : s->coordIndex[i]; ! if (tex_coord_index < s->texCoord.size()) { ! glTexCoord2fv(&s->texCoord[tex_coord_index][0]); } else { float c0, c1; *************** *** 2995,2999 **** // Texture coordinate generation parameters. ! int texAxes[2]; // Map s,t to x,y,z float texParams[4]; // s0, 1/sSize, t0, 1/tSize --- 2995,2999 ---- // Texture coordinate generation parameters. ! int texAxes[2] = { 0, 1 }; // Map s,t to x,y,z float texParams[4]; // s0, 1/sSize, t0, 1/tSize |