EggVertexPool

class EggVertexPool

Bases: EggNode

A collection of vertices. There may be any number of vertex pools in a single egg structure. The vertices in a single pool need not necessarily have any connection to each other, but it is necessary that any one primitive (e.g. a polygon) must pull all its vertices from the same pool.

An EggVertexPool is an STL-style container of pointers to EggVertex’s. Functions add_vertex() and remove_vertex() are provided to manipulate the list. The list may also be operated on (read-only) via iterators and begin()/end().

Inheritance diagram

Inheritance diagram of EggVertexPool

explicit EggVertexPool(std::string const &name)
EggVertexPool(EggVertexPool const &copy)

Copying a vertex pool is of questionable value, since it will copy all of the vertices and assign new pointers to them all. There will be no polygons referring to the new vertices.

void add_unused_vertices_to_prim(EggPrimitive *prim)

Adds all of the unused vertices in this vertex pool to the indicated primitive, in ascending order.

EggVertex *add_vertex(EggVertex *vertex, int index = -1)

add_vertex() adds a freshly-allocated vertex. It is up to the user to allocate the vertex.

Adds the indicated vertex to the pool. It is an error if the vertex is already a member of this or any other pool. The vertex must have been allocated from the free store; its pointer will now be owned by the vertex pool. If the index number is supplied, tries to assign that index number; it is an error if the index number is already in use.

It is possible that a forward reference to this vertex was requested in the past; if so, the data from the supplied vertex is copied onto the forward reference, which becomes the actual vertex. In this case, a different pointer is saved (and returned) than the one actually passed in. In the usual case, however, the vertex pointer passed in is the one that is saved in the vertex pool and returned from this method.

void check_overall_color(bool &has_overall_color, LColor &overall_color) const

Scans the vertex pool for different colors on different vertices. If all vertices are the same color, sets has_overall_color to true and fills the color into overall_color. If no vertices have any color, set has_overall_color to true and fills white into overall_color. If at least two vertices have different colors, sets has_overall_color to false.

EggVertex *create_unique_vertex(EggVertex const &copy)

create_unique_vertex() creates a new vertex if there is not already one identical to the indicated vertex, or returns the existing one if there is.

Creates a new vertex in the pool that is a copy of the indicated one and returns it. If there is already a vertex in the pool like the indicated one, simply returns that one.

EggVertex *find_matching_vertex(EggVertex const &copy)

If the EggVertexPool already has a vertex matching the indicated vertex, returns it; otherwise, returns NULL. This is similar to create_unique_vertex() except that a new vertex is never created.

void get_aux_names(vector_string &aux_names) const

Returns the list of auxiliary data names that are defined by any vertices in the pool.

static TypeHandle get_class_type(void)
EggVertex *get_forward_vertex(int index)

Returns a forward reference if there is no such vertex.

Returns the vertex in the pool with the indicated index number. If there is not a vertex in the pool with the indicated index number, creates a special forward-reference EggVertex that has no data, on the assumption that the vertex pool has not yet been fully read and more data will be available later.

int get_highest_index(void) const

Returns 0 if the pool is empty.

Returns the highest index number used by any vertex in the pool (except forward references). Returns -1 if the pool is empty.

int get_num_dimensions(void) const

Returns the maximum number of dimensions used by any vertex in the pool.

void get_uv_names(vector_string &uv_names, vector_string &uvw_names, vector_string &tbn_names) const

Returns the list of UV names that are defined by any vertices in the pool, as well as the subset of UV names that actually define 3-d texture coordinates (“uvw_names”). Also returns the subset of UV/UVW names that define a tangent and binormal. It is the user’s responsibility to clear both vectors before calling this method.

EggVertex *get_vertex(int index) const

Returns NULL if there is no such vertex.

Returns the vertex in the pool with the indicated index number, or NULL if no vertices have that index number.

bool has_aux(void) const

Returns true if any vertex in the pool has auxiliary data defined, false if none of them do.

bool has_colors(void) const

Returns true if any vertex in the pool has a color defined, false if none of them do.

bool has_defined_vertices(void) const

Returns true if any vertices in the pool are fully defined vertices, false if all vertices are forward references.

bool has_forward_vertices(void) const

Returns true if any vertices in the pool are undefined forward-reference vertices, false if all vertices are defined.

bool has_nonwhite_colors(void) const

Returns true if any vertex in the pool has a color defined other than white, false if no vertices have colors, or if all colors are white.

virtual bool has_normals(void) const

Returns true if any vertex in the pool has a normal defined, false if none of them do.

bool has_uvs(void) const

Returns true if any vertex in the pool has a uv defined, false if none of them do.

bool has_vertex(int index) const

Returns true if the indicated vertex has been defined in the vertex pool, false otherwise. This does not include forward references.

EggVertex *make_new_vertex(void)
EggVertex *make_new_vertex(double pos)
EggVertex *make_new_vertex(LPoint2d const &pos)
EggVertex *make_new_vertex(LPoint3d const &pos)
EggVertex *make_new_vertex(LPoint4d const &pos)

make_new_vertex() allocates and returns a new vertex from the pool.

Allocates and returns a new vertex from the pool. This is one of three ways to add new vertices to a vertex pool.

Allocates and returns a new vertex from the pool. This is one of three ways to add new vertices to a vertex pool.

This flavor of make_new_vertex() explicitly sets the vertex position as it is allocated. It does not attempt to share vertices.

Allocates and returns a new vertex from the pool. This is one of three ways to add new vertices to a vertex pool.

This flavor of make_new_vertex() explicitly sets the vertex position as it is allocated. It does not attempt to share vertices.

Allocates and returns a new vertex from the pool. This is one of three ways to add new vertices to a vertex pool.

This flavor of make_new_vertex() explicitly sets the vertex position as it is allocated. It does not attempt to share vertices.

Allocates and returns a new vertex from the pool. This is one of three ways to add new vertices to a vertex pool.

This flavor of make_new_vertex() explicitly sets the vertex position as it is allocated. It does not attempt to share vertices.

int remove_unused_vertices(void)

Removes all vertices from the pool that are not referenced by at least one primitive. Also collapses together equivalent vertices, and renumbers all vertices after the operation so their indices are consecutive, beginning at zero. Returns the number of vertices removed.

void remove_vertex(EggVertex *vertex)

Removes the vertex from the pool. It is an error if the vertex is not already a member of the pool.

void set_highest_index(int highest_index)

Artificially changes the “highest index number”, so that a newly created vertex will begin at this number plus 1. This can be used to default a vertex pool to start counting at 1 (or any other index number), instead of the default of 0. Use with caution.

size_type size(void) const

Returns the number of vertices in the pool.

void sort_by_external_index(void)

Re-orders (and re-numbers) the vertices in this vertex pool so that they appear in increasing order by the optional external_index that has been assigned to each vertex.

void transform(LMatrix4d const &mat)

Applies the indicated transformation matrix to all the vertices. However, vertices that are attached to primitives that believe their vertices are in a local coordinate system are transformed only by the scale and rotation component. If a vertex happens to be attached both to a local and a global primitive, and the transformation includes a translation component, the vertex will be split.