From 541bbe440365977085012d6b80bbca1ce44a6501 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 15 Apr 2005 00:18:40 +0000 Subject: [PATCH] more assertions for recompute_bound() --- panda/src/gobj/geom.cxx | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index 5e6dcc2b5a..77e4c9a243 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -1108,11 +1108,33 @@ recompute_bound() { // of our vertices. pvector vertices; VertexIterator vi = make_vertex_iterator(); - - for (int p = 0; p < get_num_prims(); p++) { - for (int v = 0; v < get_length(p); v++) { - vertices.push_back(get_next_vertex(vi)); + int num_vertices = _coords.size(); + + if (_vindex.is_null()) { + // Nonindexed case. + int vcount = 0; + for (int p = 0; p < get_num_prims(); p++) { + for (int v = 0; v < get_length(p); v++) { + nassertr(vcount < num_vertices, bound); + vertices.push_back(get_next_vertex(vi)); + ++vcount; + } } + nassertr(vcount == num_vertices, bound); + + } else { + // Indexed case. + int num_indices = _vindex.size(); + int vindex = 0; + for (int p = 0; p < get_num_prims(); p++) { + for (int v = 0; v < get_length(p); v++) { + nassertr(vindex < num_indices, bound); + nassertr(_vindex[vindex] < num_vertices, bound); + vertices.push_back(get_next_vertex(vi)); + ++vindex; + } + } + nassertr(vindex == num_indices, bound); } const LPoint3f *vertices_begin = &vertices[0];