Panda3D
geomVertexWriter.I
1 // Filename: geomVertexWriter.I
2 // Created by: drose (25Mar05)
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: GeomVertexWriter::Default Constructor
18 // Access: Published
19 // Description: Constructs an invalid GeomVertexWriter. You must use
20 // the assignment operator to assign a valid
21 // GeomVertexWriter to this object before you can use
22 // it.
23 ////////////////////////////////////////////////////////////////////
24 INLINE GeomVertexWriter::
25 GeomVertexWriter(Thread *current_thread) :
26  _vertex_data(NULL),
27  _current_thread(current_thread)
28 {
29  initialize();
30 }
31 
32 ////////////////////////////////////////////////////////////////////
33 // Function: GeomVertexWriter::Constructor
34 // Access: Published
35 // Description: Constructs a new writer to process the vertices of
36 // the indicated data object.
37 ////////////////////////////////////////////////////////////////////
38 INLINE GeomVertexWriter::
39 GeomVertexWriter(GeomVertexData *vertex_data, Thread *current_thread) :
40  _vertex_data(vertex_data),
41  _current_thread(current_thread)
42 {
43  initialize();
44 }
45 
46 ////////////////////////////////////////////////////////////////////
47 // Function: GeomVertexWriter::Constructor
48 // Access: Published
49 // Description: Constructs a new writer to process the vertices of
50 // the indicated data object. This flavor creates the
51 // writer specifically to process the named data type.
52 ////////////////////////////////////////////////////////////////////
53 INLINE GeomVertexWriter::
55  Thread *current_thread) :
56  _vertex_data(vertex_data),
57  _current_thread(current_thread)
58 {
59  initialize();
60  set_column(MOVE(name));
61 }
62 
63 ////////////////////////////////////////////////////////////////////
64 // Function: GeomVertexWriter::Constructor
65 // Access: Published
66 // Description: Constructs a new writer to process the vertices of
67 // the indicated array only.
68 ////////////////////////////////////////////////////////////////////
69 INLINE GeomVertexWriter::
71  Thread *current_thread) :
72  _array_data(array_data),
73  _current_thread(current_thread)
74 {
75  initialize();
76 }
77 
78 ////////////////////////////////////////////////////////////////////
79 // Function: GeomVertexWriter::Constructor
80 // Access: Published
81 // Description: Constructs a new writer to process the vertices of
82 // the indicated array only.
83 ////////////////////////////////////////////////////////////////////
84 INLINE GeomVertexWriter::
85 GeomVertexWriter(GeomVertexArrayData *array_data, int column,
86  Thread *current_thread) :
87  _array_data(array_data),
88  _current_thread(current_thread)
89 {
90  initialize();
91  set_column(column);
92 }
93 
94 ////////////////////////////////////////////////////////////////////
95 // Function: GeomVertexWriter::Constructor
96 // Access: Public
97 // Description: Constructs a new writer to process the vertices of
98 // the indicated data object. This flavor creates the
99 // writer specifically to process the named data type.
100 ////////////////////////////////////////////////////////////////////
101 INLINE GeomVertexWriter::
103  const InternalName *name) :
104  _vertex_data(data_writer->get_object()),
105  _current_thread(data_writer->get_current_thread())
106 {
107  initialize();
108  const GeomVertexFormat *format = data_writer->get_format();
109  set_vertex_column(format->get_array_with(name),
110  format->get_column(name),
111  data_writer);
112 }
113 
114 ////////////////////////////////////////////////////////////////////
115 // Function: GeomVertexWriter::Copy Constructor
116 // Access: Published
117 // Description:
118 ////////////////////////////////////////////////////////////////////
119 INLINE GeomVertexWriter::
120 GeomVertexWriter(const GeomVertexWriter &copy) :
121  _vertex_data(copy._vertex_data),
122  _array(copy._array),
123  _array_data(copy._array_data),
124  _current_thread(copy._current_thread),
125  _packer(copy._packer),
126  _stride(copy._stride),
127  _handle(copy._handle),
128  _pointer_begin(copy._pointer_begin),
129  _pointer_end(copy._pointer_end),
130  _pointer(copy._pointer),
131  _start_row(copy._start_row)
132 {
133 }
134 
135 ////////////////////////////////////////////////////////////////////
136 // Function: GeomVertexWriter::Copy Assignment Operator
137 // Access: Published
138 // Description:
139 ////////////////////////////////////////////////////////////////////
140 INLINE void GeomVertexWriter::
141 operator = (const GeomVertexWriter &copy) {
142  _vertex_data = copy._vertex_data;
143  _array = copy._array;
144  _array_data = copy._array_data;
145  _current_thread = copy._current_thread;
146  _packer = copy._packer;
147  _stride = copy._stride;
148  _handle = copy._handle;
149  _pointer_begin = copy._pointer_begin;
150  _pointer_end = copy._pointer_end;
151  _pointer = copy._pointer;
152  _start_row = copy._start_row;
153 }
154 
155 ////////////////////////////////////////////////////////////////////
156 // Function: GeomVertexWriter::Destructor
157 // Access: Published
158 // Description:
159 ////////////////////////////////////////////////////////////////////
160 INLINE GeomVertexWriter::
161 ~GeomVertexWriter() {
162 }
163 
164 ////////////////////////////////////////////////////////////////////
165 // Function: GeomVertexWriter::get_vertex_data
166 // Access: Published
167 // Description: Returns the vertex data object that the
168 // writer is processing. This may return NULL if the
169 // writer was constructed with just an array pointer.
170 ////////////////////////////////////////////////////////////////////
173  return _vertex_data;
174 }
175 
176 ////////////////////////////////////////////////////////////////////
177 // Function: GeomVertexWriter::get_array_data
178 // Access: Published
179 // Description: Returns the particular array object that the
180 // writer is currently processing.
181 ////////////////////////////////////////////////////////////////////
183 get_array_data() const {
184  return _array_data;
185 }
186 
187 ////////////////////////////////////////////////////////////////////
188 // Function: GeomVertexWriter::get_array_handle
189 // Access: Published
190 // Description: Returns the write handle to the array object that the
191 // writer is currently processing. This low-level call
192 // should be used with caution; be careful with
193 // modifying the data in the handle out from under the
194 // GeomVertexWriter.
195 ////////////////////////////////////////////////////////////////////
198  return _handle;
199 }
200 
201 ////////////////////////////////////////////////////////////////////
202 // Function: GeomVertexWriter::get_stride
203 // Access: Published
204 // Description: Returns the per-row stride (bytes between consecutive
205 // rows) of the underlying vertex array. This low-level
206 // information is normally not needed to use the
207 // GeomVertexWriter directly.
208 ////////////////////////////////////////////////////////////////////
209 INLINE size_t GeomVertexWriter::
210 get_stride() const {
211  return _stride;
212 }
213 
214 ////////////////////////////////////////////////////////////////////
215 // Function: GeomVertexWriter::get_current_thread
216 // Access: Published
217 // Description: Returns the Thread pointer of the currently-executing
218 // thread, as passed to the constructor of this object.
219 ////////////////////////////////////////////////////////////////////
222  return _current_thread;
223 }
224 
225 ////////////////////////////////////////////////////////////////////
226 // Function: GeomVertexWriter::set_column
227 // Access: Published
228 // Description: Sets up the writer to use the nth data type of the
229 // GeomVertexFormat, numbering from 0.
230 //
231 // This also resets the write row number to the start
232 // row (the same value passed to a previous call to
233 // set_row(), or 0 if set_row() was never called.)
234 //
235 // The return value is true if the data type is valid,
236 // false otherwise.
237 ////////////////////////////////////////////////////////////////////
238 INLINE bool GeomVertexWriter::
239 set_column(int column) {
240  if (_vertex_data != (GeomVertexData *)NULL) {
241  GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread);
242  writer.check_array_writers();
243  const GeomVertexFormat *format = writer.get_format();
244  return set_vertex_column(format->get_array_with(column),
245  format->get_column(column),
246  &writer);
247  }
248  if (_array_data != (GeomVertexArrayData *)NULL) {
249  return set_array_column(_array_data->get_array_format()->get_column(column));
250  }
251  return false;
252 }
253 
254 ////////////////////////////////////////////////////////////////////
255 // Function: GeomVertexWriter::set_column
256 // Access: Published
257 // Description: Sets up the writer to use the data type with the
258 // indicated name.
259 //
260 // This also resets the write number to the start row
261 // (the same value passed to a previous call to
262 // set_row(), or 0 if set_row() was never called.)
263 //
264 // The return value is true if the data type is valid,
265 // false otherwise.
266 ////////////////////////////////////////////////////////////////////
267 INLINE bool GeomVertexWriter::
269  if (_vertex_data != (GeomVertexData *)NULL) {
270  GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread);
271  writer.check_array_writers();
272  const GeomVertexFormat *format = writer.get_format();
273  return set_vertex_column(format->get_array_with(name),
274  format->get_column(name),
275  &writer);
276  }
277  if (_array_data != (GeomVertexArrayData *)NULL) {
278  return set_array_column(_array_data->get_array_format()->get_column(name));
279  }
280  return false;
281 }
282 
283 ////////////////////////////////////////////////////////////////////
284 // Function: GeomVertexWriter::clear
285 // Access: Published
286 // Description: Resets the GeomVertexWriter to the initial state.
287 ////////////////////////////////////////////////////////////////////
288 INLINE void GeomVertexWriter::
289 clear() {
290  (*this) = GeomVertexWriter(_current_thread);
291 }
292 
293 ////////////////////////////////////////////////////////////////////
294 // Function: GeomVertexWriter::has_column
295 // Access: Published
296 // Description: Returns true if a valid data type has been
297 // successfully set, or false if the data type does not
298 // exist.
299 ////////////////////////////////////////////////////////////////////
300 INLINE bool GeomVertexWriter::
301 has_column() const {
302  return (_packer != (GeomVertexColumn::Packer *)NULL);
303 }
304 
305 ////////////////////////////////////////////////////////////////////
306 // Function: GeomVertexWriter::get_array
307 // Access: Published
308 // Description: Returns the array index containing the data type that
309 // the writer is working on.
310 ////////////////////////////////////////////////////////////////////
311 INLINE int GeomVertexWriter::
312 get_array() const {
313  return _array;
314 }
315 
316 ////////////////////////////////////////////////////////////////////
317 // Function: GeomVertexWriter::get_column
318 // Access: Published
319 // Description: Returns the description of the data type that the
320 // writer is working on.
321 ////////////////////////////////////////////////////////////////////
323 get_column() const {
324  if (_packer != (GeomVertexColumn::Packer *)NULL) {
325  return _packer->_column;
326  }
327  return NULL;
328 }
329 
330 ////////////////////////////////////////////////////////////////////
331 // Function: GeomVertexWriter::set_row_unsafe
332 // Access: Published
333 // Description: Sets the start row to the indicated value, without
334 // internal checks. This is the same as set_row(), but
335 // it does not check for the possibility that the array
336 // has been reallocated internally for some reason; use
337 // only when you are confident that the array is
338 // unchanged and you really need every bit of available
339 // performance.
340 ////////////////////////////////////////////////////////////////////
341 INLINE void GeomVertexWriter::
342 set_row_unsafe(int row) {
343  _start_row = row;
344  if (has_column()) {
345  quick_set_pointer(_start_row);
346  }
347 }
348 
349 ////////////////////////////////////////////////////////////////////
350 // Function: GeomVertexWriter::set_row
351 // Access: Published
352 // Description: Sets the start row to the indicated value. The
353 // writer will begin writing to the indicated row;
354 // each subsequent set_data*() call will store the data
355 // into the subsequent row. If set_column() is called,
356 // the writer will return to this row.
357 ////////////////////////////////////////////////////////////////////
358 INLINE void GeomVertexWriter::
359 set_row(int row) {
360  _start_row = row;
361  if (has_column()) {
362  set_pointer(_start_row);
363  }
364 }
365 
366 ////////////////////////////////////////////////////////////////////
367 // Function: GeomVertexWriter::get_start_row
368 // Access: Published
369 // Description: Returns the row index at which the writer
370 // started. It will return to this row if you reset
371 // the current column.
372 ////////////////////////////////////////////////////////////////////
373 INLINE int GeomVertexWriter::
374 get_start_row() const {
375  return _start_row;
376 }
377 
378 ////////////////////////////////////////////////////////////////////
379 // Function: GeomVertexWriter::get_write_row
380 // Access: Published
381 // Description: Returns the row index to which the data will be
382 // written at the next call to set_data*() or
383 // add_data*().
384 ////////////////////////////////////////////////////////////////////
385 INLINE int GeomVertexWriter::
386 get_write_row() const {
387  return (int)(_pointer - _pointer_begin) / _stride;
388 }
389 
390 ////////////////////////////////////////////////////////////////////
391 // Function: GeomVertexWriter::is_at_end
392 // Access: Published
393 // Description: Returns true if the writer is currently at the end of
394 // the list of vertices, false otherwise. If this is
395 // true, another call to set_data*() will result in a
396 // crash, but another call to add_data*() will add a new
397 // row.
398 ////////////////////////////////////////////////////////////////////
399 INLINE bool GeomVertexWriter::
400 is_at_end() const {
401  return _pointer >= _pointer_end;
402 }
403 
404 ////////////////////////////////////////////////////////////////////
405 // Function: GeomVertexWriter::set_data1f
406 // Access: Published
407 // Description: Sets the write row to a particular 1-component
408 // value, and advances the write row.
409 //
410 // It is an error for the write row to advance past
411 // the end of data.
412 ////////////////////////////////////////////////////////////////////
413 INLINE void GeomVertexWriter::
414 set_data1f(float data) {
415  nassertv(has_column());
416  _packer->set_data1f(inc_pointer(), data);
417 }
418 
419 ////////////////////////////////////////////////////////////////////
420 // Function: GeomVertexWriter::set_data2f
421 // Access: Published
422 // Description: Sets the write row to a particular 2-component
423 // value, and advances the write row.
424 //
425 // It is an error for the write row to advance past
426 // the end of data.
427 ////////////////////////////////////////////////////////////////////
428 INLINE void GeomVertexWriter::
429 set_data2f(float x, float y) {
430  set_data2f(LVecBase2f(x, y));
431 }
432 
433 ////////////////////////////////////////////////////////////////////
434 // Function: GeomVertexWriter::set_data2f
435 // Access: Published
436 // Description: Sets the write row to a particular 2-component
437 // value, and advances the write row.
438 //
439 // It is an error for the write row to advance past
440 // the end of data.
441 ////////////////////////////////////////////////////////////////////
442 INLINE void GeomVertexWriter::
443 set_data2f(const LVecBase2f &data) {
444  nassertv(has_column());
445  _packer->set_data2f(inc_pointer(), data);
446 }
447 
448 ////////////////////////////////////////////////////////////////////
449 // Function: GeomVertexWriter::set_data3f
450 // Access: Published
451 // Description: Sets the write row to a particular 3-component
452 // value, and advances the write row.
453 //
454 // It is an error for the write row to advance past
455 // the end of data.
456 ////////////////////////////////////////////////////////////////////
457 INLINE void GeomVertexWriter::
458 set_data3f(float x, float y, float z) {
459  set_data3f(LVecBase3f(x, y, z));
460 }
461 
462 ////////////////////////////////////////////////////////////////////
463 // Function: GeomVertexWriter::set_data3f
464 // Access: Published
465 // Description: Sets the write row to a particular 3-component
466 // value, and advances the write row.
467 //
468 // It is an error for the write row to advance past
469 // the end of data.
470 ////////////////////////////////////////////////////////////////////
471 INLINE void GeomVertexWriter::
472 set_data3f(const LVecBase3f &data) {
473  nassertv(has_column());
474  _packer->set_data3f(inc_pointer(), data);
475 }
476 
477 ////////////////////////////////////////////////////////////////////
478 // Function: GeomVertexWriter::set_data4f
479 // Access: Published
480 // Description: Sets the write row to a particular 4-component
481 // value, and advances the write row.
482 //
483 // It is an error for the write row to advance past
484 // the end of data.
485 ////////////////////////////////////////////////////////////////////
486 INLINE void GeomVertexWriter::
487 set_data4f(float x, float y, float z, float w) {
488  set_data4f(LVecBase4f(x, y, z, w));
489 }
490 
491 ////////////////////////////////////////////////////////////////////
492 // Function: GeomVertexWriter::set_data4f
493 // Access: Published
494 // Description: Sets the write row to a particular 4-component
495 // value, and advances the write row.
496 //
497 // It is an error for the write row to advance past
498 // the end of data.
499 ////////////////////////////////////////////////////////////////////
500 INLINE void GeomVertexWriter::
501 set_data4f(const LVecBase4f &data) {
502  nassertv(has_column());
503  _packer->set_data4f(inc_pointer(), data);
504 }
505 
506 ////////////////////////////////////////////////////////////////////
507 // Function: GeomVertexWriter::set_matrix3f
508 // Access: Published
509 // Description: Sets the write row to a 3-by-3 matrix, and advances
510 // the write row. This is a special method that can
511 // only be used on matrix columns.
512 //
513 // It is an error for the write row to advance past
514 // the end of data.
515 ////////////////////////////////////////////////////////////////////
516 INLINE void GeomVertexWriter::
517 set_matrix3f(const LMatrix3f &mat) {
518  nassertv(has_column() &&
519  _packer->_column->get_contents() == C_matrix &&
520  _packer->_column->get_num_elements() == 3);
521 
522  size_t col_stride = _packer->_column->get_element_stride();
523  unsigned char *pointer = inc_pointer();
524 
525  _packer->set_data3f(pointer, mat.get_row(0));
526  pointer += col_stride;
527  _packer->set_data3f(pointer, mat.get_row(1));
528  pointer += col_stride;
529  _packer->set_data3f(pointer, mat.get_row(2));
530 }
531 
532 ////////////////////////////////////////////////////////////////////
533 // Function: GeomVertexWriter::set_matrix4f
534 // Access: Published
535 // Description: Sets the write row to a 4-by-4 matrix, and advances
536 // the write row. This is a special method that can
537 // only be used on matrix columns.
538 //
539 // It is an error for the write row to advance past
540 // the end of data.
541 ////////////////////////////////////////////////////////////////////
542 INLINE void GeomVertexWriter::
543 set_matrix4f(const LMatrix4f &mat) {
544  nassertv(has_column() &&
545  _packer->_column->get_contents() == C_matrix &&
546  _packer->_column->get_num_elements() == 4);
547 
548  size_t col_stride = _packer->_column->get_element_stride();
549  unsigned char *pointer = inc_pointer();
550 
551  _packer->set_data4f(pointer, mat.get_row(0));
552  pointer += col_stride;
553  _packer->set_data4f(pointer, mat.get_row(1));
554  pointer += col_stride;
555  _packer->set_data4f(pointer, mat.get_row(2));
556  pointer += col_stride;
557  _packer->set_data4f(pointer, mat.get_row(3));
558 }
559 
560 ////////////////////////////////////////////////////////////////////
561 // Function: GeomVertexWriter::set_data1d
562 // Access: Published
563 // Description: Sets the write row to a particular 1-component
564 // value, and advances the write row.
565 //
566 // It is an error for the write row to advance past
567 // the end of data.
568 ////////////////////////////////////////////////////////////////////
569 INLINE void GeomVertexWriter::
570 set_data1d(double data) {
571  nassertv(has_column());
572  _packer->set_data1d(inc_pointer(), data);
573 }
574 
575 ////////////////////////////////////////////////////////////////////
576 // Function: GeomVertexWriter::set_data2d
577 // Access: Published
578 // Description: Sets the write row to a particular 2-component
579 // value, and advances the write row.
580 //
581 // It is an error for the write row to advance past
582 // the end of data.
583 ////////////////////////////////////////////////////////////////////
584 INLINE void GeomVertexWriter::
585 set_data2d(double x, double y) {
586  set_data2d(LVecBase2d(x, y));
587 }
588 
589 ////////////////////////////////////////////////////////////////////
590 // Function: GeomVertexWriter::set_data2d
591 // Access: Published
592 // Description: Sets the write row to a particular 2-component
593 // value, and advances the write row.
594 //
595 // It is an error for the write row to advance past
596 // the end of data.
597 ////////////////////////////////////////////////////////////////////
598 INLINE void GeomVertexWriter::
599 set_data2d(const LVecBase2d &data) {
600  nassertv(has_column());
601  _packer->set_data2d(inc_pointer(), data);
602 }
603 
604 ////////////////////////////////////////////////////////////////////
605 // Function: GeomVertexWriter::set_data3d
606 // Access: Published
607 // Description: Sets the write row to a particular 3-component
608 // value, and advances the write row.
609 //
610 // It is an error for the write row to advance past
611 // the end of data.
612 ////////////////////////////////////////////////////////////////////
613 INLINE void GeomVertexWriter::
614 set_data3d(double x, double y, double z) {
615  set_data3d(LVecBase3d(x, y, z));
616 }
617 
618 ////////////////////////////////////////////////////////////////////
619 // Function: GeomVertexWriter::set_data3d
620 // Access: Published
621 // Description: Sets the write row to a particular 3-component
622 // value, and advances the write row.
623 //
624 // It is an error for the write row to advance past
625 // the end of data.
626 ////////////////////////////////////////////////////////////////////
627 INLINE void GeomVertexWriter::
628 set_data3d(const LVecBase3d &data) {
629  nassertv(has_column());
630  _packer->set_data3d(inc_pointer(), data);
631 }
632 
633 ////////////////////////////////////////////////////////////////////
634 // Function: GeomVertexWriter::set_data4d
635 // Access: Published
636 // Description: Sets the write row to a particular 4-component
637 // value, and advances the write row.
638 //
639 // It is an error for the write row to advance past
640 // the end of data.
641 ////////////////////////////////////////////////////////////////////
642 INLINE void GeomVertexWriter::
643 set_data4d(double x, double y, double z, double w) {
644  set_data4d(LVecBase4d(x, y, z, w));
645 }
646 
647 ////////////////////////////////////////////////////////////////////
648 // Function: GeomVertexWriter::set_data4d
649 // Access: Published
650 // Description: Sets the write row to a particular 4-component
651 // value, and advances the write row.
652 //
653 // It is an error for the write row to advance past
654 // the end of data.
655 ////////////////////////////////////////////////////////////////////
656 INLINE void GeomVertexWriter::
657 set_data4d(const LVecBase4d &data) {
658  nassertv(has_column());
659  _packer->set_data4d(inc_pointer(), data);
660 }
661 
662 ////////////////////////////////////////////////////////////////////
663 // Function: GeomVertexWriter::set_matrix3d
664 // Access: Published
665 // Description: Sets the write row to a 3-by-3 matrix, and advances
666 // the write row. This is a special method that can
667 // only be used on matrix columns.
668 //
669 // It is an error for the write row to advance past
670 // the end of data.
671 ////////////////////////////////////////////////////////////////////
672 INLINE void GeomVertexWriter::
673 set_matrix3d(const LMatrix3d &mat) {
674  nassertv(has_column() &&
675  _packer->_column->get_contents() == C_matrix &&
676  _packer->_column->get_num_elements() == 3);
677 
678  size_t col_stride = _packer->_column->get_element_stride();
679  unsigned char *pointer = inc_pointer();
680 
681  _packer->set_data3d(pointer, mat.get_row(0));
682  pointer += col_stride;
683  _packer->set_data3d(pointer, mat.get_row(1));
684  pointer += col_stride;
685  _packer->set_data3d(pointer, mat.get_row(2));
686 }
687 
688 ////////////////////////////////////////////////////////////////////
689 // Function: GeomVertexWriter::set_matrix4d
690 // Access: Published
691 // Description: Sets the write row to a 4-by-4 matrix, and advances
692 // the write row. This is a special method that can
693 // only be used on matrix columns.
694 //
695 // It is an error for the write row to advance past
696 // the end of data.
697 ////////////////////////////////////////////////////////////////////
698 INLINE void GeomVertexWriter::
699 set_matrix4d(const LMatrix4d &mat) {
700  nassertv(has_column() &&
701  _packer->_column->get_contents() == C_matrix &&
702  _packer->_column->get_num_elements() == 4);
703 
704  size_t col_stride = _packer->_column->get_element_stride();
705  unsigned char *pointer = inc_pointer();
706 
707  _packer->set_data4d(pointer, mat.get_row(0));
708  pointer += col_stride;
709  _packer->set_data4d(pointer, mat.get_row(1));
710  pointer += col_stride;
711  _packer->set_data4d(pointer, mat.get_row(2));
712  pointer += col_stride;
713  _packer->set_data4d(pointer, mat.get_row(3));
714 }
715 
716 ////////////////////////////////////////////////////////////////////
717 // Function: GeomVertexWriter::set_data1
718 // Access: Published
719 // Description: Sets the write row to a particular 1-component
720 // value, and advances the write row.
721 //
722 // It is an error for the write row to advance past
723 // the end of data.
724 ////////////////////////////////////////////////////////////////////
725 INLINE void GeomVertexWriter::
726 set_data1(PN_stdfloat data) {
727 #ifndef STDFLOAT_DOUBLE
728  set_data1f(data);
729 #else
730  set_data1d(data);
731 #endif
732 }
733 
734 ////////////////////////////////////////////////////////////////////
735 // Function: GeomVertexWriter::set_data2
736 // Access: Published
737 // Description: Sets the write row to a particular 2-component
738 // value, and advances the write row.
739 //
740 // It is an error for the write row to advance past
741 // the end of data.
742 ////////////////////////////////////////////////////////////////////
743 INLINE void GeomVertexWriter::
744 set_data2(PN_stdfloat x, PN_stdfloat y) {
745 #ifndef STDFLOAT_DOUBLE
746  set_data2f(x, y);
747 #else
748  set_data2d(x, y);
749 #endif
750 }
751 
752 ////////////////////////////////////////////////////////////////////
753 // Function: GeomVertexWriter::set_data2
754 // Access: Published
755 // Description: Sets the write row to a particular 2-component
756 // value, and advances the write row.
757 //
758 // It is an error for the write row to advance past
759 // the end of data.
760 ////////////////////////////////////////////////////////////////////
761 INLINE void GeomVertexWriter::
762 set_data2(const LVecBase2 &data) {
763 #ifndef STDFLOAT_DOUBLE
764  set_data2f(data);
765 #else
766  set_data2d(data);
767 #endif
768 }
769 
770 ////////////////////////////////////////////////////////////////////
771 // Function: GeomVertexWriter::set_data3
772 // Access: Published
773 // Description: Sets the write row to a particular 3-component
774 // value, and advances the write row.
775 //
776 // It is an error for the write row to advance past
777 // the end of data.
778 ////////////////////////////////////////////////////////////////////
779 INLINE void GeomVertexWriter::
780 set_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
781 #ifndef STDFLOAT_DOUBLE
782  set_data3f(x, y, z);
783 #else
784  set_data3d(x, y, z);
785 #endif
786 }
787 
788 ////////////////////////////////////////////////////////////////////
789 // Function: GeomVertexWriter::set_data3
790 // Access: Published
791 // Description: Sets the write row to a particular 3-component
792 // value, and advances the write row.
793 //
794 // It is an error for the write row to advance past
795 // the end of data.
796 ////////////////////////////////////////////////////////////////////
797 INLINE void GeomVertexWriter::
798 set_data3(const LVecBase3 &data) {
799 #ifndef STDFLOAT_DOUBLE
800  set_data3f(data);
801 #else
802  set_data3d(data);
803 #endif
804 }
805 
806 ////////////////////////////////////////////////////////////////////
807 // Function: GeomVertexWriter::set_data4
808 // Access: Published
809 // Description: Sets the write row to a particular 4-component
810 // value, and advances the write row.
811 //
812 // It is an error for the write row to advance past
813 // the end of data.
814 ////////////////////////////////////////////////////////////////////
815 INLINE void GeomVertexWriter::
816 set_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w) {
817 #ifndef STDFLOAT_DOUBLE
818  set_data4f(x, y, z, w);
819 #else
820  set_data4d(x, y, z, w);
821 #endif
822 }
823 
824 ////////////////////////////////////////////////////////////////////
825 // Function: GeomVertexWriter::set_data4
826 // Access: Published
827 // Description: Sets the write row to a particular 4-component
828 // value, and advances the write row.
829 //
830 // It is an error for the write row to advance past
831 // the end of data.
832 ////////////////////////////////////////////////////////////////////
833 INLINE void GeomVertexWriter::
834 set_data4(const LVecBase4 &data) {
835 #ifndef STDFLOAT_DOUBLE
836  set_data4f(data);
837 #else
838  set_data4d(data);
839 #endif
840 }
841 
842 ////////////////////////////////////////////////////////////////////
843 // Function: GeomVertexWriter::set_matrix3
844 // Access: Published
845 // Description: Sets the write row to a 3-by-3 matrix, and advances
846 // the write row. This is a special method that can
847 // only be used on matrix columns.
848 //
849 // It is an error for the write row to advance past
850 // the end of data.
851 ////////////////////////////////////////////////////////////////////
852 INLINE void GeomVertexWriter::
853 set_matrix3(const LMatrix3 &mat) {
854 #ifndef STDFLOAT_DOUBLE
855  set_matrix3f(mat);
856 #else
857  set_matrix3d(mat);
858 #endif
859 }
860 
861 ////////////////////////////////////////////////////////////////////
862 // Function: GeomVertexWriter::set_matrix4
863 // Access: Published
864 // Description: Sets the write row to a 4-by-4 matrix, and advances
865 // the write row. This is a special method that can
866 // only be used on matrix columns.
867 //
868 // It is an error for the write row to advance past
869 // the end of data.
870 ////////////////////////////////////////////////////////////////////
871 INLINE void GeomVertexWriter::
872 set_matrix4(const LMatrix4 &mat) {
873 #ifndef STDFLOAT_DOUBLE
874  set_matrix4f(mat);
875 #else
876  set_matrix4d(mat);
877 #endif
878 }
879 
880 ////////////////////////////////////////////////////////////////////
881 // Function: GeomVertexWriter::set_data1i
882 // Access: Published
883 // Description: Sets the write row to a particular 1-component
884 // value, and advances the write row.
885 //
886 // It is an error for the write row to advance past
887 // the end of data.
888 ////////////////////////////////////////////////////////////////////
889 INLINE void GeomVertexWriter::
890 set_data1i(int data) {
891  nassertv(has_column());
892  _packer->set_data1i(inc_pointer(), data);
893 }
894 
895 ////////////////////////////////////////////////////////////////////
896 // Function: GeomVertexWriter::set_data2i
897 // Access: Published
898 // Description: Sets the write row to a particular 2-component
899 // value, and advances the write row.
900 //
901 // It is an error for the write row to advance past
902 // the end of data.
903 ////////////////////////////////////////////////////////////////////
904 INLINE void GeomVertexWriter::
905 set_data2i(int a, int b) {
906  set_data2i(LVecBase2i(a, b));
907 }
908 
909 ////////////////////////////////////////////////////////////////////
910 // Function: GeomVertexWriter::set_data2i
911 // Access: Published
912 // Description: Sets the write row to a particular 2-component
913 // value, and advances the write row.
914 //
915 // It is an error for the write row to advance past
916 // the end of data.
917 ////////////////////////////////////////////////////////////////////
918 INLINE void GeomVertexWriter::
919 set_data2i(const int data[2]) {
920  set_data2i(LVecBase2i(data[0], data[1]));
921 }
922 
923 ////////////////////////////////////////////////////////////////////
924 // Function: GeomVertexWriter::set_data2i
925 // Access: Published
926 // Description: Sets the write row to a particular 2-component
927 // value, and advances the write row.
928 //
929 // It is an error for the write row to advance past
930 // the end of data.
931 ////////////////////////////////////////////////////////////////////
932 INLINE void GeomVertexWriter::
933 set_data2i(const LVecBase2i &data) {
934  nassertv(has_column());
935  _packer->set_data2i(inc_pointer(), data);
936 }
937 
938 ////////////////////////////////////////////////////////////////////
939 // Function: GeomVertexWriter::set_data3i
940 // Access: Published
941 // Description: Sets the write row to a particular 3-component
942 // value, and advances the write row.
943 //
944 // It is an error for the write row to advance past
945 // the end of data.
946 ////////////////////////////////////////////////////////////////////
947 INLINE void GeomVertexWriter::
948 set_data3i(int a, int b, int c) {
949  set_data3i(LVecBase3i(a, b, c));
950 }
951 
952 ////////////////////////////////////////////////////////////////////
953 // Function: GeomVertexWriter::set_data3i
954 // Access: Published
955 // Description: Sets the write row to a particular 3-component
956 // value, and advances the write row.
957 //
958 // It is an error for the write row to advance past
959 // the end of data.
960 ////////////////////////////////////////////////////////////////////
961 INLINE void GeomVertexWriter::
962 set_data3i(const int data[3]) {
963  set_data3i(LVecBase3i(data[0], data[1], data[2]));
964 }
965 
966 ////////////////////////////////////////////////////////////////////
967 // Function: GeomVertexWriter::set_data3i
968 // Access: Published
969 // Description: Sets the write row to a particular 3-component
970 // value, and advances the write row.
971 //
972 // It is an error for the write row to advance past
973 // the end of data.
974 ////////////////////////////////////////////////////////////////////
975 INLINE void GeomVertexWriter::
976 set_data3i(const LVecBase3i &data) {
977  nassertv(has_column());
978  _packer->set_data3i(inc_pointer(), data);
979 }
980 
981 ////////////////////////////////////////////////////////////////////
982 // Function: GeomVertexWriter::set_data4i
983 // Access: Published
984 // Description: Sets the write row to a particular 4-component
985 // value, and advances the write row.
986 //
987 // It is an error for the write row to advance past
988 // the end of data.
989 ////////////////////////////////////////////////////////////////////
990 INLINE void GeomVertexWriter::
991 set_data4i(int a, int b, int c, int d) {
992  set_data4i(LVecBase4i(a, b, c, d));
993 }
994 
995 ////////////////////////////////////////////////////////////////////
996 // Function: GeomVertexWriter::set_data4i
997 // Access: Published
998 // Description: Sets the write row to a particular 4-component
999 // value, and advances the write row.
1000 //
1001 // It is an error for the write row to advance past
1002 // the end of data.
1003 ////////////////////////////////////////////////////////////////////
1004 INLINE void GeomVertexWriter::
1005 set_data4i(const int data[4]) {
1006  set_data4i(LVecBase4i(data[0], data[1], data[2], data[3]));
1007 }
1008 
1009 ////////////////////////////////////////////////////////////////////
1010 // Function: GeomVertexWriter::set_data4i
1011 // Access: Published
1012 // Description: Sets the write row to a particular 4-component
1013 // value, and advances the write row.
1014 //
1015 // It is an error for the write row to advance past
1016 // the end of data.
1017 ////////////////////////////////////////////////////////////////////
1018 INLINE void GeomVertexWriter::
1019 set_data4i(const LVecBase4i &data) {
1020  nassertv(has_column());
1021  _packer->set_data4i(inc_pointer(), data);
1022 }
1023 
1024 ////////////////////////////////////////////////////////////////////
1025 // Function: GeomVertexWriter::add_data1f
1026 // Access: Published
1027 // Description: Sets the write row to a particular 1-component
1028 // value, and advances the write row.
1029 //
1030 // If the write row advances past the end of data,
1031 // implicitly adds a new row to the data.
1032 ////////////////////////////////////////////////////////////////////
1033 INLINE void GeomVertexWriter::
1034 add_data1f(float data) {
1035  nassertv(has_column());
1036  _packer->set_data1f(inc_add_pointer(), data);
1037 }
1038 
1039 ////////////////////////////////////////////////////////////////////
1040 // Function: GeomVertexWriter::add_data2f
1041 // Access: Published
1042 // Description: Sets the write row to a particular 2-component
1043 // value, and advances the write row.
1044 //
1045 // If the write row advances past the end of data,
1046 // implicitly adds a new row to the data.
1047 ////////////////////////////////////////////////////////////////////
1048 INLINE void GeomVertexWriter::
1049 add_data2f(float x, float y) {
1050  add_data2f(LVecBase2f(x, y));
1051 }
1052 
1053 ////////////////////////////////////////////////////////////////////
1054 // Function: GeomVertexWriter::add_data2f
1055 // Access: Published
1056 // Description: Sets the write row to a particular 2-component
1057 // value, and advances the write row.
1058 //
1059 // If the write row advances past the end of data,
1060 // implicitly adds a new row to the data.
1061 ////////////////////////////////////////////////////////////////////
1062 INLINE void GeomVertexWriter::
1063 add_data2f(const LVecBase2f &data) {
1064  nassertv(has_column());
1065  _packer->set_data2f(inc_add_pointer(), data);
1066 }
1067 
1068 ////////////////////////////////////////////////////////////////////
1069 // Function: GeomVertexWriter::add_data3f
1070 // Access: Published
1071 // Description: Sets the write row to a particular 3-component
1072 // value, and advances the write row.
1073 //
1074 // If the write row advances past the end of data,
1075 // implicitly adds a new row to the data.
1076 ////////////////////////////////////////////////////////////////////
1077 INLINE void GeomVertexWriter::
1078 add_data3f(float x, float y, float z) {
1079  add_data3f(LVecBase3f(x, y, z));
1080 }
1081 
1082 ////////////////////////////////////////////////////////////////////
1083 // Function: GeomVertexWriter::add_data3f
1084 // Access: Published
1085 // Description: Sets the write row to a particular 3-component
1086 // value, and advances the write row.
1087 //
1088 // If the write row advances past the end of data,
1089 // implicitly adds a new row to the data.
1090 ////////////////////////////////////////////////////////////////////
1091 INLINE void GeomVertexWriter::
1092 add_data3f(const LVecBase3f &data) {
1093  nassertv(has_column());
1094  _packer->set_data3f(inc_add_pointer(), data);
1095 }
1096 
1097 ////////////////////////////////////////////////////////////////////
1098 // Function: GeomVertexWriter::add_data4f
1099 // Access: Published
1100 // Description: Sets the write row to a particular 4-component
1101 // value, and advances the write row.
1102 //
1103 // If the write row advances past the end of data,
1104 // implicitly adds a new row to the data.
1105 ////////////////////////////////////////////////////////////////////
1106 INLINE void GeomVertexWriter::
1107 add_data4f(float x, float y, float z, float w) {
1108  add_data4f(LVecBase4f(x, y, z, w));
1109 }
1110 
1111 ////////////////////////////////////////////////////////////////////
1112 // Function: GeomVertexWriter::add_data4f
1113 // Access: Published
1114 // Description: Sets the write row to a particular 4-component
1115 // value, and advances the write row.
1116 //
1117 // If the write row advances past the end of data,
1118 // implicitly adds a new row to the data.
1119 ////////////////////////////////////////////////////////////////////
1120 INLINE void GeomVertexWriter::
1121 add_data4f(const LVecBase4f &data) {
1122  nassertv(has_column());
1123  _packer->set_data4f(inc_add_pointer(), data);
1124 }
1125 
1126 ////////////////////////////////////////////////////////////////////
1127 // Function: GeomVertexWriter::add_matrix3f
1128 // Access: Published
1129 // Description: Sets the write row to a 3-by-3 matrix, and advances
1130 // the write row. This is a special method that can
1131 // only be used on matrix columns.
1132 //
1133 // If the write row advances past the end of data,
1134 // implicitly adds a new row to the data.
1135 ////////////////////////////////////////////////////////////////////
1136 INLINE void GeomVertexWriter::
1138  nassertv(has_column() &&
1139  _packer->_column->get_contents() == C_matrix &&
1140  _packer->_column->get_num_elements() == 3);
1141 
1142  size_t col_stride = _packer->_column->get_element_stride();
1143  unsigned char *pointer = inc_add_pointer();
1144 
1145  _packer->set_data3f(pointer, mat.get_row(0));
1146  pointer += col_stride;
1147  _packer->set_data3f(pointer, mat.get_row(1));
1148  pointer += col_stride;
1149  _packer->set_data3f(pointer, mat.get_row(2));
1150 }
1151 
1152 ////////////////////////////////////////////////////////////////////
1153 // Function: GeomVertexWriter::add_matrix4f
1154 // Access: Published
1155 // Description: Sets the write row to a 4-by-4 matrix, and advances
1156 // the write row. This is a special method that can
1157 // only be used on matrix columns.
1158 //
1159 // If the write row advances past the end of data,
1160 // implicitly adds a new row to the data.
1161 ////////////////////////////////////////////////////////////////////
1162 INLINE void GeomVertexWriter::
1164  nassertv(has_column() &&
1165  _packer->_column->get_contents() == C_matrix &&
1166  _packer->_column->get_num_elements() == 4);
1167 
1168  size_t col_stride = _packer->_column->get_element_stride();
1169  unsigned char *pointer = inc_add_pointer();
1170 
1171  _packer->set_data4f(pointer, mat.get_row(0));
1172  pointer += col_stride;
1173  _packer->set_data4f(pointer, mat.get_row(1));
1174  pointer += col_stride;
1175  _packer->set_data4f(pointer, mat.get_row(2));
1176  pointer += col_stride;
1177  _packer->set_data4f(pointer, mat.get_row(3));
1178 }
1179 
1180 ////////////////////////////////////////////////////////////////////
1181 // Function: GeomVertexWriter::add_data1d
1182 // Access: Published
1183 // Description: Sets the write row to a particular 1-component
1184 // value, and advances the write row.
1185 //
1186 // If the write row advances past the end of data,
1187 // implicitly adds a new row to the data.
1188 ////////////////////////////////////////////////////////////////////
1189 INLINE void GeomVertexWriter::
1190 add_data1d(double data) {
1191  nassertv(has_column());
1192  _packer->set_data1d(inc_add_pointer(), data);
1193 }
1194 
1195 ////////////////////////////////////////////////////////////////////
1196 // Function: GeomVertexWriter::add_data2d
1197 // Access: Published
1198 // Description: Sets the write row to a particular 2-component
1199 // value, and advances the write row.
1200 //
1201 // If the write row advances past the end of data,
1202 // implicitly adds a new row to the data.
1203 ////////////////////////////////////////////////////////////////////
1204 INLINE void GeomVertexWriter::
1205 add_data2d(double x, double y) {
1206  add_data2d(LVecBase2d(x, y));
1207 }
1208 
1209 ////////////////////////////////////////////////////////////////////
1210 // Function: GeomVertexWriter::add_data2d
1211 // Access: Published
1212 // Description: Sets the write row to a particular 2-component
1213 // value, and advances the write row.
1214 //
1215 // If the write row advances past the end of data,
1216 // implicitly adds a new row to the data.
1217 ////////////////////////////////////////////////////////////////////
1218 INLINE void GeomVertexWriter::
1219 add_data2d(const LVecBase2d &data) {
1220  nassertv(has_column());
1221  _packer->set_data2d(inc_add_pointer(), data);
1222 }
1223 
1224 ////////////////////////////////////////////////////////////////////
1225 // Function: GeomVertexWriter::add_data3d
1226 // Access: Published
1227 // Description: Sets the write row to a particular 3-component
1228 // value, and advances the write row.
1229 //
1230 // If the write row advances past the end of data,
1231 // implicitly adds a new row to the data.
1232 ////////////////////////////////////////////////////////////////////
1233 INLINE void GeomVertexWriter::
1234 add_data3d(double x, double y, double z) {
1235  add_data3d(LVecBase3d(x, y, z));
1236 }
1237 
1238 ////////////////////////////////////////////////////////////////////
1239 // Function: GeomVertexWriter::add_data3d
1240 // Access: Published
1241 // Description: Sets the write row to a particular 3-component
1242 // value, and advances the write row.
1243 //
1244 // If the write row advances past the end of data,
1245 // implicitly adds a new row to the data.
1246 ////////////////////////////////////////////////////////////////////
1247 INLINE void GeomVertexWriter::
1248 add_data3d(const LVecBase3d &data) {
1249  nassertv(has_column());
1250  _packer->set_data3d(inc_add_pointer(), data);
1251 }
1252 
1253 ////////////////////////////////////////////////////////////////////
1254 // Function: GeomVertexWriter::add_data4d
1255 // Access: Published
1256 // Description: Sets the write row to a particular 4-component
1257 // value, and advances the write row.
1258 //
1259 // If the write row advances past the end of data,
1260 // implicitly adds a new row to the data.
1261 ////////////////////////////////////////////////////////////////////
1262 INLINE void GeomVertexWriter::
1263 add_data4d(double x, double y, double z, double w) {
1264  add_data4d(LVecBase4d(x, y, z, w));
1265 }
1266 
1267 ////////////////////////////////////////////////////////////////////
1268 // Function: GeomVertexWriter::add_data4d
1269 // Access: Published
1270 // Description: Sets the write row to a particular 4-component
1271 // value, and advances the write row.
1272 //
1273 // If the write row advances past the end of data,
1274 // implicitly adds a new row to the data.
1275 ////////////////////////////////////////////////////////////////////
1276 INLINE void GeomVertexWriter::
1277 add_data4d(const LVecBase4d &data) {
1278  nassertv(has_column());
1279  _packer->set_data4d(inc_add_pointer(), data);
1280 }
1281 
1282 ////////////////////////////////////////////////////////////////////
1283 // Function: GeomVertexWriter::add_matrix3d
1284 // Access: Published
1285 // Description: Sets the write row to a 3-by-3 matrix, and advances
1286 // the write row. This is a special method that can
1287 // only be used on matrix columns.
1288 //
1289 // If the write row advances past the end of data,
1290 // implicitly adds a new row to the data.
1291 ////////////////////////////////////////////////////////////////////
1292 INLINE void GeomVertexWriter::
1294  nassertv(has_column() &&
1295  _packer->_column->get_contents() == C_matrix &&
1296  _packer->_column->get_num_elements() == 3);
1297 
1298  size_t col_stride = _packer->_column->get_element_stride();
1299  unsigned char *pointer = inc_add_pointer();
1300 
1301  _packer->set_data3d(pointer, mat.get_row(0));
1302  pointer += col_stride;
1303  _packer->set_data3d(pointer, mat.get_row(1));
1304  pointer += col_stride;
1305  _packer->set_data3d(pointer, mat.get_row(2));
1306 }
1307 
1308 ////////////////////////////////////////////////////////////////////
1309 // Function: GeomVertexWriter::add_matrix4d
1310 // Access: Published
1311 // Description: Sets the write row to a 4-by-4 matrix, and advances
1312 // the write row. This is a special method that can
1313 // only be used on matrix columns.
1314 //
1315 // If the write row advances past the end of data,
1316 // implicitly adds a new row to the data.
1317 ////////////////////////////////////////////////////////////////////
1318 INLINE void GeomVertexWriter::
1320  nassertv(has_column() &&
1321  _packer->_column->get_contents() == C_matrix &&
1322  _packer->_column->get_num_elements() == 4);
1323 
1324  size_t col_stride = _packer->_column->get_element_stride();
1325  unsigned char *pointer = inc_add_pointer();
1326 
1327  _packer->set_data4d(pointer, mat.get_row(0));
1328  pointer += col_stride;
1329  _packer->set_data4d(pointer, mat.get_row(1));
1330  pointer += col_stride;
1331  _packer->set_data4d(pointer, mat.get_row(2));
1332  pointer += col_stride;
1333  _packer->set_data4d(pointer, mat.get_row(3));
1334 }
1335 
1336 ////////////////////////////////////////////////////////////////////
1337 // Function: GeomVertexWriter::add_data1
1338 // Access: Published
1339 // Description: Sets the write row to a particular 1-component
1340 // value, and advances the write row.
1341 //
1342 // If the write row advances past the end of data,
1343 // implicitly adds a new row to the data.
1344 ////////////////////////////////////////////////////////////////////
1345 INLINE void GeomVertexWriter::
1346 add_data1(PN_stdfloat data) {
1347 #ifndef STDFLOAT_DOUBLE
1348  add_data1f(data);
1349 #else
1350  add_data1d(data);
1351 #endif
1352 }
1353 
1354 ////////////////////////////////////////////////////////////////////
1355 // Function: GeomVertexWriter::add_data2
1356 // Access: Published
1357 // Description: Sets the write row to a particular 2-component
1358 // value, and advances the write row.
1359 //
1360 // If the write row advances past the end of data,
1361 // implicitly adds a new row to the data.
1362 ////////////////////////////////////////////////////////////////////
1363 INLINE void GeomVertexWriter::
1364 add_data2(PN_stdfloat x, PN_stdfloat y) {
1365 #ifndef STDFLOAT_DOUBLE
1366  add_data2f(x, y);
1367 #else
1368  add_data2d(x, y);
1369 #endif
1370 }
1371 
1372 ////////////////////////////////////////////////////////////////////
1373 // Function: GeomVertexWriter::add_data2
1374 // Access: Published
1375 // Description: Sets the write row to a particular 2-component
1376 // value, and advances the write row.
1377 //
1378 // If the write row advances past the end of data,
1379 // implicitly adds a new row to the data.
1380 ////////////////////////////////////////////////////////////////////
1381 INLINE void GeomVertexWriter::
1382 add_data2(const LVecBase2 &data) {
1383 #ifndef STDFLOAT_DOUBLE
1384  add_data2f(data);
1385 #else
1386  add_data2d(data);
1387 #endif
1388 }
1389 
1390 ////////////////////////////////////////////////////////////////////
1391 // Function: GeomVertexWriter::add_data3
1392 // Access: Published
1393 // Description: Sets the write row to a particular 3-component
1394 // value, and advances the write row.
1395 //
1396 // If the write row advances past the end of data,
1397 // implicitly adds a new row to the data.
1398 ////////////////////////////////////////////////////////////////////
1399 INLINE void GeomVertexWriter::
1400 add_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
1401 #ifndef STDFLOAT_DOUBLE
1402  add_data3f(x, y, z);
1403 #else
1404  add_data3d(x, y, z);
1405 #endif
1406 }
1407 
1408 ////////////////////////////////////////////////////////////////////
1409 // Function: GeomVertexWriter::add_data3
1410 // Access: Published
1411 // Description: Sets the write row to a particular 3-component
1412 // value, and advances the write row.
1413 //
1414 // If the write row advances past the end of data,
1415 // implicitly adds a new row to the data.
1416 ////////////////////////////////////////////////////////////////////
1417 INLINE void GeomVertexWriter::
1418 add_data3(const LVecBase3 &data) {
1419 #ifndef STDFLOAT_DOUBLE
1420  add_data3f(data);
1421 #else
1422  add_data3d(data);
1423 #endif
1424 }
1425 
1426 ////////////////////////////////////////////////////////////////////
1427 // Function: GeomVertexWriter::add_data4
1428 // Access: Published
1429 // Description: Sets the write row to a particular 4-component
1430 // value, and advances the write row.
1431 //
1432 // If the write row advances past the end of data,
1433 // implicitly adds a new row to the data.
1434 ////////////////////////////////////////////////////////////////////
1435 INLINE void GeomVertexWriter::
1436 add_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w) {
1437 #ifndef STDFLOAT_DOUBLE
1438  add_data4f(x, y, z, w);
1439 #else
1440  add_data4d(x, y, z, w);
1441 #endif
1442 }
1443 
1444 ////////////////////////////////////////////////////////////////////
1445 // Function: GeomVertexWriter::add_data4
1446 // Access: Published
1447 // Description: Sets the write row to a particular 4-component
1448 // value, and advances the write row.
1449 //
1450 // If the write row advances past the end of data,
1451 // implicitly adds a new row to the data.
1452 ////////////////////////////////////////////////////////////////////
1453 INLINE void GeomVertexWriter::
1454 add_data4(const LVecBase4 &data) {
1455 #ifndef STDFLOAT_DOUBLE
1456  add_data4f(data);
1457 #else
1458  add_data4d(data);
1459 #endif
1460 }
1461 
1462 ////////////////////////////////////////////////////////////////////
1463 // Function: GeomVertexWriter::add_matrix3
1464 // Access: Published
1465 // Description: Sets the write row to a 3-by-3 matrix, and advances
1466 // the write row. This is a special method that can
1467 // only be used on matrix columns.
1468 //
1469 // If the write row advances past the end of data,
1470 // implicitly adds a new row to the data.
1471 ////////////////////////////////////////////////////////////////////
1472 INLINE void GeomVertexWriter::
1473 add_matrix3(const LMatrix3 &mat) {
1474 #ifndef STDFLOAT_DOUBLE
1475  add_matrix3f(mat);
1476 #else
1477  add_matrix3d(mat);
1478 #endif
1479 }
1480 
1481 ////////////////////////////////////////////////////////////////////
1482 // Function: GeomVertexWriter::add_matrix4
1483 // Access: Published
1484 // Description: Sets the write row to a 4-by-4 matrix, and advances
1485 // the write row. This is a special method that can
1486 // only be used on matrix columns.
1487 //
1488 // If the write row advances past the end of data,
1489 // implicitly adds a new row to the data.
1490 ////////////////////////////////////////////////////////////////////
1491 INLINE void GeomVertexWriter::
1492 add_matrix4(const LMatrix4 &mat) {
1493 #ifndef STDFLOAT_DOUBLE
1494  add_matrix4f(mat);
1495 #else
1496  add_matrix4d(mat);
1497 #endif
1498 }
1499 
1500 ////////////////////////////////////////////////////////////////////
1501 // Function: GeomVertexWriter::add_data1i
1502 // Access: Published
1503 // Description: Sets the write row to a particular 1-component
1504 // value, and advances the write row.
1505 //
1506 // If the write row advances past the end of data,
1507 // implicitly adds a new row to the data.
1508 ////////////////////////////////////////////////////////////////////
1509 INLINE void GeomVertexWriter::
1510 add_data1i(int data) {
1511  nassertv(has_column());
1512  _packer->set_data1i(inc_add_pointer(), data);
1513 }
1514 
1515 ////////////////////////////////////////////////////////////////////
1516 // Function: GeomVertexWriter::add_data2i
1517 // Access: Published
1518 // Description: Sets the write row to a particular 2-component
1519 // value, and advances the write row.
1520 //
1521 // If the write row advances past the end of data,
1522 // implicitly adds a new row to the data.
1523 ////////////////////////////////////////////////////////////////////
1524 INLINE void GeomVertexWriter::
1525 add_data2i(int a, int b) {
1526  add_data2i(LVecBase2i(a, b));
1527 }
1528 
1529 ////////////////////////////////////////////////////////////////////
1530 // Function: GeomVertexWriter::add_data2i
1531 // Access: Published
1532 // Description: Sets the write row to a particular 2-component
1533 // value, and advances the write row.
1534 //
1535 // If the write row advances past the end of data,
1536 // implicitly adds a new row to the data.
1537 ////////////////////////////////////////////////////////////////////
1538 INLINE void GeomVertexWriter::
1539 add_data2i(const int data[2]) {
1540  add_data2i(LVecBase2i(data[0], data[1]));
1541 }
1542 
1543 ////////////////////////////////////////////////////////////////////
1544 // Function: GeomVertexWriter::add_data2i
1545 // Access: Published
1546 // Description: Sets the write row to a particular 2-component
1547 // value, and advances the write row.
1548 //
1549 // If the write row advances past the end of data,
1550 // implicitly adds a new row to the data.
1551 ////////////////////////////////////////////////////////////////////
1552 INLINE void GeomVertexWriter::
1553 add_data2i(const LVecBase2i &data) {
1554  nassertv(has_column());
1555  _packer->set_data2i(inc_add_pointer(), data);
1556 }
1557 
1558 ////////////////////////////////////////////////////////////////////
1559 // Function: GeomVertexWriter::add_data3i
1560 // Access: Published
1561 // Description: Sets the write row to a particular 3-component
1562 // value, and advances the write row.
1563 //
1564 // If the write row advances past the end of data,
1565 // implicitly adds a new row to the data.
1566 ////////////////////////////////////////////////////////////////////
1567 INLINE void GeomVertexWriter::
1568 add_data3i(int a, int b, int c) {
1569  add_data3i(LVecBase3i(a, b, c));
1570 }
1571 
1572 ////////////////////////////////////////////////////////////////////
1573 // Function: GeomVertexWriter::add_data3i
1574 // Access: Published
1575 // Description: Sets the write row to a particular 3-component
1576 // value, and advances the write row.
1577 //
1578 // If the write row advances past the end of data,
1579 // implicitly adds a new row to the data.
1580 ////////////////////////////////////////////////////////////////////
1581 INLINE void GeomVertexWriter::
1582 add_data3i(const int data[3]) {
1583  add_data3i(LVecBase3i(data[0], data[1], data[2]));
1584 }
1585 
1586 ////////////////////////////////////////////////////////////////////
1587 // Function: GeomVertexWriter::add_data3i
1588 // Access: Published
1589 // Description: Sets the write row to a particular 3-component
1590 // value, and advances the write row.
1591 //
1592 // If the write row advances past the end of data,
1593 // implicitly adds a new row to the data.
1594 ////////////////////////////////////////////////////////////////////
1595 INLINE void GeomVertexWriter::
1596 add_data3i(const LVecBase3i &data) {
1597  nassertv(has_column());
1598  _packer->set_data3i(inc_add_pointer(), data);
1599 }
1600 
1601 ////////////////////////////////////////////////////////////////////
1602 // Function: GeomVertexWriter::add_data4i
1603 // Access: Published
1604 // Description: Sets the write row to a particular 4-component
1605 // value, and advances the write row.
1606 //
1607 // If the write row advances past the end of data,
1608 // implicitly adds a new row to the data.
1609 ////////////////////////////////////////////////////////////////////
1610 INLINE void GeomVertexWriter::
1611 add_data4i(int a, int b, int c, int d) {
1612  add_data4i(LVecBase4i(a, b, c, d));
1613 }
1614 
1615 ////////////////////////////////////////////////////////////////////
1616 // Function: GeomVertexWriter::add_data4i
1617 // Access: Published
1618 // Description: Sets the write row to a particular 4-component
1619 // value, and advances the write row.
1620 //
1621 // If the write row advances past the end of data,
1622 // implicitly adds a new row to the data.
1623 ////////////////////////////////////////////////////////////////////
1624 INLINE void GeomVertexWriter::
1625 add_data4i(const int data[4]) {
1626  add_data4i(LVecBase4i(data[0], data[1], data[2], data[3]));
1627 }
1628 
1629 ////////////////////////////////////////////////////////////////////
1630 // Function: GeomVertexWriter::add_data4i
1631 // Access: Published
1632 // Description: Sets the write row to a particular 4-component
1633 // value, and advances the write row.
1634 //
1635 // If the write row advances past the end of data,
1636 // implicitly adds a new row to the data.
1637 ////////////////////////////////////////////////////////////////////
1638 INLINE void GeomVertexWriter::
1639 add_data4i(const LVecBase4i &data) {
1640  nassertv(has_column());
1641  _packer->set_data4i(inc_add_pointer(), data);
1642 }
1643 
1644 ////////////////////////////////////////////////////////////////////
1645 // Function: GeomVertexWriter::get_packer
1646 // Access: Protected
1647 // Description: Returns the writer's Packer object.
1648 ////////////////////////////////////////////////////////////////////
1649 INLINE GeomVertexColumn::Packer *GeomVertexWriter::
1650 get_packer() const {
1651  return _packer;
1652 }
1653 
1654 ////////////////////////////////////////////////////////////////////
1655 // Function: GeomVertexWriter::set_pointer
1656 // Access: Private
1657 // Description: Sets up the array pointers freshly from the source
1658 // object (in case they have been reallocated recently),
1659 // and sets the internal pointer to the indicated row.
1660 ////////////////////////////////////////////////////////////////////
1661 INLINE void GeomVertexWriter::
1662 set_pointer(int row) {
1663  _pointer_begin = _handle->get_write_pointer();
1664  _pointer_end = _pointer_begin + _handle->get_data_size_bytes();
1665  quick_set_pointer(row);
1666 }
1667 
1668 ////////////////////////////////////////////////////////////////////
1669 // Function: GeomVertexWriter::quick_set_pointer
1670 // Access: Private
1671 // Description: Sets up the internal pointer to the indicated row,
1672 // without first verifying that arrays haven't been
1673 // reallocated.
1674 ////////////////////////////////////////////////////////////////////
1675 INLINE void GeomVertexWriter::
1676 quick_set_pointer(int row) {
1677  nassertv(has_column());
1678 
1679 #if defined(_DEBUG)
1680  // Make sure we still have the same pointer as stored in the array.
1681  nassertv(_pointer_begin == _handle->get_write_pointer());
1682 #endif
1683 
1684  _pointer = _pointer_begin + _packer->_column->get_start() + _stride * row;
1685 
1686 #if defined(_DEBUG)
1687  // We have to allow the pointer to exceed the end by up to one row's
1688  // width, because the next call might be to add_data_*().
1689  nassertv(_pointer_begin == _pointer_end || (_pointer - _packer->_column->get_start()) <= _pointer_end);
1690 #endif
1691 }
1692 
1693 ////////////////////////////////////////////////////////////////////
1694 // Function: GeomVertexWriter::inc_pointer
1695 // Access: Private
1696 // Description: Increments to the next row, and returns the data
1697 // pointer as it was before incrementing.
1698 ////////////////////////////////////////////////////////////////////
1699 INLINE unsigned char *GeomVertexWriter::
1700 inc_pointer() {
1701 #if defined(_DEBUG)
1702  nassertr(_pointer < _pointer_end, empty_buffer);
1703  // Make sure we still have the same pointer as stored in the array.
1704  nassertr(_pointer_begin == _handle->get_write_pointer(), empty_buffer);
1705  nassertr(_pointer < _pointer_begin + _handle->get_data_size_bytes(), empty_buffer);
1706 #endif
1707 
1708  unsigned char *orig_pointer = _pointer;
1709  _pointer += _stride;
1710  return orig_pointer;
1711 }
1712 
1713 ////////////////////////////////////////////////////////////////////
1714 // Function: GeomVertexWriter::inc_add_pointer
1715 // Access: Private
1716 // Description: Increments to the next row, and returns the data
1717 // pointer as it was before incrementing. If we are at
1718 // or past the end of data, implicitly adds more
1719 // rows first.
1720 ////////////////////////////////////////////////////////////////////
1721 INLINE unsigned char *GeomVertexWriter::
1722 inc_add_pointer() {
1723  if (_pointer >= _pointer_end) {
1724  // Reset the data pointer.
1725  int write_row = get_write_row();
1726 
1727  if (_vertex_data != (GeomVertexData *)NULL) {
1728  // If we have a whole GeomVertexData, we must set the length of
1729  // all its arrays at once.
1730  _handle = NULL;
1731  GeomVertexDataPipelineWriter writer(_vertex_data, true, _current_thread);
1732  writer.check_array_writers();
1733  writer.set_num_rows(max(write_row + 1, writer.get_num_rows()));
1734  _handle = writer.get_array_writer(_array);
1735 
1736  } else {
1737  // Otherwise, we can get away with modifying only the one array
1738  // we're using.
1739  _handle->set_num_rows(max(write_row + 1, _handle->get_num_rows()));
1740  }
1741 
1742  set_pointer(write_row);
1743  }
1744  return inc_pointer();
1745 }
1746 
void add_data4f(float x, float y, float z, float w)
Sets the write row to a particular 4-component value, and advances the write row. ...
void add_data1d(double data)
Sets the write row to a particular 1-component value, and advances the write row. ...
This object provides a high-level interface for quickly writing a sequence of numeric values from a v...
void set_matrix3f(const LMatrix3f &mat)
Sets the write row to a 3-by-3 matrix, and advances the write row.
void set_data2i(int a, int b)
Sets the write row to a particular 2-component value, and advances the write row. ...
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
void set_matrix4f(const LMatrix4f &mat)
Sets the write row to a 4-by-4 matrix, and advances the write row.
This is a const pointer to an InternalName, and should be used in lieu of a CPT(InternalName) in func...
Definition: internalName.h:197
void add_data2i(int a, int b)
Sets the write row to a particular 2-component value, and advances the write row. ...
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:4716
void set_data3i(int a, int b, int c)
Sets the write row to a particular 3-component value, and advances the write row. ...
void add_data1i(int data)
Sets the write row to a particular 1-component value, and advances the write row. ...
void set_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Sets the write row to a particular 3-component value, and advances the write row. ...
void add_data2f(float x, float y)
Sets the write row to a particular 2-component value, and advances the write row. ...
LVecBase3d get_row(int row) const
Returns the indicated row of the matrix as a three-component vector.
Definition: lmatrix.h:7289
void set_data4i(int a, int b, int c, int d)
Sets the write row to a particular 4-component value, and advances the write row. ...
This is the base class for all two-component vectors and points.
Definition: lvecBase2.h:1257
void clear()
Resets the GeomVertexWriter to the initial state.
int get_array() const
Returns the array index containing the data type that the writer is working on.
void add_data2(PN_stdfloat x, PN_stdfloat y)
Sets the write row to a particular 2-component value, and advances the write row. ...
This is the base class for all two-component vectors and points.
Definition: lvecBase2.h:2360
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:1677
void set_data1i(int data)
Sets the write row to a particular 1-component value, and advances the write row. ...
void set_matrix3(const LMatrix3 &mat)
Sets the write row to a 3-by-3 matrix, and advances the write row.
void add_data3i(int a, int b, int c)
Sets the write row to a particular 3-component value, and advances the write row. ...
This data object is returned by GeomVertexArrayData::get_handle() or modify_handle().
void add_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w)
Sets the write row to a particular 4-component value, and advances the write row. ...
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:3194
void set_data2d(double x, double y)
Sets the write row to a particular 2-component value, and advances the write row. ...
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...
void add_data2d(double x, double y)
Sets the write row to a particular 2-component value, and advances the write row. ...
void set_data2(PN_stdfloat x, PN_stdfloat y)
Sets the write row to a particular 2-component value, and advances the write row. ...
void add_data1f(float data)
Sets the write row to a particular 1-component value, and advances the write row. ...
GeomVertexArrayDataHandle * get_array_handle() const
Returns the write handle to the array object that the writer is currently processing.
void set_data3f(float x, float y, float z)
Sets the write row to a particular 3-component value, and advances the write row. ...
bool is_at_end() const
Returns true if the writer is currently at the end of the list of vertices, false otherwise...
void set_data3d(double x, double y, double z)
Sets the write row to a particular 3-component value, and advances the write row. ...
This is a 3-by-3 transform matrix.
Definition: lmatrix.h:4375
void set_data1f(float data)
Sets the write row to a particular 1-component value, and advances the write row. ...
void set_data4d(double x, double y, double z, double w)
Sets the write row to a particular 4-component value, and advances the write row. ...
void add_data4d(double x, double y, double z, double w)
Sets the write row to a particular 4-component value, and advances the write row. ...
void set_data4f(float x, float y, float z, float w)
Sets the write row to a particular 4-component value, and advances the write row. ...
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
size_t get_stride() const
Returns the per-row stride (bytes between consecutive rows) of the underlying vertex array...
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
void set_data1(PN_stdfloat data)
Sets the write row to a particular 1-component value, and advances the write row. ...
void add_data3(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z)
Sets the write row to a particular 3-component value, and advances the write row. ...
void set_data4(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z, PN_stdfloat w)
Sets the write row to a particular 4-component value, and advances the write row. ...
This is the base class for all two-component vectors and points.
Definition: lvecBase2.h:105
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:1471
void add_matrix4(const LMatrix4 &mat)
Sets the write row to a 4-by-4 matrix, and advances the write row.
void add_data3d(double x, double y, double z)
Sets the write row to a particular 3-component value, and advances the write row. ...
LVecBase3f get_row(int row) const
Returns the indicated row of the matrix as a three-component vector.
Definition: lmatrix.h:3024
void add_matrix4f(const LMatrix4f &mat)
Sets the write row to a 4-by-4 matrix, and advances the write row.
void add_data3f(float x, float y, float z)
Sets the write row to a particular 3-component value, and advances the write row. ...
void add_matrix3(const LMatrix3 &mat)
Sets the write row to a 3-by-3 matrix, and advances the write row.
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:2788
void add_data1(PN_stdfloat data)
Sets the write row to a particular 1-component value, and advances the write row. ...
void add_matrix3d(const LMatrix3d &mat)
Sets the write row to a 3-by-3 matrix, and advances the write row.
bool has_column() const
Returns true if a valid data type has been successfully set, or false if the data type does not exist...
void set_matrix3d(const LMatrix3d &mat)
Sets the write row to a 3-by-3 matrix, and advances the write row.
A thread; that is, a lightweight process.
Definition: thread.h:51
Thread * get_current_thread() const
Returns the Thread pointer of the currently-executing thread, as passed to the constructor of this ob...
LVecBase4f get_row(int row) const
Retrieves the indicated row of the matrix as a 4-component vector.
Definition: lmatrix.h:1258
void set_matrix4(const LMatrix4 &mat)
Sets the write row to a 4-by-4 matrix, and advances the write row.
void set_matrix4d(const LMatrix4d &mat)
Sets the write row to a 4-by-4 matrix, and advances the write row.
GeomVertexArrayData * get_array_data() const
Returns the particular array object that the writer is currently processing.
void set_data2f(float x, float y)
Sets the write row to a particular 2-component value, and advances the write row. ...
LVecBase4d get_row(int row) const
Retrieves the indicated row of the matrix as a 4-component vector.
Definition: lmatrix.h:5523
void add_matrix3f(const LMatrix3f &mat)
Sets the write row to a 3-by-3 matrix, and advances the write row.
bool set_column(int column)
Sets up the writer to use the nth data type of the GeomVertexFormat, numbering from 0...
void set_row(int row)
Sets the start row to the indicated value.
GeomVertexData * get_vertex_data() const
Returns the vertex data object that the writer is processing.
This is a 3-by-3 transform matrix.
Definition: lmatrix.h:110
void add_matrix4d(const LMatrix4d &mat)
Sets the write row to a 4-by-4 matrix, and advances the write row.
void set_data1d(double data)
Sets the write row to a particular 1-component value, and advances the write row. ...
GeomVertexWriter(Thread *current_thread=Thread::get_current_thread())
Constructs an invalid GeomVertexWriter.
int get_write_row() const
Returns the row index to which the data will be written at the next call to set_data*() or add_data*(...
int get_start_row() const
Returns the row index at which the writer started.
This is the data for one array of a GeomVertexData structure.
void set_row_unsafe(int row)
Sets the start row to the indicated value, without internal checks.
const GeomVertexColumn * get_column() const
Returns the description of the data type that the writer is working on.
void add_data4i(int a, int b, int c, int d)
Sets the write row to a particular 4-component value, and advances the write row. ...