From 363005d9ce99cd4f86edcca5077a93c14dc619e3 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 30 Jul 2001 23:16:22 +0000 Subject: [PATCH] fix decal problems with DepthWriteTransition under decals --- panda/src/display/graphicsStateGuardian.cxx | 7 ++++++- panda/src/display/graphicsStateGuardian.h | 2 +- panda/src/dxgsg/dxGraphicsStateGuardian.cxx | 7 ++++++- panda/src/dxgsg/dxGraphicsStateGuardian.h | 2 +- panda/src/glgsg/glGraphicsStateGuardian.cxx | 10 +++++++++- panda/src/glgsg/glGraphicsStateGuardian.h | 2 +- panda/src/sgraphutil/directRenderTraverser.cxx | 2 +- 7 files changed, 25 insertions(+), 7 deletions(-) diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 38dbcc70b3..130a557a18 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -596,9 +596,14 @@ wants_colors() const { // the GSG will render normally; subsequent geometry // rendered up until the next call of end_decal() should // be rendered as decals of the base_geom. +// +// The attributes wrapper is the current state as of the +// base geometry node. It may or may not be modified by +// the GSG to reflect whatever rendering state is +// necessary to render the decals properly. //////////////////////////////////////////////////////////////////// void GraphicsStateGuardian:: -begin_decal(GeomNode *base_geom) { +begin_decal(GeomNode *base_geom, AllAttributesWrapper &attrib) { base_geom->draw(this); } diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index 4b566691fa..278092b760 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -124,7 +124,7 @@ public: virtual bool wants_texcoords(void) const; virtual bool wants_colors(void) const; - virtual void begin_decal(GeomNode *base_geom); + virtual void begin_decal(GeomNode *base_geom, AllAttributesWrapper &attrib); virtual void end_decal(GeomNode *base_geom); virtual void reset(); diff --git a/panda/src/dxgsg/dxGraphicsStateGuardian.cxx b/panda/src/dxgsg/dxGraphicsStateGuardian.cxx index b66f76f28b..db05a7a673 100644 --- a/panda/src/dxgsg/dxGraphicsStateGuardian.cxx +++ b/panda/src/dxgsg/dxGraphicsStateGuardian.cxx @@ -4982,9 +4982,14 @@ wants_texcoords() const { // the GSG will render normally; subsequent geometry // rendered up until the next call of end_decal() should // be rendered as decals of the base_geom. +// +// The attributes wrapper is the current state as of the +// base geometry node. It may or may not be modified by +// the GSG to reflect whatever rendering state is +// necessary to render the decals properly. //////////////////////////////////////////////////////////////////// void DXGraphicsStateGuardian:: -begin_decal(GeomNode *base_geom) { +begin_decal(GeomNode *base_geom, AllAttributesWrapper &attrib) { nassertv(base_geom != (GeomNode *)NULL); _decal_level++; diff --git a/panda/src/dxgsg/dxGraphicsStateGuardian.h b/panda/src/dxgsg/dxGraphicsStateGuardian.h index 2ee46bcc03..d6c08dea22 100644 --- a/panda/src/dxgsg/dxGraphicsStateGuardian.h +++ b/panda/src/dxgsg/dxGraphicsStateGuardian.h @@ -184,7 +184,7 @@ public: virtual bool wants_texcoords(void) const; virtual bool wants_colors(void) const; - virtual void begin_decal(GeomNode *base_geom); + virtual void begin_decal(GeomNode *base_geom, AllAttributesWrapper &attrib); virtual void end_decal(GeomNode *base_geom); INLINE float compute_distance_to(const LPoint3f &point) const; diff --git a/panda/src/glgsg/glGraphicsStateGuardian.cxx b/panda/src/glgsg/glGraphicsStateGuardian.cxx index fe6b734917..c188f9e93b 100644 --- a/panda/src/glgsg/glGraphicsStateGuardian.cxx +++ b/panda/src/glgsg/glGraphicsStateGuardian.cxx @@ -3390,9 +3390,14 @@ wants_colors() const { // the GSG will render normally; subsequent geometry // rendered up until the next call of end_decal() should // be rendered as decals of the base_geom. +// +// The attributes wrapper is the current state as of the +// base geometry node. It may or may not be modified by +// the GSG to reflect whatever rendering state is +// necessary to render the decals properly. //////////////////////////////////////////////////////////////////// void GLGraphicsStateGuardian:: -begin_decal(GeomNode *base_geom) { +begin_decal(GeomNode *base_geom, AllAttributesWrapper &attrib) { nassertv(base_geom != (GeomNode *)NULL); _decal_level++; @@ -3416,6 +3421,9 @@ begin_decal(GeomNode *base_geom) { } else { // Turn off writing the depth buffer to render the base geometry. call_glDepthMask(false); + DepthWriteAttribute *dwa = new DepthWriteAttribute; + dwa->set_off(); + attrib.set_attribute(DepthWriteTransition::get_class_type(), dwa); // Now render the base geometry. base_geom->draw(this); diff --git a/panda/src/glgsg/glGraphicsStateGuardian.h b/panda/src/glgsg/glGraphicsStateGuardian.h index 327602f596..b84b5b54d8 100644 --- a/panda/src/glgsg/glGraphicsStateGuardian.h +++ b/panda/src/glgsg/glGraphicsStateGuardian.h @@ -162,7 +162,7 @@ public: virtual bool wants_texcoords(void) const; virtual bool wants_colors(void) const; - virtual void begin_decal(GeomNode *base_geom); + virtual void begin_decal(GeomNode *base_geom, AllAttributesWrapper &attrib); virtual void end_decal(GeomNode *base_geom); virtual float compute_distance_to(const LPoint3f &point) const; diff --git a/panda/src/sgraphutil/directRenderTraverser.cxx b/panda/src/sgraphutil/directRenderTraverser.cxx index 46ef1b7d2e..11b06665f0 100644 --- a/panda/src/sgraphutil/directRenderTraverser.cxx +++ b/panda/src/sgraphutil/directRenderTraverser.cxx @@ -196,7 +196,7 @@ reached_node(Node *node, AllAttributesWrapper &render_state, return false; } #endif - _gsg->begin_decal(geom); + _gsg->begin_decal(geom, render_state); } else { geom->draw(_gsg);