00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef SCENEGRAPHREDUCER_H
00020 #define SCENEGRAPHREDUCER_H
00021
00022 #include "pandabase.h"
00023 #include "transformState.h"
00024 #include "renderAttrib.h"
00025 #include "renderState.h"
00026 #include "accumulatedAttribs.h"
00027 #include "geomTransformer.h"
00028
00029 #include "typedObject.h"
00030 #include "pointerTo.h"
00031
00032 class PandaNode;
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 class EXPCL_PANDA SceneGraphReducer {
00046 PUBLISHED:
00047 INLINE SceneGraphReducer();
00048 INLINE ~SceneGraphReducer();
00049
00050 enum AttribTypes {
00051 TT_transform = 0x001,
00052 TT_color = 0x002,
00053 TT_color_scale = 0x004,
00054 TT_tex_matrix = 0x008,
00055 TT_other = 0x010,
00056 };
00057
00058 INLINE void apply_attribs(PandaNode *node, int attrib_types = ~0);
00059 INLINE void apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs,
00060 int attrib_types, GeomTransformer &transformer);
00061
00062 int flatten(PandaNode *root, bool combine_siblings);
00063
00064 protected:
00065 void r_apply_attribs(PandaNode *node, const AccumulatedAttribs &attribs,
00066 int attrib_types, GeomTransformer &transformer);
00067
00068 int r_flatten(PandaNode *grandparent_node, PandaNode *parent_node,
00069 bool combine_siblings);
00070 int flatten_siblings(PandaNode *parent_node);
00071
00072 bool consider_child(PandaNode *grandparent_node,
00073 PandaNode *parent_node, PandaNode *child_node);
00074 bool consider_siblings(PandaNode *parent_node, PandaNode *child1,
00075 PandaNode *child2);
00076
00077 bool do_flatten_child(PandaNode *grandparent_node,
00078 PandaNode *parent_node, PandaNode *child_node);
00079
00080 PandaNode *do_flatten_siblings(PandaNode *parent_node,
00081 PandaNode *child1, PandaNode *child2);
00082
00083 PT(PandaNode) collapse_nodes(PandaNode *node1, PandaNode *node2,
00084 bool siblings);
00085 void choose_name(PandaNode *preserve, PandaNode *source1,
00086 PandaNode *source2);
00087
00088 private:
00089 GeomTransformer _transformer;
00090 };
00091
00092 #include "sceneGraphReducer.I"
00093
00094 #endif