diff --git a/panda/src/egg2pg/config_egg2pg.cxx b/panda/src/egg2pg/config_egg2pg.cxx index ffee8659f0..99e35ba39e 100644 --- a/panda/src/egg2pg/config_egg2pg.cxx +++ b/panda/src/egg2pg/config_egg2pg.cxx @@ -93,6 +93,18 @@ ConfigVariableBool egg_flat_shading "to set it true if your scene largely or entirely consists of " "flat-shaded polygons.")); +ConfigVariableBool egg_flat_colors +("egg-flat-colors", true, + PRC_DESC("Set this true to allow the egg loader to create geometry with the " + "ColorAttrib::T_flat attribute set: that is, geometry that uses " + "the scene graph color instead of per-vertex color. Normally Panda " + "will do this as an optimization for Geoms whose vertices are all " + "the same color, or all white. This allows the removal of the " + "color attribute from the vertices where it is not necessary to " + "specify colors per-vertex. If this is false, the color attribute " + "will always be specified per-vertex, even if all vertices have the " + "same value.")); + ConfigVariableBool egg_load_old_curves ("egg-load-old-curves", true, PRC_DESC("When this is true, a entry appearing in an egg file " diff --git a/panda/src/egg2pg/config_egg2pg.h b/panda/src/egg2pg/config_egg2pg.h index 02fab7b82f..94e01e9c82 100644 --- a/panda/src/egg2pg/config_egg2pg.h +++ b/panda/src/egg2pg/config_egg2pg.h @@ -42,6 +42,7 @@ extern EXPCL_PANDAEGG ConfigVariableDouble egg_flatten_radius; extern EXPCL_PANDAEGG ConfigVariableBool egg_combine_geoms; extern EXPCL_PANDAEGG ConfigVariableBool egg_rigid_geometry; extern EXPCL_PANDAEGG ConfigVariableBool egg_flat_shading; +extern EXPCL_PANDAEGG ConfigVariableBool egg_flat_colors; extern EXPCL_PANDAEGG ConfigVariableBool egg_load_old_curves; extern EXPCL_PANDAEGG ConfigVariableBool egg_load_classic_nurbs_curves; extern EXPCL_PANDAEGG ConfigVariableBool egg_accept_errors; diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index 1173844e70..9dac921bef 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -371,6 +371,12 @@ make_polyset(EggBin *egg_bin, PandaNode *parent, const LMatrix4d *transform, bool has_overall_color; Colorf overall_color; vertex_pool->check_overall_color(has_overall_color, overall_color); + if (!egg_flat_colors) { + // If flat colors aren't allowed, then we don't care whether + // there is an overall color. In that case, treat all vertex + // pools as if they contain a combination of multiple colors. + has_overall_color = false; + } // Create a handful of GeomPrimitives corresponding to the various // types of primitives that reference this vertex pool.