From c59024015735f2dd1854cb313d756d3a344828b1 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 10 Jan 2001 01:10:02 +0000 Subject: [PATCH] *** empty log message *** --- panda/src/cull/cullTraverser.cxx | 26 ++++++++-- panda/src/sgattrib/config_sgattrib.cxx | 49 +++++++++++++++++-- panda/src/sgattrib/config_sgattrib.h | 10 ++++ .../src/sgraphutil/directRenderTraverser.cxx | 45 ++++++++++++----- 4 files changed, 112 insertions(+), 18 deletions(-) diff --git a/panda/src/cull/cullTraverser.cxx b/panda/src/cull/cullTraverser.cxx index 686fd16fc4..8a7f1ae52b 100644 --- a/panda/src/cull/cullTraverser.cxx +++ b/panda/src/cull/cullTraverser.cxx @@ -20,6 +20,7 @@ #include #include #include // for implicit_app_traversal +#include // for support_decals #include TypeHandle CullTraverser::_type_handle; @@ -392,9 +393,20 @@ forward_arc(NodeRelation *arc, NullTransitionWrapper &, bool is_geom = node->is_of_type(GeomNode::get_class_type()); bool node_has_sub_render = node->has_sub_render(); bool arc_has_sub_render = arc->has_sub_render_trans(); - bool has_direct_render = - arc->has_transition(DirectRenderTransition::get_class_type()) || - arc->has_transition(DecalTransition::get_class_type()); + bool has_direct_render; + +#ifndef NDEBUG + if (support_decals != SD_on) { + has_direct_render = + arc->has_transition(DirectRenderTransition::get_class_type()) && + !arc->has_transition(DecalTransition::get_class_type()); + } else +#endif + { + has_direct_render = + arc->has_transition(DirectRenderTransition::get_class_type()) || + arc->has_transition(DecalTransition::get_class_type()); + } if (arc_has_sub_render) { level_state._now = UpdateSeq::fresh(); @@ -477,5 +489,13 @@ forward_arc(NodeRelation *arc, NullTransitionWrapper &, add_geom_node(DCAST(GeomNode, node), trans, level_state); } +#ifndef NDEBUG + if (support_decals == SD_hide && + arc->has_transition(DecalTransition::get_class_type())) { + mark_backward_arc(arc); + return false; + } +#endif + return true; } diff --git a/panda/src/sgattrib/config_sgattrib.cxx b/panda/src/sgattrib/config_sgattrib.cxx index beb2b50a8d..5c1d6f2cc6 100644 --- a/panda/src/sgattrib/config_sgattrib.cxx +++ b/panda/src/sgattrib/config_sgattrib.cxx @@ -64,11 +64,53 @@ Configure(config_sgattrib); NotifyCategoryDef(sgattrib, ""); -// MPG - we want to ensure that texture transitions are applied before -// texgen transitions, so the texture transition must be initialized -// first. +// For performance testing reasons, it may be useful to support decals +// (specially rendered coplanar geometry) to varying +// less-than-complete degrees. Modify the variable support-decals to +// change this. The legal values are: +// +// on - This is the default, and causes decals to be rendered +// properly (if supported by the gsg backend). This could have +// performance implications in fill, transform, and +// state-sorting. This is equivalent to #t. +// +// off - Decals are rendered as if they were not decalled at all. +// The result will generally be horrible looking, with each +// decal Z-fighting with its base. This is equivalent to #f. +// +// hide - Decals are not drawn at all. +// +// If compiled in NDEBUG mode, this variable is ignored and decals are +// always on. +// +SupportDecals support_decals = SD_on; + +static SupportDecals +parse_support_decals(const string &type) { + if (type == "on") { + return SD_on; + } else if (type == "off") { + return SD_off; + } else if (type == "hide") { + return SD_hide; + } + return SD_invalid; +} ConfigureFn(config_sgattrib) { + string support_decals_str = config_sgattrib.GetString("support-decals", ""); + if (!support_decals_str.empty()) { + support_decals = parse_support_decals(support_decals_str); + if (support_decals == SD_invalid) { + support_decals = + config_sgattrib.GetBool("support-decals", true) ? SD_on : SD_off; + } + } + + // MPG - we want to ensure that texture transitions are applied + // before texgen transitions, so the texture transition must be + // initialized first. + RenderRelation::init_type(); TextureTransition::init_type(); TextureAttribute::init_type(); @@ -140,4 +182,3 @@ ConfigureFn(config_sgattrib) { ColorMatrixTransition::register_with_read_factory(); } - diff --git a/panda/src/sgattrib/config_sgattrib.h b/panda/src/sgattrib/config_sgattrib.h index 512e37ca4e..fb581ae639 100644 --- a/panda/src/sgattrib/config_sgattrib.h +++ b/panda/src/sgattrib/config_sgattrib.h @@ -11,4 +11,14 @@ NotifyCategoryDecl(sgattrib, EXPCL_PANDA, EXPTP_PANDA); +// Configure variables for sgattrib package. +enum SupportDecals { + SD_on, + SD_off, + SD_hide, + SD_invalid +}; + +extern EXPCL_PANDA SupportDecals support_decals; + #endif diff --git a/panda/src/sgraphutil/directRenderTraverser.cxx b/panda/src/sgraphutil/directRenderTraverser.cxx index c8ec6f5a1b..c49b4f316b 100644 --- a/panda/src/sgraphutil/directRenderTraverser.cxx +++ b/panda/src/sgraphutil/directRenderTraverser.cxx @@ -24,6 +24,7 @@ #include #include #include +#include // for support_decals TypeHandle DirectRenderTraverser::_type_handle; PStatCollector DirectRenderTraverser::_draw_pcollector = @@ -70,12 +71,17 @@ traverse(Node *root, DirectRenderLevelState level_state; - DecalAttribute *decal_attrib; - if (get_attribute_into(decal_attrib, render_state, - DecalTransition::get_class_type())) { - level_state._decal_mode = decal_attrib->is_on(); - } - +#ifndef NDEBUG + if (support_decals != SD_off) +#endif + { + DecalAttribute *decal_attrib; + if (get_attribute_into(decal_attrib, render_state, + DecalTransition::get_class_type())) { + level_state._decal_mode = decal_attrib->is_on(); + } + } + // Determine the relative transform matrix from the camera to our // starting node. This is important for proper view-frustum // culling. @@ -96,6 +102,11 @@ traverse(Node *root, if (level_state._decal_mode && root->is_of_type(GeomNode::get_class_type())) { +#ifndef NDEBUG + if (support_decals == SD_hide) { + return; + } +#endif // Close the decal. _gsg->end_decal(DCAST(GeomNode, root)); } @@ -132,13 +143,25 @@ reached_node(Node *node, AllAttributesWrapper &render_state, GeomNode *geom = DCAST(GeomNode, node); // We must make decals a special case, because they're so strange. - DecalAttribute *decal_attrib; - if (get_attribute_into(decal_attrib, render_state, - DecalTransition::get_class_type())) { - level_state._decal_mode = decal_attrib->is_on(); - } +#ifndef NDEBUG + if (support_decals != SD_off) +#endif + { + DecalAttribute *decal_attrib; + if (get_attribute_into(decal_attrib, render_state, + DecalTransition::get_class_type())) { + level_state._decal_mode = decal_attrib->is_on(); + } + } if (level_state._decal_mode) { +#ifndef NDEBUG + if (support_decals == SD_hide) { + level_state._decal_mode = false; + geom->draw(_gsg); + return false; + } +#endif _gsg->begin_decal(geom); } else {