Panda3D
|
00001 // Filename: geomVertexArrayFormat.I 00002 // Created by: drose (06Mar05) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: GeomVertexArrayFormat::is_registered 00018 // Access: Published 00019 // Description: Returns true if this format has been registered, 00020 // false if it has not. It may not be used for a Geom 00021 // until it has been registered, but once registered, it 00022 // may no longer be modified. 00023 //////////////////////////////////////////////////////////////////// 00024 INLINE bool GeomVertexArrayFormat:: 00025 is_registered() const { 00026 return _is_registered; 00027 } 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Function: GeomVertexArrayFormat::register_format 00031 // Access: Published, Static 00032 // Description: Adds the indicated format to the registry, if there 00033 // is not an equivalent format already there; in either 00034 // case, returns the pointer to the equivalent format 00035 // now in the registry. 00036 // 00037 // This is similar to 00038 // GeomVertexFormat::register_format(), except that you 00039 // generally need not call it explicitly. Calling 00040 // GeomVertexFormat::register_format() automatically 00041 // registers all of the nested array formats. 00042 //////////////////////////////////////////////////////////////////// 00043 INLINE CPT(GeomVertexArrayFormat) GeomVertexArrayFormat:: 00044 register_format(const GeomVertexArrayFormat *format) { 00045 return get_registry()->register_format((GeomVertexArrayFormat *)format); 00046 } 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Function: GeomVertexArrayFormat::get_stride 00050 // Access: Published 00051 // Description: Returns the total number of bytes reserved in the 00052 // array for each vertex. 00053 //////////////////////////////////////////////////////////////////// 00054 INLINE int GeomVertexArrayFormat:: 00055 get_stride() const { 00056 return _stride; 00057 } 00058 00059 //////////////////////////////////////////////////////////////////// 00060 // Function: GeomVertexArrayFormat::set_stride 00061 // Access: Published 00062 // Description: Changes the total number of bytes reserved in the 00063 // array for each vertex. 00064 //////////////////////////////////////////////////////////////////// 00065 INLINE void GeomVertexArrayFormat:: 00066 set_stride(int stride) { 00067 nassertv(!_is_registered); 00068 _stride = stride; 00069 } 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: GeomVertexArrayFormat::get_total_bytes 00073 // Access: Published 00074 // Description: Returns the total number of bytes used by the data 00075 // types within the format, including gaps between 00076 // elements. 00077 //////////////////////////////////////////////////////////////////// 00078 INLINE int GeomVertexArrayFormat:: 00079 get_total_bytes() const { 00080 return _total_bytes; 00081 } 00082 00083 //////////////////////////////////////////////////////////////////// 00084 // Function: GeomVertexArrayFormat::get_pad_to 00085 // Access: Published 00086 // Description: Returns the byte divisor to which the data record 00087 // must be padded to meet hardware limitations. For 00088 // instance, if this is 4, the stride will be 00089 // automatically rounded up to the next multiple of 4 00090 // bytes. 00091 //////////////////////////////////////////////////////////////////// 00092 INLINE int GeomVertexArrayFormat:: 00093 get_pad_to() const { 00094 return _pad_to; 00095 } 00096 00097 //////////////////////////////////////////////////////////////////// 00098 // Function: GeomVertexArrayFormat::get_num_columns 00099 // Access: Published 00100 // Description: Returns the number of different columns in the 00101 // array. 00102 //////////////////////////////////////////////////////////////////// 00103 INLINE int GeomVertexArrayFormat:: 00104 get_num_columns() const { 00105 return (int)_columns.size(); 00106 } 00107 00108 //////////////////////////////////////////////////////////////////// 00109 // Function: GeomVertexArrayFormat::get_column 00110 // Access: Published 00111 // Description: Returns the ith column of the array. 00112 //////////////////////////////////////////////////////////////////// 00113 INLINE const GeomVertexColumn *GeomVertexArrayFormat:: 00114 get_column(int i) const { 00115 nassertr(i >= 0 && i < (int)_columns.size(), NULL); 00116 consider_sort_columns(); 00117 return _columns[i]; 00118 } 00119 00120 //////////////////////////////////////////////////////////////////// 00121 // Function: GeomVertexArrayFormat::has_column 00122 // Access: Published 00123 // Description: Returns true if the array has the named column, 00124 // false otherwise. 00125 //////////////////////////////////////////////////////////////////// 00126 INLINE bool GeomVertexArrayFormat:: 00127 has_column(const InternalName *name) const { 00128 return (get_column(name) != (GeomVertexColumn *)NULL); 00129 } 00130 00131 //////////////////////////////////////////////////////////////////// 00132 // Function: GeomVertexArrayFormat::get_registry 00133 // Access: Private 00134 // Description: Returns the global registry object. 00135 //////////////////////////////////////////////////////////////////// 00136 INLINE GeomVertexArrayFormat::Registry *GeomVertexArrayFormat:: 00137 get_registry() { 00138 if (_registry == (Registry *)NULL) { 00139 make_registry(); 00140 } 00141 return _registry; 00142 } 00143 00144 //////////////////////////////////////////////////////////////////// 00145 // Function: GeomVertexArrayFormat::consider_sort_columns 00146 // Access: Private 00147 // Description: Resorts the _columns vector if necessary. 00148 //////////////////////////////////////////////////////////////////// 00149 INLINE void GeomVertexArrayFormat:: 00150 consider_sort_columns() const { 00151 if (_columns_unsorted) { 00152 ((GeomVertexArrayFormat *)this)->sort_columns(); 00153 } 00154 } 00155 00156 INLINE ostream & 00157 operator << (ostream &out, const GeomVertexArrayFormat &obj) { 00158 obj.output(out); 00159 return out; 00160 }