Panda3D
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends
GeomVertexArrayFormat Class Reference

This describes the structure of a single array within a Geom data. More...

#include "geomVertexArrayFormat.h"

Inheritance diagram for GeomVertexArrayFormat:
TypedWritableReferenceCount GeomEnums TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase

List of all members.

Classes

class  Registry

Public Member Functions

 GeomVertexArrayFormat (const GeomVertexArrayFormat &copy)
 GeomVertexArrayFormat (InternalName *name0, int num_components0, NumericType numeric_type0, Contents contents0)
 GeomVertexArrayFormat (InternalName *name0, int num_components0, NumericType numeric_type0, Contents contents0, InternalName *name1, int num_components1, NumericType numeric_type1, Contents contents1)
 GeomVertexArrayFormat (InternalName *name0, int num_components0, NumericType numeric_type0, Contents contents0, InternalName *name1, int num_components1, NumericType numeric_type1, Contents contents1, InternalName *name2, int num_components2, NumericType numeric_type2, Contents contents2)
 GeomVertexArrayFormat (InternalName *name0, int num_components0, NumericType numeric_type0, Contents contents0, InternalName *name1, int num_components1, NumericType numeric_type1, Contents contents1, InternalName *name2, int num_components2, NumericType numeric_type2, Contents contents2, InternalName *name3, int num_components3, NumericType numeric_type3, Contents contents3)
int add_column (InternalName *name, int num_components, NumericType numeric_type, Contents contents, int start=-1, int column_alignment=0)
 Adds a new column to the specification.
int add_column (const GeomVertexColumn &column)
 Adds a new column to the specification.
void align_columns_for_animation ()
 Reprocesses the columns in the format to align the C_point and C_vector columns to 16-byte boundaries to allow for the more efficient SSE2 operations (assuming SSE2 is enabled in the build).
void clear_columns ()
 Removes all columns previously added, sets the stride to zero, and prepares to start over.
int compare_to (const GeomVertexArrayFormat &other) const
virtual int complete_pointers (TypedWritable **plist, BamReader *manager)
 Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
int count_unused_space () const
 Returns the number of bytes per row that are not assigned to any column.
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 GeomVertexColumnget_column (int i) const
 Returns the ith column of the array.
const GeomVertexColumnget_column (const InternalName *name) const
 Returns the specification with the indicated name, or NULL if the name is not used.
const GeomVertexColumnget_column (int start_byte, int num_bytes) const
 Returns the first specification that overlaps with any of the indicated bytes in the range, or NULL if none do.
int get_num_columns () const
 Returns the number of different columns in the array.
int get_pad_to () const
 Returns the byte divisor to which the data record must be padded to meet hardware limitations.
int get_stride () const
 Returns the total number of bytes reserved in the array for each vertex.
int get_total_bytes () const
 Returns the total number of bytes used by the data types within the format, including gaps between elements.
virtual TypeHandle get_type () const
bool has_column (const InternalName *name) const
 Returns true if the array has the named column, false otherwise.
bool is_data_subset_of (const GeomVertexArrayFormat &other) const
 Returns true if all of the fields in this array format are also present and equivalent in the other array format, and in the same byte positions, and the stride is the same.
bool is_registered () const
 Returns true if this format has been registered, false if it has not.
 MAKE_SEQ (get_columns, get_num_columns, get_column)
void operator= (const GeomVertexArrayFormat &copy)
void output (ostream &out) const
void pack_columns ()
 Removes wasted space between columns.
void remove_column (const InternalName *name)
 Removes the column with the indicated name, if any.
void set_pad_to (int pad_to)
 Explicitly sets the byte divisor to which the data record must be padded to meet hardware limitations.
void set_stride (int stride)
 Changes the total number of bytes reserved in the array for each vertex.
virtual bool unref () const
 This method overrides ReferenceCount::unref() to unregister the object when its reference count goes to zero.
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.
void write_with_data (ostream &out, int indent_level, const GeomVertexArrayData *array_data) const

Static Public Member Functions

static CPT (GeomVertexArrayFormat) register_format(const GeomVertexArrayFormat *format)
static TypeHandle get_class_type ()
static void init_type ()
static void register_with_read_factory ()
 Tells the BamReader how to create objects of type GeomVertexArrayFormat.

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

Static Protected Member Functions

static TypedWritablemake_from_bam (const FactoryParams &params)
 This function is called by the BamReader's factory when a new object of type GeomVertexArrayFormat is encountered in the Bam file.

Friends

class GeomVertexFormat

Detailed Description

This describes the structure of a single array within a Geom data.

See GeomVertexFormat for the parent class which collects together all of the individual GeomVertexArrayFormat objects.

A particular array may include any number of standard or user-defined columns. All columns consist of a sequence of one or more numeric values, packed in any of a variety of formats; the semantic meaning of each column is defined in general with its contents member, and in particular by its name. The standard array types used most often are named "vertex", "normal", "texcoord", and "color"; other kinds of data may be piggybacked into the data record simply by choosing a unique name.

Definition at line 53 of file geomVertexArrayFormat.h.


Member Function Documentation

int GeomVertexArrayFormat::add_column ( InternalName name,
int  num_components,
GeomVertexArrayFormat::NumericType  numeric_type,
GeomVertexArrayFormat::Contents  contents,
int  start = -1,
int  column_alignment = 0 
)

Adds a new column to the specification.

This is a table of per-vertex floating-point numbers such as "vertex" or "normal"; you must specify where in each record the table starts, and how many components (dimensions) exist per vertex.

The return value is the index number of the new data type.

Definition at line 231 of file geomVertexArrayFormat.cxx.

Referenced by align_columns_for_animation(), ColladaInput::make_vertex_columns(), and pack_columns().

Adds a new column to the specification.

This is a table of per-vertex floating-point numbers such as "vertex" or "normal"; you must specify where in each record the table starts, and how many components (dimensions) exist per vertex.

Adding a column with the same name as a previous type, or that overlaps with one or more previous types, quietly removes the previous type(s).

The return value is the index number of the new data type.

Definition at line 260 of file geomVertexArrayFormat.cxx.

References get_column(), GeomVertexColumn::get_column_alignment(), GeomVertexColumn::get_name(), GeomVertexColumn::get_start(), GeomVertexColumn::get_total_bytes(), and remove_column().

Reprocesses the columns in the format to align the C_point and C_vector columns to 16-byte boundaries to allow for the more efficient SSE2 operations (assuming SSE2 is enabled in the build).

The caller is responsible for testing vertex_animation_align_16 to decide whether to call this method.

Definition at line 380 of file geomVertexArrayFormat.cxx.

References add_column(), clear_columns(), GeomVertexColumn::get_contents(), GeomVertexColumn::get_name(), GeomVertexColumn::get_num_components(), and GeomVertexColumn::get_numeric_type().

Removes all columns previously added, sets the stride to zero, and prepares to start over.

Definition at line 335 of file geomVertexArrayFormat.cxx.

Referenced by align_columns_for_animation(), and pack_columns().

int GeomVertexArrayFormat::complete_pointers ( TypedWritable **  p_list,
BamReader manager 
) [virtual]

Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().

Returns the number of pointers processed.

Reimplemented from TypedWritable.

Definition at line 701 of file geomVertexArrayFormat.cxx.

References GeomVertexColumn::complete_pointers().

Returns the number of bytes per row that are not assigned to any column.

Definition at line 478 of file geomVertexArrayFormat.cxx.

References GeomVertexColumn::get_start(), and GeomVertexColumn::get_total_bytes().

void GeomVertexArrayFormat::fillin ( DatagramIterator scan,
BamReader manager 
) [protected, virtual]

This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new GeomVertexArrayFormat.

Reimplemented from TypedWritable.

Definition at line 764 of file geomVertexArrayFormat.cxx.

References GeomVertexColumn::fillin(), DatagramIterator::get_uint16(), and DatagramIterator::get_uint8().

void GeomVertexArrayFormat::finalize ( BamReader manager) [virtual]

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.

Reimplemented from TypedWritable.

Definition at line 721 of file geomVertexArrayFormat.cxx.

References GeomVertexColumn::get_name().

const GeomVertexColumn * GeomVertexArrayFormat::get_column ( int  i) const [inline]

Returns the specification with the indicated name, or NULL if the name is not used.

Definition at line 409 of file geomVertexArrayFormat.cxx.

const GeomVertexColumn * GeomVertexArrayFormat::get_column ( int  start_byte,
int  num_bytes 
) const

Returns the first specification that overlaps with any of the indicated bytes in the range, or NULL if none do.

Definition at line 426 of file geomVertexArrayFormat.cxx.

References GeomVertexColumn::overlaps_with().

Returns the number of different columns in the array.

Definition at line 128 of file geomVertexArrayFormat.I.

Referenced by STTerrain::convert_vertex_format(), GeomVertexData::copy_from(), and GeomVertexFormat::remove_column().

int GeomVertexArrayFormat::get_pad_to ( ) const [inline]

Returns the byte divisor to which the data record must be padded to meet hardware limitations.

For instance, if this is 4, the stride will be automatically rounded up to the next multiple of 4 bytes. This value is automatically increased as needed to ensure the individual numeric components in the array are word-aligned.

Definition at line 86 of file geomVertexArrayFormat.I.

int GeomVertexArrayFormat::get_stride ( ) const [inline]

Returns the total number of bytes used by the data types within the format, including gaps between elements.

Definition at line 117 of file geomVertexArrayFormat.I.

bool GeomVertexArrayFormat::has_column ( const InternalName name) const [inline]

Returns true if the array has the named column, false otherwise.

Definition at line 151 of file geomVertexArrayFormat.I.

References get_column().

Returns true if all of the fields in this array format are also present and equivalent in the other array format, and in the same byte positions, and the stride is the same.

That is, true if this format can share the same data pointer as the other format (with possibly some unused gaps).

Definition at line 450 of file geomVertexArrayFormat.cxx.

References get_stride().

Referenced by GeomVertexData::copy_from().

bool GeomVertexArrayFormat::is_registered ( ) const [inline]

Returns true if this format has been registered, false if it has not.

It may not be used for a Geom until it has been registered, but once registered, it may no longer be modified.

Definition at line 25 of file geomVertexArrayFormat.I.

Referenced by GeomVertexFormat::remove_column(), and unref().

TypedWritable * GeomVertexArrayFormat::make_from_bam ( const FactoryParams params) [static, protected]

This function is called by the BamReader's factory when a new object of type GeomVertexArrayFormat is encountered in the Bam file.

It should create the GeomVertexArrayFormat and extract its information from the file.

Definition at line 744 of file geomVertexArrayFormat.cxx.

References BamReader::register_finalize().

Referenced by register_with_read_factory().

Tells the BamReader how to create objects of type GeomVertexArrayFormat.

Definition at line 665 of file geomVertexArrayFormat.cxx.

References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().

Removes the column with the indicated name, if any.

This leaves a gap in the byte structure.

Definition at line 301 of file geomVertexArrayFormat.cxx.

References GeomVertexColumn::get_start(), and GeomVertexColumn::get_total_bytes().

Referenced by add_column(), and GeomVertexFormat::remove_column().

void GeomVertexArrayFormat::set_pad_to ( int  pad_to) [inline]

Explicitly sets the byte divisor to which the data record must be padded to meet hardware limitations.

See get_pad_to(). Normally it is not necessary to call this unless you have some specific requirements for row-to-row data alignment. Note that this value may be automatically increased at each subsequent call to add_column().

Definition at line 102 of file geomVertexArrayFormat.I.

void GeomVertexArrayFormat::set_stride ( int  stride) [inline]

Changes the total number of bytes reserved in the array for each vertex.

You may not reduce this below get_total_bytes(), but you may increase it arbitrarily.

Definition at line 68 of file geomVertexArrayFormat.I.

bool GeomVertexArrayFormat::unref ( ) const [virtual]

This method overrides ReferenceCount::unref() to unregister the object when its reference count goes to zero.

Reimplemented from ReferenceCount.

Definition at line 203 of file geomVertexArrayFormat.cxx.

References is_registered(), and ReferenceCount::unref().

void GeomVertexArrayFormat::write_datagram ( BamWriter manager,
Datagram dg 
) [virtual]

Writes the contents of this object to the datagram for shipping out to a Bam file.

Reimplemented from TypedWritable.

Definition at line 676 of file geomVertexArrayFormat.cxx.

References Datagram::add_uint16(), Datagram::add_uint8(), and GeomVertexColumn::write_datagram().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations