class GeomVertexReader

Bases: GeomEnums

This object provides a high-level interface for quickly reading a sequence of numeric values from a vertex table.

It is particularly optimized for reading a single column of data values for a series of vertices, without changing columns between each number. Although you can also use one GeomVertexReader to read across the columns if it is convenient, by calling set_column() repeatedly at each vertex, it is faster to read down the columns, and to use a different GeomVertexReader for each column.

Note that a GeomVertexReader does not keep a reference count to the actual vertex data buffer (it grabs the current data buffer from the GeomVertexData whenever set_column() is called). This means that it is important not to keep a GeomVertexReader object around over a long period of time in which the data buffer is likely to be deallocated; it is intended for making a quick pass over the data in one session.

It also means that you should create any GeomVertexWriters before creating GeomVertexReaders on the same data, since the writer itself might cause the vertex buffer to be deallocated. Better yet, use a GeomVertexRewriter if you are going to create both of them anyway.

Inheritance diagram

GeomVertexReader(Thread *current_thread = Thread::get_current_thread())
GeomVertexReader(GeomVertexData const *vertex_data, Thread *current_thread = Thread::get_current_thread())
GeomVertexReader(GeomVertexData const *vertex_data, CPT_InternalName name, Thread *current_thread = Thread::get_current_thread())
GeomVertexReader(GeomVertexArrayData const *array_data, Thread *current_thread = Thread::get_current_thread())
GeomVertexReader(GeomVertexArrayData const *array_data, int column, Thread *current_thread = Thread::get_current_thread())
GeomVertexReader(GeomVertexReader const &copy)

Constructs an invalid GeomVertexReader. You must use the assignment operator to assign a valid GeomVertexReader to this object before you can use it.

Constructs a new reader to process the vertices of the indicated data object.

Constructs a new reader to process the vertices of the indicated data object. This flavor creates the reader specifically to process the named data type.

Constructs a new reader to process the vertices of the indicated array only.

Constructs a new reader to process the vertices of the indicated array only.

Constructs a new reader to process the vertices of the indicated data object. This flavor creates the reader specifically to process the named data type.

void clear(void)

Resets the GeomVertexReader to the initial state.

int get_array(void) const

Returns the array index containing the data type that the reader is working on.

GeomVertexArrayData const *get_array_data(void) const

Returns the particular array object that the reader is currently processing.

GeomVertexArrayDataHandle const *get_array_handle(void) const

Returns the read handle to the array object that the read is currently processing. This low-level call should be used with caution.

GeomVertexColumn const *get_column(void) const

Returns the description of the data type that the reader is working on.

Thread *get_current_thread(void) const

Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this object.

PN_stdfloat get_data1(void)

Returns the data associated with the read row, expressed as a 1-component value, and advances the read row.

double get_data1d(void)

Returns the data associated with the read row, expressed as a 1-component value, and advances the read row.

float get_data1f(void)

Returns the data associated with the read row, expressed as a 1-component value, and advances the read row.

int get_data1i(void)

Returns the data associated with the read row, expressed as a 1-component value, and advances the read row.

LVecBase2 const &get_data2(void)

Returns the data associated with the read row, expressed as a 2-component value, and advances the read row.

LVecBase2d const &get_data2d(void)

Returns the data associated with the read row, expressed as a 2-component value, and advances the read row.

LVecBase2f const &get_data2f(void)

Returns the data associated with the read row, expressed as a 2-component value, and advances the read row.

LVecBase2i const &get_data2i(void)

Returns the data associated with the read row, expressed as a 2-component value, and advances the read row.

LVecBase3 const &get_data3(void)

Returns the data associated with the read row, expressed as a 3-component value, and advances the read row.

LVecBase3d const &get_data3d(void)

Returns the data associated with the read row, expressed as a 3-component value, and advances the read row.

LVecBase3f const &get_data3f(void)

Returns the data associated with the read row, expressed as a 3-component value, and advances the read row.

LVecBase3i const &get_data3i(void)

Returns the data associated with the read row, expressed as a 3-component value, and advances the read row.

LVecBase4 const &get_data4(void)

