Browse Source

fix color flatten bug

David Rose 18 years ago
parent
commit
92dd6d6e89
2 changed files with 13 additions and 7 deletions
  1. 12 6
      panda/src/pgraph/accumulatedAttribs.cxx
  2. 1 1
      panda/src/pgraph/geomNode.cxx

+ 12 - 6
panda/src/pgraph/accumulatedAttribs.cxx

@@ -179,7 +179,8 @@ collect(const RenderState *state, int attrib_types) {
       new_state->get_attrib(ColorAttrib::get_class_type());
       new_state->get_attrib(ColorAttrib::get_class_type());
     if (node_attrib != (const RenderAttrib *)NULL) {
     if (node_attrib != (const RenderAttrib *)NULL) {
       int color_override = new_state->get_override(ColorAttrib::get_class_type());
       int color_override = new_state->get_override(ColorAttrib::get_class_type());
-      if (color_override >= _color_override) {
+      if (color_override >= _color_override || 
+          _color == (const RenderAttrib *)NULL) {
         // The node has a color attribute; apply it.
         // The node has a color attribute; apply it.
         if (_color == (const RenderAttrib *)NULL) {
         if (_color == (const RenderAttrib *)NULL) {
           _color = node_attrib;
           _color = node_attrib;
@@ -197,7 +198,8 @@ collect(const RenderState *state, int attrib_types) {
       new_state->get_attrib(ColorScaleAttrib::get_class_type());
       new_state->get_attrib(ColorScaleAttrib::get_class_type());
     if (node_attrib != (const RenderAttrib *)NULL) {
     if (node_attrib != (const RenderAttrib *)NULL) {
       int color_scale_override = new_state->get_override(ColorScaleAttrib::get_class_type());
       int color_scale_override = new_state->get_override(ColorScaleAttrib::get_class_type());
-      if (color_scale_override >= _color_scale_override) {
+      if (color_scale_override >= _color_scale_override ||
+          _color_scale == (const RenderAttrib *)NULL) {
         if (_color_scale == (const RenderAttrib *)NULL) {
         if (_color_scale == (const RenderAttrib *)NULL) {
           _color_scale = node_attrib;
           _color_scale = node_attrib;
         } else {
         } else {
@@ -214,7 +216,8 @@ collect(const RenderState *state, int attrib_types) {
       new_state->get_attrib(TexMatrixAttrib::get_class_type());
       new_state->get_attrib(TexMatrixAttrib::get_class_type());
     if (node_attrib != (const RenderAttrib *)NULL) {
     if (node_attrib != (const RenderAttrib *)NULL) {
       int tex_matrix_override = new_state->get_override(TexMatrixAttrib::get_class_type());
       int tex_matrix_override = new_state->get_override(TexMatrixAttrib::get_class_type());
-      if (tex_matrix_override >= _tex_matrix_override) {
+      if (tex_matrix_override >= _tex_matrix_override ||
+          _tex_matrix == (const RenderAttrib *)NULL) {
         if (_tex_matrix == (const RenderAttrib *)NULL) {
         if (_tex_matrix == (const RenderAttrib *)NULL) {
           _tex_matrix = node_attrib;
           _tex_matrix = node_attrib;
         } else {
         } else {
@@ -231,7 +234,8 @@ collect(const RenderState *state, int attrib_types) {
       new_state->get_attrib(TextureAttrib::get_class_type());
       new_state->get_attrib(TextureAttrib::get_class_type());
     if (tex_attrib != (const RenderAttrib *)NULL) {
     if (tex_attrib != (const RenderAttrib *)NULL) {
       int texture_override = new_state->get_override(TextureAttrib::get_class_type());
       int texture_override = new_state->get_override(TextureAttrib::get_class_type());
-      if (texture_override >= _texture_override) {
+      if (texture_override >= _texture_override || 
+          _texture == (const RenderAttrib *)NULL) {
         if (_texture == (const RenderAttrib *)NULL) {
         if (_texture == (const RenderAttrib *)NULL) {
           _texture = tex_attrib;
           _texture = tex_attrib;
         } else {
         } else {
@@ -251,7 +255,8 @@ collect(const RenderState *state, int attrib_types) {
       new_state->get_attrib(ClipPlaneAttrib::get_class_type());
       new_state->get_attrib(ClipPlaneAttrib::get_class_type());
     if (node_attrib != (const RenderAttrib *)NULL) {
     if (node_attrib != (const RenderAttrib *)NULL) {
       int clip_plane_override = new_state->get_override(ClipPlaneAttrib::get_class_type());
       int clip_plane_override = new_state->get_override(ClipPlaneAttrib::get_class_type());
-      if (clip_plane_override >= _clip_plane_override) {
+      if (clip_plane_override >= _clip_plane_override || 
+          _clip_plane == (const RenderAttrib *)NULL) {
         if (_clip_plane == (const RenderAttrib *)NULL) {
         if (_clip_plane == (const RenderAttrib *)NULL) {
           _clip_plane = node_attrib;
           _clip_plane = node_attrib;
         } else {
         } else {
@@ -268,7 +273,8 @@ collect(const RenderState *state, int attrib_types) {
       new_state->get_attrib(CullFaceAttrib::get_class_type());
       new_state->get_attrib(CullFaceAttrib::get_class_type());
     if (node_attrib != (const RenderAttrib *)NULL) {
     if (node_attrib != (const RenderAttrib *)NULL) {
       int cull_face_override = new_state->get_override(CullFaceAttrib::get_class_type());
       int cull_face_override = new_state->get_override(CullFaceAttrib::get_class_type());
-      if (cull_face_override >= _cull_face_override) {
+      if (cull_face_override >= _cull_face_override ||
+          _cull_face == (const RenderAttrib *)NULL) {
         if (_cull_face == (const RenderAttrib *)NULL) {
         if (_cull_face == (const RenderAttrib *)NULL) {
           _cull_face = node_attrib;
           _cull_face = node_attrib;
         } else {
         } else {

+ 1 - 1
panda/src/pgraph/geomNode.cxx

@@ -130,7 +130,7 @@ apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types,
     for (size_t i = 0; i < num_geoms; ++i) {
     for (size_t i = 0; i < num_geoms; ++i) {
       GeomEntry &entry = (*geoms)[i];
       GeomEntry &entry = (*geoms)[i];
       PT(Geom) new_geom = entry._geom.get_read_pointer()->make_copy();
       PT(Geom) new_geom = entry._geom.get_read_pointer()->make_copy();
-      
+
       AccumulatedAttribs geom_attribs = attribs;
       AccumulatedAttribs geom_attribs = attribs;
       entry._state = geom_attribs.collect(entry._state, attrib_types);
       entry._state = geom_attribs.collect(entry._state, attrib_types);