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

panda/src/builder/builderProperties.cxx

Go to the documentation of this file.
00001 // Filename: builderProperties.cxx
00002 // Created by:  drose (17Sep97)
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 "builderProperties.h"
00020 
00021 ////////////////////////////////////////////////////////////////////
00022 //     Function: BuilderProperties::Ordering operator
00023 //       Access: Public
00024 //  Description: Defines an arbitrary ordering among different
00025 //               properties, and groups identical sets of properties
00026 //               together.  This operator is used for the more
00027 //               important task of grouping BuilderBuckets together;
00028 //               see the comments for the similar function in
00029 //               builderBucket.cxx.
00030 ////////////////////////////////////////////////////////////////////
00031 bool BuilderProperties::
00032 operator < (const BuilderProperties &other) const {
00033   int sv1 = sort_value();
00034   int sv2 = other.sort_value();
00035 
00036   if (sv1 != sv2) {
00037     return sv1 < sv2;
00038   }
00039 
00040   if (_coplanar_threshold != other._coplanar_threshold) {
00041     return _coplanar_threshold < other._coplanar_threshold;
00042   }
00043 
00044   if (_max_tfan_angle != other._max_tfan_angle) {
00045     return _max_tfan_angle < other._max_tfan_angle;
00046   }
00047 
00048   if (_min_tfan_tris != other._min_tfan_tris) {
00049     return _min_tfan_tris < other._min_tfan_tris;
00050   }
00051 
00052   if (_show_normals) {
00053     if (_normal_scale != other._normal_scale) {
00054       return _normal_scale < other._normal_scale;
00055     }
00056     if (_normal_color != other._normal_color) {
00057       return _normal_color < other._normal_color;
00058     }
00059   }
00060 
00061   return false;
00062 }
00063 
00064 
00065 ////////////////////////////////////////////////////////////////////
00066 //     Function: BuilderPrimTempl::output
00067 //       Access: Public
00068 //  Description: Outputs the properties meaningfully.
00069 ////////////////////////////////////////////////////////////////////
00070 void BuilderProperties::
00071 output(ostream &out) const {
00072   if (_mesh) {
00073     out << "T-Mesh using Mesher\n";
00074 
00075     if (_show_tstrips) {
00076       out << "Color individual tristrips\n";
00077     } else if (_show_qsheets) {
00078       out << "Color individual quadsheets\n";
00079     } else if (_show_quads) {
00080       out << "Color individual quads\n";
00081     }
00082     if (_retesselate_coplanar) {
00083       out << "Retesselate coplanar triangles when needed; threshold = "
00084           << _coplanar_threshold << "\n";
00085     }
00086   }
00087   if (_subdivide_polys) {
00088     out << "Subdivide polygons into tris.\n";
00089   }
00090   if (_consider_fans) {
00091     out << "Look for possible triangle fans with max per-triangle angle of "
00092         << _max_tfan_angle << " degrees.\n";
00093     if (_min_tfan_tris==0) {
00094       out << "Do not create tfans";
00095     } else {
00096       out << "Do not create tfans smaller than " << _min_tfan_tris << " tris";
00097     }
00098     if (_unroll_fans) {
00099       out << "; retesselate to tstrips.\n";
00100     } else {
00101       out << ".\n";
00102     }
00103   }
00104 }
00105 
00106 
00107 
00108 ////////////////////////////////////////////////////////////////////
00109 //     Function: BuilderPrimTempl::sort_value
00110 //       Access: Protected
00111 //  Description: Returns a number for grouping properties.  This is
00112 //               used as a helper function to the ordering operator,
00113 //               above.  It simply collects all the booleans together
00114 //               into a single number.
00115 ////////////////////////////////////////////////////////////////////
00116 int BuilderProperties::
00117 sort_value() const {
00118   return
00119     ((_mesh!=0) << 8) |
00120     ((_show_tstrips!=0) << 7) |
00121     ((_show_qsheets!=0) << 6) |
00122     ((_show_quads!=0) << 5) |
00123     ((_show_normals!=0) << 4) |
00124     ((_retesselate_coplanar!=0) << 3) |
00125     ((_unroll_fans!=0) << 2) |
00126     ((_subdivide_polys!=0) << 1) |
00127     ((_consider_fans!=0) << 0);
00128 }

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