gobj: speed up GeomVertexData::get_num_rows() considerably

This commit is contained in:
rdb 2018-10-15 22:06:04 +02:00
parent 70f4c1cd4e
commit 6e370ebbdd
2 changed files with 17 additions and 4 deletions

View File

@ -45,7 +45,9 @@ has_column(const InternalName *name) const {
*/
INLINE int GeomVertexArrayData::
get_num_rows() const {
return get_handle()->get_num_rows();
CDReader cdata(_cycler);
nassertr(_array_format->get_stride() != 0, 0);
return cdata->_buffer.get_size() / _array_format->get_stride();
}
/**

View File

@ -60,9 +60,20 @@ has_column(const InternalName *name) const {
*/
INLINE int GeomVertexData::
get_num_rows() const {
GeomVertexDataPipelineReader reader(this, Thread::get_current_thread());
reader.check_array_readers();
return reader.get_num_rows();
CPT(GeomVertexArrayData) array;
{
CDReader cdata(_cycler);
nassertr(cdata->_format->get_num_arrays() == cdata->_arrays.size(), 0);
if (cdata->_arrays.size() == 0) {
// No arrays means no rows. Weird but legal.
return 0;
}
array = cdata->_arrays[0].get_read_pointer();
}
return array->get_num_rows();
}
/**