21 CDReader cdata(_cycler);
22 return cdata->_shade_model;
38 cdata->_shade_model = shade_model;
54 CDReader cdata(_cycler);
55 return cdata->_usage_hint;
64 CDReader cdata(_cycler);
65 return cdata->_index_type;
88 return (!cdata->_vertices.is_null());
100 return reader.get_first_vertex();
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();
203 CDReader cdata(_cycler);
204 nassertr(!cdata->_vertices.is_null(), 0);
205 return cdata->_vertices.get_read_pointer()->get_data_size_bytes();
214 CDReader cdata(_cycler);
215 return cdata->_modified;
227 data_reader.check_array_readers();
237 reader.check_minmax();
238 return reader.check_valid(data_reader);
252get_vertices()
const {
253 CDReader cdata(_cycler);
254 return cdata->_vertices.get_read_pointer();
261get_vertices_handle(
Thread *current_thread)
const {
262 CDReader cdata(_cycler, current_thread);
270modify_vertices_handle(
Thread *current_thread) {
271 CDWriter cdata(_cycler,
true, current_thread);
286 return reader.get_index_stride();
296 CDReader cdata(_cycler);
333 reader.check_minmax();
334 return reader.get_mins();
351 reader.check_minmax();
352 return reader.get_maxs();
358INLINE
void GeomPrimitive::
359add_vertices(
int v1,
int v2) {
367INLINE
void GeomPrimitive::
368add_vertices(
int v1,
int v2,
int v3) {
377INLINE
void GeomPrimitive::
378add_vertices(
int v1,
int v2,
int v3,
int v4) {
397make_index_data()
const {
405make_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);
417INLINE GeomPrimitive::CData::
419 _shade_model(SM_smooth),
422 _index_type(NT_uint16),
423 _usage_hint(UH_unspecified),
433INLINE GeomPrimitive::CData::
434CData(
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)
453INLINE 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());
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();
476 _vertices_cdata->_rw_lock.acquire();
483INLINE GeomPrimitivePipelineReader::
484~GeomPrimitivePipelineReader() {
486 nassertv(_object->test_ref_count_nonzero());
494 if (_vertices_cdata !=
nullptr) {
497 _vertices_cdata->_rw_lock.
release();
521INLINE
Thread *GeomPrimitivePipelineReader::
522get_current_thread()
const {
523 return _current_thread;
529INLINE GeomPrimitivePipelineReader::ShadeModel GeomPrimitivePipelineReader::
530get_shade_model()
const {
531 return _cdata->_shade_model;
537INLINE GeomPrimitivePipelineReader::UsageHint GeomPrimitivePipelineReader::
538get_usage_hint()
const {
539 return _cdata->_usage_hint;
545INLINE GeomPrimitivePipelineReader::NumericType GeomPrimitivePipelineReader::
546get_index_type()
const {
547 return _cdata->_index_type;
553INLINE
bool GeomPrimitivePipelineReader::
555 return (!_vertices.is_null());
561INLINE
int GeomPrimitivePipelineReader::
562get_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);
576INLINE
int GeomPrimitivePipelineReader::
577get_min_vertex()
const {
578 nassertr(_cdata->_got_minmax, 0);
579 return _cdata->_min_vertex;
585INLINE
int GeomPrimitivePipelineReader::
586get_max_vertex()
const {
587 nassertr(_cdata->_got_minmax, 0);
588 return _cdata->_max_vertex;
596 return _vertices_cdata->_buffer.
get_size();
602INLINE
UpdateSeq GeomPrimitivePipelineReader::
603get_modified()
const {
604 return _cdata->_modified;
610INLINE
int GeomPrimitivePipelineReader::
611get_index_stride()
const {
612 nassertr(is_indexed(), 0);
613 return _vertices->_array_format->get_stride();
619INLINE
const unsigned char *GeomPrimitivePipelineReader::
620get_read_pointer(
bool force)
const {
628INLINE
int GeomPrimitivePipelineReader::
629get_strip_cut_index()
const {
636INLINE
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);
673INLINE
bool GeomPrimitivePipelineReader::
675 return _object->draw(gsg,
this, force);
Similar to PointerToArray, except that its contents may not be modified.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
A single page of data maintained by a PipelineCycler.
Encapsulates the data from a GeomPrimitive, pre-fetched for one stage of the pipeline.
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 an abstract base class for a family of classes that represent the fundamental geometry primit...
get_data_size_bytes
Returns the number of bytes stored in the vertices array.
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_primitive_num_faces(int n) const
Returns the number of triangles or other fundamental type (such as line segments) represented by the ...
int get_max_vertex() const
Returns the maximum vertex index number used by all the primitives in this object.
int get_num_primitives() const
Returns the number of individual primitives stored within this object.
CPTA_int get_ends() const
Returns a const pointer to the primitive ends array so application code can read it directly.
get_modified
Returns a sequence number which is guaranteed to change at least every time the vertex index array is...
get_vertex
Returns the ith vertex index in the table.
int get_num_faces() const
Returns the number of triangles or other fundamental type (such as line segments) represented by all ...
get_usage_hint
Returns the usage hint for this primitive.
get_num_vertices
Returns the number of indices used by all the primitives in this object.
bool check_valid(const GeomVertexData *vertex_data) const
Verifies that the primitive only references vertices that actually exist within the indicated GeomVer...
bool is_composite() const
Returns true if the primitive is a composite primitive such as a tristrip or trifan,...
get_strip_cut_index
Returns the index of the indicated type that is reserved for use as a strip cut index,...
int get_first_vertex() const
Returns the first vertex number referenced by the primitive.
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.
const GeomVertexArrayFormat * get_index_format() const
Returns a registered format appropriate for using to store the index table.
get_num_unused_vertices_per_primitive
Returns the number of vertices that are added between primitives that aren't, strictly speaking,...
get_index_stride
A convenience function to return the gap between successive index numbers, in bytes,...
get_num_vertices_per_primitive
If the primitive type is a simple type in which all primitives have the same number of vertices,...
int get_min_vertex() const
Returns the minimum vertex index number used by all the primitives in this object.
get_shade_model
Returns the ShadeModel hint for this primitive.
int get_primitive_num_vertices(int n) const
Returns the number of vertices used by the nth primitive.
void add_vertex(int vertex)
Adds the indicated vertex to the list of vertex indices used by the graphics primitive type.
bool is_indexed() const
Returns true if the primitive is indexed, false otherwise.
This data object is returned by GeomVertexArrayData::get_handle() or modify_handle().
This is the data for one array of a GeomVertexData structure.
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
This is a special class object that holds all the information returned by a particular GSG to indicat...
A table of objects that are saved within the graphics context for reference by handle later.
void release() const
Releases the reMutex.
A thread; that is, a lightweight process.
get_current_thread
Returns a pointer to the currently-executing Thread object.
This is a sequence number that increments monotonically.
const unsigned char * get_read_pointer(bool force) const
Returns a read-only pointer to the raw data, or NULL if the data is not currently resident.
size_t get_size() const
Returns the number of bytes in the buffer.
void unref_delete(RefCountType *ptr)
This global helper function will unref the given ReferenceCount object, and if the reference count re...