Panda3D
|
This object provides a high-level interface for quickly reading a sequence of numeric values from a vertex table. More...
#include "geomVertexReader.h"
Public Member Functions | |
GeomVertexReader (Thread *current_thread=Thread::get_current_thread()) | |
Constructs an invalid GeomVertexReader. | |
GeomVertexReader (const GeomVertexData *vertex_data, Thread *current_thread=Thread::get_current_thread()) | |
Constructs a new reader to process the vertices of the indicated data object. | |
GeomVertexReader (const GeomVertexData *vertex_data, const InternalName *name, Thread *current_thread=Thread::get_current_thread()) | |
Constructs a new reader to process the vertices of the indicated data object. | |
GeomVertexReader (const GeomVertexReader ©) | |
GeomVertexReader (const GeomVertexArrayData *array_data, Thread *current_thread=Thread::get_current_thread()) | |
Constructs a new reader to process the vertices of the indicated array only. | |
GeomVertexReader (const GeomVertexData *vertex_data, const string &name, Thread *current_thread=Thread::get_current_thread()) | |
Constructs a new reader to process the vertices of the indicated data object. | |
GeomVertexReader (const GeomVertexArrayData *array_data, int column, Thread *current_thread=Thread::get_current_thread()) | |
Constructs a new reader to process the vertices of the indicated array only. | |
GeomVertexReader (const GeomVertexDataPipelineReader *data_reader, const InternalName *name, bool force=true) | |
Constructs a new reader to process the vertices of the indicated data object. | |
void | clear () |
Resets the GeomVertexReader to the initial state. | |
int | get_array () const |
Returns the array index containing the data type that the reader is working on. | |
const GeomVertexArrayData * | get_array_data () const |
Returns the particular array object that the reader is currently processing. | |
const GeomVertexColumn * | get_column () const |
Returns the description of the data type that the reader is working on. | |
Thread * | get_current_thread () const |
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this object. | |
float | get_data1f () |
Returns the data associated with the read row, expressed as a 1-component value, and advances the read row. | |
int | get_data1i () |
Returns the data associated with the read row, expressed as a 1-component value, and advances the read row. | |
const LVecBase2f & | get_data2f () |
Returns the data associated with the read row, expressed as a 2-component value, and advances the read row. | |
const int * | get_data2i () |
Returns the data associated with the read row, expressed as a 2-component value, and advances the read row. | |
const LVecBase3f & | get_data3f () |
Returns the data associated with the read row, expressed as a 3-component value, and advances the read row. | |
const int * | get_data3i () |
Returns the data associated with the read row, expressed as a 3-component value, and advances the read row. | |
const LVecBase4f & | get_data4f () |
Returns the data associated with the read row, expressed as a 4-component value, and advances the read row. | |
const int * | get_data4i () |
Returns the data associated with the read row, expressed as a 4-component value, and advances the read row. | |
bool | get_force () const |
Returns the value of the force flag. | |
int | get_read_row () const |
Returns the row index from which the data will be retrieved by the next call to get_data*(). | |
int | get_start_row () const |
Returns the row index at which the reader started. | |
const GeomVertexData * | get_vertex_data () const |
Returns the vertex data object that the reader is processing. | |
bool | has_column () 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 () const |
Returns true if the reader is currently at the end of the list of vertices, false otherwise. | |
void | operator= (const GeomVertexReader ©) |
void | output (ostream &out) const |
bool | set_column (const InternalName *name) |
Sets up the reader to use the data type with the indicated name. | |
bool | set_column (int column) |
Sets up the reader to use the nth data type of the GeomVertexFormat, numbering from 0. | |
bool | set_column (const string &name) |
Sets up the reader to use the data type with the indicated name. | |
bool | set_column (int array, const GeomVertexColumn *column) |
Sets up the reader to use the indicated column description on the given array. | |
void | set_force (bool force) |
Sets the value of the force flag. | |
void | set_row (int row) |
Sets the start row to the indicated value. | |
Protected Member Functions | |
GeomVertexColumn::Packer * | get_packer () const |
Returns the reader's Packer object. |
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.
Definition at line 56 of file geomVertexReader.h.
GeomVertexReader::GeomVertexReader | ( | Thread * | current_thread = Thread::get_current_thread() | ) | [inline] |
Constructs an invalid GeomVertexReader.
You must use the assignment operator to assign a valid GeomVertexReader to this object before you can use it.
Definition at line 25 of file geomVertexReader.I.
Referenced by clear().
GeomVertexReader::GeomVertexReader | ( | const GeomVertexData * | vertex_data, |
Thread * | current_thread = Thread::get_current_thread() |
||
) | [inline] |
Constructs a new reader to process the vertices of the indicated data object.
Definition at line 39 of file geomVertexReader.I.
GeomVertexReader::GeomVertexReader | ( | const GeomVertexData * | vertex_data, |
const string & | name, | ||
Thread * | current_thread = Thread::get_current_thread() |
||
) | [inline] |
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.
Definition at line 55 of file geomVertexReader.I.
References set_column().
GeomVertexReader::GeomVertexReader | ( | const GeomVertexData * | vertex_data, |
const InternalName * | name, | ||
Thread * | current_thread = Thread::get_current_thread() |
||
) | [inline] |
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.
Definition at line 72 of file geomVertexReader.I.
References set_column().
GeomVertexReader::GeomVertexReader | ( | const GeomVertexArrayData * | array_data, |
Thread * | current_thread = Thread::get_current_thread() |
||
) | [inline] |
Constructs a new reader to process the vertices of the indicated array only.
Definition at line 89 of file geomVertexReader.I.
GeomVertexReader::GeomVertexReader | ( | const GeomVertexArrayData * | array_data, |
int | column, | ||
Thread * | current_thread = Thread::get_current_thread() |
||
) | [inline] |
Constructs a new reader to process the vertices of the indicated array only.
Definition at line 104 of file geomVertexReader.I.
References set_column().
GeomVertexReader::GeomVertexReader | ( | const GeomVertexDataPipelineReader * | data_reader, |
const InternalName * | name, | ||
bool | force = true |
||
) | [inline] |
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.
Definition at line 121 of file geomVertexReader.I.
References GeomVertexFormat::get_array_with(), and GeomVertexFormat::get_column().
void GeomVertexReader::clear | ( | ) | [inline] |
Resets the GeomVertexReader to the initial state.
Reimplemented in GeomVertexRewriter.
Definition at line 335 of file geomVertexReader.I.
References GeomVertexReader().
int GeomVertexReader::get_array | ( | ) | const [inline] |
Returns the array index containing the data type that the reader is working on.
Reimplemented in GeomVertexRewriter.
Definition at line 359 of file geomVertexReader.I.
Referenced by GeomVertexRewriter::get_array().
const GeomVertexArrayData * GeomVertexReader::get_array_data | ( | ) | const [inline] |
Returns the particular array object that the reader is currently processing.
Reimplemented in GeomVertexRewriter.
Definition at line 205 of file geomVertexReader.I.
Referenced by GeomVertexRewriter::get_array_data().
const GeomVertexColumn * GeomVertexReader::get_column | ( | ) | const [inline] |
Returns the description of the data type that the reader is working on.
Reimplemented in GeomVertexRewriter.
Definition at line 370 of file geomVertexReader.I.
Referenced by GeomVertexRewriter::get_column(), and GeomVertexRewriter::has_column().
Thread * GeomVertexReader::get_current_thread | ( | ) | const [inline] |
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this object.
Definition at line 216 of file geomVertexReader.I.
float GeomVertexReader::get_data1f | ( | ) | [inline] |
Returns the data associated with the read row, expressed as a 1-component value, and advances the read row.
Definition at line 438 of file geomVertexReader.I.
References has_column().
int GeomVertexReader::get_data1i | ( | ) | [inline] |
Returns the data associated with the read row, expressed as a 1-component value, and advances the read row.
Definition at line 490 of file geomVertexReader.I.
References has_column().
Referenced by GeomTristrips::append_unused_vertices(), GeomPrimitive::calc_tight_bounds(), GeomVertexData::copy_from(), GeomVertexData::describe_vertex(), GeomPrimitive::get_primitive_max_vertex(), GeomPrimitive::get_primitive_min_vertex(), and GeomPrimitive::offset_vertices().
const LVecBase2f & GeomVertexReader::get_data2f | ( | ) | [inline] |
Returns the data associated with the read row, expressed as a 2-component value, and advances the read row.
Definition at line 451 of file geomVertexReader.I.
References has_column(), and LVecBase2f::zero().
Referenced by MeshDrawer::geometry(), PhysxSoftBodyNode::set_from_geom(), and PhysxClothMeshDesc::set_from_node_path().
const int * GeomVertexReader::get_data2i | ( | ) | [inline] |
Returns the data associated with the read row, expressed as a 2-component value, and advances the read row.
Definition at line 503 of file geomVertexReader.I.
References has_column().
const LVecBase3f & GeomVertexReader::get_data3f | ( | ) | [inline] |
Returns the data associated with the read row, expressed as a 3-component value, and advances the read row.
Definition at line 464 of file geomVertexReader.I.
References has_column(), and LVecBase3f::zero().
Referenced by TinyGraphicsStateGuardian::begin_draw_primitives(), GeomPrimitive::calc_tight_bounds(), MeshDrawer::geometry(), LineSegs::get_vertex(), PhysxSoftBodyNode::set_from_geom(), PhysxTriangleMeshDesc::set_from_node_path(), PhysxConvexMeshDesc::set_from_node_path(), and PhysxClothMeshDesc::set_from_node_path().
const int * GeomVertexReader::get_data3i | ( | ) | [inline] |
Returns the data associated with the read row, expressed as a 3-component value, and advances the read row.
Definition at line 516 of file geomVertexReader.I.
References has_column().
const LVecBase4f & GeomVertexReader::get_data4f | ( | ) | [inline] |
Returns the data associated with the read row, expressed as a 4-component value, and advances the read row.
Definition at line 477 of file geomVertexReader.I.
References has_column(), and LVecBase4f::zero().
Referenced by TinyGraphicsStateGuardian::begin_draw_primitives(), GeomVertexData::copy_from(), GeomVertexData::describe_vertex(), LineSegs::get_vertex_color(), and GeomTransformer::transform_texcoords().
const int * GeomVertexReader::get_data4i | ( | ) | [inline] |
Returns the data associated with the read row, expressed as a 4-component value, and advances the read row.
Definition at line 529 of file geomVertexReader.I.
References has_column().
bool GeomVertexReader::get_force | ( | ) | const [inline] |
Returns the value of the force flag.
See set_force().
Definition at line 248 of file geomVertexReader.I.
GeomVertexColumn::Packer * GeomVertexReader::get_packer | ( | ) | const [inline, protected] |
Returns the reader's Packer object.
Definition at line 540 of file geomVertexReader.I.
int GeomVertexReader::get_read_row | ( | ) | const [inline] |
Returns the row index from which the data will be retrieved by the next call to get_data*().
Definition at line 413 of file geomVertexReader.I.
int GeomVertexReader::get_start_row | ( | ) | const [inline] |
Returns the row index at which the reader started.
It will return to this row if you reset the current column.
Reimplemented in GeomVertexRewriter.
Definition at line 402 of file geomVertexReader.I.
Referenced by GeomVertexRewriter::get_start_row().
const GeomVertexData * GeomVertexReader::get_vertex_data | ( | ) | const [inline] |
Returns the vertex data object that the reader is processing.
This may return NULL if the reader was constructed with just an array pointer.
Reimplemented in GeomVertexRewriter.
Definition at line 194 of file geomVertexReader.I.
Referenced by GeomVertexRewriter::get_vertex_data().
bool GeomVertexReader::has_column | ( | ) | const [inline] |
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).
Reimplemented in GeomVertexRewriter.
Definition at line 348 of file geomVertexReader.I.
Referenced by TinyGraphicsStateGuardian::begin_draw_primitives(), GeomPrimitive::calc_tight_bounds(), get_data1f(), get_data1i(), get_data2f(), get_data2i(), get_data3f(), get_data3i(), get_data4f(), get_data4i(), and set_row().
bool GeomVertexReader::is_at_end | ( | ) | const [inline] |
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.
Reimplemented in GeomVertexRewriter.
Definition at line 426 of file geomVertexReader.I.
Referenced by GeomVertexData::copy_from(), PhysxSoftBodyNode::set_from_geom(), PhysxTriangleMeshDesc::set_from_node_path(), PhysxConvexMeshDesc::set_from_node_path(), PhysxClothMeshDesc::set_from_node_path(), and GeomTransformer::transform_texcoords().
bool GeomVertexReader::set_column | ( | int | column | ) | [inline] |
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.
Reimplemented in GeomVertexRewriter.
Definition at line 266 of file geomVertexReader.I.
References GeomVertexFormat::get_array_with(), and GeomVertexFormat::get_column().
Referenced by GeomVertexData::copy_from(), GeomVertexData::describe_vertex(), GeomVertexReader(), and set_column().
bool GeomVertexReader::set_column | ( | int | array, |
const GeomVertexColumn * | column | ||
) |
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.
Reimplemented in GeomVertexRewriter.
Definition at line 38 of file geomVertexReader.cxx.
bool GeomVertexReader::set_column | ( | const InternalName * | name | ) | [inline] |
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.
Reimplemented in GeomVertexRewriter.
Definition at line 313 of file geomVertexReader.I.
References GeomVertexFormat::get_array_with(), and GeomVertexFormat::get_column().
bool GeomVertexReader::set_column | ( | const string & | name | ) | [inline] |
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.
Reimplemented in GeomVertexRewriter.
Definition at line 295 of file geomVertexReader.I.
References set_column().
void GeomVertexReader::set_force | ( | bool | force | ) | [inline] |
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.
Definition at line 237 of file geomVertexReader.I.
void GeomVertexReader::set_row | ( | int | row | ) | [inline] |
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.
Reimplemented in GeomVertexRewriter.
Definition at line 387 of file geomVertexReader.I.
References has_column().
Referenced by GeomTristrips::append_unused_vertices(), TinyGraphicsStateGuardian::begin_draw_primitives(), GeomPrimitive::calc_tight_bounds(), GeomVertexData::describe_vertex(), MeshDrawer::geometry(), GeomPrimitive::get_primitive_max_vertex(), GeomPrimitive::get_primitive_min_vertex(), LineSegs::get_vertex(), GeomPrimitivePipelineReader::get_vertex(), and LineSegs::get_vertex_color().