diff --git a/panda/src/pgraph/renderAttrib.I b/panda/src/pgraph/renderAttrib.I index f4d6da83d1..bb43313796 100644 --- a/panda/src/pgraph/renderAttrib.I +++ b/panda/src/pgraph/renderAttrib.I @@ -92,3 +92,18 @@ compare_to(const RenderAttrib &other) const { // We only call compare_to_impl() if they have the same type. return compare_to_impl(&other); } + +//////////////////////////////////////////////////////////////////// +// Function: RenderAttrib::always_reissue +// Access: Public +// Description: Returns true if the RenderAttrib should be reissued +// to the GSG with every state change, even if it is the +// same pointer as it was before; or false for the +// normal case, to reissue only when the RenderAttrib +// pointer changes. +//////////////////////////////////////////////////////////////////// +INLINE bool RenderAttrib:: +always_reissue() const { + return _always_reissue; +} + diff --git a/panda/src/pgraph/renderAttrib.cxx b/panda/src/pgraph/renderAttrib.cxx index 73eaf92de0..9abde7e05d 100644 --- a/panda/src/pgraph/renderAttrib.cxx +++ b/panda/src/pgraph/renderAttrib.cxx @@ -39,6 +39,8 @@ RenderAttrib() { _attribs = new Attribs; } _saved_entry = _attribs->end(); + + _always_reissue = false; } //////////////////////////////////////////////////////////////////// @@ -112,12 +114,6 @@ output(ostream &out) const { out << get_type(); } -void RenderAttrib:: -output_comparefunc(ostream &out,PandaCompareFunc fn) const { - static char *FuncStrs[M_always+1] = {"none","never","less","equal", "less or equal","greater","not equal","greater or equal","always"}; - out << FuncStrs[fn]; -} - //////////////////////////////////////////////////////////////////// // Function: RenderAttrib::write // Access: Published, Virtual @@ -223,6 +219,53 @@ invert_compose_impl(const RenderAttrib *other) const { return other; } +//////////////////////////////////////////////////////////////////// +// Function: RenderAttrib::output_comparefunc +// Access: Protected +// Description: Outputs a string representation of the given +// PandaCompareFunc object. +//////////////////////////////////////////////////////////////////// +void RenderAttrib:: +output_comparefunc(ostream &out, PandaCompareFunc fn) const { + switch (fn) { + case M_none: + out << "none"; + break; + + case M_never: + out << "never"; + break; + + case M_less: + out << "less"; + break; + + case M_equal: + out << "equal"; + break; + + case M_less_equal: + out << "less_equal"; + break; + + case M_greater: + out << "greater"; + break; + + case M_not_equal: + out << "not_equal"; + break; + + case M_greater_equal: + out << "greater_equal"; + break; + + case M_always: + out << "always"; + break; + } +} + //////////////////////////////////////////////////////////////////// // Function: RenderAttrib::make_default_impl // Access: Protected, Virtual diff --git a/panda/src/pgraph/renderAttrib.h b/panda/src/pgraph/renderAttrib.h index 1f1d44ff88..fc015cf2a1 100644 --- a/panda/src/pgraph/renderAttrib.h +++ b/panda/src/pgraph/renderAttrib.h @@ -71,6 +71,8 @@ public: INLINE int compare_to(const RenderAttrib &other) const; virtual void issue(GraphicsStateGuardianBase *gsg) const; + INLINE bool always_reissue() const; + PUBLISHED: virtual void output(ostream &out) const; virtual void write(ostream &out, int indent_level) const; @@ -93,7 +95,10 @@ protected: virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const; virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const; virtual RenderAttrib *make_default_impl() const=0; - void output_comparefunc(ostream &out,PandaCompareFunc fn) const; + void output_comparefunc(ostream &out, PandaCompareFunc fn) const; + +protected: + bool _always_reissue; private: typedef pset > Attribs; diff --git a/panda/src/pgraph/renderState.cxx b/panda/src/pgraph/renderState.cxx index f78edca0dd..519513cca2 100644 --- a/panda/src/pgraph/renderState.cxx +++ b/panda/src/pgraph/renderState.cxx @@ -842,7 +842,11 @@ issue_delta_modify(const RenderState *other, if ((*ai)._attrib != (*bi)._attrib) { any_changed = true; (*bi)._attrib->issue(gsg); + + } else if ((*bi)._attrib->always_reissue()) { + (*bi)._attrib->issue(gsg); } + *result = *bi; ++ai; ++bi; @@ -910,7 +914,7 @@ issue_delta_set(const RenderState *other, } else { // Here is an attribute we have in both. Issue the new one if // it's different. - if ((*ai)._attrib != (*bi)._attrib) { + if ((*ai)._attrib != (*bi)._attrib || (*bi)._attrib->always_reissue()) { (*bi)._attrib->issue(gsg); } ++ai;