early-out on empty Geoms

This commit is contained in:
David Rose 2007-10-25 21:19:22 +00:00
parent 0c56b38f6a
commit b706a17f25
3 changed files with 24 additions and 0 deletions

View File

@ -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

View File

@ -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);

View File

@ -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)) {