Returns the data associated with the read row, expressed as a 4-component value, and advances the read row.

LVecBase4d const &get_data4d(void)

Returns the data associated with the read row, expressed as a 4-component value, and advances the read row.

LVecBase4f const &get_data4f(void)

Returns the data associated with the read row, expressed as a 4-component value, and advances the read row.

LVecBase4i const &get_data4i(void)

Returns the data associated with the read row, expressed as a 4-component value, and advances the read row.

bool get_force(void) const

Returns the value of the force flag. See set_force().

LMatrix3 get_matrix3(void)

Returns the 3-by-3 matrix associated with the read row and advances the read row. This is a special method that only works when the column in question contains a matrix of an appropriate size.

LMatrix3d get_matrix3d(void)

Returns the 3-by-3 matrix associated with the read row and advances the read row. This is a special method that only works when the column in question contains a matrix of an appropriate size.

LMatrix3f get_matrix3f(void)

Returns the 3-by-3 matrix associated with the read row and advances the read row. This is a special method that only works when the column in question contains a matrix of an appropriate size.

LMatrix4 get_matrix4(void)

Returns the 4-by-4 matrix associated with the read row and advances the read row. This is a special method that only works when the column in question contains a matrix of an appropriate size.

LMatrix4d get_matrix4d(void)

Returns the 4-by-4 matrix associated with the read row and advances the read row. This is a special method that only works when the column in question contains a matrix of an appropriate size.

LMatrix4f get_matrix4f(void)

Returns the 4-by-4 matrix associated with the read row and advances the read row. This is a special method that only works when the column in question contains a matrix of an appropriate size.

int get_read_row(void) const

Returns the row index from which the data will be retrieved by the next call to get_data*().

int get_start_row(void) const

Returns the row index at which the reader started. It will return to this row if you reset the current column.

std::size_t get_stride(void) const

Returns the per-row stride (bytes between consecutive rows) of the underlying vertex array. This low-level information is normally not needed to use the GeomVertexReader directly.

GeomVertexData const *get_vertex_data(void) const

Returns the vertex data object that the reader is processing. This may return NULL if the reader was constructed with just an array pointer.

bool has_column(void) const

Returns true if a valid data type has been successfully set, or false if the data type does not exist (or if get_force() is false and the vertex data is nonresident).

bool is_at_end(void) const

Returns true if the reader is currently at the end of the list of vertices, false otherwise. If this is true, another call to get_data*() will result in a crash.

void output(std::ostream &out) const
bool set_column(int column)
bool set_column(CPT_InternalName name)
bool set_column(int array, GeomVertexColumn const *column)

Sets up the reader to use the nth data type of the GeomVertexFormat, numbering from 0.

This also resets the read row number to the start row (the same value passed to a previous call to set_row(), or 0 if set_row() was never called.)

The return value is true if the data type is valid, false otherwise.

Sets up the reader to use the data type with the indicated name.

This also resets the read row number to the start row (the same value passed to a previous call to set_row(), or 0 if set_row() was never called.)

The return value is true if the data type is valid, false otherwise.

Sets up the reader to use the indicated column description on the given array.

This also resets the current read row number to the start row (the same value passed to a previous call to set_row(), or 0 if set_row() was never called.)

The return value is true if the data type is valid, false otherwise.

void set_force(bool force)

Sets the value of the force flag. When this is true (the default), vertex data will be paged in from disk if necessary. When this is false, the GeomVertexData will simply return a failure code when attempting to read vertex data that is not resident (but will put it on the queue to become resident later).

Normally, vertex data is always resident, so this will not be an issue. It is only possible for vertex data to be nonresident if you have enabled vertex paging via the GeomVertexArrayData and VertexDataPage interfaces.

void set_row(int row)

Sets the start row to the indicated value. The reader will begin reading from the indicated row; each subsequent get_data*() call will return the data from the subsequent row. If set_column() is called, the reader will return to this row.

void set_row_unsafe(int row)

Sets the start row to the indicated value, without internal checks. This is the same as set_row(), but it does not check for the possibility that the array has been reallocated internally for some reason; use only when you are confident that the array is unchanged and you really need every bit of available performance.