Panda3D
|
This is an abstract base class for a family of classes that represent the fundamental geometry primitives that may be stored in a Geom. More...
#include "geomPrimitive.h"
Classes | |
class | CData |
Public Member Functions | |
GeomPrimitive (UsageHint usage_hint) | |
GeomPrimitive (const GeomPrimitive ©) | |
void | add_consecutive_vertices (int start, int num_vertices) |
Adds a consecutive sequence of vertices, beginning at start, to the primitive. | |
void | add_next_vertices (int num_vertices) |
Adds the next n vertices in sequence, beginning from the last vertex added to the primitive + 1. | |
void | add_vertex (int vertex) |
Adds the indicated vertex to the list of vertex indices used by the graphics primitive type. | |
void | add_vertices (int v1, int v2) |
Adds several vertices in a row. | |
void | add_vertices (int v1, int v2, int v3) |
Adds several vertices in a row. | |
void | add_vertices (int v1, int v2, int v3, int v4) |
Adds several vertices in a row. | |
void | calc_tight_bounds (LPoint3 &min_point, LPoint3 &max_point, bool &found_any, const GeomVertexData *vertex_data, bool got_mat, const LMatrix4 &mat, const InternalName *column_name, Thread *current_thread) const |
Expands min_point and max_point to include all of the vertices in the Geom, if any (or the data of any point type, for instance, texture coordinates--based on the column name). | |
bool | check_valid (const GeomVertexData *vertex_data) const |
Verifies that the primitive only references vertices that actually exist within the indicated GeomVertexData. | |
void | clear_minmax () |
Undoes a previous call to set_minmax(), and allows the minimum and maximum values to be recomputed normally. | |
void | clear_vertices () |
Removes all of the vertices and primitives from the object, so they can be re-added. | |
bool | close_primitive () |
Indicates that the previous n calls to add_vertex(), since the last call to close_primitive(), have fully defined a new primitive. | |
CPT (GeomVertexArrayData) get_mins() const | |
CPT (GeomVertexArrayData) get_maxs() const | |
CPT (GeomVertexArrayFormat) get_index_format() const | |
CPT (GeomPrimitive) decompose() const | |
CPT (GeomPrimitive) rotate() const | |
CPT (GeomPrimitive) doubleside() const | |
CPT (GeomPrimitive) reverse() const | |
CPT (GeomPrimitive) match_shade_model(ShadeModel shade_model) const | |
CPT (GeomPrimitive) make_points() const | |
CPT (GeomVertexArrayData) get_vertices() const | |
virtual bool | draw (GraphicsStateGuardianBase *gsg, const GeomPrimitivePipelineReader *reader, bool force) const =0 |
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 () |
int | get_data_size_bytes () const |
Returns the number of bytes stored in the vertices array. | |
CPTA_int | get_ends () const |
Returns a const pointer to the primitive ends array so application code can read it directly. | |
int | get_first_vertex () const |
Returns the first vertex number referenced by the primitive. | |
virtual int | get_geom_rendering () const |
Returns the set of GeomRendering bits that represent the rendering properties required to properly render this primitive. | |
int | get_index_stride () const |
A convenience function to return the gap between successive index numbers, in bytes, of the index data. | |
NumericType | get_index_type () const |
Returns the numeric type of the index column. | |
int | get_max_vertex () const |
Returns the maximum vertex index number used by all the primitives in this object. | |
virtual int | get_min_num_vertices_per_primitive () const |
Returns the minimum number of vertices that must be added before close_primitive() may legally be called. | |
int | get_min_vertex () const |
Returns the minimum vertex index number used by all the primitives in this object. | |
UpdateSeq | get_modified () const |
Returns a sequence number which is guaranteed to change at least every time the vertex index array is modified. | |
int | get_num_bytes () const |
Returns the number of bytes consumed by the primitive and its index table(s). | |
int | get_num_faces () const |
Returns the number of triangles or other fundamental type (such as line segments) represented by all the primitives in this object. | |
int | get_num_primitives () const |
Returns the number of individual primitives stored within this object. | |
virtual int | get_num_unused_vertices_per_primitive () const |
Returns the number of vertices that are added between primitives that aren't, strictly speaking, part of the primitives themselves. | |
int | get_num_vertices () const |
Returns the number of vertices used by all the primitives in this object. | |
virtual int | get_num_vertices_per_primitive () const |
If the primitive type is a simple type in which all primitives have the same number of vertices, like triangles, returns the number of vertices per primitive. | |
int | get_primitive_end (int n) const |
Returns the element within the _vertices list at which the nth primitive ends. | |
int | get_primitive_max_vertex (int n) const |
Returns the maximum vertex index number used by the nth primitive in this object. | |
int | get_primitive_min_vertex (int n) const |
Returns the minimum vertex index number used by the nth primitive in this object. | |
int | get_primitive_num_faces (int n) const |
Returns the number of triangles or other fundamental type (such as line segments) represented by the nth primitive in this object. | |
int | get_primitive_num_vertices (int n) const |
Returns the number of vertices used by the nth primitive. | |
int | get_primitive_start (int n) const |
Returns the element within the _vertices list at which the nth primitive starts. | |
virtual PrimitiveType | get_primitive_type () const =0 |
ShadeModel | get_shade_model () const |
Returns the ShadeModel hint for this primitive. | |
virtual TypeHandle | get_type () const |
UsageHint | get_usage_hint () const |
Returns the usage hint for this primitive. | |
int | get_vertex (int i) const |
Returns the ith vertex index in the table. | |
bool | is_composite () const |
Returns true if the primitive is a composite primitive such as a tristrip or trifan, or false if it is a fundamental primitive such as a collection of triangles. | |
bool | is_indexed () const |
Returns true if the primitive is indexed, false otherwise. | |
bool | is_prepared (PreparedGraphicsObjects *prepared_objects) const |
Returns true if the data has already been prepared or enqueued for preparation on the indicated GSG, false otherwise. | |
void | make_indexed () |
Converts the primitive from nonindexed form to indexed form. | |
void | make_nonindexed (GeomVertexData *dest, const GeomVertexData *source) |
Converts the primitive from indexed to nonindexed by duplicating vertices as necessary into the indicated dest GeomVertexData. | |
MAKE_SEQ (get_vertices, get_num_vertices, get_vertex) | |
PTA_int | modify_ends () |
Returns a modifiable pointer to the primitive ends array, so application code can directly fiddle with this data. | |
void | offset_vertices (int offset) |
Adds the indicated offset to all vertices used by the primitive. | |
void | operator= (const GeomPrimitive ©) |
The copy assignment operator is not pipeline-safe. | |
virtual void | output (ostream &out) const |
void | pack_vertices (GeomVertexData *dest, const GeomVertexData *source) |
Packs the vertices used by the primitive from the indicated source array onto the end of the indicated destination array. | |
void | prepare (PreparedGraphicsObjects *prepared_objects) |
Indicates that the data should be enqueued to be prepared in the indicated prepared_objects at the beginning of the next frame. | |
IndexBufferContext * | prepare_now (PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) |
Creates a context for the data on the particular GSG, if it does not already exist. | |
virtual | PT (GeomPrimitive) make_copy() const =0 |
PT (GeomVertexArrayData) make_index_data() const | |
PT (GeomVertexArrayData) modify_vertices(int num_vertices | |
bool | release (PreparedGraphicsObjects *prepared_objects) |
Frees the data context only on the indicated object, if it exists there. | |
int | release_all () |
Frees the context allocated on all objects for which the data has been declared. | |
bool | request_resident () const |
Returns true if the primitive data is currently resident in memory. | |
void | reserve_num_vertices (int num_vertices) |
This ensures that enough memory space for n vertices is allocated, so that you may increase the number of vertices to n without causing a new memory allocation. | |
void | set_ends (CPTA_int ends) |
Completely replaces the primitive ends array with a new table. | |
void | set_index_type (NumericType index_type) |
Changes the numeric type of the index column. | |
void | set_minmax (int min_vertex, int max_vertex, GeomVertexArrayData *mins, GeomVertexArrayData *maxs) |
Explicitly specifies the minimum and maximum vertices, as well as the lists of per-component min and max. | |
void | set_nonindexed_vertices (int first_vertex, int num_vertices) |
Sets the primitive up as a nonindexed primitive, using the indicated vertex range. | |
void | set_shade_model (ShadeModel shade_model) |
Changes the ShadeModel hint for this primitive. | |
void | set_usage_hint (UsageHint usage_hint) |
Changes the UsageHint hint for this primitive. | |
void | set_vertices (const GeomVertexArrayData *vertices, int num_vertices=-1) |
Completely replaces the vertex index list with a new table. | |
virtual void | write (ostream &out, int indent_level) 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 () |
Protected Member Functions | |
GeomPrimitive () | |
Constructs an invalid object. | |
virtual void | append_unused_vertices (GeomVertexArrayData *vertices, int vertex) |
Called when a new primitive is begun (other than the first primitive), this should add some degenerate vertices between primitives, if the primitive type requires that. | |
virtual | CPT (GeomVertexArrayData) rotate_impl() const |
virtual | CPT (GeomPrimitive) doubleside_impl() const |
virtual | CPT (GeomPrimitive) reverse_impl() const |
virtual | CPT (GeomPrimitive) decompose_impl() const |
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 GeomPrimitive. | |
virtual | PT (CopyOnWriteObject) make_cow_copy() |
virtual bool | requires_unused_vertices () const |
Should be redefined to return true in any primitive that implements append_unused_vertices(). | |
Friends | |
class | Geom |
class | GeomPrimitivePipelineReader |
class | PreparedGraphicsObjects |
This is an abstract base class for a family of classes that represent the fundamental geometry primitives that may be stored in a Geom.
They all have in common the fact that they are defined by tables of vertex data stored in a GeomVertexData object. Each GeomPrimitive object contains an ordered list of integers, which index into the vertex array defined by the GeomVertexData and define the particular vertices of the GeomVertexData that are used for this primitive.
The meaning of a given arrangement of vertices is defined by each individual primitive type; for instance, a GeomTriangle renders a triangle from each three consecutive vertices, while a GeomTriangleStrip renders a strip of (n - 2) connected triangles from each sequence of n vertices.
Definition at line 63 of file geomPrimitive.h.
GeomPrimitive::GeomPrimitive | ( | ) | [protected] |
Constructs an invalid object.
Only used when reading from bam.
Definition at line 48 of file geomPrimitive.cxx.
void GeomPrimitive::add_consecutive_vertices | ( | int | start, |
int | num_vertices | ||
) |
Adds a consecutive sequence of vertices, beginning at start, to the primitive.
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 253 of file geomPrimitive.cxx.
References GeomVertexWriter::add_data1i(), append_unused_vertices(), Geom::get_next_modified(), get_num_primitives(), get_num_vertices(), get_primitive_end(), and GeomVertexWriter::set_row_unsafe().
Referenced by add_next_vertices().
void GeomPrimitive::add_next_vertices | ( | int | num_vertices | ) |
Adds the next n vertices in sequence, beginning from the last vertex added to the primitive + 1.
This is most useful when you are building up a primitive and a GeomVertexData at the same time, and you just want the primitive to reference the first n vertices from the data, then the next n, and so on.
Definition at line 320 of file geomPrimitive.cxx.
References add_consecutive_vertices(), get_num_vertices(), and get_vertex().
void GeomPrimitive::add_vertex | ( | int | vertex | ) |
Adds the indicated vertex to the list of vertex indices used by the graphics primitive type.
To define a primitive, you must call add_vertex() for each vertex of the new primitive, and then call close_primitive() after you have specified the last vertex of each primitive.
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 188 of file geomPrimitive.cxx.
References GeomVertexWriter::add_data1i(), append_unused_vertices(), Geom::get_next_modified(), get_num_primitives(), get_num_vertices(), get_primitive_end(), requires_unused_vertices(), and GeomVertexWriter::set_row_unsafe().
Referenced by add_vertices().
void GeomPrimitive::add_vertices | ( | int | v1, |
int | v2, | ||
int | v3, | ||
int | v4 | ||
) | [inline] |
Adds several vertices in a row.
Definition at line 411 of file geomPrimitive.I.
References add_vertex().
void GeomPrimitive::add_vertices | ( | int | v1, |
int | v2 | ||
) | [inline] |
Adds several vertices in a row.
Definition at line 388 of file geomPrimitive.I.
References add_vertex().
void GeomPrimitive::add_vertices | ( | int | v1, |
int | v2, | ||
int | v3 | ||
) | [inline] |
Adds several vertices in a row.
Definition at line 399 of file geomPrimitive.I.
References add_vertex().
void GeomPrimitive::append_unused_vertices | ( | GeomVertexArrayData * | vertices, |
int | vertex | ||
) | [protected, virtual] |
Called when a new primitive is begun (other than the first primitive), this should add some degenerate vertices between primitives, if the primitive type requires that.
The second parameter is the first vertex that begins the new primitive.
This method is only called if requires_unused_vertices(), above, returns true.
Reimplemented in GeomTristrips.
Definition at line 1671 of file geomPrimitive.cxx.
Referenced by add_consecutive_vertices(), and add_vertex().
void GeomPrimitive::calc_tight_bounds | ( | LPoint3 & | min_point, |
LPoint3 & | max_point, | ||
bool & | found_any, | ||
const GeomVertexData * | vertex_data, | ||
bool | got_mat, | ||
const LMatrix4 & | mat, | ||
const InternalName * | column_name, | ||
Thread * | current_thread | ||
) | const |
Expands min_point and max_point to include all of the vertices in the Geom, if any (or the data of any point type, for instance, texture coordinates--based on the column name).
found_any is set true if any points are found. It is the caller's responsibility to initialize min_point, max_point, and found_any before calling this function.
Definition at line 1495 of file geomPrimitive.cxx.
References GeomVertexReader::get_data1i(), GeomVertexReader::get_data3(), GeomVertexReader::has_column(), GeomVertexReader::set_row_unsafe(), and LMatrix4f::xform_point().
bool GeomPrimitive::check_valid | ( | const GeomVertexData * | vertex_data | ) | const [inline] |
Verifies that the primitive only references vertices that actually exist within the indicated GeomVertexData.
Returns true if the primitive appears to be valid, false otherwise.
Definition at line 266 of file geomPrimitive.I.
References GeomPrimitivePipelineReader::check_minmax(), and Thread::get_current_thread().
Referenced by Geom::add_primitive(), Geom::set_primitive(), and Geom::unify_in_place().
void GeomPrimitive::clear_minmax | ( | ) |
Undoes a previous call to set_minmax(), and allows the minimum and maximum values to be recomputed normally.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Definition at line 1237 of file geomPrimitive.cxx.
void GeomPrimitive::clear_vertices | ( | ) |
Removes all of the vertices and primitives from the object, so they can be re-added.
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 430 of file geomPrimitive.cxx.
References Geom::get_next_modified().
Referenced by Geom::unify_in_place().
bool GeomPrimitive::close_primitive | ( | ) |
Indicates that the previous n calls to add_vertex(), since the last call to close_primitive(), have fully defined a new primitive.
Returns true if successful, false otherwise.
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 377 of file geomPrimitive.cxx.
References get_min_num_vertices_per_primitive(), Geom::get_next_modified(), get_num_unused_vertices_per_primitive(), get_num_vertices(), and get_num_vertices_per_primitive().
void GeomPrimitive::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 GeomPrimitive.
Reimplemented from TypedWritable.
Definition at line 1913 of file geomPrimitive.cxx.
References BamReader::read_cdata(), and BamReader::register_finalize().
void GeomPrimitive::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 1898 of file geomPrimitive.cxx.
References GeomVertexArrayData::get_usage_hint(), and set_usage_hint().
int GeomPrimitive::get_data_size_bytes | ( | ) | const [inline] |
Returns the number of bytes stored in the vertices array.
Definition at line 238 of file geomPrimitive.I.
Referenced by PreparedGraphicsObjects::prepare_index_buffer_now(), and PreparedGraphicsObjects::release_index_buffer().
CPTA_int GeomPrimitive::get_ends | ( | ) | const [inline] |
Returns a const pointer to the primitive ends array so application code can read it directly.
Do not attempt to modify the returned array; use modify_ends() or set_ends() for this.
Note that simple primitive types, like triangles, do not have a ends array: since all the primitives have the same number of vertices, it is not needed.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Definition at line 331 of file geomPrimitive.I.
int GeomPrimitive::get_first_vertex | ( | ) | const [inline] |
Returns the first vertex number referenced by the primitive.
This is particularly important in the case of a nonindexed primitive, in which case get_first_vertex() and get_num_vertices() completely define the extent of the vertex range.
Definition at line 124 of file geomPrimitive.I.
References Thread::get_current_thread().
int GeomPrimitive::get_geom_rendering | ( | ) | const [virtual] |
Returns the set of GeomRendering bits that represent the rendering properties required to properly render this primitive.
Reimplemented in GeomLinestrips, GeomPoints, GeomTrifans, and GeomTristrips.
Definition at line 116 of file geomPrimitive.cxx.
References is_indexed().
int GeomPrimitive::get_index_stride | ( | ) | const [inline] |
A convenience function to return the gap between successive index numbers, in bytes, of the index data.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Definition at line 308 of file geomPrimitive.I.
References Thread::get_current_thread().
GeomPrimitive::NumericType GeomPrimitive::get_index_type | ( | ) | const [inline] |
Returns the numeric type of the index column.
Normally, this will be either NT_uint16 or NT_uint32.
Definition at line 79 of file geomPrimitive.I.
int GeomPrimitive::get_max_vertex | ( | ) | const [inline] |
Returns the maximum vertex index number used by all the primitives in this object.
Definition at line 225 of file geomPrimitive.I.
References GeomPrimitivePipelineReader::check_minmax(), and Thread::get_current_thread().
Referenced by set_index_type().
int GeomPrimitive::get_min_num_vertices_per_primitive | ( | ) | const [virtual] |
Returns the minimum number of vertices that must be added before close_primitive() may legally be called.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Reimplemented in GeomLines, GeomLinestrips, and GeomPoints.
Definition at line 1275 of file geomPrimitive.cxx.
Referenced by close_primitive(), get_num_faces(), and get_primitive_num_faces().
int GeomPrimitive::get_min_vertex | ( | ) | const [inline] |
Returns the minimum vertex index number used by all the primitives in this object.
Definition at line 212 of file geomPrimitive.I.
References GeomPrimitivePipelineReader::check_minmax(), and Thread::get_current_thread().
UpdateSeq GeomPrimitive::get_modified | ( | ) | const [inline] |
Returns a sequence number which is guaranteed to change at least every time the vertex index array is modified.
Definition at line 252 of file geomPrimitive.I.
int GeomPrimitive::get_num_bytes | ( | ) | const |
Returns the number of bytes consumed by the primitive and its index table(s).
Definition at line 936 of file geomPrimitive.cxx.
int GeomPrimitive::get_num_faces | ( | ) | const [inline] |
Returns the number of triangles or other fundamental type (such as line segments) represented by all the primitives in this object.
Definition at line 173 of file geomPrimitive.I.
References get_min_num_vertices_per_primitive(), get_num_primitives(), get_num_unused_vertices_per_primitive(), get_num_vertices(), and get_num_vertices_per_primitive().
int GeomPrimitive::get_num_primitives | ( | ) | const [inline] |
Returns the number of individual primitives stored within this object.
All primitives are the same type.
Definition at line 160 of file geomPrimitive.I.
References Thread::get_current_thread().
Referenced by add_consecutive_vertices(), add_vertex(), and get_num_faces().
int GeomPrimitive::get_num_unused_vertices_per_primitive | ( | ) | const [virtual] |
Returns the number of vertices that are added between primitives that aren't, strictly speaking, part of the primitives themselves.
This is used, for instance, to define degenerate triangles to connect otherwise disconnected triangle strips.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Reimplemented in GeomTristrips.
Definition at line 1294 of file geomPrimitive.cxx.
Referenced by close_primitive(), get_num_faces(), get_primitive_end(), get_primitive_num_vertices(), and get_primitive_start().
int GeomPrimitive::get_num_vertices | ( | ) | const [inline] |
Returns the number of vertices used by all the primitives in this object.
Definition at line 136 of file geomPrimitive.I.
References Thread::get_current_thread().
Referenced by add_consecutive_vertices(), SpriteParticleRenderer::add_from_node(), add_next_vertices(), add_vertex(), close_primitive(), get_num_faces(), make_nonindexed(), pack_vertices(), and Geom::unify_in_place().
int GeomPrimitive::get_num_vertices_per_primitive | ( | ) | const [virtual] |
If the primitive type is a simple type in which all primitives have the same number of vertices, like triangles, returns the number of vertices per primitive.
If the primitive type is a more complex type in which different primitives might have different numbers of vertices, for instance a triangle strip, returns 0.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Reimplemented in GeomLines, GeomPoints, and GeomTriangles.
Definition at line 1259 of file geomPrimitive.cxx.
Referenced by close_primitive(), get_num_faces(), get_primitive_end(), get_primitive_num_faces(), get_primitive_num_vertices(), get_primitive_start(), and is_composite().
int GeomPrimitive::get_primitive_end | ( | int | n | ) | const |
Returns the element within the _vertices list at which the nth primitive ends.
This is one past the last valid element for the nth primitive.
Definition at line 622 of file geomPrimitive.cxx.
References get_num_unused_vertices_per_primitive(), and get_num_vertices_per_primitive().
Referenced by add_consecutive_vertices(), add_vertex(), get_primitive_max_vertex(), and Geom::unify_in_place().
int GeomPrimitive::get_primitive_max_vertex | ( | int | n | ) | const |
Returns the maximum vertex index number used by the nth primitive in this object.
Definition at line 697 of file geomPrimitive.cxx.
References GeomVertexReader::get_data1i(), get_primitive_end(), is_indexed(), and GeomVertexReader::set_row_unsafe().
int GeomPrimitive::get_primitive_min_vertex | ( | int | n | ) | const |
Returns the minimum vertex index number used by the nth primitive in this object.
Definition at line 677 of file geomPrimitive.cxx.
References GeomVertexReader::get_data1i(), get_primitive_start(), is_indexed(), and GeomVertexReader::set_row_unsafe().
int GeomPrimitive::get_primitive_num_faces | ( | int | n | ) | const [inline] |
Returns the number of triangles or other fundamental type (such as line segments) represented by the nth primitive in this object.
Definition at line 195 of file geomPrimitive.I.
References get_min_num_vertices_per_primitive(), get_num_vertices_per_primitive(), and get_primitive_num_vertices().
int GeomPrimitive::get_primitive_num_vertices | ( | int | n | ) | const |
Returns the number of vertices used by the nth primitive.
This is the same thing as get_primitive_end(n) - get_primitive_start(n).
Definition at line 648 of file geomPrimitive.cxx.
References get_num_unused_vertices_per_primitive(), and get_num_vertices_per_primitive().
Referenced by get_primitive_num_faces(), and Geom::unify_in_place().
int GeomPrimitive::get_primitive_start | ( | int | n | ) | const |
Returns the element within the _vertices list at which the nth primitive starts.
If i is one more than the highest valid primitive vertex, the return value will be one more than the last valid vertex. Thus, it is generally true that the vertices used by a particular primitive i are the set get_primitive_start(n) <= vi < get_primitive_start(n + 1) (although this range also includes the unused vertices between primitives).
Definition at line 592 of file geomPrimitive.cxx.
References get_num_unused_vertices_per_primitive(), and get_num_vertices_per_primitive().
Referenced by get_primitive_min_vertex(), and Geom::unify_in_place().
GeomPrimitive::ShadeModel GeomPrimitive::get_shade_model | ( | ) | const [inline] |
Returns the ShadeModel hint for this primitive.
This is intended as a hint to the renderer to tell it how the per-vertex colors and normals are applied.
Definition at line 24 of file geomPrimitive.I.
GeomPrimitive::UsageHint GeomPrimitive::get_usage_hint | ( | ) | const [inline] |
Returns the usage hint for this primitive.
See geomEnums.h. This has nothing to do with the usage hint associated with the primitive's vertices; this only specifies how often the vertex indices that define the primitive will be modified.
It is perfectly legal (and, in fact, common) for a GeomPrimitive to have UH_static on itself, while referencing vertex data with UH_dynamic. This means that the vertices themselves will be animated, but the primitive will always reference the same set of vertices from the pool.
Definition at line 67 of file geomPrimitive.I.
Referenced by PreparedGraphicsObjects::prepare_index_buffer_now(), and PreparedGraphicsObjects::release_index_buffer().
int GeomPrimitive::get_vertex | ( | int | i | ) | const [inline] |
Returns the ith vertex index in the table.
Definition at line 147 of file geomPrimitive.I.
References Thread::get_current_thread(), and GeomPrimitivePipelineReader::get_vertex().
Referenced by SpriteParticleRenderer::add_from_node(), add_next_vertices(), make_nonindexed(), pack_vertices(), and Geom::unify_in_place().
bool GeomPrimitive::is_composite | ( | ) | const [inline] |
Returns true if the primitive is a composite primitive such as a tristrip or trifan, or false if it is a fundamental primitive such as a collection of triangles.
Definition at line 93 of file geomPrimitive.I.
References get_num_vertices_per_primitive().
Referenced by request_resident().
bool GeomPrimitive::is_indexed | ( | ) | const [inline] |
Returns true if the primitive is indexed, false otherwise.
An indexed primitive stores a table of index numbers into its GeomVertexData, so that it can reference the vertices in any order. A nonindexed primitive, on the other hand, stores only the first vertex number and number of vertices used, so that it can only reference the vertices consecutively.
Definition at line 109 of file geomPrimitive.I.
References Thread::get_current_thread().
Referenced by GeomTrifans::get_geom_rendering(), GeomLinestrips::get_geom_rendering(), get_geom_rendering(), GeomTristrips::get_geom_rendering(), GeomPoints::get_geom_rendering(), get_primitive_max_vertex(), get_primitive_min_vertex(), offset_vertices(), pack_vertices(), prepare(), and prepare_now().
bool GeomPrimitive::is_prepared | ( | PreparedGraphicsObjects * | prepared_objects | ) | const |
Returns true if the data has already been prepared or enqueued for preparation on the indicated GSG, false otherwise.
Definition at line 1325 of file geomPrimitive.cxx.
References PreparedGraphicsObjects::is_index_buffer_queued().
Referenced by PreparedGraphicsObjects::is_index_buffer_prepared().
void GeomPrimitive::make_indexed | ( | ) |
Converts the primitive from nonindexed form to indexed form.
This will simply create an index table that is numbered consecutively from get_first_vertex(); it does not automatically collapse together identical vertices that may have been split apart by a previous call to make_nonindexed().
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 572 of file geomPrimitive.cxx.
void GeomPrimitive::make_nonindexed | ( | GeomVertexData * | dest, |
const GeomVertexData * | source | ||
) |
Converts the primitive from indexed to nonindexed by duplicating vertices as necessary into the indicated dest GeomVertexData.
Definition at line 495 of file geomPrimitive.cxx.
References GeomVertexData::copy_row_from(), Thread::get_current_thread(), GeomVertexData::get_num_rows(), get_num_vertices(), get_vertex(), set_nonindexed_vertices(), and GeomVertexData::set_num_rows().
Referenced by pack_vertices().
PTA_int GeomPrimitive::modify_ends | ( | ) |
Returns a modifiable pointer to the primitive ends array, so application code can directly fiddle with this data.
Use with caution, since there are no checks that the data will be left in a stable state.
Note that simple primitive types, like triangles, do not have a ends array: since all the primitives have the same number of vertices, it is not needed.
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.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Definition at line 1146 of file geomPrimitive.cxx.
References Geom::get_next_modified().
void GeomPrimitive::offset_vertices | ( | int | offset | ) |
Adds the indicated offset to all vertices used by the primitive.
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 459 of file geomPrimitive.cxx.
References GeomVertexReader::get_data1i(), Geom::get_next_modified(), GeomVertexRewriter::is_at_end(), is_indexed(), and GeomVertexWriter::set_data1i().
void GeomPrimitive::operator= | ( | const GeomPrimitive & | copy | ) |
The copy assignment operator is not pipeline-safe.
This will completely obliterate all stages of the pipeline, so don't do it for a GeomPrimitive that is actively being used for rendering.
Definition at line 93 of file geomPrimitive.cxx.
void GeomPrimitive::pack_vertices | ( | GeomVertexData * | dest, |
const GeomVertexData * | source | ||
) |
Packs the vertices used by the primitive from the indicated source array onto the end of the indicated destination array.
Definition at line 517 of file geomPrimitive.cxx.
References GeomVertexWriter::add_data1i(), GeomVertexData::copy_row_from(), Thread::get_current_thread(), GeomVertexData::get_num_rows(), get_num_vertices(), get_vertex(), is_indexed(), make_nonindexed(), and set_vertices().
void GeomPrimitive::prepare | ( | PreparedGraphicsObjects * | prepared_objects | ) |
Indicates that the data should be enqueued to be prepared in the indicated prepared_objects at the beginning of the next frame.
This will ensure the data is already loaded into the GSG if it is expected to be rendered soon.
Use this function instead of prepare_now() to preload datas from a user interface standpoint.
Definition at line 1311 of file geomPrimitive.cxx.
References PreparedGraphicsObjects::enqueue_index_buffer(), and is_indexed().
IndexBufferContext * GeomPrimitive::prepare_now | ( | PreparedGraphicsObjects * | prepared_objects, |
GraphicsStateGuardianBase * | gsg | ||
) |
Creates a context for the data on the particular GSG, if it does not already exist.
Returns the new (or old) IndexBufferContext. This assumes that the GraphicsStateGuardian is the currently active rendering context and that it is ready to accept new datas. If this is not necessarily the case, you should use prepare() instead.
Normally, this is not called directly except by the GraphicsStateGuardian; a data does not need to be explicitly prepared by the user before it may be rendered.
Definition at line 1351 of file geomPrimitive.cxx.
References is_indexed(), and PreparedGraphicsObjects::prepare_index_buffer_now().
Referenced by PreparedGraphicsObjects::begin_frame().
bool GeomPrimitive::release | ( | PreparedGraphicsObjects * | prepared_objects | ) |
Frees the data context only on the indicated object, if it exists there.
Returns true if it was released, false if it had not been prepared.
Definition at line 1376 of file geomPrimitive.cxx.
References PreparedGraphicsObjects::dequeue_index_buffer(), and PreparedGraphicsObjects::release_index_buffer().
int GeomPrimitive::release_all | ( | ) |
Frees the context allocated on all objects for which the data has been declared.
Returns the number of contexts which have been freed.
Definition at line 1397 of file geomPrimitive.cxx.
References PreparedGraphicsObjects::release_index_buffer().
bool GeomPrimitive::request_resident | ( | ) | const |
Returns true if the primitive data is currently resident in memory.
If this returns false, the primitive data will be brought back into memory shortly; try again later.
Definition at line 955 of file geomPrimitive.cxx.
References is_composite().
bool GeomPrimitive::requires_unused_vertices | ( | ) | const [protected, virtual] |
Should be redefined to return true in any primitive that implements append_unused_vertices().
Reimplemented in GeomTristrips.
Definition at line 1654 of file geomPrimitive.cxx.
Referenced by add_vertex().
void GeomPrimitive::reserve_num_vertices | ( | int | num_vertices | ) |
This ensures that enough memory space for n vertices is allocated, so that you may increase the number of vertices 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 vertices to the primitive.
Note that the total you specify here should also include implicit vertices which may be added at each close_primitive() call, according to get_num_unused_vertices_per_primitive().
Note also that making this call will implicitly make the primitive indexed if it is not already, which could result in a performance *penalty*. If you would prefer not to lose the nonindexed nature of your existing GeomPrimitives, check is_indexed() before making this call.
Definition at line 351 of file geomPrimitive.cxx.
void GeomPrimitive::set_ends | ( | CPTA_int | ends | ) |
Completely replaces the primitive ends array with a new table.
Chances are good that you should also replace the vertices list with set_vertices() at the same time.
Note that simple primitive types, like triangles, do not have a ends array: since all the primitives have the same number of vertices, it is not needed.
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.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Definition at line 1182 of file geomPrimitive.cxx.
References Geom::get_next_modified().
void GeomPrimitive::set_index_type | ( | GeomPrimitive::NumericType | index_type | ) |
Changes the numeric type of the index column.
Normally, this should be either NT_uint16 or NT_uint32.
The index type must be large enough to include all of the index values in the primitive. It may be automatically elevated, if necessary, to a larger index type, by a subsequent call to add_index() that names an index value that does not fit in the index type you specify.
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 164 of file geomPrimitive.cxx.
References get_max_vertex().
void GeomPrimitive::set_minmax | ( | int | min_vertex, |
int | max_vertex, | ||
GeomVertexArrayData * | mins, | ||
GeomVertexArrayData * | maxs | ||
) |
Explicitly specifies the minimum and maximum vertices, as well as the lists of per-component min and max.
Use this method with extreme caution. It's generally better to let the GeomPrimitive compute these explicitly, unless for some reason you can do it faster and you absolutely need the speed improvement.
Note that any modification to the vertex array will normally cause this to be recomputed, unless you set it immediately again.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Definition at line 1212 of file geomPrimitive.cxx.
References Geom::get_next_modified().
void GeomPrimitive::set_nonindexed_vertices | ( | int | first_vertex, |
int | num_vertices | ||
) |
Sets the primitive up as a nonindexed primitive, using the indicated vertex range.
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.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Definition at line 1110 of file geomPrimitive.cxx.
References Geom::get_next_modified().
Referenced by make_nonindexed().
void GeomPrimitive::set_shade_model | ( | GeomPrimitive::ShadeModel | shade_model | ) | [inline] |
Changes the ShadeModel hint for this primitive.
This is different from the ShadeModelAttrib that might also be applied from the scene graph. This does not affect the shade model that is in effect when rendering, but rather serves as a hint to the renderer to tell it how the per-vertex colors and normals on this primitive are applied.
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 45 of file geomPrimitive.I.
Referenced by Geom::unify_in_place().
void GeomPrimitive::set_usage_hint | ( | GeomPrimitive::UsageHint | usage_hint | ) |
Changes the UsageHint hint for this primitive.
See get_usage_hint().
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 135 of file geomPrimitive.cxx.
References Geom::get_next_modified().
Referenced by finalize().
void GeomPrimitive::set_vertices | ( | const GeomVertexArrayData * | vertices, |
int | num_vertices = -1 |
||
) |
Completely replaces the vertex index list with a new table.
Chances are good that you should also replace the ends list with set_ends() at the same time.
If num_vertices is not -1, it specifies an artificial limit to the number of vertices in the array. Otherwise, all of the vertices in the array will be used.
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.
This method is intended for low-level usage only. There are higher-level methods for more common usage. We recommend you do not use this method directly. If you do, be sure you know what you are doing!
Definition at line 1085 of file geomPrimitive.cxx.
References Geom::get_next_modified().
Referenced by pack_vertices().
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented from TypedWritable.
Definition at line 1884 of file geomPrimitive.cxx.
References TypedWritable::write_datagram().