add egg-flat-colors

This commit is contained in:
David Rose 2010-09-25 03:31:56 +00:00
parent fc021fb6af
commit 80705de816
3 changed files with 19 additions and 0 deletions

View File

@ -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 <NurbsCurve> entry appearing in an egg file "

View File

@ -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;

View File

@ -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.