From ee7cc2cccec025a2d559fb5dbcbc50d7bb049045 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 11 Jan 2001 02:39:57 +0000 Subject: [PATCH] *** empty log message *** --- panda/Package.pp | 8 --- panda/src/cull/cullTraverser.cxx | 26 ++++++++ panda/src/display/graphicsStateGuardian.h | 10 +-- panda/src/graph/Sources.pp | 5 +- panda/src/graph/multiAttribute.I | 5 +- panda/src/graph/multiAttribute.h | 7 ++- panda/src/graph/multiTransition.I | 3 +- panda/src/graph/multiTransition.h | 6 +- panda/src/graph/multiTransitionHelpers.h | 2 + panda/src/light/ambientLight.h | 10 +-- panda/src/light/config_light.N | 2 + panda/src/light/directionalLight.h | 12 ++-- panda/src/light/light.h | 7 ++- panda/src/light/lightAttribute.h | 3 +- panda/src/light/lightTransition.h | 5 +- panda/src/light/pointLight.h | 18 +++--- panda/src/light/spotlight.h | 18 +++--- panda/src/sgattrib/config_sgattrib.cxx | 62 ++++++++++++------- panda/src/sgattrib/config_sgattrib.h | 9 +-- .../src/sgraphutil/directRenderTraverser.cxx | 34 ++++++---- 20 files changed, 161 insertions(+), 91 deletions(-) create mode 100644 panda/src/light/config_light.N diff --git a/panda/Package.pp b/panda/Package.pp index 3238854479..2abd52cb7c 100644 --- a/panda/Package.pp +++ b/panda/Package.pp @@ -13,14 +13,6 @@ // files. -// Check the version of ppremake in use. This is temporary until -// everyone gets up to at least 0.50. After that, the test in dtool -// will suffice. -#if $[not $[>= $[PPREMAKE_VERSION],0.50]] - #error You need at least ppremake version 0.50 to process this tree. -#endif - - // What is the name and version of this source tree? #if $[eq $[PACKAGE],] #define PACKAGE panda diff --git a/panda/src/cull/cullTraverser.cxx b/panda/src/cull/cullTraverser.cxx index 8a7f1ae52b..a745d859b9 100644 --- a/panda/src/cull/cullTraverser.cxx +++ b/panda/src/cull/cullTraverser.cxx @@ -408,6 +408,32 @@ forward_arc(NodeRelation *arc, NullTransitionWrapper &, arc->has_transition(DecalTransition::get_class_type()); } +#ifndef NDEBUG + if (support_subrender == SD_off) { + node_has_sub_render = false; + arc_has_sub_render = false; + + } else if (support_subrender == SD_hide) { + if ((node_has_sub_render || arc_has_sub_render) && + !arc->has_transition(DecalTransition::get_class_type())) { + return false; + } + node_has_sub_render = false; + arc_has_sub_render = false; + } +#endif + +#ifndef NDEBUG + if (support_direct == SD_off) { + has_direct_render = false; + + } else if (support_direct == SD_hide) { + if (has_direct_render) { + return false; + } + } +#endif + if (arc_has_sub_render) { level_state._now = UpdateSeq::fresh(); } diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index 1a1a4708b1..01c8a3498a 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -41,11 +41,10 @@ class EXPCL_PANDA GraphicsStateGuardian : public GraphicsStateGuardianBase { public: GraphicsStateGuardian(GraphicsWindow *win); +PUBLISHED: INLINE void set_render_traverser(RenderTraverser *rt); INLINE RenderTraverser *get_render_traverser() const; - void release_all_textures(); - virtual void set_color_clear_value(const Colorf& value); virtual void set_depth_clear_value(const float value); virtual void set_stencil_clear_value(const bool value); @@ -62,6 +61,10 @@ public: INLINE Colorf get_accum_clear_value(void) const { return _accum_clear_value; } + +public: + void release_all_textures(); + virtual void clear(const RenderBuffer &buffer)=0; virtual void clear(const RenderBuffer &buffer, const DisplayRegion* region)=0; @@ -187,8 +190,7 @@ private: public: INLINE GraphicsWindow* get_window(void) const { return _win; } - -PUBLISHED: +public: static TypeHandle get_class_type() { return _type_handle; } diff --git a/panda/src/graph/Sources.pp b/panda/src/graph/Sources.pp index 4edcf57a1e..6ed3595e01 100644 --- a/panda/src/graph/Sources.pp +++ b/panda/src/graph/Sources.pp @@ -22,9 +22,12 @@ lmatrix4fTransition.cxx lmatrix4fTransition.h \ matrixAttribute.I matrixAttribute.h matrixTransition.I \ matrixTransition.h \ + multiAttribute.I multiAttribute.h \ multiNodeAttribute.I \ multiNodeAttribute.cxx multiNodeAttribute.h multiNodeTransition.I \ - multiNodeTransition.cxx multiNodeTransition.h namedNode.I \ + multiNodeTransition.cxx multiNodeTransition.h \ + multiTransition.I multiTransition.h multiTransitionHelpers.I \ + multiTransitionHelpers.h namedNode.I \ namedNode.cxx namedNode.h node.I node.cxx node.h nodeAttribute.I \ nodeAttribute.N nodeAttribute.cxx nodeAttribute.h \ nodeAttributeWrapper.I nodeAttributeWrapper.cxx \ diff --git a/panda/src/graph/multiAttribute.I b/panda/src/graph/multiAttribute.I index 3a289efe37..6b168689d4 100644 --- a/panda/src/graph/multiAttribute.I +++ b/panda/src/graph/multiAttribute.I @@ -3,11 +3,8 @@ // //////////////////////////////////////////////////////////////////// +/* okcircular */ #include "multiTransition.h" -#include "multiTransitionHelpers.h" - -#include -#include template TypeHandle MultiAttribute::_type_handle; diff --git a/panda/src/graph/multiAttribute.h b/panda/src/graph/multiAttribute.h index 227d44d49b..2a99989f93 100644 --- a/panda/src/graph/multiAttribute.h +++ b/panda/src/graph/multiAttribute.h @@ -9,6 +9,10 @@ #include #include "nodeAttribute.h" +#include "multiTransitionHelpers.h" + +#include +#include template class MultiTransition; @@ -27,7 +31,7 @@ protected: MultiAttribute(const MultiAttribute ©); void operator = (const MultiAttribute ©); -public: +PUBLISHED: void set_on(const Property &prop); void set_off(const Property &prop); @@ -36,6 +40,7 @@ public: INLINE bool get_properties_is_on() const; +public: virtual void output(ostream &out) const; virtual void write(ostream &out, int indent_level = 0) const; diff --git a/panda/src/graph/multiTransition.I b/panda/src/graph/multiTransition.I index 28e37805db..acc8dd0ca2 100644 --- a/panda/src/graph/multiTransition.I +++ b/panda/src/graph/multiTransition.I @@ -3,10 +3,9 @@ // //////////////////////////////////////////////////////////////////// -#include "multiTransitionHelpers.h" +/* okcircular */ #include "multiAttribute.h" -#include template TypeHandle MultiTransition::_type_handle; diff --git a/panda/src/graph/multiTransition.h b/panda/src/graph/multiTransition.h index 4d925f7626..bf3bbcad32 100644 --- a/panda/src/graph/multiTransition.h +++ b/panda/src/graph/multiTransition.h @@ -10,6 +10,9 @@ #include "nodeTransition.h" #include "transitionDirection.h" +#include "multiTransitionHelpers.h" + +#include //////////////////////////////////////////////////////////////////// // Class : MultiTransition @@ -43,7 +46,7 @@ protected: MultiTransition(const MultiTransition ©); void operator = (const MultiTransition ©); -public: +PUBLISHED: void clear(); bool is_identity() const; @@ -71,6 +74,7 @@ public: bool is_on(const Property &prop) const; bool is_off(const Property &prop) const; +public: virtual NodeTransition *make_identity() const=0; virtual NodeTransition *compose(const NodeTransition *other) const; diff --git a/panda/src/graph/multiTransitionHelpers.h b/panda/src/graph/multiTransitionHelpers.h index d1fbd580ba..d699511643 100644 --- a/panda/src/graph/multiTransitionHelpers.h +++ b/panda/src/graph/multiTransitionHelpers.h @@ -8,6 +8,8 @@ #include +#include "transitionDirection.h" + //////////////////////////////////////////////////////////////////// // Function: dmap_compose // Description: Accepts two DirectionMaps, and builds a new diff --git a/panda/src/light/ambientLight.h b/panda/src/light/ambientLight.h index 72471c6006..c3f52f1fcb 100644 --- a/panda/src/light/ambientLight.h +++ b/panda/src/light/ambientLight.h @@ -27,18 +27,20 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA AmbientLight : public Light, public NamedNode { - public: + PUBLISHED: AmbientLight( const string& name = "" ); ~AmbientLight( void ) { } - virtual void apply( GraphicsStateGuardian* gsg ) { - gsg->apply_light( this ); - } + public: virtual void output( ostream &out ) const; virtual void write( ostream &out, int indent_level = 0 ) const; + virtual void apply( GraphicsStateGuardian* gsg ) { + gsg->apply_light( this ); + } + public: static TypeHandle get_class_type( void ) { diff --git a/panda/src/light/config_light.N b/panda/src/light/config_light.N new file mode 100644 index 0000000000..dc637f1820 --- /dev/null +++ b/panda/src/light/config_light.N @@ -0,0 +1,2 @@ +forcetype MultiTransition +forcetype MultiAttribute diff --git a/panda/src/light/directionalLight.h b/panda/src/light/directionalLight.h index 7a0a4ee565..b0371cc976 100644 --- a/panda/src/light/directionalLight.h +++ b/panda/src/light/directionalLight.h @@ -27,21 +27,23 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA DirectionalLight : public Light, public NamedNode { - public: + PUBLISHED: DirectionalLight( const string& name = "" ); ~DirectionalLight( void ) { } - virtual void apply( GraphicsStateGuardian* gsg ) { - gsg->apply_light( this ); - } - INLINE Colorf get_specular( void ) const; INLINE void set_specular( const Colorf& color ); + public: + virtual void output( ostream &out ) const; virtual void write( ostream &out, int indent_level = 0 ) const; + virtual void apply( GraphicsStateGuardian* gsg ) { + gsg->apply_light( this ); + } + protected: Colorf _specular; diff --git a/panda/src/light/light.h b/panda/src/light/light.h index f6420ec449..5adfc7f7e2 100644 --- a/panda/src/light/light.h +++ b/panda/src/light/light.h @@ -25,19 +25,20 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA Light : virtual public ReferenceCount { - public: + PUBLISHED: Light( void ) { _color.set(0.0, 0.0, 0.0, 1.0); } virtual ~Light( void ) { } - virtual void apply( GraphicsStateGuardian* gsg ) = 0; - INLINE Colorf get_color(void) const { return _color; } INLINE void set_color(const Colorf& color) { _color = color; } virtual void output(ostream &out) const=0; virtual void write(ostream &out, int indent_level = 0) const=0; + public: + virtual void apply( GraphicsStateGuardian* gsg ) = 0; + protected: Colorf _color; diff --git a/panda/src/light/lightAttribute.h b/panda/src/light/lightAttribute.h index 07e4b4a4bd..de98546454 100644 --- a/panda/src/light/lightAttribute.h +++ b/panda/src/light/lightAttribute.h @@ -26,9 +26,10 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, MULTIATTRIBUTE_LIGHT); // Description : See LightTransition. //////////////////////////////////////////////////////////////////// class EXPCL_PANDA LightAttribute : public MultiAttribute { -public: +PUBLISHED: INLINE LightAttribute(); +public: virtual TypeHandle get_handle() const; virtual NodeAttribute *make_copy() const; virtual NodeAttribute *make_initial() const; diff --git a/panda/src/light/lightTransition.h b/panda/src/light/lightTransition.h index 8eb379f4e0..f62651cb27 100644 --- a/panda/src/light/lightTransition.h +++ b/panda/src/light/lightTransition.h @@ -30,10 +30,11 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, MULTITRANSITION_LIGHT); // indicated lights in effect. //////////////////////////////////////////////////////////////////// class EXPCL_PANDA LightTransition : public MultiTransition { -public: +PUBLISHED: INLINE LightTransition(); INLINE static LightTransition all_off(); - + +public: virtual NodeTransition *make_copy() const; virtual NodeAttribute *make_attrib() const; virtual NodeTransition *make_identity() const; diff --git a/panda/src/light/pointLight.h b/panda/src/light/pointLight.h index e91cbdb578..f316faf616 100644 --- a/panda/src/light/pointLight.h +++ b/panda/src/light/pointLight.h @@ -27,18 +27,11 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA PointLight : public Light, public NamedNode { - public: + PUBLISHED: PointLight( const string& name = "" ); ~PointLight( void ) { } - virtual void apply( GraphicsStateGuardian* gsg ) { - gsg->apply_light( this ); - } - - virtual void output( ostream &out ) const; - virtual void write( ostream &out, int indent_level = 0 ) const; - INLINE Colorf get_specular( void ) const; INLINE void set_specular( const Colorf& color ); @@ -51,6 +44,15 @@ class EXPCL_PANDA PointLight : public Light, public NamedNode INLINE float get_quadratic_attenuation( void ) const; INLINE void set_quadratic_attenuation( float att ); + public: + + virtual void output( ostream &out ) const; + virtual void write( ostream &out, int indent_level = 0 ) const; + + virtual void apply( GraphicsStateGuardian* gsg ) { + gsg->apply_light( this ); + } + protected: Colorf _specular; diff --git a/panda/src/light/spotlight.h b/panda/src/light/spotlight.h index 053adf3350..f6f9fcedd8 100644 --- a/panda/src/light/spotlight.h +++ b/panda/src/light/spotlight.h @@ -29,18 +29,11 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDA Spotlight : public Light, public ProjectionNode { - public: + PUBLISHED: Spotlight( const string& name = "" ); ~Spotlight( void ) { } - virtual void apply( GraphicsStateGuardian* gsg ) { - gsg->apply_light( this ); - } - - virtual void output( ostream &out ) const; - virtual void write( ostream &out, int indent_level = 0 ) const; - INLINE float get_exponent( void ) const; INLINE void set_exponent( float exponent ); @@ -58,6 +51,15 @@ class EXPCL_PANDA Spotlight : public Light, public ProjectionNode INLINE float get_quadratic_attenuation( void ) const; INLINE void set_quadratic_attenuation( float att ); + public: + + virtual void output( ostream &out ) const; + virtual void write( ostream &out, int indent_level = 0 ) const; + + virtual void apply( GraphicsStateGuardian* gsg ) { + gsg->apply_light( this ); + } + bool make_image(Texture* texture, float radius = 0.7); NamedNode* make_geometry(float intensity = 0.05, float length = 20.0, int num_facets = 36); diff --git a/panda/src/sgattrib/config_sgattrib.cxx b/panda/src/sgattrib/config_sgattrib.cxx index 5c1d6f2cc6..0487fa892b 100644 --- a/panda/src/sgattrib/config_sgattrib.cxx +++ b/panda/src/sgattrib/config_sgattrib.cxx @@ -64,29 +64,44 @@ Configure(config_sgattrib); NotifyCategoryDef(sgattrib, ""); -// 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: +// For performance testing reasons, it may be useful to support +// certain rendering special effects that require a special-case +// direct render traversal to varying less-than-complete degrees. The +// variables support-decals, support-subrender, or support-direct may +// be set to change these. support-decals specifically controls the +// rendering of decal geometry (polygons against a coplanar +// background), while support-subrender controls other effects such as +// LOD's and billboards. support-direct controls any effect which +// requires switching to DirectRenderTraverser from a CullTraverser, +// including decals and things specifically flagged with a +// DirectRenderTransition. // -// on - This is the default, and causes decals to be rendered +// The legal values for each variable are: +// +// on - This is the default, and causes the effect 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. +// off - The special effect is ignored, and the geometry is rendered +// as if the effect were not set at all. The result will +// generally be horrible looking, for instance with decals +// Z-fighting with the base geometry. This is equivalent to +// #f. // -// hide - Decals are not drawn at all. +// hide - The nested geometry--the decals, or the billboards, or +// whatever--is not drawn at all. // -// If compiled in NDEBUG mode, this variable is ignored and decals are -// always on. +// If compiled in NDEBUG mode, this variable is ignored and decals +// etc. are always on. // -SupportDecals support_decals = SD_on; +SupportDirect support_decals = SD_on; +SupportDirect support_subrender = SD_on; +SupportDirect support_direct = SD_on; -static SupportDecals -parse_support_decals(const string &type) { +static SupportDirect +get_support_direct(const string &varname) { + string type = config_sgattrib.GetString(varname, ""); if (type == "on") { return SD_on; } else if (type == "off") { @@ -94,18 +109,19 @@ parse_support_decals(const string &type) { } else if (type == "hide") { return SD_hide; } - return SD_invalid; + + // None of the above, so use #t/#f. + if (config_sgattrib.GetBool(varname, true)) { + return SD_on; + } else { + return SD_off; + } } 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; - } - } + support_decals = get_support_direct("support-decals"); + support_subrender = get_support_direct("support-subrender"); + support_direct = get_support_direct("support-direct"); // MPG - we want to ensure that texture transitions are applied // before texgen transitions, so the texture transition must be diff --git a/panda/src/sgattrib/config_sgattrib.h b/panda/src/sgattrib/config_sgattrib.h index fb581ae639..68ceb85550 100644 --- a/panda/src/sgattrib/config_sgattrib.h +++ b/panda/src/sgattrib/config_sgattrib.h @@ -12,13 +12,14 @@ NotifyCategoryDecl(sgattrib, EXPCL_PANDA, EXPTP_PANDA); // Configure variables for sgattrib package. -enum SupportDecals { +enum SupportDirect { SD_on, SD_off, - SD_hide, - SD_invalid + SD_hide }; -extern EXPCL_PANDA SupportDecals support_decals; +extern EXPCL_PANDA SupportDirect support_decals; +extern EXPCL_PANDA SupportDirect support_subrender; +extern EXPCL_PANDA SupportDirect support_direct; #endif diff --git a/panda/src/sgraphutil/directRenderTraverser.cxx b/panda/src/sgraphutil/directRenderTraverser.cxx index c49b4f316b..09f98e7420 100644 --- a/panda/src/sgraphutil/directRenderTraverser.cxx +++ b/panda/src/sgraphutil/directRenderTraverser.cxx @@ -130,10 +130,15 @@ reached_node(Node *node, AllAttributesWrapper &render_state, AllTransitionsWrapper new_trans; - if (!node->sub_render(render_state, new_trans, this)) { - return false; - } - render_state.apply_in_place(new_trans); +#ifndef NDEBUG + if (support_subrender == SD_on) +#endif + { + if (!node->sub_render(render_state, new_trans, this)) { + return false; + } + render_state.apply_in_place(new_trans); + } if (node->is_of_type(GeomNode::get_class_type())) { _gsg->set_state(render_state.get_attributes(), true); @@ -190,15 +195,20 @@ forward_arc(NodeRelation *arc, AllTransitionsWrapper &trans, mark_forward_arc(arc); - AllTransitionsWrapper::const_iterator nti; - for (nti = trans.begin(); nti != trans.end(); ++nti) { - NodeTransition *t = (*nti).second.get_trans(); - AllTransitionsWrapper new_trans; - if (!t->sub_render(arc, post, new_trans, this)) { - carry_on = false; +#ifndef NDEBUG + if (support_subrender == SD_on) +#endif + { + AllTransitionsWrapper::const_iterator nti; + for (nti = trans.begin(); nti != trans.end(); ++nti) { + NodeTransition *t = (*nti).second.get_trans(); + AllTransitionsWrapper new_trans; + if (!t->sub_render(arc, post, new_trans, this)) { + carry_on = false; + } + post.apply_in_place(new_trans); + } } - post.apply_in_place(new_trans); - } if (!carry_on) { mark_backward_arc(arc);