00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "geomVertexReader.h"
00016
00017
00018 #ifndef NDEBUG
00019
00020
00021 const unsigned char GeomVertexReader::empty_buffer[100] = { 0 };
00022 #endif
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 bool GeomVertexReader::
00038 set_column(int array, const GeomVertexColumn *column) {
00039 if (column == (const GeomVertexColumn *)NULL) {
00040
00041 _array = -1;
00042 _packer = NULL;
00043 _stride = 0;
00044 _pointer = NULL;
00045 _pointer_end = NULL;
00046
00047 return false;
00048 }
00049
00050 if (_vertex_data != (const GeomVertexData *)NULL) {
00051 GeomVertexDataPipelineReader reader(_vertex_data, _current_thread);
00052 reader.check_array_readers();
00053 return set_vertex_column(array, column, &reader);
00054 }
00055 if (_array_data != (const GeomVertexArrayData *)NULL) {
00056 return set_array_column(column);
00057 }
00058
00059
00060 return false;
00061 }
00062
00063
00064
00065
00066
00067
00068 void GeomVertexReader::
00069 output(ostream &out) const {
00070 const GeomVertexColumn *column = get_column();
00071 if (column == (GeomVertexColumn *)NULL) {
00072 out << "GeomVertexReader()";
00073
00074 } else {
00075 out << "GeomVertexReader, array = " << get_array_data()
00076 << ", column = " << column->get_name()
00077 << " (" << get_packer()->get_name()
00078 << "), read row " << get_read_row();
00079 }
00080 }
00081
00082
00083
00084
00085
00086
00087 void GeomVertexReader::
00088 initialize() {
00089 _array = 0;
00090 _packer = NULL;
00091 _pointer_begin = NULL;
00092 _pointer_end = NULL;
00093 _pointer = NULL;
00094 _start_row = 0;
00095 _force = true;
00096 }
00097
00098
00099
00100
00101
00102
00103
00104 bool GeomVertexReader::
00105 set_vertex_column(int array, const GeomVertexColumn *column,
00106 const GeomVertexDataPipelineReader *data_reader) {
00107 if (column == (const GeomVertexColumn *)NULL) {
00108 return set_column(0, NULL);
00109 }
00110
00111 nassertr(_vertex_data != (const GeomVertexData *)NULL, false);
00112
00113 #ifndef NDEBUG
00114 _array = -1;
00115 _packer = NULL;
00116 nassertr(array >= 0 && array < _vertex_data->get_num_arrays(), false);
00117 #endif
00118
00119 _array = array;
00120 _handle = data_reader->get_array_reader(_array);
00121 _stride = _handle->get_array_format()->get_stride();
00122
00123 _packer = column->_packer;
00124 return set_pointer(_start_row);
00125 }
00126
00127
00128
00129
00130
00131
00132
00133
00134 bool GeomVertexReader::
00135 set_array_column(const GeomVertexColumn *column) {
00136 if (column == (const GeomVertexColumn *)NULL) {
00137 return set_column(0, NULL);
00138 }
00139
00140 nassertr(_array_data != (const GeomVertexArrayData *)NULL, false);
00141
00142 _handle = _array_data->get_handle();
00143 _stride = _handle->get_array_format()->get_stride();
00144
00145 _packer = column->_packer;
00146 return set_pointer(_start_row);
00147 }