gobj: speed up GeomVertexData::get_num_rows() considerably
This commit is contained in:
parent
70f4c1cd4e
commit
6e370ebbdd
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue