Panda3D
 All Classes Functions Variables Enumerations
geomVertexData.I
1 // Filename: geomVertexData.I
2 // Created by: drose (06Mar05)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: GeomVertexData::get_name
18 // Access: Published
19 // Description: Returns the name passed to the constructor, if any.
20 // This name is reported on the PStats graph for vertex
21 // computations.
22 ////////////////////////////////////////////////////////////////////
23 INLINE const string &GeomVertexData::
24 get_name() const {
25  return _name;
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: GeomVertexData::get_usage_hint
30 // Access: Published
31 // Description: Returns the usage hint that was passed to the
32 // constructor, and which will be passed to each array
33 // data object created initially, and arrays created as
34 // the result of a convert_to() operation. See
35 // geomEnums.h.
36 //
37 // However, each individual array may be replaced with a
38 // different array object with an independent usage hint
39 // specified, so there is no guarantee that the
40 // individual arrays all have the same usage_hint.
41 ////////////////////////////////////////////////////////////////////
42 INLINE GeomVertexData::UsageHint GeomVertexData::
43 get_usage_hint() const {
44  CDReader cdata(_cycler);
45  return cdata->_usage_hint;
46 }
47 
48 ////////////////////////////////////////////////////////////////////
49 // Function: GeomVertexData::get_format
50 // Access: Published
51 // Description: Returns a pointer to the GeomVertexFormat structure
52 // that defines this data.
53 ////////////////////////////////////////////////////////////////////
54 INLINE const GeomVertexFormat *GeomVertexData::
55 get_format() const {
56  CDReader cdata(_cycler);
57  return cdata->_format;
58 }
59 
60 ////////////////////////////////////////////////////////////////////
61 // Function: GeomVertexData::has_column
62 // Access: Published
63 // Description: Returns true if the data has the named column,
64 // false otherwise. This is really just a shortcut for
65 // asking the same thing from the format.
66 ////////////////////////////////////////////////////////////////////
67 INLINE bool GeomVertexData::
68 has_column(const InternalName *name) const {
69  CDReader cdata(_cycler);
70  return cdata->_format->has_column(name);
71 }
72 
73 ////////////////////////////////////////////////////////////////////
74 // Function: GeomVertexData::get_num_rows
75 // Access: Published
76 // Description: Returns the number of rows stored within all the
77 // arrays. All arrays store data for the same n
78 // rows.
79 ////////////////////////////////////////////////////////////////////
80 INLINE int GeomVertexData::
81 get_num_rows() const {
83  reader.check_array_readers();
84  return reader.get_num_rows();
85 }
86 
87 ////////////////////////////////////////////////////////////////////
88 // Function: GeomVertexData::set_num_rows
89 // Access: Published
90 // Description: Sets the length of the array to n rows in all of
91 // the various arrays (presumably by adding rows).
92 //
93 // The new vertex data is initialized to 0, except for
94 // the "color" column, which is initialized to (1, 1, 1,
95 // 1).
96 //
97 // The return value is true if the number of rows
98 // was changed, false if the object already contained n
99 // rows (or if there was some error).
100 //
101 // This can be used when you know exactly how many
102 // rows you will be needing. It is faster than
103 // reserve_num_rows(). Also see unclean_set_num_rows()
104 // if you are planning to fill in all the data yourself.
105 //
106 // Don't call this in a downstream thread unless you
107 // don't mind it blowing away other changes you might
108 // have recently made in an upstream thread.
109 ////////////////////////////////////////////////////////////////////
110 INLINE bool GeomVertexData::
111 set_num_rows(int n) {
113  writer.check_array_writers();
114  return writer.set_num_rows(n);
115 }
116 
117 ////////////////////////////////////////////////////////////////////
118 // Function: GeomVertexData::unclean_set_num_rows
119 // Access: Published
120 // Description: This method behaves like set_num_rows(), except the
121 // new data is not initialized. Furthermore, after this
122 // call, *any* of the data in the GeomVertexData may be
123 // uninitialized, including the earlier rows.
124 //
125 // This is intended for applications that are about to
126 // completely fill the GeomVertexData with new data
127 // anyway; it provides a tiny performance boost over
128 // set_num_rows().
129 //
130 // This can be used when you know exactly how many
131 // rows you will be needing. It is faster than
132 // reserve_num_rows().
133 ////////////////////////////////////////////////////////////////////
134 INLINE bool GeomVertexData::
137  writer.check_array_writers();
138  return writer.unclean_set_num_rows(n);
139 }
140 
141 ////////////////////////////////////////////////////////////////////
142 // Function: GeomVertexData::reserve_num_rows
143 // Access: Published
144 // Description: This ensures that enough memory space for n rows is
145 // allocated, so that you may increase the number of
146 // rows to n without causing a new memory allocation.
147 // This is a performance optimization only; it is
148 // especially useful when you know ahead of time that
149 // you will be adding n rows to the data.
150 //
151 // If you know exactly how many rows you will be
152 // needing, it is significantly faster to use
153 // set_num_rows() or unclean_set_num_rows() instead.
154 ////////////////////////////////////////////////////////////////////
155 INLINE bool GeomVertexData::
158  writer.check_array_writers();
159  return writer.reserve_num_rows(n);
160 }
161 
162 ////////////////////////////////////////////////////////////////////
163 // Function: GeomVertexData::get_num_arrays
164 // Access: Published
165 // Description: Returns the number of individual arrays stored within
166 // the data. This must match
167 // get_format()->get_num_arrays().
168 ////////////////////////////////////////////////////////////////////
169 INLINE int GeomVertexData::
170 get_num_arrays() const {
171  CDReader cdata(_cycler);
172  return cdata->_arrays.size();
173 }
174 
175 ////////////////////////////////////////////////////////////////////
176 // Function: GeomVertexData::get_array
177 // Access: Published
178 // Description: Returns a const pointer to the vertex data for the
179 // indicated array, for application code to directly
180 // examine (but not modify) the underlying vertex data.
181 ////////////////////////////////////////////////////////////////////
183 get_array(int i) const {
184  CDReader cdata(_cycler);
185  nassertr(i >= 0 && i < (int)cdata->_arrays.size(), NULL);
186  return cdata->_arrays[i].get_read_pointer();
187 }
188 
189 ////////////////////////////////////////////////////////////////////
190 // Function: GeomVertexData::modify_array
191 // Access: Published
192 // Description: Returns a modifiable pointer to the indicated vertex
193 // array, so that application code may directly
194 // manipulate the data. You should avoid changing
195 // the length of this array, since all of the arrays
196 // should be kept in sync--use set_num_rows()
197 // instead.
198 //
199 // Don't call this in a downstream thread unless you
200 // don't mind it blowing away other changes you might
201 // have recently made in an upstream thread.
202 ////////////////////////////////////////////////////////////////////
204 modify_array(int i) {
206  return writer.modify_array(i);
207 }
208 
209 ////////////////////////////////////////////////////////////////////
210 // Function: GeomVertexData::set_array
211 // Access: Published
212 // Description: Replaces the indicated vertex data array with
213 // a completely new array. You should be careful that
214 // the new array has the same length and format as the
215 // old one, unless you know what you are doing.
216 //
217 // Don't call this in a downstream thread unless you
218 // don't mind it blowing away other changes you might
219 // have recently made in an upstream thread.
220 ////////////////////////////////////////////////////////////////////
221 INLINE void GeomVertexData::
222 set_array(int i, const GeomVertexArrayData *array) {
224  writer.set_array(i, array);
225 }
226 
227 ////////////////////////////////////////////////////////////////////
228 // Function: GeomVertexData::get_transform_table
229 // Access: Published
230 // Description: Returns a const pointer to the TransformTable
231 // assigned to this data. Vertices within the table
232 // will index into this table to indicate their
233 // dynamic skinning information; this table is used when
234 // the vertex animation is to be performed by the
235 // graphics hardware (but also see
236 // get_transform_blend_table()).
237 //
238 // This will return NULL if the vertex data does not
239 // have a TransformTable assigned (which implies the
240 // vertices will not be animated by the graphics
241 // hardware).
242 ////////////////////////////////////////////////////////////////////
243 INLINE const TransformTable *GeomVertexData::
245  CDReader cdata(_cycler);
246  return cdata->_transform_table;
247 }
248 
249 ////////////////////////////////////////////////////////////////////
250 // Function: GeomVertexData::clear_transform_table
251 // Access: Published
252 // Description: Sets the TransformTable pointer to NULL,
253 // removing the table from the vertex data. This
254 // disables hardware-driven vertex animation.
255 ////////////////////////////////////////////////////////////////////
256 INLINE void GeomVertexData::
258  set_transform_table(NULL);
259 }
260 
261 ////////////////////////////////////////////////////////////////////
262 // Function: GeomVertexData::get_transform_blend_table
263 // Access: Published
264 // Description: Returns a const pointer to the TransformBlendTable
265 // assigned to this data. Vertices within the table
266 // will index into this table to indicate their
267 // dynamic skinning information; this table is used when
268 // the vertex animation is to be performed by the CPU
269 // (but also see get_transform_table()).
270 //
271 // This will return NULL if the vertex data does not
272 // have a TransformBlendTable assigned (which implies
273 // the vertices will not be animated by the CPU).
274 ////////////////////////////////////////////////////////////////////
276 get_transform_blend_table() const {
277  CDReader cdata(_cycler);
278  return cdata->_transform_blend_table.get_read_pointer();
279 }
280 
281 ////////////////////////////////////////////////////////////////////
282 // Function: GeomVertexData::clear_transform_blend_table
283 // Access: Published
284 // Description: Sets the TransformBlendTable pointer to NULL,
285 // removing the table from the vertex data. This
286 // disables CPU-driven vertex animation.
287 ////////////////////////////////////////////////////////////////////
288 INLINE void GeomVertexData::
291 }
292 
293 ////////////////////////////////////////////////////////////////////
294 // Function: GeomVertexData::get_slider_table
295 // Access: Published
296 // Description: Returns a const pointer to the SliderTable
297 // assigned to this data. Vertices within the vertex
298 // data will look up their morph offsets, if any, within
299 // this table.
300 //
301 // This will return NULL if the vertex data does not
302 // have a SliderTable assigned.
303 ////////////////////////////////////////////////////////////////////
304 INLINE const SliderTable *GeomVertexData::
306  CDReader cdata(_cycler);
307  return cdata->_slider_table;
308 }
309 
310 ////////////////////////////////////////////////////////////////////
311 // Function: GeomVertexData::clear_slider_table
312 // Access: Published
313 // Description: Sets the SliderTable pointer to NULL,
314 // removing the table from the vertex data. This
315 // disables morph (blend shape) animation.
316 ////////////////////////////////////////////////////////////////////
317 INLINE void GeomVertexData::
319  set_slider_table(NULL);
320 }
321 
322 ////////////////////////////////////////////////////////////////////
323 // Function: GeomVertexData::get_num_bytes
324 // Access: Published
325 // Description: Returns the total number of bytes consumed by the
326 // different arrays of the vertex data.
327 ////////////////////////////////////////////////////////////////////
328 INLINE int GeomVertexData::
329 get_num_bytes() const {
331  return reader.get_num_bytes();
332 }
333 
334 ////////////////////////////////////////////////////////////////////
335 // Function: GeomVertexData::get_modified
336 // Access: Published
337 // Description: Returns a sequence number which is guaranteed to
338 // change at least every time the vertex data is
339 // modified.
340 ////////////////////////////////////////////////////////////////////
342 get_modified(Thread *current_thread) const {
343  CDReader cdata(_cycler, current_thread);
344  return cdata->_modified;
345 }
346 
347 ////////////////////////////////////////////////////////////////////
348 // Function: GeomVertexData::pack_abcd
349 // Access: Public, Static
350 // Description: Packs four values in a DirectX-style NT_packed_abcd
351 // value.
352 ////////////////////////////////////////////////////////////////////
353 INLINE PN_uint32 GeomVertexData::
354 pack_abcd(unsigned int a, unsigned int b,
355  unsigned int c, unsigned int d) {
356  return (((a & 0xff) << 24) |
357  ((b & 0xff) << 16) |
358  ((c & 0xff) << 8) |
359  (d & 0xff));
360 }
361 
362 ////////////////////////////////////////////////////////////////////
363 // Function: GeomVertexData::unpack_abcd_a
364 // Access: Public, Static
365 // Description: Returns the first packed value from a DirectX-style
366 // NT_packed_abcd.
367 ////////////////////////////////////////////////////////////////////
368 INLINE unsigned int GeomVertexData::
369 unpack_abcd_a(PN_uint32 data) {
370  return (data >> 24) & 0xff;
371 }
372 
373 ////////////////////////////////////////////////////////////////////
374 // Function: GeomVertexData::unpack_abcd_b
375 // Access: Public, Static
376 // Description: Returns the second packed value from a DirectX-style
377 // NT_packed_abcd.
378 ////////////////////////////////////////////////////////////////////
379 INLINE unsigned int GeomVertexData::
380 unpack_abcd_b(PN_uint32 data) {
381  return (data >> 16) & 0xff;
382 }
383 
384 ////////////////////////////////////////////////////////////////////
385 // Function: GeomVertexData::unpack_abcd_c
386 // Access: Public, Static
387 // Description: Returns the third packed value from a DirectX-style
388 // NT_packed_abcd.
389 ////////////////////////////////////////////////////////////////////
390 INLINE unsigned int GeomVertexData::
391 unpack_abcd_c(PN_uint32 data) {
392  return (data >> 8) & 0xff;
393 }
394 
395 ////////////////////////////////////////////////////////////////////
396 // Function: GeomVertexData::unpack_abcd_d
397 // Access: Public, Static
398 // Description: Returns the fourth packed value from a DirectX-style
399 // NT_packed_abcd.
400 ////////////////////////////////////////////////////////////////////
401 INLINE unsigned int GeomVertexData::
402 unpack_abcd_d(PN_uint32 data) {
403  return data & 0xff;
404 }
405 
406 ////////////////////////////////////////////////////////////////////
407 // Function: GeomVertexData::add_transform
408 // Access: Private, Static
409 // Description: Adds the indicated transform to the table, if it is
410 // not already there, and returns its index number.
411 ////////////////////////////////////////////////////////////////////
412 INLINE int GeomVertexData::
413 add_transform(TransformTable *table, const VertexTransform *transform,
414  TransformMap &already_added) {
415  pair<TransformMap::iterator, bool> result = already_added.insert(TransformMap::value_type(transform, table->get_num_transforms()));
416 
417  if (result.second) {
418  table->add_transform(transform);
419  }
420 
421  return (*(result.first)).second;
422 }
423 
424 ////////////////////////////////////////////////////////////////////
425 // Function: GeomVertexData::CDataCache::Constructor
426 // Access: Public
427 // Description:
428 ////////////////////////////////////////////////////////////////////
429 INLINE GeomVertexData::CDataCache::
430 CDataCache() {
431 }
432 
433 ////////////////////////////////////////////////////////////////////
434 // Function: GeomVertexData::CDataCache::Copy Constructor
435 // Access: Public
436 // Description:
437 ////////////////////////////////////////////////////////////////////
438 INLINE GeomVertexData::CDataCache::
439 CDataCache(const GeomVertexData::CDataCache &copy) :
440  _result(copy._result)
441 {
442 }
443 
444 ////////////////////////////////////////////////////////////////////
445 // Function: GeomVertexData::CacheKey::Constructor
446 // Access: Public
447 // Description:
448 ////////////////////////////////////////////////////////////////////
449 INLINE GeomVertexData::CacheKey::
450 CacheKey(const GeomVertexFormat *modifier) :
451  _modifier(modifier)
452 {
453 }
454 
455 ////////////////////////////////////////////////////////////////////
456 // Function: GeomVertexData::CacheKey::Copy Constructor
457 // Access: Public
458 // Description:
459 ////////////////////////////////////////////////////////////////////
460 INLINE GeomVertexData::CacheKey::
461 CacheKey(const CacheKey &copy) :
462  _modifier(copy._modifier)
463 {
464 }
465 
466 #ifdef USE_MOVE_SEMANTICS
467 ////////////////////////////////////////////////////////////////////
468 // Function: GeomVertexData::CacheKey::Move Constructor
469 // Access: Public
470 // Description:
471 ////////////////////////////////////////////////////////////////////
472 INLINE GeomVertexData::CacheKey::
473 CacheKey(CacheKey &&from) NOEXCEPT :
474  _modifier(move(from._modifier))
475 {
476 }
477 #endif // USE_MOVE_SEMANTICS
478 
479 ////////////////////////////////////////////////////////////////////
480 // Function: GeomVertexData::CacheKey::operator <
481 // Access: Public
482 // Description: Provides a unique ordering within the set.
483 ////////////////////////////////////////////////////////////////////
484 INLINE bool GeomVertexData::CacheKey::
485 operator < (const CacheKey &other) const {
486  return _modifier < other._modifier;
487 }
488 
489 ////////////////////////////////////////////////////////////////////
490 // Function: GeomVertexData::CacheEntry::Constructor
491 // Access: Public
492 // Description:
493 ////////////////////////////////////////////////////////////////////
494 INLINE GeomVertexData::CacheEntry::
495 CacheEntry(GeomVertexData *source, const GeomVertexFormat *modifier) :
496  _source(source),
497  _key(modifier)
498 {
499 }
500 
501 ////////////////////////////////////////////////////////////////////
502 // Function: GeomVertexData::CacheEntry::Copy Constructor
503 // Access: Public
504 // Description:
505 ////////////////////////////////////////////////////////////////////
506 INLINE GeomVertexData::CacheEntry::
507 CacheEntry(GeomVertexData *source, const CacheKey &key) :
508  _source(source),
509  _key(key)
510 {
511 }
512 
513 #ifdef USE_MOVE_SEMANTICS
514 ////////////////////////////////////////////////////////////////////
515 // Function: GeomVertexData::CacheEntry::Move Constructor
516 // Access: Public
517 // Description:
518 ////////////////////////////////////////////////////////////////////
519 INLINE GeomVertexData::CacheEntry::
520 CacheEntry(GeomVertexData *source, CacheKey &&key) NOEXCEPT :
521  _source(source),
522  _key(move(key))
523 {
524 }
525 #endif // USE_MOVE_SEMANTICS
526 
527 ////////////////////////////////////////////////////////////////////
528 // Function: GeomVertexData::CData::Constructor
529 // Access: Public
530 // Description:
531 ////////////////////////////////////////////////////////////////////
532 INLINE GeomVertexData::CData::
533 CData() :
534  _usage_hint(UH_unspecified)
535 {
536 }
537 
538 ////////////////////////////////////////////////////////////////////
539 // Function: GeomVertexData::CData::Copy Constructor
540 // Access: Public
541 // Description:
542 ////////////////////////////////////////////////////////////////////
543 INLINE GeomVertexData::CData::
544 CData(const GeomVertexData::CData &copy) :
545  _usage_hint(copy._usage_hint),
546  _format(copy._format),
547  _arrays(copy._arrays),
548  _transform_table(copy._transform_table),
549  _transform_blend_table(copy._transform_blend_table),
550  _slider_table(copy._slider_table),
551  _animated_vertices(copy._animated_vertices),
552  _animated_vertices_modified(copy._animated_vertices_modified),
553  _modified(copy._modified)
554 {
555 }
556 
557 ////////////////////////////////////////////////////////////////////
558 // Function: GeomVertexDataPipelineBase::Constructor
559 // Access: Public
560 // Description:
561 ////////////////////////////////////////////////////////////////////
562 INLINE GeomVertexDataPipelineBase::
563 GeomVertexDataPipelineBase(GeomVertexData *object,
564  Thread *current_thread,
565  GeomVertexData::CData *cdata) :
566  _object(object),
567  _current_thread(current_thread),
568  _cdata(cdata)
569 {
570 #ifdef _DEBUG
571  nassertv(_object->test_ref_count_nonzero());
572 #endif // _DEBUG
573 #ifdef DO_PIPELINING
574  _cdata->ref();
575 #endif // DO_PIPELINING
576 }
577 
578 ////////////////////////////////////////////////////////////////////
579 // Function: GeomVertexDataPipelineBase::Destructor
580 // Access: Public
581 // Description:
582 ////////////////////////////////////////////////////////////////////
583 INLINE GeomVertexDataPipelineBase::
584 ~GeomVertexDataPipelineBase() {
585 #ifdef _DEBUG
586  nassertv(_object->test_ref_count_nonzero());
587 #endif // _DEBUG
588 
589 #ifdef DO_PIPELINING
590  unref_delete((CycleData *)_cdata);
591 #endif // DO_PIPELINING
592 
593 #ifdef _DEBUG
594  _object = NULL;
595  _cdata = NULL;
596 #endif // _DEBUG
597 }
598 
599 ////////////////////////////////////////////////////////////////////
600 // Function: GeomVertexDataPipelineBase::get_current_thread
601 // Access: Public
602 // Description:
603 ////////////////////////////////////////////////////////////////////
604 INLINE Thread *GeomVertexDataPipelineBase::
605 get_current_thread() const {
606  return _current_thread;
607 }
608 
609 ////////////////////////////////////////////////////////////////////
610 // Function: GeomVertexDataPipelineBase::get_usage_hint
611 // Access: Public
612 // Description:
613 ////////////////////////////////////////////////////////////////////
614 INLINE GeomVertexDataPipelineBase::UsageHint GeomVertexDataPipelineBase::
615 get_usage_hint() const {
616  return _cdata->_usage_hint;
617 }
618 
619 ////////////////////////////////////////////////////////////////////
620 // Function: GeomVertexDataPipelineBase::get_format
621 // Access: Public
622 // Description:
623 ////////////////////////////////////////////////////////////////////
624 INLINE const GeomVertexFormat *GeomVertexDataPipelineBase::
625 get_format() const {
626  return _cdata->_format;
627 }
628 
629 ////////////////////////////////////////////////////////////////////
630 // Function: GeomVertexDataPipelineBase::has_column
631 // Access: Public
632 // Description:
633 ////////////////////////////////////////////////////////////////////
634 INLINE bool GeomVertexDataPipelineBase::
635 has_column(const InternalName *name) const {
636  return _cdata->_format->has_column(name);
637 }
638 
639 ////////////////////////////////////////////////////////////////////
640 // Function: GeomVertexDataPipelineBase::get_num_arrays
641 // Access: Public
642 // Description:
643 ////////////////////////////////////////////////////////////////////
644 INLINE int GeomVertexDataPipelineBase::
645 get_num_arrays() const {
646  return _cdata->_arrays.size();
647 }
648 
649 ////////////////////////////////////////////////////////////////////
650 // Function: GeomVertexDataPipelineBase::get_array
651 // Access: Public
652 // Description:
653 ////////////////////////////////////////////////////////////////////
655 get_array(int i) const {
656  nassertr(i >= 0 && i < (int)_cdata->_arrays.size(), NULL);
657  return _cdata->_arrays[i].get_read_pointer();
658 }
659 
660 ////////////////////////////////////////////////////////////////////
661 // Function: GeomVertexDataPipelineBase::get_transform_table
662 // Access: Public
663 // Description:
664 ////////////////////////////////////////////////////////////////////
665 INLINE const TransformTable *GeomVertexDataPipelineBase::
666 get_transform_table() const {
667  return _cdata->_transform_table;
668 }
669 
670 ////////////////////////////////////////////////////////////////////
671 // Function: GeomVertexDataPipelineBase::get_transform_blend_table
672 // Access: Public
673 // Description:
674 ////////////////////////////////////////////////////////////////////
676 get_transform_blend_table() const {
677  return _cdata->_transform_blend_table.get_read_pointer();
678 }
679 
680 ////////////////////////////////////////////////////////////////////
681 // Function: GeomVertexDataPipelineBase::get_slider_table
682 // Access: Public
683 // Description:
684 ////////////////////////////////////////////////////////////////////
685 INLINE const SliderTable *GeomVertexDataPipelineBase::
686 get_slider_table() const {
687  return _cdata->_slider_table;
688 }
689 
690 ////////////////////////////////////////////////////////////////////
691 // Function: GeomVertexDataPipelineBase::get_modified
692 // Access: Public
693 // Description:
694 ////////////////////////////////////////////////////////////////////
695 INLINE UpdateSeq GeomVertexDataPipelineBase::
696 get_modified() const {
697  return _cdata->_modified;
698 }
699 
700 ////////////////////////////////////////////////////////////////////
701 // Function: GeomVertexDataPipelineReader::Constructor
702 // Access: Public
703 // Description:
704 ////////////////////////////////////////////////////////////////////
705 INLINE GeomVertexDataPipelineReader::
706 GeomVertexDataPipelineReader(const GeomVertexData *object,
707  Thread *current_thread) :
708  GeomVertexDataPipelineBase((GeomVertexData *)object, current_thread,
709  (GeomVertexData::CData *)object->_cycler.read_unlocked(current_thread)),
710  _got_array_readers(false)
711 {
712 }
713 
714 ////////////////////////////////////////////////////////////////////
715 // Function: GeomVertexDataPipelineReader::Copy Constructor
716 // Access: Private
717 // Description: Don't attempt to copy these objects.
718 ////////////////////////////////////////////////////////////////////
719 INLINE GeomVertexDataPipelineReader::
720 GeomVertexDataPipelineReader(const GeomVertexDataPipelineReader &copy) :
722 {
723  nassertv(false);
724 }
725 
726 ////////////////////////////////////////////////////////////////////
727 // Function: GeomVertexDataPipelineReader::Copy Assignment Operator
728 // Access: Private
729 // Description: Don't attempt to copy these objects.
730 ////////////////////////////////////////////////////////////////////
731 INLINE void GeomVertexDataPipelineReader::
732 operator = (const GeomVertexDataPipelineReader &) {
733  nassertv(false);
734 }
735 
736 ////////////////////////////////////////////////////////////////////
737 // Function: GeomVertexDataPipelineReader::Destructor
738 // Access: Public
739 // Description:
740 ////////////////////////////////////////////////////////////////////
741 INLINE GeomVertexDataPipelineReader::
742 ~GeomVertexDataPipelineReader() {
743  if (_got_array_readers) {
744  delete_array_readers();
745  }
746  // _object->_cycler.release_read(_cdata);
747 }
748 
749 ////////////////////////////////////////////////////////////////////
750 // Function: GeomVertexDataPipelineReader::get_object
751 // Access: Public
752 // Description:
753 ////////////////////////////////////////////////////////////////////
754 INLINE const GeomVertexData *GeomVertexDataPipelineReader::
755 get_object() const {
756  return _object;
757 }
758 
759 ////////////////////////////////////////////////////////////////////
760 // Function: GeomVertexDataPipelineReader::check_array_readers
761 // Access: Public
762 // Description:
763 ////////////////////////////////////////////////////////////////////
764 INLINE void GeomVertexDataPipelineReader::
765 check_array_readers() const {
766  if (!_got_array_readers) {
767  ((GeomVertexDataPipelineReader *)this)->make_array_readers();
768  }
769 }
770 
771 ////////////////////////////////////////////////////////////////////
772 // Function: GeomVertexDataPipelineReader::get_array_reader
773 // Access: Public
774 // Description:
775 ////////////////////////////////////////////////////////////////////
776 INLINE const GeomVertexArrayDataHandle *GeomVertexDataPipelineReader::
777 get_array_reader(int i) const {
778  nassertr(_got_array_readers, NULL);
779  nassertr(i >= 0 && i < (int)_array_readers.size(), NULL);
780  return _array_readers[i];
781 }
782 
783 ////////////////////////////////////////////////////////////////////
784 // Function: GeomVertexDataPipelineReader::has_vertex
785 // Access: Public
786 // Description:
787 ////////////////////////////////////////////////////////////////////
788 INLINE bool GeomVertexDataPipelineReader::
789 has_vertex() const {
790  return (_cdata->_format->get_vertex_column() != (GeomVertexColumn *)NULL);
791 }
792 
793 ////////////////////////////////////////////////////////////////////
794 // Function: GeomVertexDataPipelineReader::is_vertex_transformed
795 // Access: Public
796 // Description:
797 ////////////////////////////////////////////////////////////////////
798 INLINE bool GeomVertexDataPipelineReader::
799 is_vertex_transformed() const {
800  const GeomVertexColumn *column = _cdata->_format->get_vertex_column();
801  if (column != (GeomVertexColumn *)NULL) {
802  return column->get_contents() == C_clip_point;
803  }
804 
805  return false;
806 }
807 
808 ////////////////////////////////////////////////////////////////////
809 // Function: GeomVertexDataPipelineReader::has_normal
810 // Access: Public
811 // Description:
812 ////////////////////////////////////////////////////////////////////
813 INLINE bool GeomVertexDataPipelineReader::
814 has_normal() const {
815  return (_cdata->_format->get_normal_column() != (GeomVertexColumn *)NULL);
816 }
817 
818 ////////////////////////////////////////////////////////////////////
819 // Function: GeomVertexDataPipelineReader::has_color
820 // Access: Public
821 // Description:
822 ////////////////////////////////////////////////////////////////////
823 INLINE bool GeomVertexDataPipelineReader::
824 has_color() const {
825  return (_cdata->_format->get_color_column() != (GeomVertexColumn *)NULL);
826 }
827 
828 ////////////////////////////////////////////////////////////////////
829 // Function: GeomVertexDataPipelineWriter::Constructor
830 // Access: Public
831 // Description:
832 ////////////////////////////////////////////////////////////////////
833 INLINE GeomVertexDataPipelineWriter::
834 GeomVertexDataPipelineWriter(GeomVertexData *object, bool force_to_0,
835  Thread *current_thread) :
836  GeomVertexDataPipelineBase(object, current_thread,
837  object->_cycler.write_upstream(force_to_0, current_thread)),
838  _force_to_0(force_to_0),
839  _got_array_writers(false)
840 {
841 #ifdef _DEBUG
842  nassertv(_object->test_ref_count_nonzero());
843 #ifdef DO_PIPELINING
844  nassertv(_cdata->test_ref_count_nonzero());
845 #endif // DO_PIPELINING
846 #endif // _DEBUG
847 }
848 
849 ////////////////////////////////////////////////////////////////////
850 // Function: GeomVertexDataPipelineWriter::Copy Constructor
851 // Access: Private
852 // Description: Don't attempt to copy these objects.
853 ////////////////////////////////////////////////////////////////////
854 INLINE GeomVertexDataPipelineWriter::
855 GeomVertexDataPipelineWriter(const GeomVertexDataPipelineWriter &copy) :
857 {
858  nassertv(false);
859 }
860 
861 ////////////////////////////////////////////////////////////////////
862 // Function: GeomVertexDataPipelineWriter::Copy Assignment Operator
863 // Access: Private
864 // Description: Don't attempt to copy these objects.
865 ////////////////////////////////////////////////////////////////////
866 INLINE void GeomVertexDataPipelineWriter::
867 operator = (const GeomVertexDataPipelineWriter &) {
868  nassertv(false);
869 }
870 
871 ////////////////////////////////////////////////////////////////////
872 // Function: GeomVertexDataPipelineWriter::Destructor
873 // Access: Public
874 // Description:
875 ////////////////////////////////////////////////////////////////////
876 INLINE GeomVertexDataPipelineWriter::
877 ~GeomVertexDataPipelineWriter() {
878  if (_got_array_writers) {
879  delete_array_writers();
880  }
881  _object->_cycler.release_write(_cdata);
882 }
883 
884 ////////////////////////////////////////////////////////////////////
885 // Function: GeomVertexDataPipelineWriter::get_object
886 // Access: Public
887 // Description:
888 ////////////////////////////////////////////////////////////////////
889 INLINE GeomVertexData *GeomVertexDataPipelineWriter::
890 get_object() const {
891  return _object;
892 }
893 
894 ////////////////////////////////////////////////////////////////////
895 // Function: GeomVertexDataPipelineWriter::check_array_writers
896 // Access: Public
897 // Description:
898 ////////////////////////////////////////////////////////////////////
899 INLINE void GeomVertexDataPipelineWriter::
900 check_array_writers() const {
901  if (!_got_array_writers) {
902  ((GeomVertexDataPipelineWriter *)this)->make_array_writers();
903  }
904 }
905 
906 ////////////////////////////////////////////////////////////////////
907 // Function: GeomVertexDataPipelineWriter::get_array_writer
908 // Access: Public
909 // Description:
910 ////////////////////////////////////////////////////////////////////
911 INLINE GeomVertexArrayDataHandle *GeomVertexDataPipelineWriter::
912 get_array_writer(int i) const {
913  nassertr(_got_array_writers, NULL);
914  nassertr(i >= 0 && i < (int)_array_writers.size(), NULL);
915  return _array_writers[i];
916 }
917 
918 INLINE ostream &
919 operator << (ostream &out, const GeomVertexData &obj) {
920  obj.output(out);
921  return out;
922 }
The common code from GeomVertexDataPipelineReader and GeomVertexDataPipelineWriter.
bool has_column(const InternalName *name) const
Returns true if the data has the named column, false otherwise.
bool unclean_set_num_rows(int n)
This method behaves like set_num_rows(), except the new data is not initialized.
void set_transform_table(const TransformTable *table)
Replaces the TransformTable on this vertex data with the indicated table.
static PN_uint32 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.
const TransformTable * get_transform_table() const
Returns a const pointer to the TransformTable assigned to this data.
UsageHint get_usage_hint() const
Returns the usage hint that was passed to the constructor, and which will be passed to each array dat...
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:50
void set_array(int i, const GeomVertexArrayData *array)
Replaces the indicated vertex data array with a completely new array.
void set_slider_table(const SliderTable *table)
Replaces the SliderTable on this vertex data with the indicated table.
This data object is returned by GeomVertexArrayData::get_handle() or modify_handle().
const SliderTable * get_slider_table() const
Returns a const pointer to the SliderTable assigned to this data.
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
This defines how a single column is interleaved within a vertex array stored within a Geom...
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
Definition: thread.I:145
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
const string & get_name() const
Returns the name passed to the constructor, if any.
void set_transform_blend_table(const TransformBlendTable *table)
Replaces the TransformBlendTable on this vertex data with the indicated table.
int add_transform(const VertexTransform *transform)
Adds a new transform to the table and returns the index number of the new transform.
Stores the total set of VertexSliders that the vertices in a particular GeomVertexData object might d...
Definition: sliderTable.h:42
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. ...
This is an abstract base class that holds a pointer to some transform, computed in some arbitrary way...
static unsigned int unpack_abcd_c(PN_uint32 data)
Returns the third packed value from a DirectX-style NT_packed_abcd.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
const GeomVertexFormat * get_format() const
Returns a pointer to the GeomVertexFormat structure that defines this data.
bool operator<(const CacheKey &other) const
Provides a unique ordering within the set.
UpdateSeq get_modified(Thread *current_thread=Thread::get_current_thread()) const
Returns a sequence number which is guaranteed to change at least every time the vertex data is modifi...
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)...
int get_num_arrays() const
Returns the number of individual arrays stored within the data.
void clear_slider_table()
Sets the SliderTable pointer to NULL, removing the table from the vertex data.
int get_num_bytes() const
Returns the total number of bytes consumed by the different arrays of the vertex data.
Stores the total set of VertexTransforms that the vertices in a particular GeomVertexData object migh...
A thread; that is, a lightweight process.
Definition: thread.h:51
static unsigned int unpack_abcd_d(PN_uint32 data)
Returns the fourth packed value from a DirectX-style NT_packed_abcd.
int get_num_transforms() const
Returns the number of transforms in the table.
Contents get_contents() const
Returns the token representing the semantic meaning of the stored value.
This structure collects together the different combinations of transforms and blend amounts used by a...
static unsigned int unpack_abcd_b(PN_uint32 data)
Returns the second packed value from a DirectX-style NT_packed_abcd.
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
static unsigned int unpack_abcd_a(PN_uint32 data)
Returns the first packed value from a DirectX-style NT_packed_abcd.
This is a sequence number that increments monotonically.
Definition: updateSeq.h:43
void clear_transform_blend_table()
Sets the TransformBlendTable pointer to NULL, removing the table from the vertex data.
This is the data for one array of a GeomVertexData structure.
int get_num_rows() const
Returns the number of rows stored within all the arrays.