Panda3D
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
GeomVertexArrayFormat Class Referencefinal

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

Public Member Functions

 GeomVertexArrayFormat (const GeomVertexArrayFormat &copy)
 
 GeomVertexArrayFormat (CPT_InternalName name0, int num_components0, NumericType numeric_type0, Contents contents0)
 
 GeomVertexArrayFormat (CPT_InternalName name0, int num_components0, NumericType numeric_type0, Contents contents0, CPT_InternalName name1, int num_components1, NumericType numeric_type1, Contents contents1)
 
 GeomVertexArrayFormat (CPT_InternalName name0, int num_components0, NumericType numeric_type0, Contents contents0, CPT_InternalName name1, int num_components1, NumericType numeric_type1, Contents contents1, CPT_InternalName name2, int num_components2, NumericType numeric_type2, Contents contents2)
 
 GeomVertexArrayFormat (CPT_InternalName name0, int num_components0, NumericType numeric_type0, Contents contents0, CPT_InternalName name1, int num_components1, NumericType numeric_type1, Contents contents1, CPT_InternalName name2, int num_components2, NumericType numeric_type2, Contents contents2, CPT_InternalName name3, int num_components3, NumericType numeric_type3, Contents contents3)
 
int add_column (CPT_InternalName name, int num_components, NumericType numeric_type, Contents contents, int start=-1, int column_alignment=0)
 Adds a new column to the specification. More...
 
int add_column (const GeomVertexColumn &column)
 Adds a new column to the specification. More...
 
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). More...
 
void clear_columns ()
 Removes all columns previously added, sets the stride to zero, and prepares to start over. More...
 
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(). More...
 
int count_unused_space () const
 Returns the number of bytes per row that are not assigned to any column. More...
 
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. More...
 
virtual TypeHandle force_init_type ()
 
const GeomVertexColumnget_column (int i) const
 
const GeomVertexColumnget_column (const InternalName *name) const
 
const GeomVertexColumnget_column (int start_byte, int num_bytes) const
 
int get_divisor () const
 
std::string get_format_string (bool pad=true) const
 Returns a string with format codes representing the exact memory layout of the columns in memory, as understood by Python's struct module. More...
 
int get_num_columns () const
 
int get_pad_to () const
 
int get_stride () const
 
int get_total_bytes () const
 
virtual TypeHandle get_type () const
 
bool has_column (const InternalName *name) const
 Returns true if the array has the named column, false otherwise. More...
 
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. More...
 
bool is_registered () const
 
void operator= (const GeomVertexArrayFormat &copy)
 
void output (std::ostream &out) const
 
void pack_columns ()
 Removes wasted space between columns. More...
 
void remove_column (const InternalName *name)
 Removes the column with the indicated name, if any. More...
 
void set_divisor (int divisor)
 
void set_pad_to (int pad_to)
 
void set_stride (int stride)
 
virtual bool unref () const
 This method overrides ReferenceCount::unref() to unregister the object when its reference count goes to zero. More...
 
void write (std::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. More...
 
void write_with_data (std::ostream &out, int indent_level, const GeomVertexArrayData *array_data) const
 
- Public Member Functions inherited from TypedWritableReferenceCount
 TypedWritableReferenceCount (const TypedWritableReferenceCount &copy)
 
virtual ReferenceCountas_reference_count ()
 Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type. More...
 
void operator= (const TypedWritableReferenceCount &copy)
 
- Public Member Functions inherited from TypedWritable
 TypedWritable (const TypedWritable &copy)
 
vector_uchar encode_to_bam_stream () const
 Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object. More...
 
bool encode_to_bam_stream (vector_uchar &data, BamWriter *writer=nullptr) const
 Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. More...
 
UpdateSeq get_bam_modified () const
 Returns the current bam_modified counter. More...
 
void mark_bam_modified ()
 Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. More...
 
void operator= (const TypedWritable &copy)
 
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. More...
 
virtual void update_bam_nested (BamWriter *manager)
 Called by the BamWriter when this object has not itself been modified recently, but it should check its nested objects for updates. More...
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)=default
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly. More...
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type. More...
 
TypedObjectoperator= (const TypedObject &copy)=default
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object. More...
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
 
void ref () const
 Explicitly increments the reference count. More...
 
bool ref_if_nonzero () const
 Atomically increases the reference count of this object if it is not zero. More...
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
WeakReferenceListweak_ref ()
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref ()
 Removes the indicated PointerToVoid as a weak reference to this object. More...
 

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. More...
 
