18 INLINE
const std::string &GeomVertexData::
32 INLINE GeomVertexData::UsageHint GeomVertexData::
33 get_usage_hint()
const {
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);
143 INLINE
size_t GeomVertexData::
144 get_num_arrays()
const {
145 CDReader cdata(_cycler);
146 return cdata->_arrays.size();
155 get_array(
size_t i)
const {
156 CDReader cdata(_cycler);
157 nassertr(i < cdata->_arrays.size(),
nullptr);
158 return cdata->_arrays[i].get_read_pointer();
165 get_array_handle(
size_t i)
const {
167 CDReader cdata(_cycler, current_thread);
168 nassertr(i < cdata->_arrays.size(),
nullptr);
182 modify_array(
size_t i) {
184 return writer.modify_array(i);
191 modify_array_handle(
size_t i) {
192 Thread *current_thread = Thread::get_current_thread();
208 writer.set_array(i, array);
223 get_transform_table()
const {
224 CDReader cdata(_cycler);
225 return cdata->_transform_table;
248 get_transform_blend_table()
const {
249 CDReader cdata(_cycler);
250 return cdata->_transform_blend_table.get_read_pointer();
257 INLINE
void GeomVertexData::
258 clear_transform_blend_table() {
271 get_slider_table()
const {
272 CDReader cdata(_cycler);
273 return cdata->_slider_table;
289 INLINE
int GeomVertexData::
290 get_num_bytes()
const {
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;
487 INLINE
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;
502 INLINE GeomVertexData::CDataCache::
509 INLINE GeomVertexData::CDataCache::
510 CDataCache(
const GeomVertexData::CDataCache ©) :
511 _result(copy._result)
518 INLINE GeomVertexData::CacheKey::
527 INLINE GeomVertexData::CacheKey::
528 CacheKey(
const CacheKey ©) :
529 _modifier(copy._modifier)
536 INLINE GeomVertexData::CacheKey::
537 CacheKey(CacheKey &&from) noexcept :
538 _modifier(std::move(from._modifier))
547 return _modifier < other._modifier;
553 INLINE GeomVertexData::CacheEntry::
563 INLINE GeomVertexData::CacheEntry::
573 INLINE GeomVertexData::CacheEntry::
583 INLINE GeomVertexData::CData::
585 _usage_hint(UH_unspecified)
592 INLINE GeomVertexData::CData::
593 CData(
const GeomVertexFormat *format, GeomVertexData::UsageHint usage_hint) :
595 _usage_hint(usage_hint)
598 for (
size_t i = 0; i < num_arrays; ++i) {
606 INLINE GeomVertexDataPipelineBase::
607 GeomVertexDataPipelineBase(
Thread *current_thread) :
609 _current_thread(current_thread),
617 INLINE GeomVertexDataPipelineBase::
620 GeomVertexData::CData *cdata) :
622 _current_thread(current_thread),
626 nassertv(_object->test_ref_count_nonzero());
630 #endif // DO_PIPELINING 636 INLINE GeomVertexDataPipelineBase::
637 ~GeomVertexDataPipelineBase() {
639 if (_object !=
nullptr) {
640 nassertv(_object->test_ref_count_nonzero());
645 if (_cdata !=
nullptr) {
648 #endif // DO_PIPELINING 659 INLINE
Thread *GeomVertexDataPipelineBase::
660 get_current_thread()
const {
661 return _current_thread;
667 INLINE GeomVertexDataPipelineBase::UsageHint GeomVertexDataPipelineBase::
668 get_usage_hint()
const {
669 return _cdata->_usage_hint;
677 return _cdata->_format;
683 INLINE
bool GeomVertexDataPipelineBase::
685 return _cdata->_format->has_column(name);
691 INLINE
size_t GeomVertexDataPipelineBase::
692 get_num_arrays()
const {
693 return _cdata->_arrays.size();
700 get_array(
size_t i)
const {
701 nassertr(i < _cdata->_arrays.size(),
nullptr);
702 return _cdata->_arrays[i].get_read_pointer();
709 get_transform_table()
const {
710 return _cdata->_transform_table;
717 get_transform_blend_table()
const {
718 return _cdata->_transform_blend_table.get_read_pointer();
724 INLINE
const SliderTable *GeomVertexDataPipelineBase::
725 get_slider_table()
const {
726 return _cdata->_slider_table;
732 INLINE
UpdateSeq GeomVertexDataPipelineBase::
733 get_modified()
const {
734 return _cdata->_modified;
740 INLINE GeomVertexDataPipelineReader::
741 GeomVertexDataPipelineReader(
Thread *current_thread) :
743 _got_array_readers(false)
750 INLINE GeomVertexDataPipelineReader::
754 (
GeomVertexData::CData *)object->_cycler.read_unlocked(current_thread)),
755 _got_array_readers(false)
762 INLINE
void GeomVertexDataPipelineReader::
765 if (_cdata !=
nullptr) {
768 #endif // DO_PIPELINING 769 _array_readers.clear();
772 _cdata = (GeomVertexData::CData *)_object->_cycler.read_unlocked(_current_thread);
773 _got_array_readers =
false;
777 #endif // DO_PIPELINING 791 INLINE
void GeomVertexDataPipelineReader::
792 check_array_readers()
const {
793 if (!_got_array_readers) {
802 get_array_reader(
int i)
const {
803 nassertr(_got_array_readers,
nullptr);
804 nassertr(i >= 0 && i < (
int)_array_readers.size(),
nullptr);
805 return _array_readers[i];
811 INLINE
bool GeomVertexDataPipelineReader::
813 return (_cdata->_format->get_vertex_column() !=
nullptr);
819 INLINE
bool GeomVertexDataPipelineReader::
820 is_vertex_transformed()
const {
822 if (column !=
nullptr) {
832 INLINE
bool GeomVertexDataPipelineReader::
834 return (_cdata->_format->get_normal_column() !=
nullptr);
840 INLINE
bool GeomVertexDataPipelineReader::
842 return (_cdata->_format->get_color_column() !=
nullptr);
848 INLINE GeomVertexDataPipelineWriter::
849 GeomVertexDataPipelineWriter(
GeomVertexData *
object,
bool force_to_0,
852 object->_cycler.write_upstream(force_to_0, current_thread)),
853 _got_array_writers(false)
856 nassertv(_object->test_ref_count_nonzero());
858 nassertv(_cdata->test_ref_count_nonzero());
859 #endif // DO_PIPELINING 866 INLINE GeomVertexDataPipelineWriter::
867 ~GeomVertexDataPipelineWriter() {
868 if (_got_array_writers) {
869 delete_array_writers();
871 _object->_cycler.release_write(_cdata);
885 INLINE
void GeomVertexDataPipelineWriter::
886 check_array_writers()
const {
887 if (!_got_array_writers) {
896 get_array_writer(
size_t i)
const {
897 nassertr(_got_array_writers,
nullptr);
898 nassertr(i < _array_writers.size(),
nullptr);
899 return _array_writers[i];
902 INLINE std::ostream &
set_transform_table
Replaces the TransformTable on this vertex data with the indicated table.
static unsigned int unpack_abcd_d(uint32_t data)
Returns the fourth packed value from a DirectX-style NT_packed_abcd.
The common code from GeomVertexDataPipelineReader and GeomVertexDataPipelineWriter.
Contents get_contents() const
Returns the token representing the semantic meaning of the stored value.
bool unclean_set_num_rows(int n)
This method behaves like set_num_rows(), except the new data is not initialized.
PT(GeomVertexArrayDataHandle) GeomVertexData
Equivalent to modify_array(i).modify_handle().
A single page of data maintained by a PipelineCycler.
static unsigned int unpack_abcd_b(uint32_t data)
Returns the second packed value from a DirectX-style NT_packed_abcd.
get_modified
Returns a sequence number which is guaranteed to change at least every time the vertex data is modifi...
This data object is returned by GeomVertexArrayData::get_handle() or modify_handle().
static unsigned int unpack_abcd_c(uint32_t data)
Returns the third packed value from a DirectX-style NT_packed_abcd.
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
static float unpack_ufloat_a(uint32_t data)
Unpacks an unsigned float11 value from an uint32.
This defines how a single column is interleaved within a vertex array stored within a Geom.
set_array
Replaces the indicated vertex data array with a completely new array.
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
void set_transform_blend_table(const TransformBlendTable *table)
Replaces the TransformBlendTable on this vertex data with the indicated table.
set_slider_table
Replaces the SliderTable on this vertex data with the indicated table.
Stores the total set of VertexSliders that the vertices in a particular GeomVertexData object might d...
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...
void clear_transform_table()
Sets the TransformTable pointer to NULL, removing the table from the vertex data.
get_current_thread
Returns a pointer to the currently-executing Thread object.
static float unpack_ufloat_b(uint32_t data)
Unpacks an unsigned float11 value from an uint32.
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.
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).
void clear_slider_table()
Sets the SliderTable pointer to NULL, removing the table from the vertex data.
int get_num_rows() const
Returns the number of rows stored within all the arrays.
Encodes a string name in a hash table, mapping it to a pointer.
static uint32_t pack_ufloat(float a, float b, float c)
Packs three float values in an unsigned 32-bit int.
static unsigned int unpack_abcd_a(uint32_t data)
Returns the first packed value from a DirectX-style NT_packed_abcd.
bool has_column(const InternalName *name) const
Returns true if the data has the named column, false otherwise.
A thread; that is, a lightweight process.
bool operator<(const CacheKey &other) const
Provides a unique ordering within the set.
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
CPT(GeomVertexArrayData) GeomVertexData
Returns a const pointer to the vertex data for the indicated array, for application code to directly ...
This is a sequence number that increments monotonically.
static float unpack_ufloat_c(uint32_t data)
Unpacks an unsigned float10 value from an uint32.
void unref_delete(RefCountType *ptr)
This global helper function will unref the given ReferenceCount object, and if the reference count re...
This is the data for one array of a GeomVertexData structure.