|
|
|
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particular GeomVertexFormat object.
More...
#include "geomVertexData.h"
List of all members.
Classes |
| class | CacheEntry |
| class | CacheKey |
| class | CData |
| class | CDataCache |
Public Types |
typedef pmap< const CacheKey
*, PT(CacheEntry),
IndirectLess< CacheKey > > | Cache |
Public Member Functions |
|
| GeomVertexData (const string &name, const GeomVertexFormat *format, UsageHint usage_hint) |
|
| GeomVertexData (const GeomVertexData ©) |
| | GeomVertexData (const GeomVertexData ©, const GeomVertexFormat *format) |
| | This constructor copies all of the basic properties of the source VertexData, like usage_hint and animation tables, but does not copy the actual data, and it allows you to specify a different format.
|
| void | clear_animated_vertices () |
| | Removes the cache of animated vertices computed by a previous call to animate_vertices() within the same frame.
|
| void | clear_cache () |
| | Removes all of the previously-cached results of convert_to().
|
| void | clear_cache_stage () |
| | Removes all of the previously-cached results of convert_to(), at the current pipeline stage and upstream.
|
| void | clear_rows () |
| | Removes all of the rows from the arrays; functionally equivalent to set_num_rows(0) (but faster).
|
| void | clear_slider_table () |
| | Sets the SliderTable pointer to NULL, removing the table from the vertex data.
|
| void | clear_transform_blend_table () |
| | Sets the TransformBlendTable pointer to NULL, removing the table from the vertex data.
|
| void | clear_transform_table () |
| | Sets the TransformTable pointer to NULL, removing the table from the vertex data.
|
| int | compare_to (const GeomVertexData &other) const |
| | Returns 0 if the two objects are equivalent, even if they are not the same pointer.
|
| virtual int | complete_pointers (TypedWritable **plist, BamReader *manager) |
| | Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
|
| void | copy_from (const GeomVertexData *source, bool keep_data_objects, Thread *current_thread=Thread::get_current_thread()) |
| | Copies all the data from the other array into the corresponding data types in this array, by matching data types name-by-name.
|
| void | copy_row_from (int dest_row, const GeomVertexData *source, int source_row, Thread *current_thread) |
| | Copies a single row of the data from the other array into the indicated row of this array.
|
|
| CPT (GeomVertexArrayData) get_array(int i) const |
|
| CPT (TransformBlendTable) get_transform_blend_table() const |
|
| CPT (GeomVertexData) convert_to(const GeomVertexFormat *new_format) const |
|
| CPT (GeomVertexData) scale_color(const LVecBase4 &color_scale) const |
|
| CPT (GeomVertexData) scale_color(const LVecBase4 &color_scale |
|
| CPT (GeomVertexData) set_color(const LColor &color) const |
|
| CPT (GeomVertexData) set_color(const LColor &color |
|
| CPT (GeomVertexData) reverse_normals() const |
|
| CPT (GeomVertexData) animate_vertices(bool force |
| void | describe_vertex (ostream &out, int row) const |
| | Writes a verbose, human-friendly description of the indicated vertex number.
|
| virtual void | finalize (BamReader *manager) |
| | Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed.
|
|
virtual TypeHandle | force_init_type () |
| const GeomVertexFormat * | get_format () const |
| | Returns a pointer to the GeomVertexFormat structure that defines this data.
|
| UpdateSeq | get_modified (Thread *current_thread=Thread::get_current_thread()) const |
| | Returns a sequence number which is guaranteed to change at least every time the vertex data is modified.
|
| const string & | get_name () const |
| | Returns the name passed to the constructor, if any.
|
| int | get_num_arrays () const |
| | Returns the number of individual arrays stored within the data.
|
| int | get_num_bytes () const |
| | Returns the total number of bytes consumed by the different arrays of the vertex data.
|
| int | get_num_rows () const |
| | Returns the number of rows stored within all the arrays.
|
| const SliderTable * | get_slider_table () const |
| | Returns a const pointer to the SliderTable assigned to this data.
|
| const TransformTable * | get_transform_table () const |
| | Returns a const pointer to the TransformTable assigned to this data.
|
|
virtual TypeHandle | get_type () const |
| UsageHint | get_usage_hint () const |
| | Returns the usage hint that was passed to the constructor, and which will be passed to each array data object created initially, and arrays created as the result of a convert_to() operation.
|
| bool | has_column (const InternalName *name) const |
| | Returns true if the data has the named column, false otherwise.
|
|
| MAKE_SEQ (get_arrays, get_num_arrays, get_array) |
| void | operator= (const GeomVertexData ©) |
| | The copy assignment operator is not pipeline-safe.
|
|
void | output (ostream &out) const |
|
| PT (GeomVertexArrayData) modify_array(int i) |
|
| PT (TransformBlendTable) modify_transform_blend_table() |
|
| PT (GeomVertexData) replace_column(InternalName *name |
| bool | request_resident () const |
| | Returns true if the vertex data is currently resident in memory.
|
| virtual bool | require_fully_complete () const |
| | Some objects require all of their nested pointers to have been completed before the objects themselves can be completed.
|
| bool | reserve_num_rows (int n) |
| | This ensures that enough memory space for n rows is allocated, so that you may increase the number of rows to n without causing a new memory allocation.
|
| void | set_array (int i, const GeomVertexArrayData *array) |
| | Replaces the indicated vertex data array with a completely new array.
|
| void | set_format (const GeomVertexFormat *format) |
| | Changes the format of the vertex data.
|
| void | set_name (const string &name) |
| | Changes the name of the vertex data.
|
| bool | set_num_rows (int n) |
| | Sets the length of the array to n rows in all of the various arrays (presumably by adding rows).
|
| void | set_slider_table (const SliderTable *table) |
| | Replaces the SliderTable on this vertex data with the indicated table.
|
| void | set_transform_blend_table (const TransformBlendTable *table) |
| | Replaces the TransformBlendTable on this vertex data with the indicated table.
|
| void | set_transform_table (const TransformTable *table) |
| | Replaces the TransformTable on this vertex data with the indicated table.
|
| void | set_usage_hint (UsageHint usage_hint) |
| | Changes the UsageHint hint for this vertex data, and for all of the arrays that share this data.
|
| void | transform_vertices (const LMatrix4 &mat) |
| | Applies the indicated transform matrix to all of the vertices in the GeomVertexData.
|
| void | transform_vertices (const LMatrix4 &mat, int begin_row, int end_row) |
| | Applies the indicated transform matrix to all of the vertices from begin_row up to but not including end_row.
|
| void | unclean_set_format (const GeomVertexFormat *format) |
| | Changes the format of the vertex data, without reformatting the data to match.
|
| bool | unclean_set_num_rows (int n) |
| | This method behaves like set_num_rows(), except the new data is not initialized.
|
|
void | write (ostream &out, int indent_level=0) const |
| virtual void | write_datagram (BamWriter *manager, Datagram &dg) |
| | Writes the contents of this object to the datagram for shipping out to a Bam file.
|
Static Public Member Functions |
|
static TypeHandle | get_class_type () |
|
static void | init_type () |
| static PN_uint32 | pack_abcd (unsigned int a, unsigned int b, unsigned int c, unsigned int d) |
| | Packs four values in a DirectX-style NT_packed_abcd value.
|
| static void | register_with_read_factory () |
| | Tells the BamReader how to create objects of type GeomVertexData.
|
| static unsigned int | unpack_abcd_a (PN_uint32 data) |
| | Returns the first packed value from a DirectX-style NT_packed_abcd.
|
| static unsigned int | unpack_abcd_b (PN_uint32 data) |
| | Returns the second packed value from a DirectX-style NT_packed_abcd.
|
| static unsigned int | unpack_abcd_c (PN_uint32 data) |
| | Returns the third packed value from a DirectX-style NT_packed_abcd.
|
| static unsigned int | unpack_abcd_d (PN_uint32 data) |
| | Returns the fourth packed value from a DirectX-style NT_packed_abcd.
|
Public Attributes |
|
int NumericType Contents contents | const |
|
Thread *current_thread | const |
|
int | num_components |
|
int NumericType | numeric_type |
Protected Member Functions |
| void | fillin (DatagramIterator &scan, BamReader *manager) |
| | This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new GeomVertexData.
|
|
virtual | PT (CopyOnWriteObject) make_cow_copy() |
Static Protected Member Functions |
| static TypedWritable * | make_from_bam (const FactoryParams ¶ms) |
| | This function is called by the BamReader's factory when a new object of type GeomVertexData is encountered in the Bam file.
|
Friends |
|
class | CacheEntry |
|
class | GeomVertexDataPipelineBase |
|
class | GeomVertexDataPipelineReader |
|
class | GeomVertexDataPipelineWriter |
Detailed Description
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particular GeomVertexFormat object.
The data consists of one or more arrays, each of which in turn consists of a series of rows, one per vertex. All arrays should have the same number of rows; each vertex is defined by the column data from a particular row across all arrays.
Often, there will be only one array per Geom, and the various columns defined in the GeomVertexFormat will be interleaved within that array. However, it is also possible to have multiple different arrays, with a certain subset of the total columns defined in each array.
However the data is distributed, the effect is of a single table of vertices, where each vertex is represented by one row of the table.
In general, application code should not attempt to directly manipulate the vertex data through this structure; instead, use the GeomVertexReader, GeomVertexWriter, and GeomVertexRewriter objects to read and write vertex data at a high level.
Definition at line 76 of file geomVertexData.h.
Constructor & Destructor Documentation
Member Function Documentation
Removes the cache of animated vertices computed by a previous call to animate_vertices() within the same frame.
This will force the next call to animate_vertices() to recompute these values from scratch. Normally it is not necessary to call this.
Definition at line 1146 of file geomVertexData.cxx.
Removes all of the previously-cached results of convert_to().
This blows away the entire cache, upstream and downstream the pipeline. Use clear_cache_stage() instead if you only want to blow away the cache at the current stage and upstream.
Definition at line 1434 of file geomVertexData.cxx.
Referenced by operator=().
Returns 0 if the two objects are equivalent, even if they are not the same pointer.
Definition at line 210 of file geomVertexData.cxx.
Copies all the data from the other array into the corresponding data types in this array, by matching data types name-by-name.
keep_data_objects specifies what to do when one or more of the arrays can be copied without the need to apply any conversion operation. If it is true, the original GeomVertexArrayData objects in this object are retained, and their data arrays are copied byte-by-byte from the source; if it is false, then the GeomVertexArrayData objects are copied pointerwise from the source.
Don't call this in a downstream thread unless you don't mind it blowing away other changes you might have recently made in an upstream thread.
Definition at line 553 of file geomVertexData.cxx.
References clear_transform_blend_table(), GeomVertexFormat::get_animation(), GeomVertexAnimationSpec::get_animation_type(), GeomVertexFormat::get_array(), GeomVertexWriter::get_array(), GeomVertexFormat::get_array_with(), TransformBlend::get_blend(), GeomVertexArrayFormat::get_column(), GeomVertexReader::get_data1i(), GeomVertexReader::get_data4(), get_format(), GeomVertexAnimationSpec::get_indexed_transforms(), GeomVertexColumn::get_name(), GeomVertexFormat::get_num_arrays(), GeomVertexArrayFormat::get_num_columns(), get_num_rows(), TransformBlend::get_num_transforms(), GeomVertexColumn::get_start(), GeomVertexArrayFormat::get_stride(), TransformBlend::get_transform(), TransformBlend::get_weight(), GeomVertexWriter::has_column(), GeomVertexReader::is_at_end(), GeomVertexColumn::is_bytewise_equivalent(), GeomVertexArrayFormat::is_data_subset_of(), GeomVertexColumn::is_packed_argb(), GeomVertexColumn::is_uint8_rgba(), reserve_num_rows(), set_array(), GeomVertexReader::set_column(), GeomVertexWriter::set_column(), GeomVertexWriter::set_data4(), GeomVertexWriter::set_data4i(), set_num_rows(), set_transform_table(), and LVecBase4f::zero().
Referenced by set_format().
Writes a verbose, human-friendly description of the indicated vertex number.
Definition at line 1359 of file geomVertexData.cxx.
References Datagram::dump_hex(), GeomVertexFormat::get_animation(), GeomVertexAnimationSpec::get_animation_type(), GeomVertexFormat::get_array(), GeomVertexWriter::get_array(), GeomVertexFormat::get_array_with(), TransformBlendTable::get_blend(), GeomVertexFormat::get_column(), GeomVertexReader::get_data1i(), GeomVertexReader::get_data4(), get_format(), GeomVertexColumn::get_name(), GeomVertexFormat::get_num_arrays(), GeomVertexFormat::get_num_columns(), get_num_rows(), GeomVertexColumn::get_num_values(), GeomVertexReader::set_column(), and GeomVertexReader::set_row_unsafe().
Returns the name passed to the constructor, if any.
This name is reported on the PStats graph for vertex computations.
Definition at line 24 of file geomVertexData.I.
Returns a const pointer to the SliderTable assigned to this data.
Vertices within the vertex data will look up their morph offsets, if any, within this table.
This will return NULL if the vertex data does not have a SliderTable assigned.
Definition at line 306 of file geomVertexData.I.
Returns a const pointer to the TransformTable assigned to this data.
Vertices within the table will index into this table to indicate their dynamic skinning information; this table is used when the vertex animation is to be performed by the graphics hardware (but also see get_transform_blend_table()).
This will return NULL if the vertex data does not have a TransformTable assigned (which implies the vertices will not be animated by the graphics hardware).
Definition at line 245 of file geomVertexData.I.
Returns the usage hint that was passed to the constructor, and which will be passed to each array data object created initially, and arrays created as the result of a convert_to() operation.
See geomEnums.h.
However, each individual array may be replaced with a different array object with an independent usage hint specified, so there is no guarantee that the individual arrays all have the same usage_hint.
Definition at line 43 of file geomVertexData.I.
Referenced by SceneGraphReducer::r_make_nonindexed().
Returns true if the data has the named column, false otherwise.
This is really just a shortcut for asking the same thing from the format.
Definition at line 68 of file geomVertexData.I.
Packs four values in a DirectX-style NT_packed_abcd value.
Definition at line 355 of file geomVertexData.I.
Returns true if the vertex data is currently resident in memory.
If this returns false, the vertex data will be brought back into memory shortly; try again later.
Definition at line 515 of file geomVertexData.cxx.
Referenced by GeomMunger::munge_geom().
Some objects require all of their nested pointers to have been completed before the objects themselves can be completed.
If this is the case, override this method to return true, and be careful with circular references (which would make the object unreadable from a bam file).
Reimplemented from TypedWritable.
Definition at line 2083 of file geomVertexData.cxx.
This ensures that enough memory space for n rows is allocated, so that you may increase the number of rows to n without causing a new memory allocation.
This is a performance optimization only; it is especially useful when you know ahead of time that you will be adding n rows to the data.
Definition at line 157 of file geomVertexData.I.
References Thread::get_current_thread().
Referenced by copy_from().
Replaces the indicated vertex data array with a completely new array.
You should be careful that the new array has the same length and format as the old one, unless you know what you are doing.
Don't call this in a downstream thread unless you don't mind it blowing away other changes you might have recently made in an upstream thread.
Definition at line 223 of file geomVertexData.I.
References Thread::get_current_thread().
Referenced by copy_from().
Changes the name of the vertex data.
This name is reported on the PStats graph for vertex computations.
Definition at line 248 of file geomVertexData.cxx.
Referenced by fillin().
Sets the length of the array to n rows in all of the various arrays (presumably by adding rows).
The new vertex data is initialized to 0, except for the "color" column, which is initialized to (1, 1, 1, 1).
The return value is true if the number of rows was changed, false if the object already contained n rows (or if there was some error).
Although this method is Published, application code only very rarely has any need to call it. Instead, you should use the GeomVertexWriter to build up the rows in a GeomVertexData object automatically, without need to explicitly set the number of rows.
Don't call this in a downstream thread unless you don't mind it blowing away other changes you might have recently made in an upstream thread.
Definition at line 113 of file geomVertexData.I.
References Thread::get_current_thread().
Referenced by copy_from(), copy_row_from(), and GeomPrimitive::make_nonindexed().
Applies the indicated transform matrix to all of the vertices in the GeomVertexData.
The transform is applied to all "point" and "vector" type columns described in the format.
Definition at line 1162 of file geomVertexData.cxx.
References get_num_rows().
This method behaves like set_num_rows(), except the new data is not initialized.
Furthermore, after this call, *any* of the data in the GeomVertexData may be uninitialized, including the earlier rows.
This is intended for applications that are about to completely fill the GeomVertexData with new data anyway; it provides a tiny performance boost over set_num_rows().
Although this method is Published, application code only very rarely has any need to call it. Instead, you should use the GeomVertexWriter to build up the rows in a GeomVertexData object automatically, without need to explicitly set the number of rows.
Definition at line 140 of file geomVertexData.I.
References Thread::get_current_thread().
Returns the first packed value from a DirectX-style NT_packed_abcd.
Definition at line 370 of file geomVertexData.I.
Returns the second packed value from a DirectX-style NT_packed_abcd.
Definition at line 381 of file geomVertexData.I.
Returns the third packed value from a DirectX-style NT_packed_abcd.
Definition at line 392 of file geomVertexData.I.
Returns the fourth packed value from a DirectX-style NT_packed_abcd.
Definition at line 403 of file geomVertexData.I.
The documentation for this class was generated from the following files:
| | |