- Static Public Member Functions inherited from TypedWritableReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
static PT (TypedWritableReferenceCount) decode_from_bam_stream(vector_uchar data
 
- Static Public Member Functions inherited from TypedWritable
static bool decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, BamReader *reader=nullptr)
 Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts the single object on those bytes. More...
 
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle get_class_type ()
 
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96. More...
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 

Public Attributes

 get_column
 Returns the specification with the indicated name, or NULL if the name is not used. More...
 
 get_divisor
 Returns the divisor attribute for the data in this array. More...
 
 get_num_columns
 Returns the number of different columns in the array. More...
 
 get_pad_to
 Returns the byte divisor to which the data record must be padded to meet hardware limitations. More...
 
 get_stride
 Returns the total number of bytes reserved in the array for each vertex. More...
 
 get_total_bytes
 Returns the total number of bytes used by the data types within the format, including gaps between elements. More...
 
 is_registered
 Returns true if this format has been registered, false if it has not. More...
 
 set_divisor
 Set this to 0 to indicate that this array contains per-vertex data, or to 1 to indicate that it contains per-instance data. More...
 
 set_pad_to
 Explicitly sets the byte divisor to which the data record must be padded to meet hardware limitations. More...
 
 set_stride
 Changes the total number of bytes reserved in the array for each vertex. More...
 
- Public Attributes inherited from TypedWritableReferenceCount
static BamReaderreader = nullptr)
 
- Public Attributes inherited from TypedObject
 get_type
 
- Public Attributes inherited from ReferenceCount
 get_ref_count
 Returns the current reference count. More...
 

Friends

class GeomVertexFormat
 

Additional Inherited Members

- Public Types inherited from GeomEnums
enum  AnimationType { AT_none, AT_panda, AT_hardware }
 
enum  Contents {
  C_other, C_point, C_clip_point, C_vector,
  C_texcoord, C_color, C_index, C_morph_delta,
  C_matrix, C_normal
}
 
enum  GeomRendering {
  GR_indexed_point = 0x00001, GR_indexed_other = 0x10000, GR_indexed_bits = 0x10001, GR_point = 0x00002,
  GR_point_uniform_size = 0x00004, GR_per_point_size = 0x00008, GR_point_perspective = 0x00010, GR_point_aspect_ratio = 0x00020,
  GR_point_scale = 0x00040, GR_point_rotate = 0x00080, GR_point_sprite = 0x00100, GR_point_sprite_tex_matrix = 0x00200,
  GR_point_bits = 0x003fe, GR_triangle_strip = 0x00400, GR_triangle_fan = 0x00800, GR_line_strip = 0x01000,
  GR_composite_bits = 0x01c00, GR_strip_cut_index = 0x20000, GR_flat_first_vertex = 0x02000, GR_flat_last_vertex = 0x04000,
  GR_shade_model_bits = 0x06000, GR_render_mode_wireframe = 0x40000, GR_render_mode_point = 0x80000, GR_adjacency = 0x100000
}
 
enum  NumericType {
  NT_uint8, NT_uint16, NT_uint32, NT_packed_dcba,
  NT_packed_dabc, NT_float32, NT_float64, NT_stdfloat,
  NT_int8, NT_int16, NT_int32, NT_packed_ufloat
}
 
enum  PrimitiveType {
  PT_none, PT_polygons, PT_lines, PT_points,
  PT_patches
}
 
enum  ShadeModel { SM_uniform, SM_smooth, SM_flat_first_vertex, SM_flat_last_vertex }
 
enum  UsageHint {
  UH_client, UH_stream, UH_dynamic, UH_static,
  UH_unspecified
}
 
- Static Public Attributes inherited from TypedWritable
static TypedWritable *const Null = nullptr
 

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 47 of file geomVertexArrayFormat.h.

Member Function Documentation

◆ add_column() [1/2]

int GeomVertexArrayFormat::add_column ( CPT_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 218 of file geomVertexArrayFormat.cxx.

Referenced by PT().

◆ add_column() [2/2]

int GeomVertexArrayFormat::add_column ( const GeomVertexColumn column)

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 242 of file geomVertexArrayFormat.cxx.

◆ align_columns_for_animation()

void GeomVertexArrayFormat::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).

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

Definition at line 351 of file geomVertexArrayFormat.cxx.

