diff --git a/panda/src/pgraph/textureAttrib.cxx b/panda/src/pgraph/textureAttrib.cxx index 8cfc4c21ee..f8e231bcf3 100644 --- a/panda/src/pgraph/textureAttrib.cxx +++ b/panda/src/pgraph/textureAttrib.cxx @@ -317,6 +317,44 @@ filter_to_max(int max_texture_stages) const { return tex_attrib; } +//////////////////////////////////////////////////////////////////// +// Function: TextureAttrib::lower_attrib_can_override +// Access: Public, Virtual +// Description: Intended to be overridden by derived RenderAttrib +// types to specify how two consecutive RenderAttrib +// objects of the same type interact. +// +// This should return false if a RenderAttrib on a +// higher node will compose into a RenderAttrib on a +// lower node that has a higher override value, or false +// if the lower RenderAttrib will completely replace the +// state. +// +// The default behavior is false: normally, a +// RenderAttrib in the graph cannot completely override +// a RenderAttrib above it, regardless of its override +// value--instead, the two attribs are composed. But +// for some kinds of RenderAttribs, it is useful to +// allow this kind of override. +// +// This method only handles the one special case of a +// lower RenderAttrib with a higher override value. If +// the higher RenderAttrib has a higher override value, +// it always completely overrides. And if both +// RenderAttribs have the same override value, they are +// always composed. +//////////////////////////////////////////////////////////////////// +bool TextureAttrib:: +lower_attrib_can_override() const { + // A TextureAttrib doesn't compose through an override. Normally, + // there won't be a scene-graph override on a TextureAttrib anyway, + // since the NodePath::set_texture() override is applied to the + // per-TextureStage override value. But there might be a + // scene-graph override if NodePath::adjust_all_priorities() is + // used, and in this case, we'd like for it to stick. + return true; +} + //////////////////////////////////////////////////////////////////// // Function: TextureAttrib::output // Access: Public, Virtual diff --git a/panda/src/pgraph/textureAttrib.h b/panda/src/pgraph/textureAttrib.h index 123a3584bb..e64a6cc1bb 100644 --- a/panda/src/pgraph/textureAttrib.h +++ b/panda/src/pgraph/textureAttrib.h @@ -82,6 +82,7 @@ PUBLISHED: public: CPT(TextureAttrib) filter_to_max(int max_texture_stages) const; + virtual bool lower_attrib_can_override() const; virtual void output(ostream &out) const; virtual bool has_cull_callback() const;