diff --git a/panda/src/gobj/geom.I b/panda/src/gobj/geom.I index 40c29a0ce7..44beea45c0 100644 --- a/panda/src/gobj/geom.I +++ b/panda/src/gobj/geom.I @@ -91,6 +91,19 @@ get_vertex_data(Thread *current_thread) const { return cdata->_data.get_read_pointer(); } +//////////////////////////////////////////////////////////////////// +// Function: Geom::is_empty +// Access: Published +// Description: Returns true if there appear to be no vertices to be +// rendered by this Geom, false if has some actual data. +//////////////////////////////////////////////////////////////////// +INLINE bool Geom:: +is_empty() const { + CDReader cdata(_cycler); + return (cdata->_data.get_read_pointer()->get_num_rows() == 0 || + cdata->_primitives.empty()); +} + //////////////////////////////////////////////////////////////////// // Function: Geom::get_num_primitives // Access: Published diff --git a/panda/src/gobj/geom.h b/panda/src/gobj/geom.h index 17d598b9ef..78618d4783 100644 --- a/panda/src/gobj/geom.h +++ b/panda/src/gobj/geom.h @@ -89,6 +89,8 @@ PUBLISHED: void offset_vertices(const GeomVertexData *data, int offset); int make_nonindexed(bool composite_only); + INLINE bool is_empty() const; + INLINE int get_num_primitives() const; INLINE CPT(GeomPrimitive) get_primitive(int i) const; INLINE PT(GeomPrimitive) modify_primitive(int i); diff --git a/panda/src/pgraph/cullTraverser.cxx b/panda/src/pgraph/cullTraverser.cxx index d0f00e7194..613de61328 100644 --- a/panda/src/pgraph/cullTraverser.cxx +++ b/panda/src/pgraph/cullTraverser.cxx @@ -266,6 +266,9 @@ traverse_below(CullTraverserData &data) { for (int i = 0; i < num_geoms; i++) { const Geom *geom = geoms.get_geom(i); + if (geom->is_empty()) { + continue; + } CPT(RenderState) state = data._state->compose(geoms.get_geom_state(i)); if (state->has_cull_callback() && !state->cull_callback(this, data)) { @@ -730,6 +733,9 @@ start_decal(const CullTraverserData &data) { for (int i = num_geoms - 1; i >= 0; i--) { const Geom *geom = geoms.get_geom(i); + if (geom->is_empty()) { + continue; + } CPT(RenderState) state = data._state->compose(geoms.get_geom_state(i)); if (state->has_cull_callback() && !state->cull_callback(this, data)) { @@ -839,6 +845,9 @@ r_get_decals(CullTraverserData &data, CullableObject *decals) { for (int i = num_geoms - 1; i >= 0; i--) { const Geom *geom = geoms.get_geom(i); + if (geom->is_empty()) { + continue; + } CPT(RenderState) state = data._state->compose(geoms.get_geom_state(i)); if (state->has_cull_callback() && !state->cull_callback(this, data)) {