◆ clear_columns()

void GeomVertexArrayFormat::clear_columns ( )

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

Definition at line 312 of file geomVertexArrayFormat.cxx.

◆ complete_pointers()

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 734 of file geomVertexArrayFormat.cxx.

◆ count_unused_space()

int GeomVertexArrayFormat::count_unused_space ( ) const

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

Definition at line 441 of file geomVertexArrayFormat.cxx.

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

◆ finalize()

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 752 of file geomVertexArrayFormat.cxx.

References GeomVertexColumn::get_name().

◆ get_format_string()

std::string GeomVertexArrayFormat::get_format_string ( bool  pad = true) const

Returns a string with format codes representing the exact memory layout of the columns in memory, as understood by Python's struct module.

If pad is true, extra padding bytes are added to the end as 'x' characters as needed.

Definition at line 544 of file geomVertexArrayFormat.cxx.

References GeomVertexColumn::get_num_components(), GeomVertexColumn::get_numeric_type(), GeomVertexColumn::get_start(), get_stride, GeomVertexColumn::get_total_bytes(), and get_total_bytes.

◆ has_column()

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

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

Definition at line 138 of file geomVertexArrayFormat.I.

References get_column.

◆ is_data_subset_of()

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

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

Definition at line 416 of file geomVertexArrayFormat.cxx.

References get_stride.

Referenced by GeomVertexData::copy_from().

◆ pack_columns()

void GeomVertexArrayFormat::pack_columns ( )

Removes wasted space between columns.

Definition at line 327 of file geomVertexArrayFormat.cxx.

◆ register_with_read_factory()

void GeomVertexArrayFormat::register_with_read_factory ( )
static

Tells the BamReader how to create objects of type GeomVertexArrayFormat.

Definition at line 699 of file geomVertexArrayFormat.cxx.

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

◆ remove_column()

void GeomVertexArrayFormat::remove_column ( const InternalName name)

Removes the column with the indicated name, if any.

This leaves a gap in the byte structure.

Definition at line 280 of file geomVertexArrayFormat.cxx.

Referenced by PT().

◆ unref()

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 194 of file geomVertexArrayFormat.cxx.

References is_registered, and ReferenceCount::unref().

◆ write_datagram()

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 708 of file geomVertexArrayFormat.cxx.

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

Member Data Documentation

◆ get_column

const GeomVertexColumn * GeomVertexArrayFormat::get_column
inline

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

Returns the ith column of the array.

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

Definition at line 106 of file geomVertexArrayFormat.h.

Referenced by GeomVertexData::copy_from(), and has_column().

◆ get_divisor

int GeomVertexArrayFormat::get_divisor
inline

Returns the divisor attribute for the data in this array.

If 0, it contains per-vertex data. If 1, it contains per-instance data. If higher than 1, the read row is advanced for each n instances.

Definition at line 90 of file geomVertexArrayFormat.h.

◆ get_num_columns

int GeomVertexArrayFormat::get_num_columns
inline

Returns the number of different columns in the array.

Definition at line 106 of file geomVertexArrayFormat.h.

Referenced by GeomVertexData::copy_from(), and PT().

◆ get_pad_to

int GeomVertexArrayFormat::get_pad_to
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.h.

◆ get_stride

int GeomVertexArrayFormat::get_stride
inline

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

Definition at line 82 of file geomVertexArrayFormat.h.

Referenced by get_format_string(), is_data_subset_of(), and DXShaderContext9::update_shader_vertex_arrays().

◆ get_total_bytes

int GeomVertexArrayFormat::get_total_bytes
inline

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

Definition at line 93 of file geomVertexArrayFormat.h.

Referenced by get_format_string().

◆ is_registered

bool GeomVertexArrayFormat::is_registered
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 78 of file geomVertexArrayFormat.h.

Referenced by CPT(), and unref().

◆ set_divisor

void GeomVertexArrayFormat::set_divisor
inline

Set this to 0 to indicate that this array contains per-vertex data, or to 1 to indicate that it contains per-instance data.

If higher than 1, the read row is advanced for each n instances.

Definition at line 90 of file geomVertexArrayFormat.h.

◆ set_pad_to

void GeomVertexArrayFormat::set_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 86 of file geomVertexArrayFormat.h.

◆ set_stride

void GeomVertexArrayFormat::set_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 82 of file geomVertexArrayFormat.h.


The documentation for this class was generated from the following files: