From 1e10f5238af562c5a3c4d4854cd3f131a4714439 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 9 Jun 2011 18:52:39 +0000 Subject: [PATCH] implicitly drop an empty array during register_format() --- panda/src/gobj/geomVertexFormat.cxx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/panda/src/gobj/geomVertexFormat.cxx b/panda/src/gobj/geomVertexFormat.cxx index 9050fac58a..7450fcae6d 100644 --- a/panda/src/gobj/geomVertexFormat.cxx +++ b/panda/src/gobj/geomVertexFormat.cxx @@ -713,12 +713,23 @@ do_register() { nassertv(!is_registered()); nassertv(_columns_by_name.empty()); - for (int array = 0; array < (int)_arrays.size(); ++array) { - CPT(GeomVertexArrayFormat) array_format = _arrays[array]; + Arrays orig_arrays; + orig_arrays.swap(_arrays); + Arrays::const_iterator ai; + for (ai = orig_arrays.begin(); ai != orig_arrays.end(); ++ai) { + CPT(GeomVertexArrayFormat) array_format = (*ai); if (!array_format->is_registered()) { array_format = GeomVertexArrayFormat::register_format(array_format); - _arrays[array] = (GeomVertexArrayFormat *)array_format.p(); } + if (array_format->get_num_columns() == 0) { + // Don't keep an empty array. + gobj_cat.warning() + << "Dropping empty array from GeomVertexFormat.\n"; + continue; + } + + int array = (int)_arrays.size(); + _arrays.push_back((GeomVertexArrayFormat *)array_format.p()); // Now add the names to the index. int num_columns = array_format->get_num_columns(); @@ -1063,6 +1074,10 @@ register_format(GeomVertexFormat *format) { new_format = (*fi); if (!new_format->is_registered()) { new_format->do_register(); + if (new_format->get_num_arrays() == 0) { + gobj_cat.warning() + << "Empty GeomVertexFormat registered.\n"; + } } }