19 INLINE GeomPrimitive::ShadeModel GeomPrimitive::
20 get_shade_model()
const {
21 CDReader cdata(_cycler);
22 return cdata->_shade_model;
38 cdata->_shade_model = shade_model;
52 INLINE GeomPrimitive::UsageHint GeomPrimitive::
53 get_usage_hint()
const {
54 CDReader cdata(_cycler);
55 return cdata->_usage_hint;
62 INLINE GeomPrimitive::NumericType GeomPrimitive::
63 get_index_type()
const {
64 CDReader cdata(_cycler);
65 return cdata->_index_type;
88 return (!cdata->_vertices.is_null());
100 return reader.get_first_vertex();
106 INLINE
int GeomPrimitive::
107 get_num_vertices()
const {
109 return reader.get_num_vertices();
118 return reader.get_vertex(i);
129 if (num_vertices_per_primitive == 0) {
133 return cdata->_ends.size();
150 if (num_vertices_per_primitive == 0) {
155 return num_vertices - (num_primitives * (min_num_vertices_per_primitive - 1)) - ((num_primitives - 1) * num_unused_vertices_per_primitive);
169 if (num_vertices_per_primitive == 0) {
184 return reader.get_min_vertex();
195 return reader.get_max_vertex();
201 INLINE
int GeomPrimitive::
202 get_data_size_bytes()
const {
203 CDReader cdata(_cycler);
204 nassertr(!cdata->_vertices.is_null(), 0);
205 return cdata->_vertices.get_read_pointer()->get_data_size_bytes();
213 get_modified()
const {
214 CDReader cdata(_cycler);
215 return cdata->_modified;
225 Thread *current_thread = Thread::get_current_thread();
227 data_reader.check_array_readers();
237 reader.check_minmax();
238 return reader.check_valid(data_reader);
252 get_vertices()
const {
253 CDReader cdata(_cycler);
254 return cdata->_vertices.get_read_pointer();
261 get_vertices_handle(
Thread *current_thread)
const {
262 CDReader cdata(_cycler, current_thread);
270 modify_vertices_handle(
Thread *current_thread) {
271 CDWriter cdata(_cycler,
true, current_thread);
283 INLINE
int GeomPrimitive::
284 get_index_stride()
const {
286 return reader.get_index_stride();
294 INLINE
int GeomPrimitive::
295 get_strip_cut_index()
const {
296 CDReader cdata(_cycler);
333 reader.check_minmax();
334 return reader.get_mins();
351 reader.check_minmax();
352 return reader.get_maxs();
358 INLINE
void GeomPrimitive::
359 add_vertices(
int v1,
int v2) {
367 INLINE
void GeomPrimitive::
368 add_vertices(
int v1,
int v2,
int v3) {
377 INLINE
void GeomPrimitive::
378 add_vertices(
int v1,
int v2,
int v3,
int v4) {
397 make_index_data()
const {
405 make_index_format(NumericType index_type) {
410 format->
add_column(InternalName::get_index(), 1, index_type, C_index, 0, 1);
411 return GeomVertexArrayFormat::register_format(format);
417 INLINE GeomPrimitive::CData::
419 _shade_model(SM_smooth),
422 _index_type(NT_uint16),
423 _usage_hint(UH_unspecified),
433 INLINE GeomPrimitive::CData::
434 CData(
const GeomPrimitive::CData ©) :
435 _shade_model(copy._shade_model),
436 _first_vertex(copy._first_vertex),
437 _num_vertices(copy._num_vertices),
438 _index_type(copy._index_type),
439 _usage_hint(copy._usage_hint),
440 _vertices(copy._vertices),
444 _modified(copy._modified),
445 _got_minmax(copy._got_minmax),
446 _min_vertex(copy._min_vertex),
447 _max_vertex(copy._max_vertex)
453 INLINE GeomPrimitivePipelineReader::
456 _object(std::move(object)),
457 _current_thread(current_thread),
459 _cdata(_object->_cycler.read_unlocked(current_thread)),
461 _vertices_cdata(nullptr)
463 nassertv(_object->test_ref_count_nonzero());
466 #endif // DO_PIPELINING 468 if (!_cdata->_vertices.is_null()) {
469 _vertices = _cdata->_vertices.get_read_pointer(current_thread);
470 _vertices_cdata = _vertices->_cycler.read_unlocked(current_thread);
472 _vertices_cdata->ref();
473 #endif // DO_PIPELINING 476 _vertices_cdata->_rw_lock.acquire();
483 INLINE GeomPrimitivePipelineReader::
484 ~GeomPrimitivePipelineReader() {
486 nassertv(_object->test_ref_count_nonzero());
492 #endif // DO_PIPELINING 494 if (_vertices_cdata !=
nullptr) {
497 _vertices_cdata->_rw_lock.release();
501 #endif // DO_PIPELINING 521 INLINE
Thread *GeomPrimitivePipelineReader::
522 get_current_thread()
const {
523 return _current_thread;
529 INLINE GeomPrimitivePipelineReader::ShadeModel GeomPrimitivePipelineReader::
530 get_shade_model()
const {
531 return _cdata->_shade_model;
537 INLINE GeomPrimitivePipelineReader::UsageHint GeomPrimitivePipelineReader::
538 get_usage_hint()
const {
539 return _cdata->_usage_hint;
545 INLINE GeomPrimitivePipelineReader::NumericType GeomPrimitivePipelineReader::
546 get_index_type()
const {
547 return _cdata->_index_type;
553 INLINE
bool GeomPrimitivePipelineReader::
555 return (!_vertices.is_null());
561 INLINE
int GeomPrimitivePipelineReader::
562 get_num_vertices()
const {
563 if (_cdata->_num_vertices != -1) {
564 return _cdata->_num_vertices;
566 nassertr(!_vertices.is_null(), 0);
567 size_t stride = _vertices->_array_format->get_stride();
568 nassertr(stride != 0, 0);
576 INLINE
int GeomPrimitivePipelineReader::
577 get_min_vertex()
const {
578 nassertr(_cdata->_got_minmax, 0);
579 return _cdata->_min_vertex;
585 INLINE
int GeomPrimitivePipelineReader::
586 get_max_vertex()
const {
587 nassertr(_cdata->_got_minmax, 0);
588 return _cdata->_max_vertex;
596 return _vertices_cdata->_buffer.get_size();
602 INLINE
UpdateSeq GeomPrimitivePipelineReader::
603 get_modified()
const {
604 return _cdata->_modified;
610 INLINE
int GeomPrimitivePipelineReader::
611 get_index_stride()
const {
612 nassertr(is_indexed(), 0);
613 return _vertices->_array_format->get_stride();
619 INLINE
const unsigned char *GeomPrimitivePipelineReader::
620 get_read_pointer(
bool force)
const {
622 return _vertices_cdata->_buffer.get_read_pointer(force);
628 INLINE
int GeomPrimitivePipelineReader::
629 get_strip_cut_index()
const {
636 INLINE
CPTA_int GeomPrimitivePipelineReader::
638 return _cdata->_ends;
646 nassertr(is_indexed(),
nullptr);
647 nassertr(_cdata->_got_minmax,
nullptr);
648 return _cdata->_mins.get_read_pointer();
656 nassertr(is_indexed(),
nullptr);
657 nassertr(_cdata->_got_minmax,
nullptr);
658 return _cdata->_maxs.get_read_pointer();
667 return ((
GeomPrimitive *)_object.p())->prepare_now(prepared_objects, gsg);
673 INLINE
bool GeomPrimitivePipelineReader::
675 return _object->draw(gsg,
this, force);
678 INLINE std::ostream &
int get_primitive_num_faces(int n) const
Returns the number of triangles or other fundamental type (such as line segments) represented by the ...
bool is_composite() const
Returns true if the primitive is a composite primitive such as a tristrip or trifan,...
const GeomVertexArrayFormat * get_index_format() const
Returns a registered format appropriate for using to store the index table.
get_min_num_vertices_per_primitive
Returns the minimum number of vertices that must be added before close_primitive() may legally be cal...
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.
get_vertex
Returns the ith vertex index in the table.
This is a special class object that holds all the information returned by a particular GSG to indicat...
A single page of data maintained by a PipelineCycler.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
get_num_vertices
Returns the number of indices used by all the primitives in this object.
This data object is returned by GeomVertexArrayData::get_handle() or modify_handle().
A table of objects that are saved within the graphics context for reference by handle later.
int get_first_vertex() const
Returns the first vertex number referenced by the primitive.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
CPT(GeomVertexArrayData) GeomPrimitive
Returns a const pointer to the vertex index array so application code can read it directly.
int get_num_faces() const
Returns the number of triangles or other fundamental type (such as line segments) represented by all ...
void add_vertex(int vertex)
Adds the indicated vertex to the list of vertex indices used by the graphics primitive type.
int get_min_vertex() const
Returns the minimum vertex index number used by all the primitives in this object.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
void set_shade_model(ShadeModel shade_model)
Changes the ShadeModel hint for this primitive.
get_index_type
Returns the numeric type of the index column.
CPTA_int get_ends() const
Returns a const pointer to the primitive ends array so application code can read it directly.
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
get_strip_cut_index
Returns the index of the indicated type that is reserved for use as a strip cut index,...
bool check_valid(const GeomVertexData *vertex_data) const
Verifies that the primitive only references vertices that actually exist within the indicated GeomVer...
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
int get_num_primitives() const
Returns the number of individual primitives stored within this object.
A thread; that is, a lightweight process.
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
PT(GeomVertexArrayData) GeomPrimitive
Creates and returns a new, empty index table.
int get_data_size_bytes() const
Returns the number of bytes stored in the vertices array.
This is a sequence number that increments monotonically.
Encapsulates the data from a GeomPrimitive, pre-fetched for one stage of the pipeline.
void check_minmax() const
Ensures that the primitive's minmax cache has been computed.
void unref_delete(RefCountType *ptr)
This global helper function will unref the given ReferenceCount object, and if the reference count re...
get_num_unused_vertices_per_primitive
Returns the number of vertices that are added between primitives that aren't, strictly speaking,...
bool is_indexed() const
Returns true if the primitive is indexed, false otherwise.
get_num_vertices_per_primitive
If the primitive type is a simple type in which all primitives have the same number of vertices,...
Similar to PointerToArray, except that its contents may not be modified.
This is the data for one array of a GeomVertexData structure.