34 CDReader cdata(_cycler);
35 return cdata->_usage_hint;
43 CDReader cdata(_cycler);
44 return cdata->_format;
54 return cdata->_format->has_column(name);
66 nassertr(cdata->_format->get_num_arrays() == cdata->_arrays.size(), 0);
68 if (cdata->_arrays.size() == 0) {
73 array = cdata->_arrays[0].get_read_pointer();
76 return array->get_num_rows();
99 writer.check_array_writers();
100 return writer.set_num_rows(n);
118 writer.check_array_writers();
119 return writer.unclean_set_num_rows(n);
135 writer.check_array_writers();
136 return writer.reserve_num_rows(n);
145 CDReader cdata(_cycler);
146 return cdata->_arrays.size();
155get_array(
size_t i)
const {
156 CDReader cdata(_cycler);
157 nassertr(i < cdata->_arrays.size(),
nullptr);
158 return cdata->_arrays[i].get_read_pointer();
165get_array_handle(
size_t i)
const {
167 CDReader cdata(_cycler, current_thread);
168 nassertr(i < cdata->_arrays.size(),
nullptr);
182modify_array(
size_t i) {
184 return writer.modify_array(i);
191modify_array_handle(
size_t i) {
208 writer.set_array(i, array);
224 CDReader cdata(_cycler);
225 return cdata->_transform_table;
248get_transform_blend_table()
const {
249 CDReader cdata(_cycler);
250 return cdata->_transform_blend_table.get_read_pointer();
257INLINE
void GeomVertexData::
258clear_transform_blend_table() {
272 CDReader cdata(_cycler);
273 return cdata->_slider_table;
292 return reader.get_num_bytes();
301 CDReader cdata(_cycler, current_thread);
302 return cdata->_modified;
310 unsigned int c,
unsigned int d) {
311 return (((a & 0xff) << 24) |
322 return (data >> 24) & 0xff;
330 return (data >> 16) & 0xff;
338 return (data >> 8) & 0xff;
372 if ((f0._packed & 0x7f800000) == 0x7f800000 && (
unsigned)f0._packed != 0xff800000u) {
373 packed |= (f0._packed >> 17) & 0x7ffu;
374 }
else if (f0._packed >= 0x47800000) {
376 }
else if (f0._packed >= 0x38800000) {
377 packed |= (f0._packed >> 17) - 0x1c00;
378 }
else if (f0._packed >= 0x35000000) {
379 packed |= ((f0._packed & 0x7c0000u) | 0x800000u) >> (130 - (f0._packed >> 23));
382 if ((f1._packed & 0x7f800000) == 0x7f800000 && (unsigned)f1._packed != 0xff800000u) {
383 packed |= (f1._packed >> 6) & 0x3ff800u;
384 }
else if (f1._packed >= 0x47800000) {
386 }
else if (f1._packed >= 0x38800000) {
387 packed |= ((f1._packed >> 6) - 0xe00000) & 0x3ff800;
388 }
else if (f1._packed >= 0x35000000) {
389 packed |= (((f1._packed & 0x7c0000u) | 0x800000u) >> (119 - (f1._packed >> 23))) & 0x1f800u;
392 if ((f2._packed & 0x7f800000) == 0x7f800000 && (unsigned)f2._packed != 0xff800000u) {
393 packed |= (f2._packed & 0x0ffe0000u) << 4;
394 }
else if (f2._packed >= 0x47800000) {
395 packed |= 0xf7c00000;
396 }
else if (f2._packed >= 0x38800000) {
397 packed |= ((f2._packed - 0x38000000) << 4) & 0xffc00000;
398 }
else if (f2._packed >= 0x35000000) {
399 packed |= ((((f2._packed << 3) & 0x03c00000u) | 0x04000000u) >> (112 - (f2._packed >> 23))) & 0x07c00000u;
410 if ((data & 0x7c0) == 0) {
412 return ldexpf((data & 63) / 64.0f, -14);
419 value._packed = ((data & 0x7ff) << 17);
421 if ((data & 0x7c0) == 0x7c0) {
423 value._packed |= 0x7f800000;
425 value._packed += 0x38000000;
436 if ((data & 0x3e0000) == 0) {
438 return ldexpf(((data >> 11) & 63) / 64.0f, -14);
445 value._packed = ((data & 0x3ff800) << 6);
447 if ((data & 0x3e0000) == 0x3e0000) {
449 value._packed |= 0x7f800000;
451 value._packed += 0x38000000;
462 if ((data & 0xf8000000u) == 0) {
464 return ldexpf(((data >> 22) & 31) / 32.0f, -14);
471 value._packed = ((data & 0xffc00000u) >> 4);
473 if ((data & 0xf8000000u) == 0xf8000000u) {
475 value._packed |= 0x7f800000;
477 value._packed += 0x38000000;
487INLINE
int GeomVertexData::
489 TransformMap &already_added) {
490 std::pair<TransformMap::iterator, bool> result = already_added.insert(TransformMap::value_type(transform, table->
get_num_transforms()));
496 return (*(result.first)).second;
502INLINE GeomVertexData::CDataCache::
509INLINE GeomVertexData::CDataCache::
510CDataCache(
const GeomVertexData::CDataCache ©) :
511 _result(copy._result)
518INLINE GeomVertexData::CacheKey::
527INLINE GeomVertexData::CacheKey::
528CacheKey(
const CacheKey ©) :
529 _modifier(copy._modifier)
536INLINE GeomVertexData::CacheKey::
537CacheKey(CacheKey &&from) noexcept :
538 _modifier(std::move(from._modifier))
547 return _modifier < other._modifier;
553INLINE GeomVertexData::CacheEntry::
563INLINE GeomVertexData::CacheEntry::
573INLINE GeomVertexData::CacheEntry::
583INLINE GeomVertexData::CData::
586 _usage_hint(UH_unspecified)
593INLINE GeomVertexData::CData::
594CData(
const GeomVertexFormat *format, GeomVertexData::UsageHint usage_hint) :
596 _usage_hint(usage_hint)
599 for (
size_t i = 0; i < num_arrays; ++i) {
607INLINE GeomVertexDataPipelineBase::
608GeomVertexDataPipelineBase(
Thread *current_thread) :
610 _current_thread(current_thread),
618INLINE GeomVertexDataPipelineBase::
621 GeomVertexData::CData *cdata) :
623 _current_thread(current_thread),
627 nassertv(_object->test_ref_count_nonzero());
637INLINE GeomVertexDataPipelineBase::
638~GeomVertexDataPipelineBase() {
640 if (_object !=
nullptr) {
641 nassertv(_object->test_ref_count_nonzero());
646 if (_cdata !=
nullptr) {
660INLINE
Thread *GeomVertexDataPipelineBase::
661get_current_thread()
const {
662 return _current_thread;
668INLINE GeomVertexDataPipelineBase::UsageHint GeomVertexDataPipelineBase::
669get_usage_hint()
const {
670 return _cdata->_usage_hint;
678 return _cdata->_format;
684INLINE
bool GeomVertexDataPipelineBase::
686 return _cdata->_format->has_column(name);
692INLINE
size_t GeomVertexDataPipelineBase::
693get_num_arrays()
const {
694 return _cdata->_arrays.size();
701get_array(
size_t i)
const {
702 nassertr(i < _cdata->_arrays.size(),
nullptr);
703 return _cdata->_arrays[i].get_read_pointer();
710get_transform_table()
const {
711 return _cdata->_transform_table;
718get_transform_blend_table()
const {
719 return _cdata->_transform_blend_table.get_read_pointer();
725INLINE
const SliderTable *GeomVertexDataPipelineBase::
726get_slider_table()
const {
727 return _cdata->_slider_table;
733INLINE
UpdateSeq GeomVertexDataPipelineBase::
734get_modified()
const {
735 return _cdata->_modified;
741INLINE GeomVertexDataPipelineReader::
742GeomVertexDataPipelineReader(
Thread *current_thread) :
744 _got_array_readers(false)
751INLINE GeomVertexDataPipelineReader::
755 (
GeomVertexData::CData *)object->_cycler.read_unlocked(current_thread)),
756 _got_array_readers(false)
763INLINE
void GeomVertexDataPipelineReader::
766 if (_cdata !=
nullptr) {
770 _array_readers.clear();
773 _cdata = (GeomVertexData::CData *)_object->_cycler.read_unlocked(_current_thread);
774 _got_array_readers =
false;
792INLINE
void GeomVertexDataPipelineReader::
793check_array_readers()
const {
794 if (!_got_array_readers) {
803get_array_reader(
int i)
const {
804 nassertr(_got_array_readers,
nullptr);
805 nassertr(i >= 0 && i < (
int)_array_readers.size(),
nullptr);
806 return _array_readers[i];
812INLINE
bool GeomVertexDataPipelineReader::
814 return (_cdata->_format->get_vertex_column() !=
nullptr);
820INLINE
bool GeomVertexDataPipelineReader::
821is_vertex_transformed()
const {
823 if (column !=
nullptr) {
833INLINE
bool GeomVertexDataPipelineReader::
835 return (_cdata->_format->get_normal_column() !=
nullptr);
841INLINE
bool GeomVertexDataPipelineReader::
843 return (_cdata->_format->get_color_column() !=
nullptr);
849INLINE GeomVertexDataPipelineWriter::
850GeomVertexDataPipelineWriter(
GeomVertexData *
object,
bool force_to_0,
853 object->_cycler.write_upstream(force_to_0, current_thread)),
854 _got_array_writers(false)
857 nassertv(_object->test_ref_count_nonzero());
859 nassertv(_cdata->test_ref_count_nonzero());
867INLINE GeomVertexDataPipelineWriter::
868~GeomVertexDataPipelineWriter() {
869 if (_got_array_writers) {
870 delete_array_writers();
872 _object->_cycler.release_write(_cdata);
886INLINE
void GeomVertexDataPipelineWriter::
887check_array_writers()
const {
888 if (!_got_array_writers) {
897get_array_writer(
size_t i)
const {
898 nassertr(_got_array_writers,
nullptr);
899 nassertr(i < _array_writers.size(),
nullptr);
900 return _array_writers[i];
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
A single page of data maintained by a PipelineCycler.
This data object is returned by GeomVertexArrayData::get_handle() or modify_handle().
This is the data for one array of a GeomVertexData structure.
This defines how a single column is interleaved within a vertex array stored within a Geom.
Contents get_contents() const
Returns the token representing the semantic meaning of the stored value.
The common code from GeomVertexDataPipelineReader and GeomVertexDataPipelineWriter.
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
bool operator<(const CacheKey &other) const
Provides a unique ordering within the set.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
bool set_num_rows(int n)
Sets the length of the array to n rows in all of the various arrays (presumably by adding rows).
static uint32_t pack_ufloat(float a, float b, float c)
Packs three float values in an unsigned 32-bit int.
get_name
Returns the name passed to the constructor, if any.
get_transform_table
Returns a const pointer to the TransformTable assigned to this data.
static float unpack_ufloat_c(uint32_t data)
Unpacks an unsigned float10 value from an uint32.
static float unpack_ufloat_a(uint32_t data)
Unpacks an unsigned float11 value from an uint32.
void clear_transform_table()
Sets the TransformTable pointer to NULL, removing the table from the vertex data.
bool has_column(const InternalName *name) const
Returns true if the data has the named column, false otherwise.
int get_num_rows() const
Returns the number of rows stored within all the arrays.
static float unpack_ufloat_b(uint32_t data)
Unpacks an unsigned float11 value from an uint32.
set_array
Replaces the indicated vertex data array with a completely new array.
bool reserve_num_rows(int n)
This ensures that enough memory space for n rows is allocated, so that you may increase the number of...
get_num_arrays
Returns the number of individual arrays stored within the data.
get_slider_table
Returns a const pointer to the SliderTable assigned to this data.
set_transform_table
Replaces the TransformTable on this vertex data with the indicated table.
static unsigned int unpack_abcd_b(uint32_t data)
Returns the second packed value from a DirectX-style NT_packed_abcd.
static unsigned int unpack_abcd_a(uint32_t data)
Returns the first packed value from a DirectX-style NT_packed_abcd.
set_slider_table
Replaces the SliderTable on this vertex data with the indicated table.
get_num_bytes
Returns the total number of bytes consumed by the different arrays of the vertex data.
void set_transform_blend_table(const TransformBlendTable *table)
Replaces the TransformBlendTable on this vertex data with the indicated table.
static uint32_t pack_abcd(unsigned int a, unsigned int b, unsigned int c, unsigned int d)
Packs four values in a DirectX-style NT_packed_abcd value.
get_modified
Returns a sequence number which is guaranteed to change at least every time the vertex data is modifi...
static unsigned int unpack_abcd_c(uint32_t data)
Returns the third packed value from a DirectX-style NT_packed_abcd.
static unsigned int unpack_abcd_d(uint32_t data)
Returns the fourth packed value from a DirectX-style NT_packed_abcd.
get_format
Returns a pointer to the GeomVertexFormat structure that defines this data.
get_usage_hint
Returns the usage hint that was passed to the constructor, and which will be passed to each array dat...
bool unclean_set_num_rows(int n)
This method behaves like set_num_rows(), except the new data is not initialized.
void clear_slider_table()
Sets the SliderTable pointer to NULL, removing the table from the vertex data.
Encodes a string name in a hash table, mapping it to a pointer.
Stores the total set of VertexSliders that the vertices in a particular GeomVertexData object might d...
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.
void unref_delete(RefCountType *ptr)
This global helper function will unref the given ReferenceCount object, and if the reference count re...