Panda3D
sceneGraphAnalyzer.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file sceneGraphAnalyzer.h
10  * @author drose
11  * @date 2000-07-02
12  */
13 
14 #ifndef SCENEGRAPHANALYZER_H
15 #define SCENEGRAPHANALYZER_H
16 
17 #include "pandabase.h"
18 #include "typedObject.h"
19 #include "luse.h"
20 #include "pmap.h"
21 #include "pset.h"
22 #include "bitArray.h"
23 #include "indirectCompareTo.h"
24 
25 class PandaNode;
26 class GeomNode;
27 class Geom;
28 class GeomVertexData;
29 class GeomVertexFormat;
31 class Texture;
32 
33 /**
34  * A handy class that can scrub over a scene graph and collect interesting
35  * statistics on it.
36  */
37 class EXPCL_PANDA_PGRAPHNODES SceneGraphAnalyzer {
38 PUBLISHED:
41 
42  enum LodMode {
43  LM_lowest,
44  LM_highest,
45  LM_all,
46  LM_none,
47  };
48 
49  INLINE void set_lod_mode(LodMode lod_mode);
50  INLINE LodMode get_lod_mode(LodMode lod_mode) const;
51 
52  void clear();
53  void add_node(PandaNode *node);
54 
55  void write(std::ostream &out, int indent_level = 0) const;
56 
57  INLINE int get_num_nodes() const;
58  INLINE int get_num_instances() const;
59  INLINE int get_num_transforms() const;
60  INLINE int get_num_nodes_with_attribs() const;
61  INLINE int get_num_lod_nodes() const;
62  INLINE int get_num_geom_nodes() const;
63  INLINE int get_num_geoms() const;
64  INLINE int get_num_geom_vertex_datas() const;
65  INLINE int get_num_geom_vertex_formats() const;
66  INLINE size_t get_vertex_data_size() const;
67 
68  INLINE int get_num_vertices() const;
69  INLINE int get_num_normals() const;
70  INLINE int get_num_colors() const;
71  INLINE int get_num_texcoords() const;
72  INLINE int get_num_tris() const;
73  INLINE int get_num_lines() const;
74  INLINE int get_num_points() const;
75  INLINE int get_num_patches() const;
76 
77  INLINE int get_num_individual_tris() const;
78  INLINE int get_num_tristrips() const;
79  INLINE int get_num_triangles_in_strips() const;
80  INLINE int get_num_trifans() const;
81  INLINE int get_num_triangles_in_fans() const;
82  INLINE int get_num_vertices_in_patches() const;
83 
84  INLINE size_t get_texture_bytes() const;
85 
86  INLINE int get_num_long_normals() const;
87  INLINE int get_num_short_normals() const;
88  INLINE PN_stdfloat get_total_normal_length() const;
89 
90 private:
91  void collect_statistics(PandaNode *node, bool under_instance);
92  void collect_statistics(GeomNode *geom_node);
93  void collect_statistics(const Geom *geom);
94  void collect_statistics(Texture *texture);
95  void collect_statistics(const GeomVertexArrayData *vadata);
96  void collect_prim_statistics(const GeomVertexArrayData *vadata);
97 
98  class VDataTracker {
99  public:
100  BitArray _referenced_vertices;
101  };
102 
104  typedef pmap<CPT(GeomVertexData), VDataTracker> VDatas;
105  typedef pset<CPT(GeomVertexFormat) > VFormats;
106  typedef pset<CPT(GeomVertexArrayData) > VADatas;
110 
111  LodMode _lod_mode;
112 
113  Nodes _nodes;
114  VDatas _vdatas;
115  VFormats _vformats;
116  VADatas _vadatas;
117  VADatas _prim_vadatas;
118  UniqueVDatas _unique_vdatas;
119  UniqueVADatas _unique_vadatas;
120  UniqueVADatas _unique_prim_vadatas;
121  Textures _textures;
122 
123 private:
124  int _num_nodes;
125  int _num_instances;
126  int _num_transforms;
127  int _num_nodes_with_attribs;
128  int _num_lod_nodes;
129  int _num_geom_nodes;
130  int _num_geoms;
131  int _num_geom_vertex_datas;
132  int _num_geom_vertex_formats;
133  size_t _vertex_data_size;
134  size_t _prim_data_size;
135 
136  int _num_vertices;
137  int _num_vertices_64;
138  int _num_normals;
139  int _num_colors;
140  int _num_texcoords;
141  int _num_tris;
142  int _num_lines;
143  int _num_points;
144  int _num_patches;
145 
146  int _num_individual_tris;
147  int _num_tristrips;
148  int _num_triangles_in_strips;
149  int _num_trifans;
150  int _num_triangles_in_fans;
151  int _num_vertices_in_patches;
152 
153  size_t _texture_bytes;
154 
155  int _num_long_normals;
156  int _num_short_normals;
157  PN_stdfloat _total_normal_length;
158 };
159 
160 #include "sceneGraphAnalyzer.I"
161 
162 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
Definition: texture.h:71
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A dynamic array with an unlimited number of bits.
Definition: bitArray.h:39
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A handy class that can scrub over a scene graph and collect interesting statistics on it.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
A container for geometry primitives.
Definition: geom.h:54
This class defines the physical layout of the vertex data stored within a Geom.
This is our own Panda specialization on the default STL set.
Definition: pset.h:49
A node that holds Geom objects, renderable pieces of geometry.
Definition: geomNode.h:34
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the data for one array of a GeomVertexData structure.