Przeglądaj źródła

fix decal problems with DepthWriteTransition under decals

David Rose 24 lat temu
rodzic
commit
363005d9ce

+ 6 - 1
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);
 }
 

+ 1 - 1
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();

+ 6 - 1
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++;

+ 1 - 1
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;

+ 9 - 1
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);

+ 1 - 1
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;

+ 1 - 1
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);