From 164d5a9fbeebeb6d3bc439b82875a3d14a37edff Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 27 Oct 2000 22:45:19 +0000 Subject: [PATCH] *** empty log message *** --- panda/src/builder/Sources.pp | 28 ++- panda/src/builder/builder.cxx | 2 +- panda/src/builder/builderBucket.cxx | 2 +- panda/src/builder/builderPrim.h | 5 +- panda/src/builder/builderPrimTempl.I | 20 +-- panda/src/builder/builderTypes.h | 188 ++------------------ panda/src/builder/mesher.h | 2 + panda/src/builder/mesherConfig.h | 19 ++ panda/src/builder/mesherEdge.h | 1 + panda/src/builder/mesherFanMaker.I | 1 + panda/src/builder/mesherFanMaker.h | 1 + panda/src/builder/mesherStrip.I | 10 +- panda/src/builder/mesherStrip.h | 1 + panda/src/builder/mesherTempl.I | 5 +- panda/src/builder/mesherTempl.h | 1 + panda/src/builder/pta_BuilderC.cxx | 11 -- panda/src/builder/pta_BuilderC.h | 37 ---- panda/src/builder/pta_BuilderN.cxx | 11 -- panda/src/builder/pta_BuilderN.h | 37 ---- panda/src/builder/pta_BuilderTC.cxx | 11 -- panda/src/builder/pta_BuilderTC.h | 37 ---- panda/src/builder/pta_BuilderV.cxx | 11 -- panda/src/builder/pta_BuilderV.h | 37 ---- panda/src/builder/vector_BuilderC.cxx | 11 -- panda/src/builder/vector_BuilderC.h | 32 ---- panda/src/builder/vector_BuilderN.cxx | 11 -- panda/src/builder/vector_BuilderN.h | 32 ---- panda/src/builder/vector_BuilderTC.cxx | 11 -- panda/src/builder/vector_BuilderTC.h | 32 ---- panda/src/builder/vector_BuilderV.cxx | 11 -- panda/src/builder/vector_BuilderV.h | 32 ---- panda/src/egg/eggCoordinateSystem.cxx | 3 + panda/src/egg/eggVertex.cxx | 4 +- panda/src/egg/eggXfmAnimData.cxx | 2 +- panda/src/egg/parser.yxx | 10 +- panda/src/egg2sg/characterMaker.cxx | 6 +- panda/src/egg2sg/eggLoader.cxx | 24 ++- panda/src/express/datagramIterator.cxx | 2 +- panda/src/glgsg/glGraphicsStateGuardian.cxx | 20 +-- 39 files changed, 113 insertions(+), 608 deletions(-) create mode 100644 panda/src/builder/mesherConfig.h delete mode 100644 panda/src/builder/pta_BuilderC.cxx delete mode 100644 panda/src/builder/pta_BuilderC.h delete mode 100644 panda/src/builder/pta_BuilderN.cxx delete mode 100644 panda/src/builder/pta_BuilderN.h delete mode 100644 panda/src/builder/pta_BuilderTC.cxx delete mode 100644 panda/src/builder/pta_BuilderTC.h delete mode 100644 panda/src/builder/pta_BuilderV.cxx delete mode 100644 panda/src/builder/pta_BuilderV.h delete mode 100644 panda/src/builder/vector_BuilderC.cxx delete mode 100644 panda/src/builder/vector_BuilderC.h delete mode 100644 panda/src/builder/vector_BuilderN.cxx delete mode 100644 panda/src/builder/vector_BuilderN.h delete mode 100644 panda/src/builder/vector_BuilderTC.cxx delete mode 100644 panda/src/builder/vector_BuilderTC.h delete mode 100644 panda/src/builder/vector_BuilderV.cxx delete mode 100644 panda/src/builder/vector_BuilderV.h diff --git a/panda/src/builder/Sources.pp b/panda/src/builder/Sources.pp index 448074e2cf..e0a96b5d31 100644 --- a/panda/src/builder/Sources.pp +++ b/panda/src/builder/Sources.pp @@ -8,19 +8,19 @@ #define SOURCES \ builder.I builder.cxx builder.h builderAttrib.I builderAttrib.cxx \ - builderAttrib.h builderBucket.I builderBucket.cxx builderBucket.h \ + builderAttrib.h builderAttribTempl.I builderAttribTempl.h \ + builderBucket.I builderBucket.cxx builderBucket.h \ builderBucketNode.I builderBucketNode.cxx builderBucketNode.h \ - builderMisc.cxx builderMisc.h builderNormalVisualizer.I \ - builderNormalVisualizer.cxx builderNormalVisualizer.h \ - builderPrim.cxx builderPrim.h builderProperties.cxx \ - builderProperties.h builderTypes.cxx builderTypes.h builderVertex.I \ - builderVertex.cxx builderVertex.h config_builder.cxx \ - config_builder.h mesher.cxx mesher.h pta_BuilderC.cxx \ - pta_BuilderC.h pta_BuilderN.cxx pta_BuilderN.h pta_BuilderTC.cxx \ - pta_BuilderTC.h pta_BuilderV.cxx pta_BuilderV.h vector_BuilderC.cxx \ - vector_BuilderC.h vector_BuilderN.cxx vector_BuilderN.h \ - vector_BuilderTC.cxx vector_BuilderTC.h vector_BuilderV.cxx \ - vector_BuilderV.h + builderFuncs.I builderFuncs.h builderMisc.cxx builderMisc.h \ + builderNormalVisualizer.I builderNormalVisualizer.cxx \ + builderNormalVisualizer.h builderPrim.cxx builderPrim.h \ + builderPrimTempl.I builderPrimTempl.h builderProperties.cxx \ + builderProperties.h builderTypes.cxx builderTypes.h \ + builderVertex.I builderVertex.cxx builderVertex.h \ + builderVertexTempl.I builderVertexTempl.h config_builder.cxx \ + config_builder.h mesher.cxx mesher.h mesherConfig.h mesherEdge.I \ + mesherEdge.h mesherFanMaker.I mesherFanMaker.h mesherStrip.I \ + mesherStrip.h mesherTempl.I mesherTempl.h #define INSTALL_HEADERS \ builder.I builder.h builderAttrib.I builderAttrib.h \ @@ -29,9 +29,7 @@ builderNormalVisualizer.I builderNormalVisualizer.h builderPrim.h \ builderPrimTempl.I builderPrimTempl.h builderProperties.h \ builderTypes.h builderVertex.I builderVertex.h builderVertexTempl.I \ - builderVertexTempl.h config_builder.h pta_BuilderC.h pta_BuilderN.h \ - pta_BuilderTC.h pta_BuilderV.h vector_BuilderC.h vector_BuilderN.h \ - vector_BuilderTC.h vector_BuilderV.h + builderVertexTempl.h config_builder.h #end lib_target diff --git a/panda/src/builder/builder.cxx b/panda/src/builder/builder.cxx index 12283edd2f..f068def05c 100644 --- a/panda/src/builder/builder.cxx +++ b/panda/src/builder/builder.cxx @@ -117,7 +117,7 @@ build(const string &default_name) { ++i) { BuilderBucket *bucket = (*i).get_bucket(); NamedNode *node = bucket->_node; - const string &name = bucket->get_name(); + // const string &name = bucket->get_name(); GeomNode *geom_node = NULL; if (node!=NULL && node->is_of_type(GeomNode::get_class_type())) { diff --git a/panda/src/builder/builderBucket.cxx b/panda/src/builder/builderBucket.cxx index fecb174fe6..e7e4497455 100644 --- a/panda/src/builder/builderBucket.cxx +++ b/panda/src/builder/builderBucket.cxx @@ -228,7 +228,7 @@ BuilderBucket(int) { _show_qsheets = false; _show_quads = false; _show_normals = false; - _normal_color._v.set(1.0, 0.0, 0.0, 1.0); + _normal_color.set(1.0, 0.0, 0.0, 1.0); _normal_scale = 1.0; _subdivide_polys = true; _coplanar_threshold = 0.01; diff --git a/panda/src/builder/builderPrim.h b/panda/src/builder/builderPrim.h index 0ee46180ad..d2e6c1d991 100644 --- a/panda/src/builder/builderPrim.h +++ b/panda/src/builder/builderPrim.h @@ -54,10 +54,7 @@ #include "builderPrimTempl.h" #include "builderBucket.h" -#include "pta_BuilderV.h" -#include "pta_BuilderN.h" -#include "pta_BuilderTC.h" -#include "pta_BuilderC.h" +#include "builderTypes.h" #include #include diff --git a/panda/src/builder/builderPrimTempl.I b/panda/src/builder/builderPrimTempl.I index 49ed78d70a..22ca0fc191 100644 --- a/panda/src/builder/builderPrimTempl.I +++ b/panda/src/builder/builderPrimTempl.I @@ -559,7 +559,7 @@ get_num_verts() const { template INLINE BuilderPrimTempl::Vertex &BuilderPrimTempl:: get_vertex(int n) { - nassertr(n >= 0 && n < _verts.size(), *(new Vertex)); + nassertr(n >= 0 && n < (int)_verts.size(), *(new Vertex)); return _verts[n]; } @@ -572,7 +572,7 @@ get_vertex(int n) { template INLINE const BuilderPrimTempl::Vertex &BuilderPrimTempl:: get_vertex(int n) const { - nassertr(n >= 0 && n < _verts.size(), *(new Vertex)); + nassertr(n >= 0 && n < (int)_verts.size(), *(new Vertex)); return _verts[n]; } @@ -634,7 +634,7 @@ get_num_components() const { template INLINE BuilderPrimTempl::DAttrib &BuilderPrimTempl:: get_component(int n) { - nassertr(n >= 0 && n < _components.size(), *(new DAttrib)); + nassertr(n >= 0 && n < (int)_components.size(), *(new DAttrib)); return _components[n]; } @@ -649,7 +649,7 @@ get_component(int n) { template INLINE const BuilderPrimTempl::DAttrib &BuilderPrimTempl:: get_component(int n) const { - nassertr(n >= 0 && n < _components.size(), *(new DAttrib)); + nassertr(n >= 0 && n < (int)_components.size(), *(new DAttrib)); return _components[n]; } @@ -698,12 +698,12 @@ sort_value() const { // Furthermore, if one polygon has vertex normals and another is // flat shaded, they shouldn't be stripped together. return - ((has_vertex_normal()!=0) << 5) | - ((has_vertex_color()!=0) << 4) | - ((has_any_texcoord()!=0) << 3) | - ((has_any_normal()!=0) << 2) | - ((has_any_color()!=0) << 1) | - ((has_pixel_size()!=0) << 0); + ((has_vertex_normal() ? 1:0) << 5) | + ((has_vertex_color() ? 1:0) << 4) | + ((has_any_texcoord() ? 1:0) << 3) | + ((has_any_normal() ? 1:0) << 2) | + ((has_any_color() ? 1:0) << 1) | + ((has_pixel_size() ? 1:0) << 0); } diff --git a/panda/src/builder/builderTypes.h b/panda/src/builder/builderTypes.h index 845b5c5c2a..cebc644778 100644 --- a/panda/src/builder/builderTypes.h +++ b/panda/src/builder/builderTypes.h @@ -8,184 +8,20 @@ #include #include -#include +#include +#include +#include +#include -#ifndef WIN32_VC -#include -#endif +typedef TexCoordf BuilderTC; +typedef Vertexf BuilderV; +typedef Normalf BuilderN; +typedef Colorf BuilderC; -static const float nearly_zero = 0.0001; - -// The BuilderVec classes are a series of proxies around Vertexf, -// Normalf, TexCoordf, and Colorf. They're useful for building -// collections of these vertex values, and provide handy things like -// (almost) equivalence operators and sorting operators. - -// The BuilderVec's each have a special constructor with a single int. -// These constructors create an instance of the vector with all values -// initialized to zero. This is a cheat to create a uniform way to create -// a zero-valued VType, CType, or TType without knowing whether the type -// is indexed (a ushort) or nonindexed (a BuilderVec). - -class EXPCL_PANDAEGG BuilderTC { -public: - BuilderTC() {} - BuilderTC(int) : _v(0.0, 0.0) {} - BuilderTC(const TexCoordf &v) : _v(v) {} - BuilderTC(const TexCoordd &v) : _v(v[0], v[1]) {} - BuilderTC(const BuilderTC ©) : _v(copy._v) {} - - operator TexCoordf & () { - return _v; - } - - operator const TexCoordf & () const { - return _v; - } - - float operator [] (int n) const { return _v[n]; } - float &operator [] (int n) { return _v[n]; } - - BuilderTC &operator = (const BuilderTC ©) { - _v = copy._v; - return *this; - } - bool operator == (const BuilderTC &other) const { - return _v.almost_equal(other._v, nearly_zero); - } - bool operator != (const BuilderTC &other) const { - return !operator == (other); - } - - // The < operator is simply for ordering vectors in a sorted - // container; it has no useful mathematical meaning. - bool operator < (const BuilderTC &other) const { - return (_v.compare_to(other._v) < 0); - } - TexCoordf _v; -}; - -class EXPCL_PANDAEGG BuilderV { -public: - BuilderV() {} - BuilderV(int) : _v(0.0, 0.0, 0.0) {} - BuilderV(const Vertexf &v) : _v(v) {} - BuilderV(const Vertexd &v) : _v(v[0], v[1], v[2]) {} - BuilderV(const BuilderV ©) : _v(copy._v) {} - - operator Vertexf & () { - return _v; - } - - operator const Vertexf & () const { - return _v; - } - - float operator [] (int n) const { return _v[n]; } - float &operator [] (int n) { return _v[n]; } - - BuilderV &operator = (const BuilderV ©) { - _v = copy._v; - return *this; - } - bool operator == (const BuilderV &other) const { - return _v.almost_equal(other._v, nearly_zero); - } - bool operator != (const BuilderV &other) const { - return !operator == (other); - } - bool operator < (const BuilderV &other) const { - return (_v.compare_to(other._v) < 0); - } - Vertexf _v; -}; - -class EXPCL_PANDAEGG BuilderN { -public: - BuilderN() {} - BuilderN(int) : _v(0.0, 0.0, 0.0) {} - BuilderN(const Normalf &v) : _v(v) {} - BuilderN(const Normald &v) : _v(v[0], v[1], v[2]) {} - BuilderN(const BuilderN ©) : _v(copy._v) {} - - operator Normalf & () { - return _v; - } - - operator const Normalf & () const { - return _v; - } - - float operator [] (int n) const { return _v[n]; } - float &operator [] (int n) { return _v[n]; } - - BuilderN &operator = (const BuilderN ©) { - _v = copy._v; - return *this; - } - bool operator == (const BuilderN &other) const { - return _v.almost_equal(other._v, nearly_zero); - } - bool operator != (const BuilderN &other) const { - return !operator == (other); - } - bool operator < (const BuilderN &other) const { - return (_v.compare_to(other._v) < 0); - } - Normalf _v; -}; - -class EXPCL_PANDAEGG BuilderC { -public: - BuilderC() {} - BuilderC(int) : _v(0.0, 0.0, 0.0, 0.0) {} - BuilderC(const Colorf &v) : _v(v) {} - BuilderC(const Colord &v) : _v(v[0], v[1], v[2], v[3]) {} - BuilderC(const BuilderC ©) : _v(copy._v) {} - - operator Colorf & () { - return _v; - } - - operator const Colorf & () const { - return _v; - } - - float operator [] (int n) const { return _v[n]; } - float &operator [] (int n) { return _v[n]; } - - BuilderC &operator = (const BuilderC ©) { - _v = copy._v; - return *this; - } - bool operator == (const BuilderC &other) const { - return _v.almost_equal(other._v, nearly_zero); - } - bool operator != (const BuilderC &other) const { - return !operator == (other); - } - bool operator < (const BuilderC &other) const { - return (_v.compare_to(other._v) < 0); - } - Colorf _v; -}; - -INLINE ostream &operator << (ostream &out, const BuilderTC &v) { - return out << "(" << v[0] << " " << v[1] << ")"; -} - -INLINE ostream &operator << (ostream &out, const BuilderV &v) { - return out << "(" << v[0] << " " << v[1] << " " << v[2] << ")"; -} - -INLINE ostream &operator << (ostream &out, const BuilderN &v) { - return out << "(" << v[0] << " " << v[1] << " " << v[2] << ")"; -} - -INLINE ostream &operator << (ostream &out, const BuilderC &v) { - return out << "(" << v[0] << " " << v[1] << " " << v[2] << " " - << v[3] << ")"; -} +typedef PTA_TexCoordf PTA_BuilderTC; +typedef PTA_Vertexf PTA_BuilderV; +typedef PTA_Normalf PTA_BuilderN; +typedef PTA_Colorf PTA_BuilderC; enum BuilderAttribFlags { BAF_coord = 0x00001, diff --git a/panda/src/builder/mesher.h b/panda/src/builder/mesher.h index cf28cc36d2..441b7f0397 100644 --- a/panda/src/builder/mesher.h +++ b/panda/src/builder/mesher.h @@ -7,12 +7,14 @@ #include +#include "mesherConfig.h" #include "mesherFanMaker.h" #include "mesherEdge.h" #include "mesherStrip.h" #include "mesherTempl.h" #include "builderPrim.h" + #ifdef SUPPORT_FANS EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, MesherFanMaker); EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, MesherFanMaker); diff --git a/panda/src/builder/mesherConfig.h b/panda/src/builder/mesherConfig.h new file mode 100644 index 0000000000..55092426ac --- /dev/null +++ b/panda/src/builder/mesherConfig.h @@ -0,0 +1,19 @@ +// Filename: mesherConfig.h +// Created by: drose (27Oct00) +// +//////////////////////////////////////////////////////////////////// +#ifndef MESHERCONFIG_H +#define MESHERCONFIG_H + +#include + +// This is just a file to declare a definition or two global to the +// mesher compilation. + +// Define this to support making triangle fans in addition to triangle +// strips. Fans may improve the grouping in certain models, although +// in most real cases the don't seem to help very much (and can +// actually hurt, by bitching the heuristic). +#define SUPPORT_FANS + +#endif diff --git a/panda/src/builder/mesherEdge.h b/panda/src/builder/mesherEdge.h index f6ff909089..fd231caf5e 100644 --- a/panda/src/builder/mesherEdge.h +++ b/panda/src/builder/mesherEdge.h @@ -8,6 +8,7 @@ #include +#include "mesherConfig.h" #include "builderBucket.h" #include diff --git a/panda/src/builder/mesherFanMaker.I b/panda/src/builder/mesherFanMaker.I index 617ef2cb54..61678ee728 100644 --- a/panda/src/builder/mesherFanMaker.I +++ b/panda/src/builder/mesherFanMaker.I @@ -3,6 +3,7 @@ // //////////////////////////////////////////////////////////////////// +/* okcircular */ #include "builderFuncs.h" #include diff --git a/panda/src/builder/mesherFanMaker.h b/panda/src/builder/mesherFanMaker.h index 4aabdbb46f..52f99a9427 100644 --- a/panda/src/builder/mesherFanMaker.h +++ b/panda/src/builder/mesherFanMaker.h @@ -10,6 +10,7 @@ #include +#include "mesherConfig.h" #include "builderAttrib.h" #include "builderVertex.h" #include "builderBucket.h" diff --git a/panda/src/builder/mesherStrip.I b/panda/src/builder/mesherStrip.I index b4b4760659..407af44df4 100644 --- a/panda/src/builder/mesherStrip.I +++ b/panda/src/builder/mesherStrip.I @@ -8,8 +8,8 @@ template INLINE MesherStrip:: MesherStrip(const MesherStrip ©) : - _edges(copy._edges), _prims(copy._prims), + _edges(copy._edges), _verts(copy._verts), _type(copy._type), _index(copy._index), @@ -923,11 +923,11 @@ convex_quad(Edge *common_edge, MesherStrip &front, MesherStrip &back, nassertr(a!=NULL && b!=NULL, false); Vertexf a3, b3, c3, d3; - a3 = a->get_coord_value(bucket)._v; - b3 = b->get_coord_value(bucket)._v; + a3 = a->get_coord_value(bucket); + b3 = b->get_coord_value(bucket); - c3 = common_edge->_a->get_coord_value(bucket)._v; - d3 = common_edge->_b->get_coord_value(bucket)._v; + c3 = common_edge->_a->get_coord_value(bucket); + d3 = common_edge->_b->get_coord_value(bucket); // Project both edges into the 2-d axis plane most nearly // perpendicular to the normal. We're assuming both tris have the diff --git a/panda/src/builder/mesherStrip.h b/panda/src/builder/mesherStrip.h index ba81d21d21..61b50ed8c2 100644 --- a/panda/src/builder/mesherStrip.h +++ b/panda/src/builder/mesherStrip.h @@ -8,6 +8,7 @@ #include +#include "mesherConfig.h" #include "builderTypes.h" #include "builderBucket.h" diff --git a/panda/src/builder/mesherTempl.I b/panda/src/builder/mesherTempl.I index 3fa750d5f9..867ed7e15a 100644 --- a/panda/src/builder/mesherTempl.I +++ b/panda/src/builder/mesherTempl.I @@ -3,7 +3,6 @@ // //////////////////////////////////////////////////////////////////// -#include "mesher.h" #include "builderMisc.h" #include "mesherStrip.h" #include "mesherFanMaker.h" @@ -314,8 +313,8 @@ finalize() { if (!_colors.empty()) { // Create an array in the bucket we might use to add to geoms. PTA_Colorf colors(_colors.size()); - for (int i = 0; i < _colors.size(); i++) { - colors[i] = _colors[i]._v; + for (int i = 0; i < (int)_colors.size(); i++) { + colors[i] = _colors[i]; } _bucket->set_colors(colors); diff --git a/panda/src/builder/mesherTempl.h b/panda/src/builder/mesherTempl.h index d26c59c562..aa2756560a 100644 --- a/panda/src/builder/mesherTempl.h +++ b/panda/src/builder/mesherTempl.h @@ -7,6 +7,7 @@ #include +#include "mesherConfig.h" #include "builderBucket.h" #include "mesherEdge.h" #include "mesherStrip.h" diff --git a/panda/src/builder/pta_BuilderC.cxx b/panda/src/builder/pta_BuilderC.cxx deleted file mode 100644 index de9fa8ea10..0000000000 --- a/panda/src/builder/pta_BuilderC.cxx +++ /dev/null @@ -1,11 +0,0 @@ -// Filename: pta_BuilderC.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// - -#include "pta_BuilderC.h" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/builder/pta_BuilderC.h b/panda/src/builder/pta_BuilderC.h deleted file mode 100644 index 9855066941..0000000000 --- a/panda/src/builder/pta_BuilderC.h +++ /dev/null @@ -1,37 +0,0 @@ -// Filename: pta_BuilderC.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// - -#ifndef PTA_BUILDERC_H -#define PTA_BUILDERC_H - -#include - -#include "vector_BuilderC.h" - -#include - -//////////////////////////////////////////////////////////////////// -// Class : PTA_BuilderC -// Description : A pta of BuilderCs. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// - -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, RefCountObj); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerToBase >); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerToArray) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, ConstPointerToArray) - -typedef PointerToArray PTA_BuilderC; -typedef ConstPointerToArray CPTA_BuilderC; - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - -#endif diff --git a/panda/src/builder/pta_BuilderN.cxx b/panda/src/builder/pta_BuilderN.cxx deleted file mode 100644 index ebd86762e8..0000000000 --- a/panda/src/builder/pta_BuilderN.cxx +++ /dev/null @@ -1,11 +0,0 @@ -// Filename: pta_BuilderN.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// - -#include "pta_BuilderN.h" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/builder/pta_BuilderN.h b/panda/src/builder/pta_BuilderN.h deleted file mode 100644 index 9535c29a08..0000000000 --- a/panda/src/builder/pta_BuilderN.h +++ /dev/null @@ -1,37 +0,0 @@ -// Filename: pta_BuilderN.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// - -#ifndef PTA_BUILDERN_H -#define PTA_BUILDERN_H - -#include - -#include "vector_BuilderN.h" - -#include - -//////////////////////////////////////////////////////////////////// -// Class : PTA_BuilderN -// Description : A pta of BuilderNs. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// - -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, RefCountObj); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerToBase >); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerToArray) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, ConstPointerToArray) - -typedef PointerToArray PTA_BuilderN; -typedef ConstPointerToArray CPTA_BuilderN; - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - -#endif diff --git a/panda/src/builder/pta_BuilderTC.cxx b/panda/src/builder/pta_BuilderTC.cxx deleted file mode 100644 index 7ef3df926f..0000000000 --- a/panda/src/builder/pta_BuilderTC.cxx +++ /dev/null @@ -1,11 +0,0 @@ -// Filename: pta_BuilderTC.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// - -#include "pta_BuilderTC.h" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/builder/pta_BuilderTC.h b/panda/src/builder/pta_BuilderTC.h deleted file mode 100644 index dc7f3bdab6..0000000000 --- a/panda/src/builder/pta_BuilderTC.h +++ /dev/null @@ -1,37 +0,0 @@ -// Filename: pta_BuilderTC.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// - -#ifndef PTA_BUILDERTC_H -#define PTA_BUILDERTC_H - -#include - -#include "vector_BuilderTC.h" - -#include - -//////////////////////////////////////////////////////////////////// -// Class : PTA_BuilderTC -// Description : A pta of BuilderTCs. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// - -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, RefCountObj); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerToBase >); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerToArray) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, ConstPointerToArray) - -typedef PointerToArray PTA_BuilderTC; -typedef ConstPointerToArray CPTA_BuilderTC; - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - -#endif diff --git a/panda/src/builder/pta_BuilderV.cxx b/panda/src/builder/pta_BuilderV.cxx deleted file mode 100644 index 878a899af2..0000000000 --- a/panda/src/builder/pta_BuilderV.cxx +++ /dev/null @@ -1,11 +0,0 @@ -// Filename: pta_BuilderV.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// - -#include "pta_BuilderV.h" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/builder/pta_BuilderV.h b/panda/src/builder/pta_BuilderV.h deleted file mode 100644 index 55f5b62f02..0000000000 --- a/panda/src/builder/pta_BuilderV.h +++ /dev/null @@ -1,37 +0,0 @@ -// Filename: pta_BuilderV.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// - -#ifndef PTA_BUILDERV_H -#define PTA_BUILDERV_H - -#include - -#include "vector_BuilderV.h" - -#include - -//////////////////////////////////////////////////////////////////// -// Class : PTA_BuilderV -// Description : A pta of BuilderVs. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a pta of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the pta again. -//////////////////////////////////////////////////////////////////// - -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, RefCountObj); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerToBase >); -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, PointerToArray) -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, ConstPointerToArray) - -typedef PointerToArray PTA_BuilderV; -typedef ConstPointerToArray CPTA_BuilderV; - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - -#endif diff --git a/panda/src/builder/vector_BuilderC.cxx b/panda/src/builder/vector_BuilderC.cxx deleted file mode 100644 index 6040192343..0000000000 --- a/panda/src/builder/vector_BuilderC.cxx +++ /dev/null @@ -1,11 +0,0 @@ -// Filename: vector_BuilderC.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// - -#include "vector_BuilderC.h" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/builder/vector_BuilderC.h b/panda/src/builder/vector_BuilderC.h deleted file mode 100644 index bd39b58e36..0000000000 --- a/panda/src/builder/vector_BuilderC.h +++ /dev/null @@ -1,32 +0,0 @@ -// Filename: vector_BuilderC.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// - -#ifndef VECTOR_BUILDERC_H -#define VECTOR_BUILDERC_H - -#include - -#include "builderTypes.h" - -#include - -//////////////////////////////////////////////////////////////////// -// Class : vector_BuilderC -// Description : A vector of BuilderCs. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a vector of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the vector again. -//////////////////////////////////////////////////////////////////// - -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, std::vector) -typedef vector vector_BuilderC; - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - -#endif diff --git a/panda/src/builder/vector_BuilderN.cxx b/panda/src/builder/vector_BuilderN.cxx deleted file mode 100644 index 5c37dbf298..0000000000 --- a/panda/src/builder/vector_BuilderN.cxx +++ /dev/null @@ -1,11 +0,0 @@ -// Filename: vector_BuilderN.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// - -#include "vector_BuilderN.h" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/builder/vector_BuilderN.h b/panda/src/builder/vector_BuilderN.h deleted file mode 100644 index 1f15090a02..0000000000 --- a/panda/src/builder/vector_BuilderN.h +++ /dev/null @@ -1,32 +0,0 @@ -// Filename: vector_BuilderN.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// - -#ifndef VECTOR_BUILDERN_H -#define VECTOR_BUILDERN_H - -#include - -#include "builderTypes.h" - -#include - -//////////////////////////////////////////////////////////////////// -// Class : vector_BuilderN -// Description : A vector of BuilderNs. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a vector of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the vector again. -//////////////////////////////////////////////////////////////////// - -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, std::vector) -typedef vector vector_BuilderN; - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - -#endif diff --git a/panda/src/builder/vector_BuilderTC.cxx b/panda/src/builder/vector_BuilderTC.cxx deleted file mode 100644 index 05d2aa1461..0000000000 --- a/panda/src/builder/vector_BuilderTC.cxx +++ /dev/null @@ -1,11 +0,0 @@ -// Filename: vector_BuilderTC.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// - -#include "vector_BuilderTC.h" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/builder/vector_BuilderTC.h b/panda/src/builder/vector_BuilderTC.h deleted file mode 100644 index 9aa9bb7550..0000000000 --- a/panda/src/builder/vector_BuilderTC.h +++ /dev/null @@ -1,32 +0,0 @@ -// Filename: vector_BuilderTC.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// - -#ifndef VECTOR_BUILDERTC_H -#define VECTOR_BUILDERTC_H - -#include - -#include "builderTypes.h" - -#include - -//////////////////////////////////////////////////////////////////// -// Class : vector_BuilderTC -// Description : A vector of BuilderTCs. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a vector of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the vector again. -//////////////////////////////////////////////////////////////////// - -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, std::vector) -typedef vector vector_BuilderTC; - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - -#endif diff --git a/panda/src/builder/vector_BuilderV.cxx b/panda/src/builder/vector_BuilderV.cxx deleted file mode 100644 index 3063ccd75c..0000000000 --- a/panda/src/builder/vector_BuilderV.cxx +++ /dev/null @@ -1,11 +0,0 @@ -// Filename: vector_BuilderV.cxx -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// - -#include "vector_BuilderV.h" - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma implementation -#endif diff --git a/panda/src/builder/vector_BuilderV.h b/panda/src/builder/vector_BuilderV.h deleted file mode 100644 index 721082f2b8..0000000000 --- a/panda/src/builder/vector_BuilderV.h +++ /dev/null @@ -1,32 +0,0 @@ -// Filename: vector_BuilderV.h -// Created by: drose (10May00) -// -//////////////////////////////////////////////////////////////////// - -#ifndef VECTOR_BUILDERV_H -#define VECTOR_BUILDERV_H - -#include - -#include "builderTypes.h" - -#include - -//////////////////////////////////////////////////////////////////// -// Class : vector_BuilderV -// Description : A vector of BuilderVs. This class is defined once here, -// and exported to PANDA.DLL; other packages that want -// to use a vector of this type (whether they need to -// export it or not) should include this header file, -// rather than defining the vector again. -//////////////////////////////////////////////////////////////////// - -EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, std::vector) -typedef vector vector_BuilderV; - -// Tell GCC that we'll take care of the instantiation explicitly here. -#ifdef __GNUC__ -#pragma interface -#endif - -#endif diff --git a/panda/src/egg/eggCoordinateSystem.cxx b/panda/src/egg/eggCoordinateSystem.cxx index c1613b07ef..d326ca5110 100644 --- a/panda/src/egg/eggCoordinateSystem.cxx +++ b/panda/src/egg/eggCoordinateSystem.cxx @@ -38,6 +38,9 @@ write(ostream &out, int indent_level) const { case CS_yup_left: out << "Y-Up-Left"; break; + + default: + out << "/* Invalid coordinate system " << (int)get_value() << " */"; } out << " }\n\n"; } diff --git a/panda/src/egg/eggVertex.cxx b/panda/src/egg/eggVertex.cxx index a5a91a8113..5efa82b1a6 100644 --- a/panda/src/egg/eggVertex.cxx +++ b/panda/src/egg/eggVertex.cxx @@ -44,9 +44,9 @@ EggVertex() { EggVertex:: EggVertex(const EggVertex ©) : EggObject(copy), EggAttributes(copy), + _dxyzs(copy._dxyzs), _pos(copy._pos), - _num_dimensions(copy._num_dimensions), - _dxyzs(copy._dxyzs) + _num_dimensions(copy._num_dimensions) { _pool = NULL; _index = -1; diff --git a/panda/src/egg/eggXfmAnimData.cxx b/panda/src/egg/eggXfmAnimData.cxx index 1e6fd0e0d5..796b64cbee 100644 --- a/panda/src/egg/eggXfmAnimData.cxx +++ b/panda/src/egg/eggXfmAnimData.cxx @@ -57,7 +57,7 @@ EggXfmAnimData(const EggXfmSAnim &convert_from) // Now, go through and extract out all the data. int num_rows = convert_from.get_num_rows(); for (int row = 0; row < num_rows; row++) { - for (int col = 0; col < subtables.size(); col++) { + for (int col = 0; col < (int)subtables.size(); col++) { EggSAnimData *sanim = subtables[col]; if (sanim->get_num_rows() == 1) { add_data(sanim->get_value(0)); diff --git a/panda/src/egg/parser.yxx b/panda/src/egg/parser.yxx index a5697566e0..3601d76598 100644 --- a/panda/src/egg/parser.yxx +++ b/panda/src/egg/parser.yxx @@ -1119,7 +1119,7 @@ group_vertex_ref: PTA_double nums = $3; double membership = $4; - for (int i = 0; i < nums.size(); i++) { + for (int i = 0; i < (int)nums.size(); i++) { int index = (int)nums[i]; EggVertex *vertex = pool->get_vertex(index); if (vertex == NULL) { @@ -1581,7 +1581,7 @@ primitive_vertex_ref: EggPrimitive *prim = DCAST(EggPrimitive, egg_stack.back()); PTA_double nums = $3; - for (int i = 0; i < nums.size(); i++) { + for (int i = 0; i < (int)nums.size(); i++) { int index = (int)nums[i]; EggVertex *vertex = pool->get_vertex(index); if (vertex == NULL) { @@ -1629,7 +1629,7 @@ nurbs_surface_uknots_body: PTA_double nums = $1; nurbs->set_num_u_knots(nums.size()); - for (int i = 0; i < nums.size(); i++) { + for (int i = 0; i < (int)nums.size(); i++) { nurbs->set_u_knot(i, nums[i]); } } @@ -1649,7 +1649,7 @@ nurbs_surface_vknots_body: PTA_double nums = $1; nurbs->set_num_v_knots(nums.size()); - for (int i = 0; i < nums.size(); i++) { + for (int i = 0; i < (int)nums.size(); i++) { nurbs->set_v_knot(i, nums[i]); } } @@ -1726,7 +1726,7 @@ nurbs_curve_knots_body: PTA_double nums = $1; nurbs->set_num_knots(nums.size()); - for (int i = 0; i < nums.size(); i++) { + for (int i = 0; i < (int)nums.size(); i++) { nurbs->set_knot(i, nums[i]); } } diff --git a/panda/src/egg2sg/characterMaker.cxx b/panda/src/egg2sg/characterMaker.cxx index 94531ab040..c179b278ed 100644 --- a/panda/src/egg2sg/characterMaker.cxx +++ b/panda/src/egg2sg/characterMaker.cxx @@ -25,7 +25,7 @@ //////////////////////////////////////////////////////////////////// CharacterMaker:: CharacterMaker(EggGroup *root, EggLoader &loader) - : _egg_root(root), _loader(loader) { + : _loader(loader), _egg_root(root) { _character_node = new Character(_egg_root->get_name()); _bundle = _character_node->get_bundle(); @@ -63,7 +63,7 @@ egg_to_part(EggNode *egg_node) const { // character, just return the root of the character. return _bundle; } - nassertr(index < _parts.size(), NULL); + nassertr(index < (int)_parts.size(), NULL); return _parts[index]; } @@ -173,8 +173,6 @@ build_joint_hierarchy(EggNode *egg_node, PartGroup *part) { index = _parts.size(); _parts.push_back(joint); - PartGroup *pgroup = (PartGroup *)joint; - if (egg_group->get_dcs_flag()) { // If the joint requested an explicit DCS, create a node for // it. diff --git a/panda/src/egg2sg/eggLoader.cxx b/panda/src/egg2sg/eggLoader.cxx index 6ed092c090..1c09b7bef1 100644 --- a/panda/src/egg2sg/eggLoader.cxx +++ b/panda/src/egg2sg/eggLoader.cxx @@ -272,23 +272,23 @@ make_nonindexed_primitive(EggPrimitive *egg_prim, NamedNode *parent, } if (egg_prim->has_normal()) { - bprim.set_normal(egg_prim->get_normal() * mat); + bprim.set_normal(LCAST(float, egg_prim->get_normal() * mat)); } if (egg_prim->has_color() && !egg_false_color) { - bprim.set_color(egg_prim->get_color()); + bprim.set_color(LCAST(float, egg_prim->get_color())); } bool has_vert_color = true; EggPrimitive::const_iterator vi; for (vi = egg_prim->begin(); vi != egg_prim->end(); ++vi) { EggVertex *egg_vert = *vi; - BuilderVertex bvert(egg_vert->get_pos3() * mat); + BuilderVertex bvert(LCAST(float, egg_vert->get_pos3() * mat)); if (egg_vert->has_normal()) { - bvert.set_normal(egg_vert->get_normal() * mat); + bvert.set_normal(LCAST(float, egg_vert->get_normal() * mat)); } if (egg_vert->has_color() && !egg_false_color) { - bvert.set_color(egg_vert->get_color()); + bvert.set_color(LCAST(float, egg_vert->get_color())); } else { // If any vertex doesn't have a color, we can't use any of the // vertex colors. @@ -301,7 +301,7 @@ make_nonindexed_primitive(EggPrimitive *egg_prim, NamedNode *parent, // If we have a texture matrix, apply it. uv = uv * egg_prim->get_texture()->get_transform(); } - bvert.set_texcoord(uv); + bvert.set_texcoord(LCAST(float, uv)); } bprim.add_vertex(bvert); @@ -543,6 +543,10 @@ apply_texture_attributes(Texture *tex, const EggTexture *egg_tex) { tex->set_wrapu(Texture::WM_clamp); } break; + + default: + cerr << "Unexpected texture wrap flag: " + << (int)egg_tex->determine_wrap_u() << "\n"; } switch (egg_tex->determine_wrap_v()) { @@ -559,6 +563,10 @@ apply_texture_attributes(Texture *tex, const EggTexture *egg_tex) { tex->set_wrapv(Texture::WM_clamp); } break; + + default: + cerr << "Unexpected texture wrap flag: " + << (int)egg_tex->determine_wrap_v() << "\n"; } switch (egg_tex->get_minfilter()) { @@ -786,6 +794,10 @@ apply_texture_apply_attributes(TextureApplyTransition *apply, case EggTexture::ET_decal: apply->set_mode(TextureApplyProperty::M_decal); break; + + default: + cerr << "Invalid texture environment " + << (int)egg_tex->get_env_type() << "\n"; } } } diff --git a/panda/src/express/datagramIterator.cxx b/panda/src/express/datagramIterator.cxx index 7aa80720a8..812bcb3c9a 100644 --- a/panda/src/express/datagramIterator.cxx +++ b/panda/src/express/datagramIterator.cxx @@ -221,7 +221,7 @@ get_float32() { nassertr(_current_index < _datagram.get_length(), 0.0); float tempvar; - BigEndian s = + LittleEndian s = _datagram.get_message().substr(_current_index, sizeof(tempvar)); nassertr(s.length() == sizeof(tempvar), 0.0); diff --git a/panda/src/glgsg/glGraphicsStateGuardian.cxx b/panda/src/glgsg/glGraphicsStateGuardian.cxx index 5f5498ee88..17f092541d 100644 --- a/panda/src/glgsg/glGraphicsStateGuardian.cxx +++ b/panda/src/glgsg/glGraphicsStateGuardian.cxx @@ -1163,8 +1163,8 @@ draw_polygon(const GeomPolygon *geom) { // If we have per-vertex colors or normals, we need smooth shading. // Otherwise we want flat shading for performance reasons. - if (geom->get_binding(G_COLOR) == G_PER_VERTEX || - geom->get_binding(G_NORMAL) == G_PER_VERTEX) { + if ((geom->get_binding(G_COLOR) == G_PER_VERTEX && wants_colors()) || + (geom->get_binding(G_NORMAL) == G_PER_VERTEX && wants_normals())) { call_glShadeModel(GL_SMOOTH); } else { call_glShadeModel(GL_FLAT); @@ -1233,8 +1233,8 @@ draw_tri(const GeomTri *geom) { // If we have per-vertex colors or normals, we need smooth shading. // Otherwise we want flat shading for performance reasons. - if (geom->get_binding(G_COLOR) == G_PER_VERTEX || - geom->get_binding(G_NORMAL) == G_PER_VERTEX) { + if ((geom->get_binding(G_COLOR) == G_PER_VERTEX && wants_colors()) || + (geom->get_binding(G_NORMAL) == G_PER_VERTEX && wants_normals())) { call_glShadeModel(GL_SMOOTH); } else { call_glShadeModel(GL_FLAT); @@ -1299,8 +1299,8 @@ draw_quad(const GeomQuad *geom) { // If we have per-vertex colors or normals, we need smooth shading. // Otherwise we want flat shading for performance reasons. - if (geom->get_binding(G_COLOR) == G_PER_VERTEX || - geom->get_binding(G_NORMAL) == G_PER_VERTEX) { + if ((geom->get_binding(G_COLOR) == G_PER_VERTEX && wants_colors()) || + (geom->get_binding(G_NORMAL) == G_PER_VERTEX && wants_normals())) { call_glShadeModel(GL_SMOOTH); } else { call_glShadeModel(GL_FLAT); @@ -1366,8 +1366,8 @@ draw_tristrip(const GeomTristrip *geom) { // If we have per-vertex colors or normals, we need smooth shading. // Otherwise we want flat shading for performance reasons. - if (geom->get_binding(G_COLOR) == G_PER_VERTEX || - geom->get_binding(G_NORMAL) == G_PER_VERTEX) { + if ((geom->get_binding(G_COLOR) == G_PER_VERTEX && wants_colors()) || + (geom->get_binding(G_NORMAL) == G_PER_VERTEX && wants_normals())) { call_glShadeModel(GL_SMOOTH); } else { call_glShadeModel(GL_FLAT); @@ -1454,8 +1454,8 @@ draw_trifan(const GeomTrifan *geom) { // If we have per-vertex colors or normals, we need smooth shading. // Otherwise we want flat shading for performance reasons. - if (geom->get_binding(G_COLOR) == G_PER_VERTEX || - geom->get_binding(G_NORMAL) == G_PER_VERTEX) { + if ((geom->get_binding(G_COLOR) == G_PER_VERTEX && wants_colors()) || + (geom->get_binding(G_NORMAL) == G_PER_VERTEX && wants_normals())) { call_glShadeModel(GL_SMOOTH); } else { call_glShadeModel(GL_FLAT);