26 return cdata->_shade_model;
47 cdata->_shade_model = shade_model;
69 return cdata->_usage_hint;
81 return cdata->_index_type;
111 return reader.is_indexed();
126 return reader.get_first_vertex();
138 return reader.get_num_vertices();
162 return reader.get_num_primitives();
176 if (num_vertices_per_primitive == 0) {
181 return num_vertices - (num_primitives * (min_num_vertices_per_primitive - 1)) - ((num_primitives - 1) * num_unused_vertices_per_primitive);
198 if (num_vertices_per_primitive == 0) {
215 return reader.get_min_vertex();
228 return reader.get_max_vertex();
240 nassertr(!cdata->_vertices.is_null(), 0);
241 return cdata->_vertices.get_read_pointer()->get_data_size_bytes();
254 return cdata->_modified;
271 data_reader.check_array_readers();
272 return reader.check_valid(&data_reader);
290 get_vertices()
const {
291 CDReader cdata(_cycler);
292 return cdata->_vertices.get_read_pointer();
310 return reader.get_index_stride();
369 reader.check_minmax();
370 return reader.get_mins();
392 reader.check_minmax();
393 return reader.get_maxs();
449 make_index_data()
const {
460 make_index_format(NumericType index_type) {
461 PT(GeomVertexArrayFormat) format = new GeomVertexArrayFormat;
465 format->add_column(InternalName::get_index(), 1, index_type, C_index, 0, 1);
466 return GeomVertexArrayFormat::register_format(format);
476 _shade_model(SM_smooth),
479 _index_type(NT_uint16),
480 _usage_hint(UH_unspecified),
492 INLINE GeomPrimitive::CData::
493 CData(
const GeomPrimitive::CData ©) :
494 _shade_model(copy._shade_model),
495 _first_vertex(copy._first_vertex),
496 _num_vertices(copy._num_vertices),
497 _index_type(copy._index_type),
498 _usage_hint(copy._usage_hint),
499 _vertices(copy._vertices),
503 _modified(copy._modified),
504 _got_minmax(copy._got_minmax),
505 _min_vertex(copy._min_vertex),
506 _max_vertex(copy._max_vertex)
514 INLINE GeomPrimitivePipelineReader::
518 _current_thread(current_thread),
519 _cdata(object->_cycler.read_unlocked(current_thread)),
520 _vertices_reader(NULL)
522 nassertv(_object->test_ref_count_nonzero());
525 #endif // DO_PIPELINING
526 if (!_cdata->_vertices.is_null()) {
527 _vertices_reader = _cdata->_vertices.get_read_pointer()->get_handle();
536 INLINE GeomPrimitivePipelineReader::
546 INLINE
void GeomPrimitivePipelineReader::
556 INLINE GeomPrimitivePipelineReader::
557 ~GeomPrimitivePipelineReader() {
559 nassertv(_object->test_ref_count_nonzero());
565 #endif // DO_PIPELINING
568 _vertices_reader = NULL;
589 INLINE
Thread *GeomPrimitivePipelineReader::
590 get_current_thread()
const {
591 return _current_thread;
599 INLINE GeomPrimitivePipelineReader::ShadeModel GeomPrimitivePipelineReader::
600 get_shade_model()
const {
601 return _cdata->_shade_model;
609 INLINE GeomPrimitivePipelineReader::UsageHint GeomPrimitivePipelineReader::
610 get_usage_hint()
const {
611 return _cdata->_usage_hint;
619 INLINE GeomPrimitivePipelineReader::NumericType GeomPrimitivePipelineReader::
620 get_index_type()
const {
621 return _cdata->_index_type;
629 INLINE
bool GeomPrimitivePipelineReader::
631 return (!_cdata->_vertices.is_null());
639 INLINE
int GeomPrimitivePipelineReader::
640 get_num_vertices()
const {
641 if (_cdata->_num_vertices != -1) {
642 return _cdata->_num_vertices;
644 nassertr(!_cdata->_vertices.is_null(), 0);
645 return _vertices_reader->get_num_rows();
654 INLINE
int GeomPrimitivePipelineReader::
655 get_min_vertex()
const {
656 nassertr(_cdata->_got_minmax, 0);
657 return _cdata->_min_vertex;
665 INLINE
int GeomPrimitivePipelineReader::
666 get_max_vertex()
const {
667 nassertr(_cdata->_got_minmax, 0);
668 return _cdata->_max_vertex;
679 return _vertices_reader->get_data_size_bytes();
687 INLINE
UpdateSeq GeomPrimitivePipelineReader::
688 get_modified()
const {
689 return _cdata->_modified;
697 INLINE
int GeomPrimitivePipelineReader::
698 get_index_stride()
const {
699 nassertr(is_indexed(), 0);
700 return _cdata->_vertices.get_read_pointer()->get_array_format()->get_stride();
709 get_vertices_reader()
const {
710 return _vertices_reader;
718 INLINE
const unsigned char *GeomPrimitivePipelineReader::
719 get_read_pointer(
bool force)
const {
720 return _vertices_reader->get_read_pointer(force);
728 INLINE
int GeomPrimitivePipelineReader::
729 get_strip_cut_index()
const {
738 INLINE
CPTA_int GeomPrimitivePipelineReader::
740 return _cdata->_ends;
750 nassertr(is_indexed(), NULL);
751 nassertr(_cdata->_got_minmax, NULL);
752 return _cdata->_mins.get_read_pointer();
762 nassertr(is_indexed(), NULL);
763 nassertr(_cdata->_got_minmax, NULL);
764 return _cdata->_maxs.get_read_pointer();
775 return ((
GeomPrimitive *)_object.p())->prepare_now(prepared_objects, gsg);
int get_min_vertex() const
Returns the minimum vertex index number used by all the primitives in this object.
bool is_indexed() const
Returns true if the primitive is indexed, false otherwise.
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 cal...
UsageHint get_usage_hint() const
Returns the usage hint for this primitive.
This is a special class object that holds all the information returned by a particular GSG to indicat...
int get_strip_cut_index() const
If relevant, returns the index value that may be used in some cases to signify the end of a primitive...
A single page of data maintained by a PipelineCycler.
const GeomVertexArrayFormat * get_index_format() const
Returns a registered format appropriate for using to store the index table.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
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...
int get_data_size_bytes() const
Returns the number of bytes stored in the vertices array.
virtual int get_num_unused_vertices_per_primitive() const
Returns the number of vertices that are added between primitives that aren't, strictly speaking...
ShadeModel get_shade_model() const
Returns the ShadeModel hint for this primitive.
This data object is returned by GeomVertexArrayData::get_handle() or modify_handle().
int get_index_stride() const
A convenience function to return the gap between successive index numbers, in bytes, of the index data.
A table of objects that are saved within the graphics context for reference by handle later...
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
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.
int get_first_vertex() const
Returns the first vertex number referenced by the primitive.
int get_max_vertex() const
Returns the maximum vertex index number used by all the primitives in this object.
int get_primitive_num_vertices(int n) const
Returns the number of vertices used by the nth primitive.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
bool check_valid(const GeomVertexData *vertex_data) const
Verifies that the primitive only references vertices that actually exist within the indicated GeomVer...
void set_shade_model(ShadeModel shade_model)
Changes the ShadeModel hint for this primitive.
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.
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
int get_num_faces() const
Returns the number of triangles or other fundamental type (such as line segments) represented by all ...
int get_data_size_bytes() const
Returns the number of bytes stored in the vertices array.
void check_minmax() const
Ensures that the primitive's minmax cache has been computed.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
int get_num_vertices() const
Returns the number of indices used by all the primitives in this object.
A thread; that is, a lightweight process.
CPTA_int get_ends() const
Returns a const pointer to the primitive ends array so application code can read it directly...
int get_vertex(int i) const
Returns the ith vertex index in the table.
int get_primitive_num_faces(int n) const
Returns the number of triangles or other fundamental type (such as line segments) represented by the ...
UpdateSeq get_modified() const
Returns a sequence number which is guaranteed to change at least every time the vertex index array is...
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
This is a sequence number that increments monotonically.
Encapsulates the data from a GeomPrimitive, pre-fetched for one stage of the pipeline.
int get_vertex(int i) const
Returns the ith vertex index in the table.
int get_num_primitives() const
Returns the number of individual primitives stored within this object.
Similar to PointerToArray, except that its contents may not be modified.
This is the data for one array of a GeomVertexData structure.
NumericType get_index_type() const
Returns the numeric type of the index column.