Panda3D
Public Member Functions | List of all members
GeomVertexReader Class Reference

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

Inheritance diagram for GeomVertexReader:
GeomEnums GeomVertexRewriter

Public Member Functions

 __init__ (const GeomVertexArrayData array_data, Thread current_thread)
 Constructs a new reader to process the vertices of the indicated array only. More...
 
 __init__ (const GeomVertexArrayData array_data, int column, Thread current_thread)
 Constructs a new reader to process the vertices of the indicated array only. More...
 
 __init__ (const GeomVertexData vertex_data, const InternalName name, Thread current_thread)
 Constructs a new reader to process the vertices of the indicated data object. More...
 
 __init__ (const GeomVertexData vertex_data, Thread current_thread)
 Constructs a new reader to process the vertices of the indicated data object. More...
 
 __init__ (const GeomVertexReader copy)
 
 __init__ (Thread current_thread)
 Constructs an invalid GeomVertexReader. More...
 
 clear ()
 Resets the GeomVertexReader to the initial state. More...
 
int getArray ()
 Returns the array index containing the data type that the reader is working on. More...
 
const GeomVertexArrayData getArrayData ()
 Returns the particular array object that the reader is currently processing. More...
 
const GeomVertexArrayDataHandle getArrayHandle ()
 Returns the read handle to the array object that the read is currently processing. More...
 
const GeomVertexColumn getColumn ()
 Returns the description of the data type that the reader is working on. More...
 
Thread getCurrentThread ()
 Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this object. More...
 
float getData1 ()
 Returns the data associated with the read row, expressed as a 1-component value, and advances the read row. More...
 
double getData1d ()
 Returns the data associated with the read row, expressed as a 1-component value, and advances the read row. More...
 
float getData1f ()
 Returns the data associated with the read row, expressed as a 1-component value, and advances the read row. More...
 
int getData1i ()
 Returns the data associated with the read row, expressed as a 1-component value, and advances the read row. More...
 
const LVecBase2 getData2 ()
 Returns the data associated with the read row, expressed as a 2-component value, and advances the read row. More...
 
const LVecBase2d getData2d ()
 Returns the data associated with the read row, expressed as a 2-component value, and advances the read row. More...
 
const LVecBase2f getData2f ()
 Returns the data associated with the read row, expressed as a 2-component value, and advances the read row. More...
 
const LVecBase2i getData2i ()
 Returns the data associated with the read row, expressed as a 2-component value, and advances the read row. More...
 
const LVecBase3 getData3 ()
 Returns the data associated with the read row, expressed as a 3-component value, and advances the read row. More...
 
const LVecBase3d getData3d ()
 Returns the data associated with the read row, expressed as a 3-component value, and advances the read row. More...
 
const LVecBase3f getData3f ()
 Returns the data associated with the read row, expressed as a 3-component value, and advances the read row. More...
 
const LVecBase3i getData3i ()
 Returns the data associated with the read row, expressed as a 3-component value, and advances the read row. More...
 
const LVecBase4 getData4 ()
 Returns the data associated with the read row, expressed as a 4-component value, and advances the read row. More...
 
const LVecBase4d getData4d ()
 Returns the data associated with the read row, expressed as a 4-component value, and advances the read row. More...
 
const LVecBase4f getData4f ()
 Returns the data associated with the read row, expressed as a 4-component value, and advances the read row. More...
 
const LVecBase4i getData4i ()
 Returns the data associated with the read row, expressed as a 4-component value, and advances the read row. More...
 
bool getForce ()
 Returns the value of the force flag. More...
 
LMatrix3 getMatrix3 ()
 Returns the 3-by-3 matrix associated with the read row and advances the read row. More...
 
LMatrix3d getMatrix3d ()
 Returns the 3-by-3 matrix associated with the read row and advances the read row. More...
 
LMatrix3f getMatrix3f ()
 Returns the 3-by-3 matrix associated with the read row and advances the read row. More...
 
LMatrix4 getMatrix4 ()
 Returns the 4-by-4 matrix associated with the read row and advances the read row. More...
 
LMatrix4d getMatrix4d ()
 Returns the 4-by-4 matrix associated with the read row and advances the read row. More...
 
LMatrix4f getMatrix4f ()
 Returns the 4-by-4 matrix associated with the read row and advances the read row. More...
 
int getReadRow ()
 Returns the row index from which the data will be retrieved by the next call to get_data*(). More...
 
int getStartRow ()
 Returns the row index at which the reader started. More...
 
int getStride ()
 Returns the per-row stride (bytes between consecutive rows) of the underlying vertex array. More...
 
const GeomVertexData getVertexData ()
 Returns the vertex data object that the reader is processing. More...
 
bool hasColumn ()
 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). More...
 
bool isAtEnd ()
 Returns true if the reader is currently at the end of the list of vertices, false otherwise. More...
 
GeomVertexReader operator= (const GeomVertexReader copy)
 
 output (Ostream out)
 
bool setColumn (const InternalName name)
 Sets up the reader to use the data type with the indicated name. More...
 
bool setColumn (int column)
 Sets up the reader to use the nth data type of the GeomVertexFormat, numbering from 0. More...
 
bool setColumn (int array, const GeomVertexColumn column)
 Sets up the reader to use the indicated column description on the given array. More...
 
 setForce (bool force)
 Sets the value of the force flag. More...
 
 setRow (int row)
 Sets the start row to the indicated value. More...
 
 setRowUnsafe (int row)
 Sets the start row to the indicated value, without internal checks. More...
 
- Public Member Functions inherited from GeomEnums
 __init__ ()
 
 __init__ (const GeomEnums)
 

Additional Inherited Members

- Public Types inherited from GeomEnums
enum  AnimationType { AT_none = 0, AT_panda = 1, AT_hardware = 2 }
 
enum  Contents {
  C_other = 0, C_point = 1, C_clip_point = 2, C_vector = 3,
  C_texcoord = 4, C_color = 5, C_index = 6, C_morph_delta = 7,
  C_matrix = 8, C_normal = 9
}
 
enum  GeomRendering {
  GR_indexed_point = 1, GR_indexed_other = 65536, GR_indexed_bits = 65537, GR_point = 2,
  GR_point_uniform_size = 4, GR_per_point_size = 8, GR_point_perspective = 16, GR_point_aspect_ratio = 32,
  GR_point_scale = 64, GR_point_rotate = 128, GR_point_sprite = 256, GR_point_sprite_tex_matrix = 512,
  GR_point_bits = 1022, GR_triangle_strip = 1024, GR_triangle_fan = 2048, GR_line_strip = 4096,
  GR_composite_bits = 7168, GR_strip_cut_index = 131072, GR_flat_first_vertex = 8192, GR_flat_last_vertex = 16384,
  GR_shade_model_bits = 24576, GR_render_mode_wireframe = 262144, GR_render_mode_point = 524288, GR_adjacency = 1048576
}
 
enum  NumericType {
  NT_uint8 = 0, NT_uint16 = 1, NT_uint32 = 2, NT_packed_dcba = 3,
  NT_packed_dabc = 4, NT_float32 = 5, NT_float64 = 6, NT_stdfloat = 7,
  NT_int8 = 8, NT_int16 = 9, NT_int32 = 10, NT_packed_ufloat = 11
}
 
enum  PrimitiveType {
  PT_none = 0, PT_polygons = 1, PT_lines = 2, PT_points = 3,
  PT_patches = 4
}
 
enum  ShadeModel { SM_uniform = 0, SM_smooth = 1, SM_flat_first_vertex = 2, SM_flat_last_vertex = 3 }
 
enum  UsageHint {
  UH_client = 0, UH_stream = 1, UH_dynamic = 2, UH_static = 3,
  UH_unspecified = 4
}
 

Detailed Description

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.

Member Function Documentation

◆ __init__() [1/6]

__init__ ( const GeomVertexArrayData  array_data,
Thread  current_thread 
)

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

◆ __init__() [2/6]

__init__ ( const GeomVertexArrayData  array_data,
int  column,
Thread  current_thread 
)

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

◆ __init__() [3/6]

__init__ ( const GeomVertexData  vertex_data,
const InternalName  name,
Thread  current_thread 
)

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.

◆ __init__() [4/6]

__init__ ( const GeomVertexData  vertex_data,
Thread  current_thread 
)

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

◆ __init__() [5/6]

__init__ ( const GeomVertexReader  copy)

◆ __init__() [6/6]

__init__ ( Thread  current_thread)

Constructs an invalid GeomVertexReader.

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

◆ clear()

clear ( )

Resets the GeomVertexReader to the initial state.

◆ getArray()

int getArray ( )

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

◆ getArrayData()

const GeomVertexArrayData getArrayData ( )

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

◆ getArrayHandle()

const GeomVertexArrayDataHandle getArrayHandle ( )

Returns the read handle to the array object that the read is currently processing.

This low-level call should be used with caution.

◆ getColumn()

const GeomVertexColumn getColumn ( )

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

◆ getCurrentThread()

Thread getCurrentThread ( )

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

◆ getData1()

float getData1 ( )

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

◆ getData1d()

double getData1d ( )

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

◆ getData1f()

float getData1f ( )

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

◆ getData1i()

int getData1i ( )

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

◆ getData2()

const LVecBase2 getData2 ( )

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

◆ getData2d()

const LVecBase2d getData2d ( )

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

◆ getData2f()

const LVecBase2f getData2f ( )

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

◆ getData2i()

const LVecBase2i getData2i ( )

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

◆ getData3()

const LVecBase3 getData3 ( )

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

◆ getData3d()

const LVecBase3d getData3d ( )

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

◆ getData3f()

const LVecBase3f getData3f ( )

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

◆ getData3i()

const LVecBase3i getData3i ( )

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

◆ getData4()

const LVecBase4 getData4 ( )

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

◆ getData4d()

const LVecBase4d getData4d ( )

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

◆ getData4f()

const LVecBase4f getData4f ( )

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

◆ getData4i()

const LVecBase4i getData4i ( )

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

◆ getForce()

bool getForce ( )

Returns the value of the force flag.

See set_force().

◆ getMatrix3()

LMatrix3 getMatrix3 ( )

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.

◆ getMatrix3d()

LMatrix3d getMatrix3d ( )

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.

◆ getMatrix3f()

LMatrix3f getMatrix3f ( )

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.

◆ getMatrix4()

LMatrix4 getMatrix4 ( )

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.

◆ getMatrix4d()

LMatrix4d getMatrix4d ( )

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.

◆ getMatrix4f()

LMatrix4f getMatrix4f ( )

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.

◆ getReadRow()

int getReadRow ( )

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

◆ getStartRow()

int getStartRow ( )

Returns the row index at which the reader started.

It will return to this row if you reset the current column.

◆ getStride()

int getStride ( )

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.

◆ getVertexData()

const GeomVertexData getVertexData ( )

Returns the vertex data object that the reader is processing.

This may return NULL if the reader was constructed with just an array pointer.

◆ hasColumn()

bool hasColumn ( )

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).

◆ isAtEnd()

bool isAtEnd ( )

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.

◆ operator=()

GeomVertexReader operator= ( const GeomVertexReader  copy)

◆ output()

output ( Ostream  out)

◆ setColumn() [1/3]

bool setColumn ( const InternalName  name)

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.

◆ setColumn() [2/3]

bool setColumn ( int  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.

◆ setColumn() [3/3]

bool setColumn ( 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.

◆ setForce()

setForce ( 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.

◆ setRow()

setRow ( 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.

◆ setRowUnsafe()

setRowUnsafe ( 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.