Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/builder/builderBucketNode.cxx

Go to the documentation of this file.
00001 // Filename: builderBucketNode.cxx
00002 // Created by:  drose (10Sep97)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "builderFuncs.h"
00020 #include "builderBucketNode.h"
00021 
00022 #include "geomNode.h"
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //     Function: BuilderBucketNode::add_prim
00026 //       Access: Public
00027 //  Description: Adds the indicated indexed primitive to the
00028 //               bucket, and returns true if the primitive was valid.
00029 //               Intended to be called from Builder::add_prim().
00030 ////////////////////////////////////////////////////////////////////
00031 bool BuilderBucketNode::
00032 add_prim(BuilderPrim prim) {
00033   prim.flatten_vertex_properties();
00034   bool result = expand(prim, *_bucket, inserter(_prims, _prims.begin()));
00035   return result;
00036 }
00037 
00038 
00039 ////////////////////////////////////////////////////////////////////
00040 //     Function: BuilderBucketNode::add_prim
00041 //       Access: Public
00042 //  Description: Adds the indicated nonindexed primitive to the
00043 //               bucket, and returns true if the primitive was valid.
00044 //               Intended to be called from Builder::add_prim().
00045 ////////////////////////////////////////////////////////////////////
00046 bool BuilderBucketNode::
00047 add_prim(const BuilderPrimI &prim) {
00048   bool result = expand(prim, *_bucket, inserter(_iprims, _iprims.begin()));
00049   return result;
00050 }
00051 
00052 
00053 ////////////////////////////////////////////////////////////////////
00054 //     Function: BuilderBucketNode::build
00055 //       Access: Public
00056 //  Description: Builds all the geometry assigned to this particular
00057 //               bucket, and assigns it to the indicated GeomNode.
00058 //               Returns the number of Geoms created.
00059 ////////////////////////////////////////////////////////////////////
00060 int BuilderBucketNode::
00061 build(GeomNode *geom_node) const {
00062   int count = 0;
00063 
00064   {
00065     // First, the nonindexed.
00066     Prims::const_iterator pi, last_pi;
00067     last_pi = _prims.begin();
00068 
00069     for (pi = _prims.begin();
00070          pi != _prims.end();
00071          ++pi) {
00072       if ((*last_pi) < (*pi)) {
00073         count += mesh_and_build(last_pi, pi, *_bucket, geom_node,
00074                                 (BuilderPrim *)0);
00075         last_pi = pi;
00076       }
00077     }
00078     count += mesh_and_build(last_pi, pi, *_bucket, geom_node,
00079                             (BuilderPrim *)0);
00080   }
00081 
00082   {
00083     // Then, the indexed.
00084     IPrims::const_iterator pi, last_pi;
00085     last_pi = _iprims.begin();
00086 
00087     for (pi = _iprims.begin();
00088          pi != _iprims.end();
00089          ++pi) {
00090       if ((*last_pi) < (*pi)) {
00091         count += mesh_and_build(last_pi, pi, *_bucket, geom_node,
00092                                 (BuilderPrimI *)0);
00093         last_pi = pi;
00094       }
00095     }
00096     count += mesh_and_build(last_pi, pi, *_bucket, geom_node,
00097                             (BuilderPrimI *)0);
00098   }
00099 
00100   return count;
00101 }
00102 

Generated on Fri May 2 00:34:41 2003 for Panda by doxygen1.3