From 286a640ffe7c026f5f4288787d477d90c8a412fb Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 11 Jan 2001 23:10:48 +0000 Subject: [PATCH] *** empty log message *** --- panda/src/builder/Sources.pp | 5 +- panda/src/builder/builderAttribTempl.I | 36 +++++ panda/src/builder/builderAttribTempl.h | 3 + panda/src/builder/builderBucketNode.cxx | 3 +- panda/src/builder/builderBucketNode.h | 2 +- panda/src/builder/builderNormalVisualizer.I | 2 +- panda/src/builder/builderNormalVisualizer.cxx | 12 +- panda/src/builder/builderNormalVisualizer.h | 6 +- panda/src/builder/builderPrim.I | 65 +++++++++ panda/src/builder/builderPrim.cxx | 56 ++++++++ panda/src/builder/builderPrim.h | 14 +- panda/src/builder/builderVertexTempl.I | 48 +++++++ panda/src/builder/builderVertexTempl.h | 4 + panda/src/builder/mesherConfig.h | 5 + panda/src/gobj/fog.I | 11 ++ panda/src/gobj/fog.h | 7 +- panda/src/gobj/geom.cxx | 133 ++++++++++++------ panda/src/gobj/geom.h | 4 +- panda/src/sgattrib/fogAttribute.I | 2 +- panda/src/sgattrib/fogAttribute.h | 3 +- panda/src/sgattrib/fogTransition.I | 2 +- panda/src/sgattrib/fogTransition.h | 5 +- panda/src/sgraph/geomNode.cxx | 4 +- panda/src/sgraph/geomNode.h | 2 +- 24 files changed, 362 insertions(+), 72 deletions(-) create mode 100644 panda/src/builder/builderPrim.I diff --git a/panda/src/builder/Sources.pp b/panda/src/builder/Sources.pp index 05e23db786..a90e6a9632 100644 --- a/panda/src/builder/Sources.pp +++ b/panda/src/builder/Sources.pp @@ -14,7 +14,7 @@ builderBucketNode.I builderBucketNode.cxx builderBucketNode.h \ builderFuncs.I builderFuncs.h builderMisc.cxx builderMisc.h \ builderNormalVisualizer.I builderNormalVisualizer.cxx \ - builderNormalVisualizer.h builderPrim.cxx builderPrim.h \ + builderNormalVisualizer.h builderPrim.I builderPrim.cxx builderPrim.h \ builderPrimTempl.I builderPrimTempl.h builderProperties.cxx \ builderProperties.h builderTypes.cxx builderTypes.h \ builderVertex.I builderVertex.cxx builderVertex.h \ @@ -27,7 +27,8 @@ builder.I builder.h builderAttrib.I builderAttrib.h \ builderAttribTempl.I builderAttribTempl.h builderBucket.I \ builderBucket.h builderBucketNode.I builderBucketNode.h \ - builderNormalVisualizer.I builderNormalVisualizer.h builderPrim.h \ + builderNormalVisualizer.I builderNormalVisualizer.h \ + builderPrim.I builderPrim.h \ builderPrimTempl.I builderPrimTempl.h builderProperties.h \ builderTypes.h builderVertex.I builderVertex.h builderVertexTempl.I \ builderVertexTempl.h config_builder.h diff --git a/panda/src/builder/builderAttribTempl.I b/panda/src/builder/builderAttribTempl.I index d9679c3eaf..7b6328bd3d 100644 --- a/panda/src/builder/builderAttribTempl.I +++ b/panda/src/builder/builderAttribTempl.I @@ -99,6 +99,18 @@ set_normal(const NType &n) { return *this; } +//////////////////////////////////////////////////////////////////// +// Function: BuilderAttribTempl::clear_normal +// Access: Public +// Description: Removes the attribute's normal. +//////////////////////////////////////////////////////////////////// +template +INLINE BuilderAttribTempl &BuilderAttribTempl:: +clear_normal() { + _flags &= ~BAF_normal; + return *this; +} + //////////////////////////////////////////////////////////////////// // Function: BuilderAttribTempl::has_color @@ -140,6 +152,18 @@ set_color(const CType &c) { return *this; } +//////////////////////////////////////////////////////////////////// +// Function: BuilderAttribTempl::clear_color +// Access: Public +// Description: Removes the attribute's color. +//////////////////////////////////////////////////////////////////// +template +INLINE BuilderAttribTempl &BuilderAttribTempl:: +clear_color() { + _flags &= ~BAF_color; + return *this; +} + //////////////////////////////////////////////////////////////////// // Function: BuilderAttribTempl::has_pixel_size @@ -181,6 +205,18 @@ set_pixel_size(float s) { return *this; } +//////////////////////////////////////////////////////////////////// +// Function: BuilderAttribTempl::clear_pixel_size +// Access: Public +// Description: Removes the attribute's pixel_size. +//////////////////////////////////////////////////////////////////// +template +INLINE BuilderAttribTempl &BuilderAttribTempl:: +clear_pixel_size() { + _flags &= ~BAF_pixel_size; + return *this; +} + //////////////////////////////////////////////////////////////////// // Function: BuilderAttribTempl::operator == // Access: Public diff --git a/panda/src/builder/builderAttribTempl.h b/panda/src/builder/builderAttribTempl.h index adeea043e3..913137b40d 100644 --- a/panda/src/builder/builderAttribTempl.h +++ b/panda/src/builder/builderAttribTempl.h @@ -37,14 +37,17 @@ public: INLINE bool has_normal() const; INLINE NType get_normal() const; INLINE BuilderAttribTempl &set_normal(const NType &n); + INLINE BuilderAttribTempl &clear_normal(); INLINE bool has_color() const; INLINE CType get_color() const; INLINE BuilderAttribTempl &set_color(const CType &c); + INLINE BuilderAttribTempl &clear_color(); INLINE bool has_pixel_size() const; INLINE float get_pixel_size() const; INLINE BuilderAttribTempl &set_pixel_size(float s); + INLINE BuilderAttribTempl &clear_pixel_size(); INLINE bool operator == (const BuilderAttribTempl &other) const; INLINE bool operator != (const BuilderAttribTempl &other) const; diff --git a/panda/src/builder/builderBucketNode.cxx b/panda/src/builder/builderBucketNode.cxx index 4cdbe7a742..0eea92e711 100644 --- a/panda/src/builder/builderBucketNode.cxx +++ b/panda/src/builder/builderBucketNode.cxx @@ -16,7 +16,8 @@ // Intended to be called from Builder::add_prim(). //////////////////////////////////////////////////////////////////// bool BuilderBucketNode:: -add_prim(const BuilderPrim &prim) { +add_prim(BuilderPrim prim) { + prim.flatten_vertex_properties(); bool result = expand(prim, *_bucket, inserter(_prims, _prims.begin())); return result; } diff --git a/panda/src/builder/builderBucketNode.h b/panda/src/builder/builderBucketNode.h index ca177a0269..fb8c4d0736 100644 --- a/panda/src/builder/builderBucketNode.h +++ b/panda/src/builder/builderBucketNode.h @@ -33,7 +33,7 @@ public: INLINE BuilderBucketNode(const BuilderBucketNode ©); INLINE void operator = (const BuilderBucketNode ©); - bool add_prim(const BuilderPrim &prim); + bool add_prim(BuilderPrim prim); bool add_prim(const BuilderPrimI &prim); INLINE bool add_prim_nonindexed(const BuilderPrimI &prim); diff --git a/panda/src/builder/builderNormalVisualizer.I b/panda/src/builder/builderNormalVisualizer.I index c187457c92..d1434f14dd 100644 --- a/panda/src/builder/builderNormalVisualizer.I +++ b/panda/src/builder/builderNormalVisualizer.I @@ -6,6 +6,6 @@ INLINE BuilderNormalVisualizer:: BuilderNormalVisualizer(BuilderBucket &bucket) : _bucket(bucket) { _num_vertices = 0; - _net_vertex._v.set(0.0, 0.0, 0.0); + _net_vertex.set(0.0, 0.0, 0.0); } diff --git a/panda/src/builder/builderNormalVisualizer.cxx b/panda/src/builder/builderNormalVisualizer.cxx index 95aeb886cc..897dca9b5e 100644 --- a/panda/src/builder/builderNormalVisualizer.cxx +++ b/panda/src/builder/builderNormalVisualizer.cxx @@ -3,22 +3,22 @@ // //////////////////////////////////////////////////////////////////// -#ifdef SUPPORT_SHOW_NORMALS - #include "builderNormalVisualizer.h" #include "builderFuncs.h" +#ifdef SUPPORT_SHOW_NORMALS + void BuilderNormalVisualizer:: add_prim(const BuilderPrim &prim) { if (prim.has_overall_normal()) { // Average up all the vertex values to get the primitive center. BuilderV net_vertex; - net_vertex._v.set(0.0, 0.0, 0.0); + net_vertex.set(0.0, 0.0, 0.0); int num_verts = prim.get_num_verts(); for (int i = 0; i < num_verts; i++) { - net_vertex._v += prim.get_vertex(i).get_coord(); + net_vertex += prim.get_vertex(i).get_coord(); } - net_vertex._v /= num_verts; + net_vertex /= num_verts; add_normal(net_vertex, prim.get_normal()); } else if (prim.has_vertex_normal()) { @@ -50,7 +50,7 @@ show_normals(GeomNode *node) { void BuilderNormalVisualizer:: add_normal(const BuilderV ¢er, const BuilderN &normal) { - BuilderV to = center._v + normal._v * _bucket._normal_scale; + BuilderV to = center + normal * _bucket._normal_scale; BuilderPrim line; line.set_type(BPT_line); diff --git a/panda/src/builder/builderNormalVisualizer.h b/panda/src/builder/builderNormalVisualizer.h index beb77333cb..7ad1c1c5d1 100644 --- a/panda/src/builder/builderNormalVisualizer.h +++ b/panda/src/builder/builderNormalVisualizer.h @@ -6,10 +6,12 @@ #ifndef BUILDERNORMALVISUALIZER_H #define BUILDERNORMALVISUALIZER_H -#ifdef SUPPORT_SHOW_NORMALS - #include +#include "mesherConfig.h" + +#ifdef SUPPORT_SHOW_NORMALS + #include "builderBucket.h" #include "builderAttrib.h" #include "builderVertex.h" diff --git a/panda/src/builder/builderPrim.I b/panda/src/builder/builderPrim.I new file mode 100644 index 0000000000..7410bfcfcd --- /dev/null +++ b/panda/src/builder/builderPrim.I @@ -0,0 +1,65 @@ +// Filename: builderPrim.I +// Created by: drose (11Jan01) +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: BuilderPrim::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE BuilderPrim:: +BuilderPrim() { +} + +//////////////////////////////////////////////////////////////////// +// Function: BuilderPrim::Copy Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE BuilderPrim:: +BuilderPrim(const BuilderPrim ©) : + BuilderPrimTempl(copy) { +} + +//////////////////////////////////////////////////////////////////// +// Function: BuilderPrim::Copy Assignment +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE BuilderPrim &BuilderPrim:: +operator = (const BuilderPrim ©) { + BuilderPrimTempl::operator = (copy); + return *this; +} + +//////////////////////////////////////////////////////////////////// +// Function: BuilderPrimI::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE BuilderPrimI:: +BuilderPrimI() { +} + +//////////////////////////////////////////////////////////////////// +// Function: BuilderPrimI::Copy Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE BuilderPrimI:: +BuilderPrimI(const BuilderPrimI ©) : + BuilderPrimTempl(copy) { +} + +//////////////////////////////////////////////////////////////////// +// Function: BuilderPrimI::Copy Assignment +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +INLINE BuilderPrimI &BuilderPrimI:: +operator = (const BuilderPrimI ©) { + BuilderPrimTempl::operator = (copy); + return *this; +} diff --git a/panda/src/builder/builderPrim.cxx b/panda/src/builder/builderPrim.cxx index c87b7eca52..dfdfc8b42e 100644 --- a/panda/src/builder/builderPrim.cxx +++ b/panda/src/builder/builderPrim.cxx @@ -70,6 +70,47 @@ nonindexed_copy(const BuilderPrimTempl ©, +//////////////////////////////////////////////////////////////////// +// Function: BuilderPrim::flatten_vertex_properties +// Access: Public +// Description: If all the vertices of the primitive have the same +// normal, color, etc., removes those properties from +// the vertices and assigns them to the primitive +// instead. +// +// This can provide better meshing by removing +// properties from otherwise shared vertices. +//////////////////////////////////////////////////////////////////// +void BuilderPrim:: +flatten_vertex_properties() { + int num_verts = get_num_verts(); + int i; + + if (has_overall_normal()) { + set_normal(get_normal()); + + for (i = 0; i < num_verts; i++) { + get_vertex(i).clear_normal(); + } + } + + if (has_overall_color()) { + set_color(get_color()); + + for (i = 0; i < num_verts; i++) { + get_vertex(i).clear_color(); + } + } + + if (has_overall_pixel_size()) { + set_pixel_size(get_pixel_size()); + + for (i = 0; i < num_verts; i++) { + get_vertex(i).clear_pixel_size(); + } + } +} + //////////////////////////////////////////////////////////////////// // Function: BuilderPrim::fill_geom // Access: Public @@ -103,6 +144,21 @@ fill_geom(Geom *geom, const PTA_BuilderV &v_array, } } +//////////////////////////////////////////////////////////////////// +// Function: BuilderPrimI::flatten_vertex_properties +// Access: Public +// Description: If all the vertices of the primitive have the same +// normal, color, etc., removes those properties from +// the vertices and assigns them to the primitive +// instead. +// +// This can do nothing in the case of an indexed +// primitive, because we can't monkey with the vertex +// properties in this case. +//////////////////////////////////////////////////////////////////// +void BuilderPrimI:: +flatten_vertex_properties() { +} //////////////////////////////////////////////////////////////////// // Function: BuilderPrimI::fill_geom diff --git a/panda/src/builder/builderPrim.h b/panda/src/builder/builderPrim.h index d2e6c1d991..048b45a028 100644 --- a/panda/src/builder/builderPrim.h +++ b/panda/src/builder/builderPrim.h @@ -73,11 +73,15 @@ EXPORT_TEMPLATE_CLASS(EXPCL_PANDAEGG, EXPTP_PANDAEGG, BuilderPrimTempl { public: - BuilderPrim() {} + INLINE BuilderPrim(); + INLINE BuilderPrim(const BuilderPrim ©); + INLINE BuilderPrim &operator = (const BuilderPrim ©); BuilderPrim &nonindexed_copy(const BuilderPrimTempl ©, const BuilderBucket &bucket); + void flatten_vertex_properties(); + static void fill_geom(Geom *geom, const PTA_BuilderV &v_array, GeomBindType n_attr, const PTA_BuilderN &n_array, GeomBindType t_attr, const PTA_BuilderTC &t_array, @@ -97,7 +101,11 @@ public: //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEGG BuilderPrimI : public BuilderPrimTempl { public: - BuilderPrimI() {} + INLINE BuilderPrimI(); + INLINE BuilderPrimI(const BuilderPrimI ©); + INLINE BuilderPrimI &operator = (const BuilderPrimI ©); + + void flatten_vertex_properties(); static void fill_geom(Geom *geom, const PTA_ushort &v_array, GeomBindType n_attr, PTA_ushort n_array, @@ -107,6 +115,8 @@ public: int num_prims, int num_components, int num_verts); }; +#include "builderPrim.I" + // Tell GCC that we'll take care of the instantiation explicitly here. #ifdef __GNUC__ diff --git a/panda/src/builder/builderVertexTempl.I b/panda/src/builder/builderVertexTempl.I index de98ca7e33..a12c97c3ca 100644 --- a/panda/src/builder/builderVertexTempl.I +++ b/panda/src/builder/builderVertexTempl.I @@ -138,6 +138,18 @@ set_normal(const NType &n) { return *this; } +//////////////////////////////////////////////////////////////////// +// Function: BuilderVertexTempl::clear_normal +// Access: Public +// Description: Removes the vertex's normal. +//////////////////////////////////////////////////////////////////// +template +INLINE BuilderVertexTempl &BuilderVertexTempl:: +clear_normal() { + BuilderAttribTempl::clear_normal(); + return *this; +} + //////////////////////////////////////////////////////////////////// // Function: BuilderVertexTempl::has_texcoord @@ -164,6 +176,18 @@ set_texcoord(const TType &t) { return *this; } +//////////////////////////////////////////////////////////////////// +// Function: BuilderVertexTempl::clear_texcoord +// Access: Public +// Description: Removes the vertex's texcoord. +//////////////////////////////////////////////////////////////////// +template +INLINE BuilderVertexTempl &BuilderVertexTempl:: +clear_texcoord() { + _flags &= ~BAF_texcoord; + return *this; +} + //////////////////////////////////////////////////////////////////// // Function: BuilderVertexTempl::get_texcoord @@ -196,6 +220,18 @@ set_color(const CType &c) { return *this; } +//////////////////////////////////////////////////////////////////// +// Function: BuilderVertexTempl::clear_color +// Access: Public +// Description: Removes the vertex's color. +//////////////////////////////////////////////////////////////////// +template +INLINE BuilderVertexTempl &BuilderVertexTempl:: +clear_color() { + BuilderAttribTempl::clear_color(); + return *this; +} + //////////////////////////////////////////////////////////////////// // Function: BuilderVertexTempl::set_pixel_size @@ -213,6 +249,18 @@ set_pixel_size(float s) { return *this; } +//////////////////////////////////////////////////////////////////// +// Function: BuilderVertexTempl::clear_pixel_size +// Access: Public +// Description: Removes the vertex's pixel_size. +//////////////////////////////////////////////////////////////////// +template +INLINE BuilderVertexTempl &BuilderVertexTempl:: +clear_pixel_size() { + BuilderAttribTempl::clear_pixel_size(); + return *this; +} + //////////////////////////////////////////////////////////////////// // Function: BuilderVertexTempl::operator == diff --git a/panda/src/builder/builderVertexTempl.h b/panda/src/builder/builderVertexTempl.h index 687741aecc..8df09dba5c 100644 --- a/panda/src/builder/builderVertexTempl.h +++ b/panda/src/builder/builderVertexTempl.h @@ -42,14 +42,18 @@ public: INLINE BuilderVertexTempl &set_coord(const VType &c); INLINE BuilderVertexTempl &set_normal(const NType &c); + INLINE BuilderVertexTempl &clear_normal(); INLINE bool has_texcoord() const; INLINE TType get_texcoord() const; INLINE BuilderVertexTempl &set_texcoord(const TType &t); + INLINE BuilderVertexTempl &clear_texcoord(); INLINE BuilderVertexTempl &set_color(const CType &c); + INLINE BuilderVertexTempl &clear_color(); INLINE BuilderVertexTempl &set_pixel_size(float s); + INLINE BuilderVertexTempl &clear_pixel_size(); bool operator == (const BuilderVertexTempl &other) const; INLINE bool operator != (const BuilderVertexTempl &other) const; diff --git a/panda/src/builder/mesherConfig.h b/panda/src/builder/mesherConfig.h index 55092426ac..7111366019 100644 --- a/panda/src/builder/mesherConfig.h +++ b/panda/src/builder/mesherConfig.h @@ -16,4 +16,9 @@ // actually hurt, by bitching the heuristic). #define SUPPORT_FANS +// Define this to enable code to visualize the normals when generating +// primitives. This creates line segment geometry to show each normal +// as the primitives are created. +#define SUPPORT_SHOW_NORMALS + #endif diff --git a/panda/src/gobj/fog.I b/panda/src/gobj/fog.I index 4cfc1090b5..7c60409dd9 100644 --- a/panda/src/gobj/fog.I +++ b/panda/src/gobj/fog.I @@ -109,3 +109,14 @@ INLINE float Fog::get_end(void) const { INLINE float Fog::get_density(void) const { return _density; } + +//////////////////////////////////////////////////////////////////// +// Function: Fog::apply +// Access: Public +// Description: Called during rendering to enable fogging with the +// GSG. +//////////////////////////////////////////////////////////////////// +INLINE void Fog:: +apply(GraphicsStateGuardianBase *gsg) { + gsg->apply_fog(this); +} diff --git a/panda/src/gobj/fog.h b/panda/src/gobj/fog.h index bbcec89901..6156d050c9 100644 --- a/panda/src/gobj/fog.h +++ b/panda/src/gobj/fog.h @@ -36,10 +36,6 @@ PUBLISHED: Fog(Mode mode = M_exponential, int hardware_bits = 8); ~Fog(); - void apply(GraphicsStateGuardianBase *gsg) { - gsg->apply_fog(this); - } - INLINE Mode get_mode(void) const; INLINE void set_mode(Mode mode); @@ -58,6 +54,9 @@ PUBLISHED: void output(ostream &out) const; +public: + INLINE void apply(GraphicsStateGuardianBase *gsg); + protected: void compute_density(void); diff --git a/panda/src/gobj/geom.cxx b/panda/src/gobj/geom.cxx index 4209811c6e..7bdbc3a429 100644 --- a/panda/src/gobj/geom.cxx +++ b/panda/src/gobj/geom.cxx @@ -19,6 +19,7 @@ #include #include #include +#include //////////////////////////////////////////////////////////////////// // Static variables @@ -412,8 +413,8 @@ config(void) { // Description: //////////////////////////////////////////////////////////////////// void Geom:: -write(ostream &out) const { - out << *this << endl; +write(ostream &out, int indent_level) const { + indent(out, indent_level) << *this << endl; } //////////////////////////////////////////////////////////////////// @@ -582,7 +583,7 @@ template static void describe_attr(ostream &out, const Geom *geom, GeomBindType bind, const PTA(VecType) &array, - const char *pad) { + bool newline, int indent_level) { PTA_int lengths = geom->get_lengths(); int num_prims = geom->get_num_prims(); bool components = geom->uses_components(); @@ -590,7 +591,8 @@ describe_attr(ostream &out, const Geom *geom, int i, j, vi; switch (bind) { case G_PER_VERTEX: - out << "Per vertex:"; + indent(out, indent_level) + << "Per vertex:"; vi = 0; int num_verts; num_verts = geom->get_num_vertices_per_prim(); @@ -598,11 +600,18 @@ describe_attr(ostream &out, const Geom *geom, if (components) { num_verts = lengths[i]; } - out << "\n [ "; + out << "\n"; + indent(out, indent_level) << "[ "; if (num_verts > 0) { out << array[vi++]; for (j = 1; j < num_verts; j++) { - out << pad << array[vi++]; + if (newline) { + out << "\n"; + indent(out, indent_level + 2); + } else { + out << " "; + } + out << array[vi++]; } } out << " ]"; @@ -611,17 +620,26 @@ describe_attr(ostream &out, const Geom *geom, case G_PER_COMPONENT: if (!components) { - out << "Invalid per-component attribute specified!"; + indent(out, indent_level) + << "Invalid per-component attribute specified!"; } else { - out << "Per component:"; + indent(out, indent_level) + << "Per component:"; vi = 0; for (i = 0; i < num_prims; i++) { num_verts = lengths[i] - geom->get_num_more_vertices_than_components(); - out << "\n [ "; + out << "\n"; + indent(out, indent_level) << "[ "; if (num_verts > 0) { out << array[vi++]; for (j = 1; j < num_verts; j++) { - out << pad << array[vi++]; + if (newline) { + out << "\n"; + indent(out, indent_level + 2); + } else { + out << " "; + } + out << array[vi++]; } out << " ]"; } @@ -630,14 +648,29 @@ describe_attr(ostream &out, const Geom *geom, break; case G_PER_PRIM: - out << "Per prim:"; + indent(out, indent_level) + << "Per prim:"; for (i = 0; i < num_prims; i++) { - out << pad << array[i]; + if (newline) { + out << "\n"; + indent(out, indent_level + 2); + } else { + out << " "; + } + out << array[i]; } break; case G_OVERALL: - out << "Overall:" << pad << array[0]; + indent(out, indent_level) + << "Overall:"; + if (newline) { + out << "\n"; + indent(out, indent_level + 2); + } else { + out << " "; + } + out << array[0]; case G_OFF: break; @@ -653,7 +686,7 @@ describe_attr(ostream &out, const Geom *geom, // not too much detail. //////////////////////////////////////////////////////////////////// void Geom:: -write_verbose(ostream &out) const { +write_verbose(ostream &out, int indent_level) const { GeomBindType bind_coords; GeomBindType bind_normals; GeomBindType bind_tcoords; @@ -674,51 +707,65 @@ write_verbose(ostream &out) const { get_texcoords(g_tcoords, bind_tcoords, i_tcoords); get_colors(g_colors, bind_colors, i_colors); - out << "\n" << get_type() << " contains " - << get_num_prims() << " primitives:\n"; + out << "\n"; + indent(out, indent_level) + << get_type() << " contains " + << get_num_prims() << " primitives:\n"; if (bind_coords == G_OFF) { - out << "No coords\n"; + indent(out, indent_level) + << "No coords\n"; } else if (i_coords!=(ushort*)0L) { - out << "Indexed coords = " << (void *)g_coords << ", length = " - << g_coords.size() << ":\n"; - describe_attr(out, this, bind_coords, i_coords, " "); + indent(out, indent_level) + << "Indexed coords = " << (void *)g_coords << ", length = " + << g_coords.size() << ":\n"; + describe_attr(out, this, bind_coords, i_coords, false, indent_level + 2); } else { - out << "Nonindexed coords:\n"; - describe_attr(out, this, bind_coords, g_coords, "\n "); + indent(out, indent_level) + << "Nonindexed coords:\n"; + describe_attr(out, this, bind_coords, g_coords, true, indent_level + 2); } - + if (bind_colors == G_OFF) { - out << "No colors\n"; + indent(out, indent_level) + << "No colors\n"; } else if (i_colors!=(ushort*)0L) { - out << "Indexed colors = " << (void *)g_colors << ", length = " - << g_colors.size() << "\n"; - describe_attr(out, this, bind_colors, i_colors, " "); + indent(out, indent_level) + << "Indexed colors = " << (void *)g_colors << ", length = " + << g_colors.size() << "\n"; + describe_attr(out, this, bind_colors, i_colors, false, indent_level + 2); } else { - out << "Nonindexed colors:\n"; - describe_attr(out, this, bind_colors, g_colors, "\n "); + indent(out, indent_level) + << "Nonindexed colors:\n"; + describe_attr(out, this, bind_colors, g_colors, true, indent_level + 2); } - + if (bind_tcoords == G_OFF) { - out << "No tcoords\n"; + indent(out, indent_level) + << "No tcoords\n"; } else if (i_tcoords!=(ushort*)0L) { - out << "Indexed tcoords = " << (void *)g_tcoords << ", length = " - << g_tcoords.size() << "\n"; - describe_attr(out, this, bind_tcoords, i_tcoords, " "); + indent(out, indent_level) + << "Indexed tcoords = " << (void *)g_tcoords << ", length = " + << g_tcoords.size() << "\n"; + describe_attr(out, this, bind_tcoords, i_tcoords, false, indent_level + 2); } else { - out << "Nonindexed tcoords:\n"; - describe_attr(out, this, bind_tcoords, g_tcoords, "\n "); + indent(out, indent_level) + << "Nonindexed tcoords:\n"; + describe_attr(out, this, bind_tcoords, g_tcoords, true, indent_level + 2); } - + if (bind_normals == G_OFF) { - out << "No normals\n"; + indent(out, indent_level) + << "No normals\n"; } else if (i_normals!=(ushort*)0L) { - out << "Indexed normals = " << (void *)g_normals << ", length = " - << g_normals.size() << "\n"; - describe_attr(out, this, bind_normals, i_normals, " "); + indent(out, indent_level) + << "Indexed normals = " << (void *)g_normals << ", length = " + << g_normals.size() << "\n"; + describe_attr(out, this, bind_normals, i_normals, false, indent_level + 2); } else { - out << "Nonindexed normals:\n"; - describe_attr(out, this, bind_normals, g_normals, "\n "); + indent(out, indent_level) + << "Nonindexed normals:\n"; + describe_attr(out, this, bind_normals, g_normals, true, indent_level + 2); } } diff --git a/panda/src/gobj/geom.h b/panda/src/gobj/geom.h index 26e1a34478..71161053cf 100644 --- a/panda/src/gobj/geom.h +++ b/panda/src/gobj/geom.h @@ -106,9 +106,9 @@ public: virtual Geom *make_copy() const=0; PUBLISHED: - void write(ostream &out) const; + void write(ostream &out, int indent_level = 0) const; virtual void output(ostream &out) const; - void write_verbose(ostream &out) const; + void write_verbose(ostream &out, int indent_level) const; public: // From parent dDrawable diff --git a/panda/src/sgattrib/fogAttribute.I b/panda/src/sgattrib/fogAttribute.I index c0c5dae91d..864b471f7f 100644 --- a/panda/src/sgattrib/fogAttribute.I +++ b/panda/src/sgattrib/fogAttribute.I @@ -31,7 +31,7 @@ set_on(Fog *fog) { // is only valid to call this if is_on() has returned // true. //////////////////////////////////////////////////////////////////// -INLINE PT(Fog) FogAttribute:: +INLINE Fog *FogAttribute:: get_fog() const { nassertr(is_on(), NULL); return _value; diff --git a/panda/src/sgattrib/fogAttribute.h b/panda/src/sgattrib/fogAttribute.h index 2150d51892..4d3f9b1b6b 100644 --- a/panda/src/sgattrib/fogAttribute.h +++ b/panda/src/sgattrib/fogAttribute.h @@ -20,8 +20,9 @@ public: INLINE FogAttribute(); INLINE void set_on(Fog *fog); - INLINE PT(Fog) get_fog() const; + INLINE Fog *get_fog() const; +public: virtual TypeHandle get_handle() const; virtual NodeAttribute *make_copy() const; virtual NodeAttribute *make_initial() const; diff --git a/panda/src/sgattrib/fogTransition.I b/panda/src/sgattrib/fogTransition.I index 711a763cf0..c175db9c2a 100644 --- a/panda/src/sgattrib/fogTransition.I +++ b/panda/src/sgattrib/fogTransition.I @@ -57,7 +57,7 @@ set_on(Fog *fog) { // It is only valid to call this if is_on() has returned // true. //////////////////////////////////////////////////////////////////// -INLINE PT(Fog) FogTransition:: +INLINE Fog *FogTransition:: get_fog() const { nassertr(is_on(), NULL); return _value; diff --git a/panda/src/sgattrib/fogTransition.h b/panda/src/sgattrib/fogTransition.h index 5d5ea858c7..0fc04e1060 100644 --- a/panda/src/sgattrib/fogTransition.h +++ b/panda/src/sgattrib/fogTransition.h @@ -24,8 +24,9 @@ public: INLINE static FogTransition off(); INLINE void set_on(Fog *fog); - INLINE PT(Fog) get_fog() const; - + INLINE Fog *get_fog() const; + +public: virtual NodeTransition *make_copy() const; virtual NodeAttribute *make_attrib() const; diff --git a/panda/src/sgraph/geomNode.cxx b/panda/src/sgraph/geomNode.cxx index b71c75cf42..9fd42a7144 100644 --- a/panda/src/sgraph/geomNode.cxx +++ b/panda/src/sgraph/geomNode.cxx @@ -117,12 +117,12 @@ write(ostream &out, int indent_level) const { // Description: //////////////////////////////////////////////////////////////////// void GeomNode:: -write_verbose(ostream &out) const { +write_verbose(ostream &out, int indent_level) const { Geoms::const_iterator gi; for (gi = _geoms.begin(); gi != _geoms.end(); ++gi) { dDrawable *drawable = (*gi); if (drawable->is_of_type(Geom::get_class_type())) { - DCAST(Geom, drawable)->write_verbose(out); + DCAST(Geom, drawable)->write_verbose(out, indent_level); } else { out << drawable->get_type() << "\n"; } diff --git a/panda/src/sgraph/geomNode.h b/panda/src/sgraph/geomNode.h index 3120d25604..c82fc59a6b 100644 --- a/panda/src/sgraph/geomNode.h +++ b/panda/src/sgraph/geomNode.h @@ -38,7 +38,7 @@ public: PUBLISHED: void write(ostream &out, int indent_level = 0) const; - void write_verbose(ostream &out) const; + void write_verbose(ostream &out, int indent_level) const; public: void draw(GraphicsStateGuardianBase *gsg);