From 5f75d73f3a8b93e955679b6ff4ddeadb5db393bf Mon Sep 17 00:00:00 2001 From: cxgeorge <> Date: Tue, 30 Apr 2002 00:53:01 +0000 Subject: [PATCH] compute total geom verts more efficiently --- panda/src/gobj/geom.I | 29 +++++++++++++++++++++++++++++ panda/src/gobj/geom.cxx | 30 ++++++++++-------------------- panda/src/gobj/geom.h | 2 +- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/panda/src/gobj/geom.I b/panda/src/gobj/geom.I index e54bd5dacb..edbd253e9b 100644 --- a/panda/src/gobj/geom.I +++ b/panda/src/gobj/geom.I @@ -138,6 +138,10 @@ get_texcoords_index() const { INLINE void Geom:: set_num_prims(int num) { _numprims = num; + if (!uses_components()) { + // except for strips & fans with the length arrays, total verts will be simply this + _num_vertices = _numprims*get_num_vertices_per_prim(); + } make_dirty(); } @@ -151,6 +155,30 @@ get_num_prims(void) const { return _numprims; } +//////////////////////////////////////////////////////////////////// +// Function: Geom::get_num_vertices +// Access: Public +// Description: Returns the number of vertices required by all all +// the prims in the Geom. +//////////////////////////////////////////////////////////////////// +INLINE int Geom:: +get_num_vertices() const { + return _num_vertices; +} + +INLINE int PTA_int_arraysum(const PTA_int &lengths) { + assert(lengths.size()>0); + + int *pLen=&lengths[0]; + int *pArrayEnd=pLen+lengths.size(); + int nVerts = 0; + for (;pLen