Panda3D
geomVertexColumn.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file geomVertexColumn.cxx
10  * @author drose
11  * @date 2005-03-06
12  */
13 
14 #include "geomVertexColumn.h"
15 #include "geomVertexData.h"
16 #include "bamReader.h"
17 #include "bamWriter.h"
18 
19 using std::max;
20 using std::min;
21 
22 /**
23  *
24  */
25 void GeomVertexColumn::
26 operator = (const GeomVertexColumn &copy) {
27  _name = copy._name;
28  _num_components = copy._num_components;
29  _numeric_type = copy._numeric_type;
30  _contents = copy._contents;
31  _start = copy._start;
32  _column_alignment = copy._column_alignment;
33  _num_elements = copy._num_elements;
34  _element_stride = copy._element_stride;
35 
36  setup();
37 }
38 
39 /**
40  * Replaces the name of an existing column. This is only legal on an
41  * unregistered format (i.e. when constructing the format initially).
42  */
45  _name = name;
46  setup();
47 }
48 
49 /**
50  * Changes the number of components of an existing column. This is only legal
51  * on an unregistered format (i.e. when constructing the format initially).
52  */
54 set_num_components(int num_components) {
55  _num_components = num_components;
56  setup();
57 }
58 
59 /**
60  * Changes the numeric type an existing column. This is only legal on an
61  * unregistered format (i.e. when constructing the format initially).
62  */
64 set_numeric_type(NumericType numeric_type) {
65  _numeric_type = numeric_type;
66  setup();
67 }
68 
69 /**
70  * Changes the semantic meaning of an existing column. This is only legal on
71  * an unregistered format (i.e. when constructing the format initially).
72  */
74 set_contents(Contents contents) {
75  _contents = contents;
76  setup();
77 }
78 
79 /**
80  * Changes the start byte of an existing column. This is only legal on an
81  * unregistered format (i.e. when constructing the format initially).
82  */
84 set_start(int start) {
85  _start = start;
86  setup();
87 }
88 
89 /**
90  * Changes the column alignment of an existing column. This is only legal on
91  * an unregistered format (i.e. when constructing the format initially).
92  */
94 set_column_alignment(int column_alignment) {
95  _column_alignment = column_alignment;
96  setup();
97 }
98 
99 /**
100  *
101  */
102 void GeomVertexColumn::
103 output(std::ostream &out) const {
104  out << *get_name() << "(" << get_num_components();
105  switch (get_numeric_type()) {
106  case NT_uint8:
107  case NT_int8:
108  out << "b";
109  break;
110 
111  case NT_uint16:
112  case NT_int16:
113  out << "s";
114  break;
115 
116  case NT_uint32:
117  case NT_int32:
118  out << "l";
119  break;
120 
121  case NT_packed_dcba:
122  out << "p-";
123  break;
124 
125  case NT_packed_dabc:
126  out << "p";
127  break;
128 
129  case NT_float32:
130  out << "f";
131  break;
132 
133  case NT_float64:
134  out << "d";
135  break;
136 
137  case NT_stdfloat:
138  case NT_packed_ufloat:
139  out << "?";
140  break;
141  }
142 
143  out << ")";
144 
145  if (_num_elements > 1) {
146  out << "[" << _num_elements << "]";
147  }
148 }
149 
150 /**
151  * Called once at construction time (or at bam-reading time) to initialize the
152  * internal dependent values.
153  */
154 void GeomVertexColumn::
155 setup() {
156  nassertv(_num_components > 0 && _start >= 0);
157 
158  _num_values = _num_components;
159 
160  if (_numeric_type == NT_stdfloat) {
161  if (vertices_float64) {
162  _numeric_type = NT_float64;
163  } else {
164  _numeric_type = NT_float32;
165  }
166  }
167 
168  switch (_numeric_type) {
169  case NT_uint16:
170  case NT_int16:
171  _component_bytes = 2; // sizeof(uint16_t)
172  break;
173 
174  case NT_uint32:
175  case NT_int32:
176  _component_bytes = 4; // sizeof(uint32_t)
177  break;
178 
179  case NT_uint8:
180  case NT_int8:
181  _component_bytes = 1;
182  break;
183 
184  case NT_packed_dcba:
185  case NT_packed_dabc:
186  _component_bytes = 4; // sizeof(uint32_t)
187  _num_values *= 4;
188  break;
189 
190  case NT_float32:
191  _component_bytes = 4; // sizeof(PN_float32)
192  break;
193 
194  case NT_float64:
195  _component_bytes = 8; // sizeof(PN_float64)
196  break;
197 
198  case NT_stdfloat:
199  nassertv(false);
200  break;
201 
202  case NT_packed_ufloat:
203  _component_bytes = 4; // sizeof(uint32_t)
204  _num_values *= 3;
205  break;
206  }
207 
208  if (_num_elements == 0) {
209  // Matrices are assumed to be square.
210  if (_contents == C_matrix) {
211  _num_elements = _num_components;
212  } else {
213  _num_elements = 1;
214  }
215  }
216 
217  if (_column_alignment < 1) {
218  // The default column alignment is to align to the individual numeric
219  // components, or to vertex_column_alignment, whichever is greater.
220  _column_alignment = max(_component_bytes, (int)vertex_column_alignment);
221  }
222 
223  // Enforce the column alignment requirements on the _start byte.
224  _start = ((_start + _column_alignment - 1) / _column_alignment) * _column_alignment;
225 
226  if (_element_stride < 1) {
227  _element_stride = _component_bytes * _num_components;
228  }
229  _total_bytes = _element_stride * _num_elements;
230 
231  if (_packer != nullptr) {
232  delete _packer;
233  }
234 
235  _packer = make_packer();
236  _packer->_column = this;
237 }
238 
239 /**
240  * Returns a newly-allocated Packer object suitable for packing and unpacking
241  * this column. The _column member of the packer is not filled in.
242  */
243 GeomVertexColumn::Packer *GeomVertexColumn::
244 make_packer() const {
245  switch (get_contents()) {
246  case C_point:
247  case C_clip_point:
248  case C_texcoord:
249  // These types are read as a 4-d homogeneous point.
250  switch (get_numeric_type()) {
251  case NT_float32:
252  if (sizeof(float) == sizeof(PN_float32)) {
253  // Use the native float type implementation for a tiny bit more
254  // optimization.
255  switch (get_num_components()) {
256  case 2:
257  return new Packer_point_nativefloat_2;
258  case 3:
259  return new Packer_point_nativefloat_3;
260  case 4:
261  return new Packer_point_nativefloat_4;
262  }
263  } else {
264  switch (get_num_components()) {
265  case 2:
266  return new Packer_point_float32_2;
267  case 3:
268  return new Packer_point_float32_3;
269  case 4:
270  return new Packer_point_float32_4;
271  }
272  }
273  break;
274  case NT_float64:
275  if (sizeof(double) == sizeof(PN_float64)) {
276  // Use the native float type implementation for a tiny bit more
277  // optimization.
278  switch (get_num_components()) {
279  case 2:
280  return new Packer_point_nativedouble_2;
281  case 3:
282  return new Packer_point_nativedouble_3;
283  case 4:
284  return new Packer_point_nativedouble_4;
285  }
286  } else {
287  switch (get_num_components()) {
288  case 2:
289  return new Packer_point_float64_2;
290  case 3:
291  return new Packer_point_float64_3;
292  case 4:
293  return new Packer_point_float64_4;
294  }
295  }
296  break;
297  default:
298  break;
299  }
300  return new Packer_point;
301 
302  case C_color:
303  if (get_num_values() == 4) {
304  switch (get_numeric_type()) {
305  case NT_uint8:
306  return new Packer_rgba_uint8_4;
307 
308  case NT_packed_dabc:
309  return new Packer_argb_packed;
310 
311  case NT_float32:
312  if (sizeof(float) == sizeof(PN_float32)) {
313  // Use the native float type implementation for a tiny bit more
314  // optimization.
315  return new Packer_rgba_nativefloat_4;
316  } else {
317  return new Packer_rgba_float32_4;
318  }
319 
320  default:
321  break;
322  }
323  } else if (get_num_values() != 3) {
324  gobj_cat.error()
325  << "GeomVertexColumn with contents C_color must have 3 or 4 components!\n";
326  }
327  return new Packer_color;
328 
329  case C_normal:
330  if (get_num_values() != 3 && get_num_values() != 4) {
331  gobj_cat.error()
332  << "GeomVertexColumn with contents C_normal must have 3 or 4 components!\n";
333  }
334 
335  default:
336  // Otherwise, we just read it as a generic value.
337  switch (get_numeric_type()) {
338  case NT_float32:
339  switch (get_num_components()) {
340  case 3:
341  if (sizeof(float) == sizeof(PN_float32)) {
342  // Use the native float type implementation for a tiny bit more
343  // optimization.
344  return new Packer_nativefloat_3;
345  } else {
346  return new Packer_float32_3;
347  }
348 
349  default:
350  break;
351  }
352  break;
353  case NT_float64:
354  switch (get_num_components()) {
355  case 3:
356  if (sizeof(double) == sizeof(PN_float64)) {
357  // Use the native float type implementation for a tiny bit more
358  // optimization.
359  return new Packer_nativedouble_3;
360  } else {
361  return new Packer_float64_3;
362  }
363 
364  default:
365  break;
366  }
367  break;
368  default:
369  break;
370  }
371  return new Packer;
372  }
373 }
374 
375 /**
376  * Writes the contents of this object to the datagram for shipping out to a
377  * Bam file.
378  */
381  manager->write_pointer(dg, _name);
382  dg.add_uint8(_num_components);
383  dg.add_uint8(_numeric_type);
384 
385  if (_contents == C_normal && manager->get_file_minor_ver() < 38) {
386  // Panda 1.9 did not have C_normal.
387  dg.add_uint8(C_vector);
388  } else {
389  dg.add_uint8(_contents);
390  }
391 
392  dg.add_uint16(_start);
393 
394  if (manager->get_file_minor_ver() >= 29) {
395  dg.add_uint8(_column_alignment);
396  }
397 }
398 
399 /**
400  * Receives an array of pointers, one for each time manager->read_pointer()
401  * was called in fillin(). Returns the number of pointers processed.
402  */
405  int pi = 0;
406 
407  _name = DCAST(InternalName, p_list[pi++]);
408 
409  // Make sure that old .bam files are corrected to have C_normal normal
410  // columns rather than C_vector.
411  if (manager->get_file_minor_ver() < 38 &&
412  _name == InternalName::get_normal() && _contents == C_vector) {
413  _contents = C_normal;
414  }
415 
416  return pi;
417 }
418 
419 /**
420  * This internal function is called by make_from_bam to read in all of the
421  * relevant data from the BamFile for the new GeomVertexColumn.
422  */
425  manager->read_pointer(scan);
426 
427  _num_components = scan.get_uint8();
428  _numeric_type = (NumericType)scan.get_uint8();
429  _contents = (Contents)scan.get_uint8();
430  _start = scan.get_uint16();
431 
432  _column_alignment = 1;
433  if (manager->get_file_minor_ver() >= 29) {
434  _column_alignment = scan.get_uint8();
435  }
436 
437  _num_elements = 0;
438  _element_stride = 0;
439 
440  setup();
441 }
442 
443 /**
444  *
445  */
446 GeomVertexColumn::Packer::
447 ~Packer() {
448 }
449 
450 /**
451  *
452  */
453 float GeomVertexColumn::Packer::
454 get_data1f(const unsigned char *pointer) {
455  switch (_column->get_numeric_type()) {
456  case NT_uint8:
457  return *(const uint8_t *)pointer;
458 
459  case NT_uint16:
460  return *(const uint16_t *)pointer;
461 
462  case NT_uint32:
463  return *(const uint32_t *)pointer;
464 
465  case NT_packed_dcba:
466  {
467  uint32_t dword = *(const uint32_t *)pointer;
468  return GeomVertexData::unpack_abcd_d(dword);
469  }
470 
471  case NT_packed_dabc:
472  {
473  uint32_t dword = *(const uint32_t *)pointer;
474  return GeomVertexData::unpack_abcd_b(dword);
475  }
476 
477  case NT_float32:
478  return *(const PN_float32 *)pointer;
479 
480  case NT_float64:
481  return *(const PN_float64 *)pointer;
482 
483  case NT_int8:
484  return *(const int8_t *)pointer;
485 
486  case NT_int16:
487  return *(const int16_t *)pointer;
488 
489  case NT_int32:
490  return *(const int32_t *)pointer;
491 
492  case NT_packed_ufloat:
493  {
494  uint32_t dword = *(const uint32_t *)pointer;
495  return GeomVertexData::unpack_ufloat_a(dword);
496  }
497 
498  default:
499  nassertr(false, 0.0f);
500  }
501 
502  return 0.0f;
503 }
504 
505 /**
506  *
507  */
508 const LVecBase2f &GeomVertexColumn::Packer::
509 get_data2f(const unsigned char *pointer) {
510  if (_column->get_num_values() == 1) {
511  _v2.set(get_data1f(pointer), 0.0f);
512  return _v2;
513 
514  } else {
515  switch (_column->get_numeric_type()) {
516  case NT_uint8:
517  {
518  const uint8_t *pi = (const uint8_t *)pointer;
519  _v2.set(pi[0], pi[1]);
520  }
521  return _v2;
522 
523  case NT_uint16:
524  {
525  const uint16_t *pi = (const uint16_t *)pointer;
526  _v2.set(pi[0], pi[1]);
527  }
528  return _v2;
529 
530  case NT_uint32:
531  {
532  const uint32_t *pi = (const uint32_t *)pointer;
533  _v2.set(pi[0], pi[1]);
534  }
535  return _v2;
536 
537  case NT_packed_dcba:
538  {
539  uint32_t dword = *(const uint32_t *)pointer;
540  _v2.set(GeomVertexData::unpack_abcd_d(dword),
542  }
543  return _v2;
544 
545  case NT_packed_dabc:
546  {
547  uint32_t dword = *(const uint32_t *)pointer;
548  _v2.set(GeomVertexData::unpack_abcd_b(dword),
550  }
551  return _v2;
552 
553  case NT_float32:
554  {
555  const PN_float32 *pi = (const PN_float32 *)pointer;
556  _v2.set(pi[0], pi[1]);
557  }
558  return _v2;
559 
560  case NT_float64:
561  {
562  const PN_float64 *pi = (const PN_float64 *)pointer;
563  _v2.set(pi[0], pi[1]);
564  }
565  return _v2;
566 
567  case NT_stdfloat:
568  nassertr(false, _v2);
569  return _v2;
570 
571  case NT_int8:
572  {
573  const int8_t *pi = (const int8_t *)pointer;
574  _v2.set(pi[0], pi[1]);
575  }
576  return _v2;
577 
578  case NT_int16:
579  {
580  const int16_t *pi = (const int16_t *)pointer;
581  _v2.set(pi[0], pi[1]);
582  }
583  return _v2;
584 
585  case NT_int32:
586  {
587  const int32_t *pi = (const int32_t *)pointer;
588  _v2.set(pi[0], pi[1]);
589  }
590  return _v2;
591 
592  case NT_packed_ufloat:
593  nassertr(false, _v2);
594  return _v2;
595  }
596  }
597 
598  return _v2;
599 }
600 
601 /**
602  *
603  */
604 const LVecBase3f &GeomVertexColumn::Packer::
605 get_data3f(const unsigned char *pointer) {
606  switch (_column->get_num_values()) {
607  case 1:
608  _v3.set(get_data1f(pointer), 0.0f, 0.0f);
609  return _v3;
610 
611  case 2:
612  {
613  const LVecBase2f &v2 = get_data2f(pointer);
614  _v3.set(v2[0], v2[1], 0.0f);
615  }
616  return _v3;
617 
618  default:
619  switch (_column->get_numeric_type()) {
620  case NT_uint8:
621  {
622  const uint8_t *pi = (const uint8_t *)pointer;
623  _v3.set(pi[0], pi[1], pi[2]);
624  }
625  return _v3;
626 
627  case NT_uint16:
628  {
629  const uint16_t *pi = (const uint16_t *)pointer;
630  _v3.set(pi[0], pi[1], pi[2]);
631  }
632  return _v3;
633 
634  case NT_uint32:
635  {
636  const uint32_t *pi = (const uint32_t *)pointer;
637  _v3.set(pi[0], pi[1], pi[2]);
638  }
639  return _v3;
640 
641  case NT_packed_dcba:
642  {
643  uint32_t dword = *(const uint32_t *)pointer;
644  _v3.set(GeomVertexData::unpack_abcd_d(dword),
647  }
648  return _v3;
649 
650  case NT_packed_dabc:
651  {
652  uint32_t dword = *(const uint32_t *)pointer;
653  _v3.set(GeomVertexData::unpack_abcd_b(dword),
656  }
657  return _v3;
658 
659  case NT_float32:
660  {
661  const PN_float32 *pi = (const PN_float32 *)pointer;
662  _v3.set(pi[0], pi[1], pi[2]);
663  }
664  return _v3;
665 
666  case NT_float64:
667  {
668  const PN_float64 *pi = (const PN_float64 *)pointer;
669  _v3.set(pi[0], pi[1], pi[2]);
670  }
671  return _v3;
672 
673  case NT_stdfloat:
674  nassertr(false, _v3);
675  return _v3;
676 
677  case NT_int8:
678  {
679  const int8_t *pi = (const int8_t *)pointer;
680  _v3.set(pi[0], pi[1], pi[2]);
681  }
682  return _v3;
683 
684  case NT_int16:
685  {
686  const int16_t *pi = (const int16_t *)pointer;
687  _v3.set(pi[0], pi[1], pi[2]);
688  }
689  return _v3;
690 
691  case NT_int32:
692  {
693  const int32_t *pi = (const int32_t *)pointer;
694  _v3.set(pi[0], pi[1], pi[2]);
695  }
696  return _v3;
697 
698  case NT_packed_ufloat:
699  {
700  uint32_t dword = *(const uint32_t *)pointer;
701  _v3.set(GeomVertexData::unpack_ufloat_a(dword),
704  }
705  return _v3;
706  }
707  }
708 
709  return _v3;
710 }
711 
712 /**
713  *
714  */
715 const LVecBase4f &GeomVertexColumn::Packer::
716 get_data4f(const unsigned char *pointer) {
717  switch (_column->get_num_values()) {
718  case 1:
719  _v4.set(get_data1f(pointer), 0.0f, 0.0f, 0.0f);
720  return _v4;
721 
722  case 2:
723  {
724  const LVecBase2f &v2 = get_data2f(pointer);
725  _v4.set(v2[0], v2[1], 0.0f, 0.0f);
726  }
727  return _v4;
728 
729  case 3:
730  {
731  const LVecBase3f &v3 = get_data3f(pointer);
732  _v4.set(v3[0], v3[1], v3[2], 0.0f);
733  }
734  return _v4;
735 
736  default:
737  switch (_column->get_numeric_type()) {
738  case NT_uint8:
739  {
740  const uint8_t *pi = (const uint8_t *)pointer;
741  _v4.set(pi[0], pi[1], pi[2], pi[3]);
742  }
743  return _v4;
744 
745  case NT_uint16:
746  {
747  const uint16_t *pi = (const uint16_t *)pointer;
748  _v4.set(pi[0], pi[1], pi[2], pi[3]);
749  }
750  return _v4;
751 
752  case NT_uint32:
753  {
754  const uint32_t *pi = (const uint32_t *)pointer;
755  _v4.set(pi[0], pi[1], pi[2], pi[3]);
756  }
757  return _v4;
758 
759  case NT_packed_dcba:
760  {
761  uint32_t dword = *(const uint32_t *)pointer;
762  _v4.set(GeomVertexData::unpack_abcd_d(dword),
766  }
767  return _v4;
768 
769  case NT_packed_dabc:
770  {
771  uint32_t dword = *(const uint32_t *)pointer;
772  _v4.set(GeomVertexData::unpack_abcd_b(dword),
776  }
777  return _v4;
778 
779  case NT_float32:
780  {
781  const PN_float32 *pi = (const PN_float32 *)pointer;
782  _v4.set(pi[0], pi[1], pi[2], pi[3]);
783  }
784  return _v4;
785 
786  case NT_float64:
787  {
788  const PN_float64 *pi = (const PN_float64 *)pointer;
789  _v4.set(pi[0], pi[1], pi[2], pi[3]);
790  }
791  return _v4;
792 
793  case NT_stdfloat:
794  nassertr(false, _v4);
795  break;
796 
797  case NT_int8:
798  {
799  const int8_t *pi = (const int8_t *)pointer;
800  _v4.set(pi[0], pi[1], pi[2], pi[3]);
801  }
802  return _v4;
803 
804  case NT_int16:
805  {
806  const int16_t *pi = (const int16_t *)pointer;
807  _v4.set(pi[0], pi[1], pi[2], pi[3]);
808  }
809  return _v4;
810 
811  case NT_int32:
812  {
813  const int32_t *pi = (const int32_t *)pointer;
814  _v4.set(pi[0], pi[1], pi[2], pi[3]);
815  }
816  return _v4;
817 
818  case NT_packed_ufloat:
819  nassertr(false, _v4);
820  break;
821  }
822  }
823 
824  return _v4;
825 }
826 
827 /**
828  *
829  */
830 double GeomVertexColumn::Packer::
831 get_data1d(const unsigned char *pointer) {
832  switch (_column->get_numeric_type()) {
833  case NT_uint8:
834  return *(const uint8_t *)pointer;
835 
836  case NT_uint16:
837  return *(const uint16_t *)pointer;
838 
839  case NT_uint32:
840  return *(const uint32_t *)pointer;
841 
842  case NT_packed_dcba:
843  {
844  uint32_t dword = *(const uint32_t *)pointer;
845  return GeomVertexData::unpack_abcd_d(dword);
846  }
847 
848  case NT_packed_dabc:
849  {
850  uint32_t dword = *(const uint32_t *)pointer;
851  return GeomVertexData::unpack_abcd_b(dword);
852  }
853 
854  case NT_float32:
855  return *(const PN_float32 *)pointer;
856 
857  case NT_float64:
858  return *(const PN_float64 *)pointer;
859 
860  case NT_stdfloat:
861  nassertr(false, 0.0);
862  return 0.0;
863 
864  case NT_int8:
865  return *(const int8_t *)pointer;
866 
867  case NT_int16:
868  return *(const int16_t *)pointer;
869 
870  case NT_int32:
871  return *(const int32_t *)pointer;
872 
873  case NT_packed_ufloat:
874  {
875  uint32_t dword = *(const uint32_t *)pointer;
876  return GeomVertexData::unpack_ufloat_a(dword);
877  }
878  }
879 
880  return 0.0;
881 }
882 
883 /**
884  *
885  */
886 const LVecBase2d &GeomVertexColumn::Packer::
887 get_data2d(const unsigned char *pointer) {
888  if (_column->get_num_values() == 1) {
889  _v2d.set(get_data1d(pointer), 0.0f);
890  return _v2d;
891 
892  } else {
893  switch (_column->get_numeric_type()) {
894  case NT_uint8:
895  {
896  const uint8_t *pi = (const uint8_t *)pointer;
897  _v2d.set(pi[0], pi[1]);
898  }
899  return _v2d;
900 
901  case NT_uint16:
902  {
903  const uint16_t *pi = (const uint16_t *)pointer;
904  _v2d.set(pi[0], pi[1]);
905  }
906  return _v2d;
907 
908  case NT_uint32:
909  {
910  const uint32_t *pi = (const uint32_t *)pointer;
911  _v2d.set(pi[0], pi[1]);
912  }
913  return _v2d;
914 
915  case NT_packed_dcba:
916  {
917  uint32_t dword = *(const uint32_t *)pointer;
918  _v2d.set(GeomVertexData::unpack_abcd_d(dword),
920  }
921  return _v2d;
922 
923  case NT_packed_dabc:
924  {
925  uint32_t dword = *(const uint32_t *)pointer;
926  _v2d.set(GeomVertexData::unpack_abcd_b(dword),
928  }
929  return _v2d;
930 
931  case NT_float32:
932  {
933  const PN_float32 *pi = (const PN_float32 *)pointer;
934  _v2d.set(pi[0], pi[1]);
935  }
936  return _v2d;
937 
938  case NT_float64:
939  {
940  const PN_float64 *pi = (const PN_float64 *)pointer;
941  _v2d.set(pi[0], pi[1]);
942  }
943  return _v2d;
944 
945  case NT_stdfloat:
946  nassertr(false, _v2d);
947  return _v2d;
948 
949  case NT_int8:
950  {
951  const int8_t *pi = (const int8_t *)pointer;
952  _v2d.set(pi[0], pi[1]);
953  }
954  return _v2d;
955 
956  case NT_int16:
957  {
958  const int16_t *pi = (const int16_t *)pointer;
959  _v2d.set(pi[0], pi[1]);
960  }
961  return _v2d;
962 
963  case NT_int32:
964  {
965  const int32_t *pi = (const int32_t *)pointer;
966  _v2d.set(pi[0], pi[1]);
967  }
968  return _v2d;
969 
970  case NT_packed_ufloat:
971  nassertr(false, _v2d);
972  break;
973  }
974  }
975 
976  return _v2d;
977 }
978 
979 /**
980  *
981  */
982 const LVecBase3d &GeomVertexColumn::Packer::
983 get_data3d(const unsigned char *pointer) {
984  switch (_column->get_num_values()) {
985  case 1:
986  _v3d.set(get_data1d(pointer), 0.0f, 0.0f);
987  return _v3d;
988 
989  case 2:
990  {
991  const LVecBase2d &v2 = get_data2d(pointer);
992  _v3d.set(v2[0], v2[1], 0.0f);
993  }
994  return _v3d;
995 
996  default:
997  switch (_column->get_numeric_type()) {
998  case NT_uint8:
999  {
1000  const uint8_t *pi = (const uint8_t *)pointer;
1001  _v3d.set(pi[0], pi[1], pi[2]);
1002  }
1003  return _v3d;
1004 
1005  case NT_uint16:
1006  {
1007  const uint16_t *pi = (const uint16_t *)pointer;
1008  _v3d.set(pi[0], pi[1], pi[2]);
1009  }
1010  return _v3d;
1011 
1012  case NT_uint32:
1013  {
1014  const uint32_t *pi = (const uint32_t *)pointer;
1015  _v3d.set(pi[0], pi[1], pi[2]);
1016  }
1017  return _v3d;
1018 
1019  case NT_packed_dcba:
1020  {
1021  uint32_t dword = *(const uint32_t *)pointer;
1022  _v3d.set(GeomVertexData::unpack_abcd_d(dword),
1025  }
1026  return _v3d;
1027 
1028  case NT_packed_dabc:
1029  {
1030  uint32_t dword = *(const uint32_t *)pointer;
1031  _v3d.set(GeomVertexData::unpack_abcd_b(dword),
1034  }
1035  return _v3d;
1036 
1037  case NT_float32:
1038  {
1039  const PN_float32 *pi = (const PN_float32 *)pointer;
1040  _v3d.set(pi[0], pi[1], pi[2]);
1041  }
1042  return _v3d;
1043 
1044  case NT_float64:
1045  {
1046  const PN_float64 *pi = (const PN_float64 *)pointer;
1047  _v3d.set(pi[0], pi[1], pi[2]);
1048  }
1049  return _v3d;
1050 
1051  case NT_stdfloat:
1052  nassertr(false, _v3d);
1053  return _v3d;
1054 
1055  case NT_int8:
1056  {
1057  const int8_t *pi = (const int8_t *)pointer;
1058  _v3d.set(pi[0], pi[1], pi[2]);
1059  }
1060  return _v3d;
1061 
1062  case NT_int16:
1063  {
1064  const int16_t *pi = (const int16_t *)pointer;
1065  _v3d.set(pi[0], pi[1], pi[2]);
1066  }
1067  return _v3d;
1068 
1069  case NT_int32:
1070  {
1071  const int32_t *pi = (const int32_t *)pointer;
1072  _v3d.set(pi[0], pi[1], pi[2]);
1073  }
1074  return _v3d;
1075 
1076  case NT_packed_ufloat:
1077  {
1078  uint32_t dword = *(const uint32_t *)pointer;
1079  _v3d.set(GeomVertexData::unpack_ufloat_a(dword),
1082  }
1083  return _v3d;
1084  }
1085  }
1086 
1087  return _v3d;
1088 }
1089 
1090 /**
1091  *
1092  */
1093 const LVecBase4d &GeomVertexColumn::Packer::
1094 get_data4d(const unsigned char *pointer) {
1095  switch (_column->get_num_values()) {
1096  case 1:
1097  _v4d.set(get_data1d(pointer), 0.0f, 0.0f, 0.0f);
1098  return _v4d;
1099 
1100  case 2:
1101  {
1102  const LVecBase2d &v2 = get_data2d(pointer);
1103  _v4d.set(v2[0], v2[1], 0.0f, 0.0f);
1104  }
1105  return _v4d;
1106 
1107  case 3:
1108  {
1109  const LVecBase3d &v3 = get_data3d(pointer);
1110  _v4d.set(v3[0], v3[1], v3[2], 0.0f);
1111  }
1112  return _v4d;
1113 
1114  default:
1115  switch (_column->get_numeric_type()) {
1116  case NT_uint8:
1117  {
1118  const uint8_t *pi = (const uint8_t *)pointer;
1119  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
1120  }
1121  return _v4d;
1122 
1123  case NT_uint16:
1124  {
1125  const uint16_t *pi = (const uint16_t *)pointer;
1126  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
1127  }
1128  return _v4d;
1129 
1130  case NT_uint32:
1131  {
1132  const uint32_t *pi = (const uint32_t *)pointer;
1133  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
1134  }
1135  return _v4d;
1136 
1137  case NT_packed_dcba:
1138  {
1139  uint32_t dword = *(const uint32_t *)pointer;
1140  _v4d.set(GeomVertexData::unpack_abcd_d(dword),
1144  }
1145  return _v4d;
1146 
1147  case NT_packed_dabc:
1148  {
1149  uint32_t dword = *(const uint32_t *)pointer;
1150  _v4d.set(GeomVertexData::unpack_abcd_b(dword),
1154  }
1155  return _v4d;
1156 
1157  case NT_float32:
1158  {
1159  const PN_float32 *pi = (const PN_float32 *)pointer;
1160  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
1161  }
1162  return _v4d;
1163 
1164  case NT_float64:
1165  {
1166  const PN_float64 *pi = (const PN_float64 *)pointer;
1167  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
1168  }
1169  return _v4d;
1170 
1171  case NT_stdfloat:
1172  nassertr(false, _v4d);
1173  break;
1174 
1175  case NT_int8:
1176  {
1177  const int8_t *pi = (const int8_t *)pointer;
1178  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
1179  }
1180  return _v4d;
1181 
1182  case NT_int16:
1183  {
1184  const int16_t *pi = (const int16_t *)pointer;
1185  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
1186  }
1187  return _v4d;
1188 
1189  case NT_int32:
1190  {
1191  const int32_t *pi = (const int32_t *)pointer;
1192  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
1193  }
1194  return _v4d;
1195 
1196  case NT_packed_ufloat:
1197  nassertr(false, _v4d);
1198  break;
1199  }
1200  }
1201 
1202  return _v4d;
1203 }
1204 
1205 /**
1206  *
1207  */
1208 int GeomVertexColumn::Packer::
1209 get_data1i(const unsigned char *pointer) {
1210  switch (_column->get_numeric_type()) {
1211  case NT_uint8:
1212  return *pointer;
1213 
1214  case NT_uint16:
1215  return *(const uint16_t *)pointer;
1216 
1217  case NT_uint32:
1218  return *(const uint32_t *)pointer;
1219 
1220  case NT_packed_dcba:
1221  {
1222  uint32_t dword = *(const uint32_t *)pointer;
1223  return GeomVertexData::unpack_abcd_d(dword);
1224  }
1225 
1226  case NT_packed_dabc:
1227  {
1228  uint32_t dword = *(const uint32_t *)pointer;
1229  return GeomVertexData::unpack_abcd_b(dword);
1230  }
1231 
1232  case NT_float32:
1233  return (int)*(const PN_float32 *)pointer;
1234 
1235  case NT_float64:
1236  return (int)*(const PN_float64 *)pointer;
1237 
1238  case NT_stdfloat:
1239  nassertr(false, 0);
1240  break;
1241 
1242  case NT_int8:
1243  return *(const int8_t *)pointer;
1244 
1245  case NT_int16:
1246  return *(const int16_t *)pointer;
1247 
1248  case NT_int32:
1249  return *(const int32_t *)pointer;
1250 
1251  case NT_packed_ufloat:
1252  {
1253  uint32_t dword = *(const uint32_t *)pointer;
1254  return (int)GeomVertexData::unpack_ufloat_a(dword);
1255  }
1256  }
1257 
1258  return 0;
1259 }
1260 
1261 /**
1262  *
1263  */
1264 const LVecBase2i &GeomVertexColumn::Packer::
1265 get_data2i(const unsigned char *pointer) {
1266  switch (_column->get_num_values()) {
1267  case 1:
1268  _v2i.set(get_data1i(pointer), 0);
1269  return _v2i;
1270 
1271  default:
1272  switch (_column->get_numeric_type()) {
1273  case NT_uint8:
1274  _v2i.set(pointer[0], pointer[1]);
1275  return _v2i;
1276 
1277  case NT_uint16:
1278  {
1279  const uint16_t *pi = (const uint16_t *)pointer;
1280  _v2i.set(pi[0], pi[1]);
1281  }
1282  return _v2i;
1283 
1284  case NT_uint32:
1285  {
1286  const uint32_t *pi = (const uint32_t *)pointer;
1287  _v2i.set(pi[0], pi[1]);
1288  }
1289  return _v2i;
1290 
1291  case NT_packed_dcba:
1292  {
1293  uint32_t dword = *(const uint32_t *)pointer;
1294  _v2i.set(GeomVertexData::unpack_abcd_d(dword),
1296  }
1297  return _v2i;
1298 
1299  case NT_packed_dabc:
1300  {
1301  uint32_t dword = *(const uint32_t *)pointer;
1302  _v2i.set(GeomVertexData::unpack_abcd_b(dword),
1304  }
1305  return _v2i;
1306 
1307  case NT_float32:
1308  {
1309  const PN_float32 *pi = (const PN_float32 *)pointer;
1310  _v2i.set((int)pi[0], (int)pi[1]);
1311  }
1312  return _v2i;
1313 
1314  case NT_float64:
1315  {
1316  const PN_float64 *pi = (const PN_float64 *)pointer;
1317  _v2i.set((int)pi[0], (int)pi[1]);
1318  }
1319  return _v2i;
1320 
1321  case NT_stdfloat:
1322  nassertr(false, _v2i);
1323  break;
1324 
1325  case NT_int8:
1326  {
1327  const int8_t *pi = (const int8_t *)pointer;
1328  _v2i.set(pi[0], pi[1]);
1329  }
1330  return _v2i;
1331 
1332  case NT_int16:
1333  {
1334  const int16_t *pi = (const int16_t *)pointer;
1335  _v2i.set(pi[0], pi[1]);
1336  }
1337  return _v2i;
1338 
1339  case NT_int32:
1340  {
1341  const int32_t *pi = (const int32_t *)pointer;
1342  _v2i.set(pi[0], pi[1]);
1343  }
1344  return _v2i;
1345 
1346  case NT_packed_ufloat:
1347  nassertr(false, _v2i);
1348  break;
1349  }
1350  }
1351 
1352  return _v2i;
1353 }
1354 
1355 /**
1356  *
1357  */
1358 const LVecBase3i &GeomVertexColumn::Packer::
1359 get_data3i(const unsigned char *pointer) {
1360  switch (_column->get_num_values()) {
1361  case 1:
1362  _v3i.set(get_data1i(pointer), 0, 0);
1363  return _v3i;
1364 
1365  case 2:
1366  {
1367  const LVecBase2i &v2 = get_data2i(pointer);
1368  _v3i.set(v2[0], v2[1], 0);
1369  }
1370  return _v3i;
1371 
1372  default:
1373  switch (_column->get_numeric_type()) {
1374  case NT_uint8:
1375  _v3i.set(pointer[0], pointer[1], 0);
1376  return _v3i;
1377 
1378  case NT_uint16:
1379  {
1380  const uint16_t *pi = (const uint16_t *)pointer;
1381  _v3i.set(pi[0], pi[1], pi[2]);
1382  }
1383  return _v3i;
1384 
1385  case NT_uint32:
1386  {
1387  const uint32_t *pi = (const uint32_t *)pointer;
1388  _v3i.set(pi[0], pi[1], pi[2]);
1389  }
1390  return _v3i;
1391 
1392  case NT_packed_dcba:
1393  {
1394  uint32_t dword = *(const uint32_t *)pointer;
1395  _v3i.set(GeomVertexData::unpack_abcd_d(dword),
1398  }
1399  return _v3i;
1400 
1401  case NT_packed_dabc:
1402  {
1403  uint32_t dword = *(const uint32_t *)pointer;
1404  _v3i.set(GeomVertexData::unpack_abcd_b(dword),
1407  }
1408  return _v3i;
1409 
1410  case NT_float32:
1411  {
1412  const PN_float32 *pi = (const PN_float32 *)pointer;
1413  _v3i.set((int)pi[0], (int)pi[1], (int)pi[2]);
1414  }
1415  return _v3i;
1416 
1417  case NT_float64:
1418  {
1419  const PN_float64 *pi = (const PN_float64 *)pointer;
1420  _v3i.set((int)pi[0], (int)pi[1], (int)pi[2]);
1421  }
1422  return _v3i;
1423 
1424  case NT_stdfloat:
1425  nassertr(false, _v3i);
1426  break;
1427 
1428  case NT_int8:
1429  {
1430  const int8_t *pi = (const int8_t *)pointer;
1431  _v3i.set(pi[0], pi[1], pi[2]);
1432  }
1433  return _v3i;
1434 
1435  case NT_int16:
1436  {
1437  const int16_t *pi = (const int16_t *)pointer;
1438  _v3i.set(pi[0], pi[1], pi[2]);
1439  }
1440  return _v3i;
1441 
1442  case NT_int32:
1443  {
1444  const int32_t *pi = (const int32_t *)pointer;
1445  _v3i.set(pi[0], pi[1], pi[2]);
1446  }
1447  return _v3i;
1448 
1449  case NT_packed_ufloat:
1450  {
1451  uint32_t dword = *(const uint32_t *)pointer;
1452  _v3i.set((int)GeomVertexData::unpack_ufloat_a(dword),
1453  (int)GeomVertexData::unpack_ufloat_b(dword),
1454  (int)GeomVertexData::unpack_ufloat_c(dword));
1455  }
1456  return _v3i;
1457  }
1458  }
1459 
1460  return _v3i;
1461 }
1462 
1463 /**
1464  *
1465  */
1466 const LVecBase4i &GeomVertexColumn::Packer::
1467 get_data4i(const unsigned char *pointer) {
1468  switch (_column->get_num_values()) {
1469  case 1:
1470  _v4i.set(get_data1i(pointer), 0, 0, 0);
1471  return _v4i;
1472 
1473  case 2:
1474  {
1475  const LVecBase2i &v2 = get_data2i(pointer);
1476  _v4i.set(v2[0], v2[1], 0, 0);
1477  }
1478  return _v4i;
1479 
1480  case 3:
1481  {
1482  const LVecBase3i &v3 = get_data3i(pointer);
1483  _v4i.set(v3[0], v3[1], v3[2], 0);
1484  }
1485  return _v4i;
1486 
1487  default:
1488  switch (_column->get_numeric_type()) {
1489  case NT_uint8:
1490  _v4i.set(pointer[0], pointer[1], pointer[2], pointer[3]);
1491  return _v4i;
1492 
1493  case NT_uint16:
1494  {
1495  const uint16_t *pi = (const uint16_t *)pointer;
1496  _v4i.set(pi[0], pi[1], pi[2], pi[3]);
1497  }
1498  return _v4i;
1499 
1500  case NT_uint32:
1501  {
1502  const uint32_t *pi = (const uint32_t *)pointer;
1503  _v4i.set(pi[0], pi[1], pi[2], pi[3]);
1504  }
1505  return _v4i;
1506 
1507  case NT_packed_dcba:
1508  {
1509  uint32_t dword = *(const uint32_t *)pointer;
1510  _v4i.set(GeomVertexData::unpack_abcd_d(dword),
1514  }
1515  return _v4i;
1516 
1517  case NT_packed_dabc:
1518  {
1519  uint32_t dword = *(const uint32_t *)pointer;
1520  _v4i.set(GeomVertexData::unpack_abcd_b(dword),
1524  }
1525  return _v4i;
1526 
1527  case NT_float32:
1528  {
1529  const PN_float32 *pi = (const PN_float32 *)pointer;
1530  _v4i.set((int)pi[0], (int)pi[1], (int)pi[2], (int)pi[3]);
1531  }
1532  return _v4i;
1533 
1534  case NT_float64:
1535  {
1536  const PN_float64 *pi = (const PN_float64 *)pointer;
1537  _v4i.set((int)pi[0], (int)pi[1], (int)pi[2], (int)pi[3]);
1538  }
1539  return _v4i;
1540 
1541  case NT_stdfloat:
1542  nassertr(false, _v4i);
1543  break;
1544 
1545  case NT_int8:
1546  {
1547  const int8_t *pi = (const int8_t *)pointer;
1548  _v4i.set(pi[0], pi[1], pi[2], pi[3]);
1549  }
1550  return _v4i;
1551 
1552  case NT_int16:
1553  {
1554  const int16_t *pi = (const int16_t *)pointer;
1555  _v4i.set(pi[0], pi[1], pi[2], pi[3]);
1556  }
1557  return _v4i;
1558 
1559  case NT_int32:
1560  {
1561  const int32_t *pi = (const int32_t *)pointer;
1562  _v4i.set(pi[0], pi[1], pi[2], pi[3]);
1563  }
1564  return _v4i;
1565 
1566  case NT_packed_ufloat:
1567  nassertr(false, _v4i);
1568  break;
1569  }
1570  }
1571 
1572  return _v4i;
1573 }
1574 
1575 /**
1576  *
1577  */
1578 void GeomVertexColumn::Packer::
1579 set_data1f(unsigned char *pointer, float data) {
1580  switch (_column->get_num_values()) {
1581  case 1:
1582  switch (_column->get_numeric_type()) {
1583  case NT_uint8:
1584  *(uint8_t *)pointer = (unsigned int)data;
1585  break;
1586 
1587  case NT_uint16:
1588  *(uint16_t *)pointer = (unsigned int)data;
1589  break;
1590 
1591  case NT_uint32:
1592  *(uint32_t *)pointer = (unsigned int)data;
1593  break;
1594 
1595  case NT_packed_dcba:
1596  case NT_packed_dabc:
1597  nassertv(false);
1598  break;
1599 
1600  case NT_float32:
1601  *(PN_float32 *)pointer = data;
1602  break;
1603 
1604  case NT_float64:
1605  *(PN_float64 *)pointer = data;
1606  break;
1607 
1608  case NT_stdfloat:
1609  nassertv(false);
1610  break;
1611 
1612  case NT_int8:
1613  *(int8_t *)pointer = (int)data;
1614  break;
1615 
1616  case NT_int16:
1617  *(int16_t *)pointer = (int)data;
1618  break;
1619 
1620  case NT_int32:
1621  *(int32_t *)pointer = (int)data;
1622  break;
1623 
1624  case NT_packed_ufloat:
1625  nassertv(false);
1626  break;
1627  }
1628  break;
1629 
1630  case 2:
1631  set_data2f(pointer, LVecBase2f(data, 0.0f));
1632  break;
1633 
1634  case 3:
1635  set_data3f(pointer, LVecBase3f(data, 0.0f, 0.0f));
1636  break;
1637 
1638  case 4:
1639  set_data4f(pointer, LVecBase4f(data, 0.0f, 0.0f, 0.0f));
1640  break;
1641  }
1642 }
1643 
1644 /**
1645  *
1646  */
1647 void GeomVertexColumn::Packer::
1648 set_data2f(unsigned char *pointer, const LVecBase2f &data) {
1649  switch (_column->get_num_values()) {
1650  case 1:
1651  set_data1f(pointer, data[0]);
1652  break;
1653 
1654  case 2:
1655  switch (_column->get_numeric_type()) {
1656  case NT_uint8:
1657  {
1658  uint8_t *pi = (uint8_t *)pointer;
1659  pi[0] = (unsigned int)data[0];
1660  pi[1] = (unsigned int)data[1];
1661  }
1662  break;
1663 
1664  case NT_uint16:
1665  {
1666  uint16_t *pi = (uint16_t *)pointer;
1667  pi[0] = (unsigned int)data[0];
1668  pi[1] = (unsigned int)data[1];
1669  }
1670  break;
1671 
1672  case NT_uint32:
1673  {
1674  uint32_t *pi = (uint32_t *)pointer;
1675  pi[0] = (unsigned int)data[0];
1676  pi[1] = (unsigned int)data[1];
1677  }
1678  break;
1679 
1680  case NT_packed_dcba:
1681  case NT_packed_dabc:
1682  nassertv(false);
1683  break;
1684 
1685  case NT_float32:
1686  {
1687  PN_float32 *pi = (PN_float32 *)pointer;
1688  pi[0] = data[0];
1689  pi[1] = data[1];
1690  }
1691  break;
1692 
1693  case NT_float64:
1694  {
1695  PN_float64 *pi = (PN_float64 *)pointer;
1696  pi[0] = data[0];
1697  pi[1] = data[1];
1698  }
1699  break;
1700 
1701  case NT_stdfloat:
1702  nassertv(false);
1703  break;
1704 
1705  case NT_int8:
1706  {
1707  int8_t *pi = (int8_t *)pointer;
1708  pi[0] = (int)data[0];
1709  pi[1] = (int)data[1];
1710  }
1711  break;
1712 
1713  case NT_int16:
1714  {
1715  int16_t *pi = (int16_t *)pointer;
1716  pi[0] = (int)data[0];
1717  pi[1] = (int)data[1];
1718  }
1719  break;
1720 
1721  case NT_int32:
1722  {
1723  int32_t *pi = (int32_t *)pointer;
1724  pi[0] = (int)data[0];
1725  pi[1] = (int)data[1];
1726  }
1727  break;
1728 
1729  case NT_packed_ufloat:
1730  nassertv(false);
1731  break;
1732  }
1733  break;
1734 
1735  case 3:
1736  set_data3f(pointer, LVecBase3f(data[0], data[1], 0.0f));
1737  break;
1738 
1739  default:
1740  set_data4f(pointer, LVecBase4f(data[0], data[1], 0.0f, 0.0f));
1741  break;
1742  }
1743 }
1744 
1745 /**
1746  *
1747  */
1748 void GeomVertexColumn::Packer::
1749 set_data3f(unsigned char *pointer, const LVecBase3f &data) {
1750  switch (_column->get_num_values()) {
1751  case 1:
1752  set_data1f(pointer, data[0]);
1753  break;
1754 
1755  case 2:
1756  set_data2f(pointer, LVecBase2f(data[0], data[1]));
1757  break;
1758 
1759  case 3:
1760  switch (_column->get_numeric_type()) {
1761  case NT_uint8:
1762  {
1763  uint8_t *pi = (uint8_t *)pointer;
1764  pi[0] = (unsigned int)data[0];
1765  pi[1] = (unsigned int)data[1];
1766  pi[2] = (unsigned int)data[2];
1767  }
1768  break;
1769 
1770  case NT_uint16:
1771  {
1772  uint16_t *pi = (uint16_t *)pointer;
1773  pi[0] = (unsigned int)data[0];
1774  pi[1] = (unsigned int)data[1];
1775  pi[2] = (unsigned int)data[2];
1776  }
1777  break;
1778 
1779  case NT_uint32:
1780  {
1781  uint32_t *pi = (uint32_t *)pointer;
1782  pi[0] = (unsigned int)data[0];
1783  pi[1] = (unsigned int)data[1];
1784  pi[2] = (unsigned int)data[2];
1785  }
1786  break;
1787 
1788  case NT_packed_dcba:
1789  case NT_packed_dabc:
1790  nassertv(false);
1791  break;
1792 
1793  case NT_float32:
1794  {
1795  PN_float32 *pi = (PN_float32 *)pointer;
1796  pi[0] = data[0];
1797  pi[1] = data[1];
1798  pi[2] = data[2];
1799  }
1800  break;
1801 
1802  case NT_float64:
1803  {
1804  PN_float64 *pi = (PN_float64 *)pointer;
1805  pi[0] = data[0];
1806  pi[1] = data[1];
1807  pi[2] = data[2];
1808  }
1809  break;
1810 
1811  case NT_stdfloat:
1812  nassertv(false);
1813  break;
1814 
1815  case NT_int8:
1816  {
1817  int8_t *pi = (int8_t *)pointer;
1818  pi[0] = (int)data[0];
1819  pi[1] = (int)data[1];
1820  pi[2] = (int)data[2];
1821  }
1822  break;
1823 
1824  case NT_int16:
1825  {
1826  int16_t *pi = (int16_t *)pointer;
1827  pi[0] = (int)data[0];
1828  pi[1] = (int)data[1];
1829  pi[2] = (int)data[2];
1830  }
1831  break;
1832 
1833  case NT_int32:
1834  {
1835  int32_t *pi = (int32_t *)pointer;
1836  pi[0] = (int)data[0];
1837  pi[1] = (int)data[1];
1838  pi[2] = (int)data[2];
1839  }
1840  break;
1841 
1842  case NT_packed_ufloat:
1843  *(uint32_t *)pointer = GeomVertexData::pack_ufloat(data[0], data[1], data[2]);
1844  break;
1845  }
1846  break;
1847 
1848  default:
1849  set_data4f(pointer, LVecBase4f(data[0], data[1], data[2], 0.0f));
1850  break;
1851  }
1852 }
1853 
1854 /**
1855  *
1856  */
1857 void GeomVertexColumn::Packer::
1858 set_data4f(unsigned char *pointer, const LVecBase4f &data) {
1859  switch (_column->get_num_values()) {
1860  case 1:
1861  set_data1f(pointer, data[0]);
1862  break;
1863 
1864  case 2:
1865  set_data2f(pointer, LVecBase2f(data[0], data[1]));
1866  break;
1867 
1868  case 3:
1869  set_data3f(pointer, LVecBase3f(data[0], data[1], data[2]));
1870  break;
1871 
1872  default:
1873  switch (_column->get_numeric_type()) {
1874  case NT_uint8:
1875  {
1876  uint8_t *pi = (uint8_t *)pointer;
1877  pi[0] = (unsigned int)data[0];
1878  pi[1] = (unsigned int)data[1];
1879  pi[2] = (unsigned int)data[2];
1880  pi[3] = (unsigned int)data[3];
1881  }
1882  break;
1883 
1884  case NT_uint16:
1885  {
1886  uint16_t *pi = (uint16_t *)pointer;
1887  pi[0] = (unsigned int)data[0];
1888  pi[1] = (unsigned int)data[1];
1889  pi[2] = (unsigned int)data[2];
1890  pi[3] = (unsigned int)data[3];
1891  }
1892  break;
1893 
1894  case NT_uint32:
1895  {
1896  uint32_t *pi = (uint32_t *)pointer;
1897  pi[0] = (unsigned int)data[0];
1898  pi[1] = (unsigned int)data[1];
1899  pi[2] = (unsigned int)data[2];
1900  pi[3] = (unsigned int)data[3];
1901  }
1902  break;
1903 
1904  case NT_packed_dcba:
1905  *(uint32_t *)pointer = GeomVertexData::pack_abcd(data[3], data[2], data[1], data[0]);
1906  break;
1907 
1908  case NT_packed_dabc:
1909  *(uint32_t *)pointer = GeomVertexData::pack_abcd(data[3], data[0], data[1], data[2]);
1910  break;
1911 
1912  case NT_float32:
1913  {
1914  PN_float32 *pi = (PN_float32 *)pointer;
1915  pi[0] = data[0];
1916  pi[1] = data[1];
1917  pi[2] = data[2];
1918  pi[3] = data[3];
1919  }
1920  break;
1921 
1922  case NT_float64:
1923  {
1924  PN_float64 *pi = (PN_float64 *)pointer;
1925  pi[0] = data[0];
1926  pi[1] = data[1];
1927  pi[2] = data[2];
1928  pi[3] = data[3];
1929  }
1930  break;
1931 
1932  case NT_stdfloat:
1933  nassertv(false);
1934  break;
1935 
1936  case NT_int8:
1937  {
1938  int8_t *pi = (int8_t *)pointer;
1939  pi[0] = (int)data[0];
1940  pi[1] = (int)data[1];
1941  pi[2] = (int)data[2];
1942  pi[3] = (int)data[3];
1943  }
1944  break;
1945 
1946  case NT_int16:
1947  {
1948  int16_t *pi = (int16_t *)pointer;
1949  pi[0] = (int)data[0];
1950  pi[1] = (int)data[1];
1951  pi[2] = (int)data[2];
1952  pi[3] = (int)data[3];
1953  }
1954  break;
1955 
1956  case NT_int32:
1957  {
1958  int32_t *pi = (int32_t *)pointer;
1959  pi[0] = (int)data[0];
1960  pi[1] = (int)data[1];
1961  pi[2] = (int)data[2];
1962  pi[3] = (int)data[3];
1963  }
1964  break;
1965 
1966  case NT_packed_ufloat:
1967  nassertv(false);
1968  break;
1969  }
1970  break;
1971  }
1972 }
1973 
1974 /**
1975  *
1976  */
1977 void GeomVertexColumn::Packer::
1978 set_data1d(unsigned char *pointer, double data) {
1979  switch (_column->get_num_values()) {
1980  case 1:
1981  switch (_column->get_numeric_type()) {
1982  case NT_uint8:
1983  *(uint8_t *)pointer = (unsigned int)data;
1984  break;
1985 
1986  case NT_uint16:
1987  *(uint16_t *)pointer = (unsigned int)data;
1988  break;
1989 
1990  case NT_uint32:
1991  *(uint32_t *)pointer = (unsigned int)data;
1992  break;
1993 
1994  case NT_packed_dcba:
1995  case NT_packed_dabc:
1996  nassertv(false);
1997  break;
1998 
1999  case NT_float32:
2000  *(PN_float32 *)pointer = data;
2001  break;
2002 
2003  case NT_float64:
2004  *(PN_float64 *)pointer = data;
2005  break;
2006 
2007  case NT_stdfloat:
2008  nassertv(false);
2009  break;
2010 
2011  case NT_int8:
2012  *(int8_t *)pointer = (int)data;
2013  break;
2014 
2015  case NT_int16:
2016  *(int16_t *)pointer = (int)data;
2017  break;
2018 
2019  case NT_int32:
2020  *(int32_t *)pointer = (int)data;
2021  break;
2022 
2023  case NT_packed_ufloat:
2024  nassertv(false);
2025  break;
2026  }
2027  break;
2028 
2029  case 2:
2030  set_data2d(pointer, LVecBase2d(data, 0.0f));
2031  break;
2032 
2033  case 3:
2034  set_data3d(pointer, LVecBase3d(data, 0.0f, 0.0f));
2035  break;
2036 
2037  case 4:
2038  set_data4d(pointer, LVecBase4d(data, 0.0f, 0.0f, 0.0f));
2039  break;
2040  }
2041 }
2042 
2043 /**
2044  *
2045  */
2046 void GeomVertexColumn::Packer::
2047 set_data2d(unsigned char *pointer, const LVecBase2d &data) {
2048  switch (_column->get_num_values()) {
2049  case 1:
2050  set_data1d(pointer, data[0]);
2051 
2052  case 2:
2053  switch (_column->get_numeric_type()) {
2054  case NT_uint8:
2055  {
2056  uint8_t *pi = (uint8_t *)pointer;
2057  pi[0] = (unsigned int)data[0];
2058  pi[1] = (unsigned int)data[1];
2059  }
2060  break;
2061 
2062  case NT_uint16:
2063  {
2064  uint16_t *pi = (uint16_t *)pointer;
2065  pi[0] = (unsigned int)data[0];
2066  pi[1] = (unsigned int)data[1];
2067  }
2068  break;
2069 
2070  case NT_uint32:
2071  {
2072  uint32_t *pi = (uint32_t *)pointer;
2073  pi[0] = (unsigned int)data[0];
2074  pi[1] = (unsigned int)data[1];
2075  }
2076  break;
2077 
2078  case NT_packed_dcba:
2079  case NT_packed_dabc:
2080  nassertv(false);
2081  break;
2082 
2083  case NT_float32:
2084  {
2085  PN_float32 *pi = (PN_float32 *)pointer;
2086  pi[0] = data[0];
2087  pi[1] = data[1];
2088  }
2089  break;
2090 
2091  case NT_float64:
2092  {
2093  PN_float64 *pi = (PN_float64 *)pointer;
2094  pi[0] = data[0];
2095  pi[1] = data[1];
2096  }
2097  break;
2098 
2099  case NT_stdfloat:
2100  nassertv(false);
2101  break;
2102 
2103  case NT_int8:
2104  {
2105  int8_t *pi = (int8_t *)pointer;
2106  pi[0] = (int)data[0];
2107  pi[1] = (int)data[1];
2108  }
2109  break;
2110 
2111  case NT_int16:
2112  {
2113  int16_t *pi = (int16_t *)pointer;
2114  pi[0] = (int)data[0];
2115  pi[1] = (int)data[1];
2116  }
2117  break;
2118 
2119  case NT_int32:
2120  {
2121  int32_t *pi = (int32_t *)pointer;
2122  pi[0] = (int)data[0];
2123  pi[1] = (int)data[1];
2124  }
2125  break;
2126 
2127  case NT_packed_ufloat:
2128  nassertv(false);
2129  break;
2130  }
2131  break;
2132 
2133  case 3:
2134  set_data3d(pointer, LVecBase3d(data[0], data[1], 0.0f));
2135  break;
2136 
2137  default:
2138  set_data4d(pointer, LVecBase4d(data[0], data[1], 0.0f, 0.0f));
2139  break;
2140  }
2141 }
2142 
2143 /**
2144  *
2145  */
2146 void GeomVertexColumn::Packer::
2147 set_data3d(unsigned char *pointer, const LVecBase3d &data) {
2148  switch (_column->get_num_values()) {
2149  case 1:
2150  set_data1d(pointer, data[0]);
2151  break;
2152 
2153  case 2:
2154  set_data2d(pointer, LVecBase2d(data[0], data[1]));
2155  break;
2156 
2157  case 3:
2158  switch (_column->get_numeric_type()) {
2159  case NT_uint8:
2160  {
2161  uint8_t *pi = (uint8_t *)pointer;
2162  pi[0] = (unsigned int)data[0];
2163  pi[1] = (unsigned int)data[1];
2164  pi[2] = (unsigned int)data[2];
2165  }
2166  break;
2167 
2168  case NT_uint16:
2169  {
2170  uint16_t *pi = (uint16_t *)pointer;
2171  pi[0] = (unsigned int)data[0];
2172  pi[1] = (unsigned int)data[1];
2173  pi[2] = (unsigned int)data[2];
2174  }
2175  break;
2176 
2177  case NT_uint32:
2178  {
2179  uint32_t *pi = (uint32_t *)pointer;
2180  pi[0] = (unsigned int)data[0];
2181  pi[1] = (unsigned int)data[1];
2182  pi[2] = (unsigned int)data[2];
2183  }
2184  break;
2185 
2186  case NT_packed_dcba:
2187  case NT_packed_dabc:
2188  nassertv(false);
2189  break;
2190 
2191  case NT_float32:
2192  {
2193  PN_float32 *pi = (PN_float32 *)pointer;
2194  pi[0] = data[0];
2195  pi[1] = data[1];
2196  pi[2] = data[2];
2197  }
2198  break;
2199 
2200  case NT_float64:
2201  {
2202  PN_float64 *pi = (PN_float64 *)pointer;
2203  pi[0] = data[0];
2204  pi[1] = data[1];
2205  pi[2] = data[2];
2206  }
2207  break;
2208 
2209  case NT_stdfloat:
2210  nassertv(false);
2211  break;
2212 
2213  case NT_int8:
2214  {
2215  int8_t *pi = (int8_t *)pointer;
2216  pi[0] = (int)data[0];
2217  pi[1] = (int)data[1];
2218  pi[2] = (int)data[2];
2219  }
2220  break;
2221 
2222  case NT_int16:
2223  {
2224  int16_t *pi = (int16_t *)pointer;
2225  pi[0] = (int)data[0];
2226  pi[1] = (int)data[1];
2227  pi[2] = (int)data[2];
2228  }
2229  break;
2230 
2231  case NT_int32:
2232  {
2233  int32_t *pi = (int32_t *)pointer;
2234  pi[0] = (int)data[0];
2235  pi[1] = (int)data[1];
2236  pi[2] = (int)data[2];
2237  }
2238  break;
2239 
2240  case NT_packed_ufloat:
2241  *(uint32_t *)pointer = GeomVertexData::pack_ufloat(data[0], data[1], data[2]);
2242  break;
2243  }
2244  break;
2245 
2246  default:
2247  set_data4d(pointer, LVecBase4d(data[0], data[1], data[2], 0.0f));
2248  break;
2249  }
2250 }
2251 
2252 /**
2253  *
2254  */
2255 void GeomVertexColumn::Packer::
2256 set_data4d(unsigned char *pointer, const LVecBase4d &data) {
2257  switch (_column->get_num_values()) {
2258  case 1:
2259  set_data1d(pointer, data[0]);
2260  break;
2261 
2262  case 2:
2263  set_data2d(pointer, LVecBase2d(data[0], data[1]));
2264  break;
2265 
2266  case 3:
2267  set_data3d(pointer, LVecBase3d(data[0], data[1], data[2]));
2268  break;
2269 
2270  default:
2271  switch (_column->get_numeric_type()) {
2272  case NT_uint8:
2273  {
2274  uint8_t *pi = (uint8_t *)pointer;
2275  pi[0] = (unsigned int)data[0];
2276  pi[1] = (unsigned int)data[1];
2277  pi[2] = (unsigned int)data[2];
2278  pi[3] = (unsigned int)data[3];
2279  }
2280  break;
2281 
2282  case NT_uint16:
2283  {
2284  uint16_t *pi = (uint16_t *)pointer;
2285  pi[0] = (unsigned int)data[0];
2286  pi[1] = (unsigned int)data[1];
2287  pi[2] = (unsigned int)data[2];
2288  pi[3] = (unsigned int)data[3];
2289  }
2290  break;
2291 
2292  case NT_uint32:
2293  {
2294  uint32_t *pi = (uint32_t *)pointer;
2295  pi[0] = (unsigned int)data[0];
2296  pi[1] = (unsigned int)data[1];
2297  pi[2] = (unsigned int)data[2];
2298  pi[3] = (unsigned int)data[3];
2299  }
2300  break;
2301 
2302  case NT_packed_dcba:
2303  *(uint32_t *)pointer = GeomVertexData::pack_abcd(data[3], data[2], data[1], data[0]);
2304  break;
2305 
2306  case NT_packed_dabc:
2307  *(uint32_t *)pointer = GeomVertexData::pack_abcd(data[3], data[0], data[1], data[2]);
2308  break;
2309 
2310  case NT_float32:
2311  {
2312  PN_float32 *pi = (PN_float32 *)pointer;
2313  pi[0] = data[0];
2314  pi[1] = data[1];
2315  pi[2] = data[2];
2316  pi[3] = data[3];
2317  }
2318  break;
2319 
2320  case NT_float64:
2321  {
2322  PN_float64 *pi = (PN_float64 *)pointer;
2323  pi[0] = data[0];
2324  pi[1] = data[1];
2325  pi[2] = data[2];
2326  pi[3] = data[3];
2327  }
2328  break;
2329 
2330  case NT_stdfloat:
2331  nassertv(false);
2332  break;
2333 
2334  case NT_int8:
2335  {
2336  int8_t *pi = (int8_t *)pointer;
2337  pi[0] = (int)data[0];
2338  pi[1] = (int)data[1];
2339  pi[2] = (int)data[2];
2340  pi[3] = (int)data[3];
2341  }
2342  break;
2343 
2344  case NT_int16:
2345  {
2346  int16_t *pi = (int16_t *)pointer;
2347  pi[0] = (int)data[0];
2348  pi[1] = (int)data[1];
2349  pi[2] = (int)data[2];
2350  pi[3] = (int)data[3];
2351  }
2352  break;
2353 
2354  case NT_int32:
2355  {
2356  int32_t *pi = (int32_t *)pointer;
2357  pi[0] = (int)data[0];
2358  pi[1] = (int)data[1];
2359  pi[2] = (int)data[2];
2360  pi[3] = (int)data[3];
2361  }
2362  break;
2363 
2364  case NT_packed_ufloat:
2365  nassertv(false);
2366  break;
2367  }
2368  break;
2369  }
2370 }
2371 
2372 /**
2373  *
2374  */
2375 void GeomVertexColumn::Packer::
2376 set_data1i(unsigned char *pointer, int data) {
2377  switch (_column->get_num_values()) {
2378  case 1:
2379  switch (_column->get_numeric_type()) {
2380  case NT_uint8:
2381  *pointer = data;
2382  nassertv((*pointer) == data);
2383  break;
2384 
2385  case NT_uint16:
2386  *(uint16_t *)pointer = data;
2387  nassertv(*(uint16_t *)pointer == data);
2388  break;
2389 
2390  case NT_uint32:
2391  *(uint32_t *)pointer = data;
2392  break;
2393 
2394  case NT_packed_dcba:
2395  case NT_packed_dabc:
2396  nassertv(false);
2397  break;
2398 
2399  case NT_float32:
2400  *(PN_float32 *)pointer = (float)data;
2401  break;
2402 
2403  case NT_float64:
2404  *(PN_float64 *)pointer = (double)data;
2405  break;
2406 
2407  case NT_stdfloat:
2408  nassertv(false);
2409  break;
2410 
2411  case NT_int8:
2412  *(int8_t *)pointer = data;
2413  nassertv(*(int8_t *)pointer == data);
2414  break;
2415 
2416  case NT_int16:
2417  *(int16_t *)pointer = data;
2418  nassertv(*(int16_t *)pointer == data);
2419  break;
2420 
2421  case NT_int32:
2422  *(int32_t *)pointer = data;
2423  break;
2424 
2425  case NT_packed_ufloat:
2426  nassertv(false);
2427  break;
2428  }
2429  break;
2430 
2431  case 2:
2432  set_data2i(pointer, LVecBase2i(data, 0));
2433  break;
2434 
2435  case 3:
2436  set_data3i(pointer, LVecBase3i(data, 0, 0));
2437  break;
2438 
2439  default:
2440  set_data4i(pointer, LVecBase4i(data, 0, 0, 0));
2441  break;
2442  }
2443 }
2444 
2445 /**
2446  *
2447  */
2448 void GeomVertexColumn::Packer::
2449 set_data2i(unsigned char *pointer, const LVecBase2i &data) {
2450  switch (_column->get_num_values()) {
2451  case 1:
2452  set_data1i(pointer, data[0]);
2453  break;
2454 
2455  case 2:
2456  switch (_column->get_numeric_type()) {
2457  case NT_uint8:
2458  pointer[0] = data[0];
2459  pointer[1] = data[1];
2460  break;
2461 
2462  case NT_uint16:
2463  {
2464  uint16_t *pi = (uint16_t *)pointer;
2465  pi[0] = data[0];
2466  pi[1] = data[1];
2467  }
2468  break;
2469 
2470  case NT_uint32:
2471  {
2472  uint32_t *pi = (uint32_t *)pointer;
2473  pi[0] = data[0];
2474  pi[1] = data[1];
2475  }
2476  break;
2477 
2478  case NT_packed_dcba:
2479  case NT_packed_dabc:
2480  nassertv(false);
2481  break;
2482 
2483  case NT_float32:
2484  {
2485  PN_float32 *pi = (PN_float32 *)pointer;
2486  pi[0] = data[0];
2487  pi[1] = data[1];
2488  }
2489  break;
2490 
2491  case NT_float64:
2492  {
2493  PN_float64 *pi = (PN_float64 *)pointer;
2494  pi[0] = data[0];
2495  pi[1] = data[1];
2496  }
2497  break;
2498 
2499  case NT_stdfloat:
2500  nassertv(false);
2501  break;
2502 
2503  case NT_int8:
2504  {
2505  int8_t *pi = (int8_t *)pointer;
2506  pi[0] = data[0];
2507  pi[1] = data[1];
2508  }
2509  break;
2510 
2511  case NT_int16:
2512  {
2513  int16_t *pi = (int16_t *)pointer;
2514  pi[0] = data[0];
2515  pi[1] = data[1];
2516  }
2517  break;
2518 
2519  case NT_int32:
2520  {
2521  int32_t *pi = (int32_t *)pointer;
2522  pi[0] = data[0];
2523  pi[1] = data[1];
2524  }
2525  break;
2526 
2527  case NT_packed_ufloat:
2528  nassertv(false);
2529  break;
2530  }
2531  break;
2532 
2533  case 3:
2534  set_data3i(pointer, LVecBase3i(data[0], data[1], 0));
2535  break;
2536 
2537  default:
2538  set_data4i(pointer, LVecBase4i(data[0], data[1], 0, 0));
2539  break;
2540  }
2541 }
2542 
2543 /**
2544  *
2545  */
2546 void GeomVertexColumn::Packer::
2547 set_data3i(unsigned char *pointer, const LVecBase3i &data) {
2548  switch (_column->get_num_values()) {
2549  case 1:
2550  set_data1i(pointer, data[0]);
2551  break;
2552 
2553  case 2:
2554  set_data2i(pointer, LVecBase2i(data[0], data[1]));
2555  break;
2556 
2557  case 3:
2558  switch (_column->get_numeric_type()) {
2559  case NT_uint8:
2560  pointer[0] = data[0];
2561  pointer[1] = data[1];
2562  pointer[2] = data[2];
2563  break;
2564 
2565  case NT_uint16:
2566  {
2567  uint16_t *pi = (uint16_t *)pointer;
2568  pi[0] = data[0];
2569  pi[1] = data[1];
2570  pi[2] = data[2];
2571  }
2572  break;
2573 
2574  case NT_uint32:
2575  {
2576  uint32_t *pi = (uint32_t *)pointer;
2577  pi[0] = data[0];
2578  pi[1] = data[1];
2579  pi[2] = data[2];
2580  }
2581  break;
2582 
2583  case NT_packed_dcba:
2584  case NT_packed_dabc:
2585  nassertv(false);
2586  break;
2587 
2588  case NT_float32:
2589  {
2590  PN_float32 *pi = (PN_float32 *)pointer;
2591  pi[0] = data[0];
2592  pi[1] = data[1];
2593  pi[2] = data[2];
2594  }
2595  break;
2596 
2597  case NT_float64:
2598  {
2599  PN_float64 *pi = (PN_float64 *)pointer;
2600  pi[0] = data[0];
2601  pi[1] = data[1];
2602  pi[2] = data[2];
2603  }
2604  break;
2605 
2606  case NT_stdfloat:
2607  nassertv(false);
2608  break;
2609 
2610  case NT_int8:
2611  {
2612  int8_t *pi = (int8_t *)pointer;
2613  pi[0] = data[0];
2614  pi[1] = data[1];
2615  pi[2] = data[2];
2616  }
2617  break;
2618 
2619  case NT_int16:
2620  {
2621  int16_t *pi = (int16_t *)pointer;
2622  pi[0] = data[0];
2623  pi[1] = data[1];
2624  pi[2] = data[2];
2625  }
2626  break;
2627 
2628  case NT_int32:
2629  {
2630  int32_t *pi = (int32_t *)pointer;
2631  pi[0] = data[0];
2632  pi[1] = data[1];
2633  pi[2] = data[2];
2634  }
2635  break;
2636 
2637  case NT_packed_ufloat:
2638  *(uint32_t *)pointer = GeomVertexData::pack_ufloat(data[0], data[1], data[2]);
2639  break;
2640  }
2641  break;
2642 
2643  default:
2644  set_data4i(pointer, LVecBase4i(data[0], data[1], data[2], 0));
2645  break;
2646  }
2647 }
2648 
2649 /**
2650  *
2651  */
2652 void GeomVertexColumn::Packer::
2653 set_data4i(unsigned char *pointer, const LVecBase4i &data) {
2654  switch (_column->get_num_values()) {
2655  case 1:
2656  set_data1i(pointer, data[0]);
2657  break;
2658 
2659  case 2:
2660  set_data2i(pointer, LVecBase2i(data[0], data[1]));
2661  break;
2662 
2663  case 3:
2664  set_data3i(pointer, LVecBase3i(data[0], data[1], data[2]));
2665  break;
2666 
2667  default:
2668  switch (_column->get_numeric_type()) {
2669  case NT_uint8:
2670  pointer[0] = data[0];
2671  pointer[1] = data[1];
2672  pointer[2] = data[2];
2673  pointer[3] = data[3];
2674  break;
2675 
2676  case NT_uint16:
2677  {
2678  uint16_t *pi = (uint16_t *)pointer;
2679  pi[0] = data[0];
2680  pi[1] = data[1];
2681  pi[2] = data[2];
2682  pi[3] = data[3];
2683  }
2684  break;
2685 
2686  case NT_uint32:
2687  {
2688  uint32_t *pi = (uint32_t *)pointer;
2689  pi[0] = data[0];
2690  pi[1] = data[1];
2691  pi[2] = data[2];
2692  pi[3] = data[3];
2693  }
2694  break;
2695 
2696  case NT_packed_dcba:
2697  *(uint32_t *)pointer = GeomVertexData::pack_abcd(data[3], data[2], data[1], data[0]);
2698  break;
2699 
2700  case NT_packed_dabc:
2701  *(uint32_t *)pointer = GeomVertexData::pack_abcd(data[3], data[0], data[1], data[2]);
2702  break;
2703 
2704  case NT_float32:
2705  {
2706  PN_float32 *pi = (PN_float32 *)pointer;
2707  pi[0] = data[0];
2708  pi[1] = data[1];
2709  pi[2] = data[2];
2710  pi[3] = data[3];
2711  }
2712  break;
2713 
2714  case NT_float64:
2715  {
2716  PN_float64 *pi = (PN_float64 *)pointer;
2717  pi[0] = data[0];
2718  pi[1] = data[1];
2719  pi[2] = data[2];
2720  pi[3] = data[3];
2721  }
2722  break;
2723 
2724  case NT_stdfloat:
2725  nassertv(false);
2726  break;
2727 
2728  case NT_int8:
2729  {
2730  int8_t *pi = (int8_t *)pointer;
2731  pi[0] = data[0];
2732  pi[1] = data[1];
2733  pi[2] = data[2];
2734  pi[3] = data[3];
2735  }
2736  break;
2737 
2738  case NT_int16:
2739  {
2740  int16_t *pi = (int16_t *)pointer;
2741  pi[0] = data[0];
2742  pi[1] = data[1];
2743  pi[2] = data[2];
2744  pi[3] = data[3];
2745  }
2746  break;
2747 
2748  case NT_int32:
2749  {
2750  int32_t *pi = (int32_t *)pointer;
2751  pi[0] = data[0];
2752  pi[1] = data[1];
2753  pi[2] = data[2];
2754  pi[3] = data[3];
2755  }
2756  break;
2757 
2758  case NT_packed_ufloat:
2759  nassertv(false);
2760  break;
2761  }
2762  break;
2763  }
2764 }
2765 
2766 /**
2767  *
2768  */
2769 float GeomVertexColumn::Packer_point::
2770 get_data1f(const unsigned char *pointer) {
2771  if (_column->get_num_values() == 4) {
2772  const LVecBase4f &v4 = get_data4f(pointer);
2773  return v4[0] / v4[3];
2774  } else {
2775  return Packer::get_data1f(pointer);
2776  }
2777 }
2778 
2779 /**
2780  *
2781  */
2782 const LVecBase2f &GeomVertexColumn::Packer_point::
2783 get_data2f(const unsigned char *pointer) {
2784  if (_column->get_num_values() == 4) {
2785  const LVecBase4f &v4 = get_data4f(pointer);
2786  _v2.set(v4[0] / v4[3], v4[1] / v4[3]);
2787  return _v2;
2788  } else {
2789  return Packer::get_data2f(pointer);
2790  }
2791 }
2792 
2793 /**
2794  *
2795  */
2796 const LVecBase3f &GeomVertexColumn::Packer_point::
2797 get_data3f(const unsigned char *pointer) {
2798  if (_column->get_num_values() == 4) {
2799  const LVecBase4f &v4 = get_data4f(pointer);
2800  _v3.set(v4[0] / v4[3], v4[1] / v4[3], v4[2] / v4[3]);
2801  return _v3;
2802  } else {
2803  return Packer::get_data3f(pointer);
2804  }
2805 }
2806 
2807 /**
2808  *
2809  */
2810 const LVecBase4f &GeomVertexColumn::Packer_point::
2811 get_data4f(const unsigned char *pointer) {
2812  switch (_column->get_num_values()) {
2813  case 1:
2814  _v4.set(get_data1f(pointer), 0.0f, 0.0f, 1.0f);
2815  return _v4;
2816 
2817  case 2:
2818  {
2819  const LVecBase2f &v2 = get_data2f(pointer);
2820  _v4.set(v2[0], v2[1], 0.0f, 1.0f);
2821  }
2822  return _v4;
2823 
2824  case 3:
2825  {
2826  const LVecBase3f &v3 = get_data3f(pointer);
2827  _v4.set(v3[0], v3[1], v3[2], 1.0f);
2828  }
2829  return _v4;
2830 
2831  default:
2832  switch (_column->get_numeric_type()) {
2833  case NT_uint8:
2834  {
2835  const uint8_t *pi = (const uint8_t *)pointer;
2836  _v4.set(pi[0], pi[1], pi[2], pi[3]);
2837  }
2838  return _v4;
2839 
2840  case NT_uint16:
2841  {
2842  const uint16_t *pi = (const uint16_t *)pointer;
2843  _v4.set(pi[0], pi[1], pi[2], pi[3]);
2844  }
2845  return _v4;
2846 
2847  case NT_uint32:
2848  {
2849  const uint32_t *pi = (const uint32_t *)pointer;
2850  _v4.set(pi[0], pi[1], pi[2], pi[3]);
2851  }
2852  return _v4;
2853 
2854  case NT_packed_dcba:
2855  {
2856  uint32_t dword = *(const uint32_t *)pointer;
2857  _v4.set(GeomVertexData::unpack_abcd_d(dword),
2861  }
2862  return _v4;
2863 
2864  case NT_packed_dabc:
2865  {
2866  uint32_t dword = *(const uint32_t *)pointer;
2867  _v4.set(GeomVertexData::unpack_abcd_b(dword),
2871  }
2872  return _v4;
2873 
2874  case NT_float32:
2875  {
2876  const PN_float32 *pi = (const PN_float32 *)pointer;
2877  _v4.set(pi[0], pi[1], pi[2], pi[3]);
2878  }
2879  return _v4;
2880 
2881  case NT_float64:
2882  {
2883  const PN_float64 *pi = (const PN_float64 *)pointer;
2884  _v4.set(pi[0], pi[1], pi[2], pi[3]);
2885  }
2886  return _v4;
2887 
2888  case NT_stdfloat:
2889  nassertr(false, _v4);
2890  break;
2891 
2892  case NT_int8:
2893  {
2894  const int8_t *pi = (const int8_t *)pointer;
2895  _v4.set(pi[0], pi[1], pi[2], pi[3]);
2896  }
2897  return _v4;
2898 
2899  case NT_int16:
2900  {
2901  const int16_t *pi = (const int16_t *)pointer;
2902  _v4.set(pi[0], pi[1], pi[2], pi[3]);
2903  }
2904  return _v4;
2905 
2906  case NT_int32:
2907  {
2908  const int32_t *pi = (const int32_t *)pointer;
2909  _v4.set(pi[0], pi[1], pi[2], pi[3]);
2910  }
2911  return _v4;
2912 
2913  case NT_packed_ufloat:
2914  nassertr(false, _v4);
2915  break;
2916  }
2917  }
2918 
2919  return _v4;
2920 }
2921 
2922 /**
2923  *
2924  */
2925 double GeomVertexColumn::Packer_point::
2926 get_data1d(const unsigned char *pointer) {
2927  if (_column->get_num_values() == 4) {
2928  const LVecBase4d &v4 = get_data4d(pointer);
2929  return v4[0] / v4[3];
2930  } else {
2931  return Packer::get_data1d(pointer);
2932  }
2933 }
2934 
2935 /**
2936  *
2937  */
2938 const LVecBase2d &GeomVertexColumn::Packer_point::
2939 get_data2d(const unsigned char *pointer) {
2940  if (_column->get_num_values() == 4) {
2941  const LVecBase4d &v4 = get_data4d(pointer);
2942  _v2d.set(v4[0] / v4[3], v4[1] / v4[3]);
2943  return _v2d;
2944  } else {
2945  return Packer::get_data2d(pointer);
2946  }
2947 }
2948 
2949 /**
2950  *
2951  */
2952 const LVecBase3d &GeomVertexColumn::Packer_point::
2953 get_data3d(const unsigned char *pointer) {
2954  if (_column->get_num_values() == 4) {
2955  const LVecBase4d &v4 = get_data4d(pointer);
2956  _v3d.set(v4[0] / v4[3], v4[1] / v4[3], v4[2] / v4[3]);
2957  return _v3d;
2958  } else {
2959  return Packer::get_data3d(pointer);
2960  }
2961 }
2962 
2963 /**
2964  *
2965  */
2966 const LVecBase4d &GeomVertexColumn::Packer_point::
2967 get_data4d(const unsigned char *pointer) {
2968  switch (_column->get_num_values()) {
2969  case 1:
2970  _v4d.set(get_data1d(pointer), 0.0f, 0.0f, 1.0f);
2971  return _v4d;
2972 
2973  case 2:
2974  {
2975  const LVecBase2d &v2 = get_data2d(pointer);
2976  _v4d.set(v2[0], v2[1], 0.0f, 1.0f);
2977  }
2978  return _v4d;
2979 
2980  case 3:
2981  {
2982  const LVecBase3d &v3 = get_data3d(pointer);
2983  _v4d.set(v3[0], v3[1], v3[2], 1.0f);
2984  }
2985  return _v4d;
2986 
2987  default:
2988  switch (_column->get_numeric_type()) {
2989  case NT_uint8:
2990  {
2991  const uint8_t *pi = (const uint8_t *)pointer;
2992  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
2993  }
2994  return _v4d;
2995 
2996  case NT_uint16:
2997  {
2998  const uint16_t *pi = (const uint16_t *)pointer;
2999  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
3000  }
3001  return _v4d;
3002 
3003  case NT_uint32:
3004  {
3005  const uint32_t *pi = (const uint32_t *)pointer;
3006  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
3007  }
3008  return _v4d;
3009 
3010  case NT_packed_dcba:
3011  {
3012  uint32_t dword = *(const uint32_t *)pointer;
3013  _v4d.set(GeomVertexData::unpack_abcd_d(dword),
3017  }
3018  return _v4d;
3019 
3020  case NT_packed_dabc:
3021  {
3022  uint32_t dword = *(const uint32_t *)pointer;
3023  _v4d.set(GeomVertexData::unpack_abcd_b(dword),
3027  }
3028  return _v4d;
3029 
3030  case NT_float32:
3031  {
3032  const PN_float32 *pi = (const PN_float32 *)pointer;
3033  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
3034  }
3035  return _v4d;
3036 
3037  case NT_float64:
3038  {
3039  const PN_float64 *pi = (const PN_float64 *)pointer;
3040  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
3041  }
3042  return _v4d;
3043 
3044  case NT_stdfloat:
3045  nassertr(false, _v4d);
3046  break;
3047 
3048  case NT_int8:
3049  {
3050  const int8_t *pi = (const int8_t *)pointer;
3051  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
3052  }
3053  return _v4d;
3054 
3055  case NT_int16:
3056  {
3057  const int16_t *pi = (const int16_t *)pointer;
3058  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
3059  }
3060  return _v4d;
3061 
3062  case NT_int32:
3063  {
3064  const int32_t *pi = (const int32_t *)pointer;
3065  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
3066  }
3067  return _v4d;
3068 
3069  case NT_packed_ufloat:
3070  nassertr(false, _v4d);
3071  break;
3072  }
3073  }
3074 
3075  return _v4d;
3076 }
3077 
3078 /**
3079  *
3080  */
3081 void GeomVertexColumn::Packer_point::
3082 set_data1f(unsigned char *pointer, float data) {
3083  if (_column->get_num_values() == 4) {
3084  set_data4f(pointer, LVecBase4f(data, 0.0f, 0.0f, 1.0f));
3085  } else {
3086  Packer::set_data1f(pointer, data);
3087  }
3088 }
3089 
3090 /**
3091  *
3092  */
3093 void GeomVertexColumn::Packer_point::
3094 set_data2f(unsigned char *pointer, const LVecBase2f &data) {
3095  if (_column->get_num_values() == 4) {
3096  set_data4f(pointer, LVecBase4f(data[0], data[1], 0.0f, 1.0f));
3097  } else {
3098  Packer::set_data2f(pointer, data);
3099  }
3100 }
3101 
3102 /**
3103  *
3104  */
3105 void GeomVertexColumn::Packer_point::
3106 set_data3f(unsigned char *pointer, const LVecBase3f &data) {
3107  if (_column->get_num_values() == 4) {
3108  set_data4f(pointer, LVecBase4f(data[0], data[1], data[2], 1.0f));
3109  } else {
3110  Packer::set_data3f(pointer, data);
3111  }
3112 }
3113 
3114 /**
3115  *
3116  */
3117 void GeomVertexColumn::Packer_point::
3118 set_data4f(unsigned char *pointer, const LVecBase4f &data) {
3119  switch (_column->get_num_values()) {
3120  case 1:
3121  set_data1f(pointer, data[0] / data[3]);
3122  break;
3123 
3124  case 2:
3125  set_data2f(pointer, LVecBase2f(data[0] / data[3], data[1] / data[3]));
3126  break;
3127 
3128  case 3:
3129  set_data3f(pointer, LVecBase3f(data[0] / data[3], data[1] / data[3], data[2] / data[3]));
3130  break;
3131 
3132  default:
3133  switch (_column->get_numeric_type()) {
3134  case NT_uint8:
3135  {
3136  uint8_t *pi = (uint8_t *)pointer;
3137  pi[0] = (unsigned int)data[0];
3138  pi[1] = (unsigned int)data[1];
3139  pi[2] = (unsigned int)data[2];
3140  pi[3] = (unsigned int)data[3];
3141  }
3142  break;
3143 
3144  case NT_uint16:
3145  {
3146  uint16_t *pi = (uint16_t *)pointer;
3147  pi[0] = (unsigned int)data[0];
3148  pi[1] = (unsigned int)data[1];
3149  pi[2] = (unsigned int)data[2];
3150  pi[3] = (unsigned int)data[3];
3151  }
3152  break;
3153 
3154  case NT_uint32:
3155  {
3156  uint32_t *pi = (uint32_t *)pointer;
3157  pi[0] = (unsigned int)data[0];
3158  pi[1] = (unsigned int)data[1];
3159  pi[2] = (unsigned int)data[2];
3160  pi[3] = (unsigned int)data[3];
3161  }
3162  break;
3163 
3164  case NT_packed_dcba:
3165  *(uint32_t *)pointer = GeomVertexData::pack_abcd(data[3], data[2], data[1], data[0]);
3166  break;
3167 
3168  case NT_packed_dabc:
3169  *(uint32_t *)pointer = GeomVertexData::pack_abcd(data[3], data[0], data[1], data[2]);
3170  break;
3171 
3172  case NT_float32:
3173  {
3174  PN_float32 *pi = (PN_float32 *)pointer;
3175  pi[0] = data[0];
3176  pi[1] = data[1];
3177  pi[2] = data[2];
3178  pi[3] = data[3];
3179  }
3180  break;
3181 
3182  case NT_float64:
3183  {
3184  PN_float64 *pi = (PN_float64 *)pointer;
3185  pi[0] = data[0];
3186  pi[1] = data[1];
3187  pi[2] = data[2];
3188  pi[3] = data[3];
3189  }
3190  break;
3191 
3192  case NT_stdfloat:
3193  nassertv(false);
3194  break;
3195 
3196  case NT_int8:
3197  {
3198  int8_t *pi = (int8_t *)pointer;
3199  pi[0] = (int)data[0];
3200  pi[1] = (int)data[1];
3201  pi[2] = (int)data[2];
3202  pi[3] = (int)data[3];
3203  }
3204  break;
3205 
3206  case NT_int16:
3207  {
3208  int16_t *pi = (int16_t *)pointer;
3209  pi[0] = (int)data[0];
3210  pi[1] = (int)data[1];
3211  pi[2] = (int)data[2];
3212  pi[3] = (int)data[3];
3213  }
3214  break;
3215 
3216  case NT_int32:
3217  {
3218  int32_t *pi = (int32_t *)pointer;
3219  pi[0] = (int)data[0];
3220  pi[1] = (int)data[1];
3221  pi[2] = (int)data[2];
3222  pi[3] = (int)data[3];
3223  }
3224  break;
3225 
3226  case NT_packed_ufloat:
3227  nassertv(false);
3228  break;
3229  }
3230  break;
3231  }
3232 }
3233 
3234 /**
3235  *
3236  */
3237 void GeomVertexColumn::Packer_point::
3238 set_data1d(unsigned char *pointer, double data) {
3239  if (_column->get_num_values() == 4) {
3240  set_data4d(pointer, LVecBase4d(data, 0.0f, 0.0f, 1.0f));
3241  } else {
3242  Packer::set_data1d(pointer, data);
3243  }
3244 }
3245 
3246 /**
3247  *
3248  */
3249 void GeomVertexColumn::Packer_point::
3250 set_data2d(unsigned char *pointer, const LVecBase2d &data) {
3251  if (_column->get_num_values() == 4) {
3252  set_data4d(pointer, LVecBase4d(data[0], data[1], 0.0f, 1.0f));
3253  } else {
3254  Packer::set_data2d(pointer, data);
3255  }
3256 }
3257 
3258 /**
3259  *
3260  */
3261 void GeomVertexColumn::Packer_point::
3262 set_data3d(unsigned char *pointer, const LVecBase3d &data) {
3263  if (_column->get_num_values() == 4) {
3264  set_data4d(pointer, LVecBase4d(data[0], data[1], data[2], 1.0f));
3265  } else {
3266  Packer::set_data3d(pointer, data);
3267  }
3268 }
3269 
3270 /**
3271  *
3272  */
3273 void GeomVertexColumn::Packer_point::
3274 set_data4d(unsigned char *pointer, const LVecBase4d &data) {
3275  switch (_column->get_num_values()) {
3276  case 1:
3277  set_data1d(pointer, data[0] / data[3]);
3278  break;
3279 
3280  case 2:
3281  set_data2d(pointer, LVecBase2d(data[0] / data[3], data[1] / data[3]));
3282  break;
3283 
3284  case 3:
3285  set_data3d(pointer, LVecBase3d(data[0] / data[3], data[1] / data[3], data[2] / data[3]));
3286  break;
3287 
3288  default:
3289  switch (_column->get_numeric_type()) {
3290  case NT_uint8:
3291  {
3292  uint8_t *pi = (uint8_t *)pointer;
3293  pi[0] = (unsigned int)data[0];
3294  pi[1] = (unsigned int)data[1];
3295  pi[2] = (unsigned int)data[2];
3296  pi[3] = (unsigned int)data[3];
3297  }
3298  break;
3299 
3300  case NT_uint16:
3301  {
3302  uint16_t *pi = (uint16_t *)pointer;
3303  pi[0] = (unsigned int)data[0];
3304  pi[1] = (unsigned int)data[1];
3305  pi[2] = (unsigned int)data[2];
3306  pi[3] = (unsigned int)data[3];
3307  }
3308  break;
3309 
3310  case NT_uint32:
3311  {
3312  uint32_t *pi = (uint32_t *)pointer;
3313  pi[0] = (unsigned int)data[0];
3314  pi[1] = (unsigned int)data[1];
3315  pi[2] = (unsigned int)data[2];
3316  pi[3] = (unsigned int)data[3];
3317  }
3318  break;
3319 
3320  case NT_packed_dcba:
3321  *(uint32_t *)pointer = GeomVertexData::pack_abcd(data[3], data[2], data[1], data[0]);
3322  break;
3323 
3324  case NT_packed_dabc:
3325  *(uint32_t *)pointer = GeomVertexData::pack_abcd(data[3], data[0], data[1], data[2]);
3326  break;
3327 
3328  case NT_float32:
3329  {
3330  PN_float32 *pi = (PN_float32 *)pointer;
3331  pi[0] = data[0];
3332  pi[1] = data[1];
3333  pi[2] = data[2];
3334  pi[3] = data[3];
3335  }
3336  break;
3337 
3338  case NT_float64:
3339  {
3340  PN_float64 *pi = (PN_float64 *)pointer;
3341  pi[0] = data[0];
3342  pi[1] = data[1];
3343  pi[2] = data[2];
3344  pi[3] = data[3];
3345  }
3346  break;
3347 
3348  case NT_stdfloat:
3349  nassertv(false);
3350  break;
3351 
3352  case NT_int8:
3353  {
3354  int8_t *pi = (int8_t *)pointer;
3355  pi[0] = (int)data[0];
3356  pi[1] = (int)data[1];
3357  pi[2] = (int)data[2];
3358  pi[3] = (int)data[3];
3359  }
3360  break;
3361 
3362  case NT_int16:
3363  {
3364  int16_t *pi = (int16_t *)pointer;
3365  pi[0] = (int)data[0];
3366  pi[1] = (int)data[1];
3367  pi[2] = (int)data[2];
3368  pi[3] = (int)data[3];
3369  }
3370  break;
3371 
3372  case NT_int32:
3373  {
3374  int32_t *pi = (int32_t *)pointer;
3375  pi[0] = (int)data[0];
3376  pi[1] = (int)data[1];
3377  pi[2] = (int)data[2];
3378  pi[3] = (int)data[3];
3379  }
3380  break;
3381 
3382  case NT_packed_ufloat:
3383  nassertv(false);
3384  break;
3385  }
3386  break;
3387  }
3388 }
3389 
3390 /**
3391  *
3392  */
3393 float GeomVertexColumn::Packer_color::
3394 get_data1f(const unsigned char *pointer) {
3395  switch (_column->get_numeric_type()) {
3396  case NT_uint8:
3397  return (*(const uint8_t *)pointer) / 255.0f;
3398 
3399  case NT_uint16:
3400  return (*(const uint16_t *)pointer) / 65535.0f;
3401 
3402  case NT_uint32:
3403  return (*(const uint32_t *)pointer) / 4294967295.0f;
3404 
3405  case NT_packed_dcba:
3406  {
3407  uint32_t dword = *(const uint32_t *)pointer;
3408  return GeomVertexData::unpack_abcd_d(dword) / 255.0f;
3409  }
3410 
3411  case NT_packed_dabc:
3412  {
3413  uint32_t dword = *(const uint32_t *)pointer;
3414  return GeomVertexData::unpack_abcd_b(dword) / 255.0f;
3415  }
3416 
3417  case NT_float32:
3418  return *(const PN_float32 *)pointer;
3419 
3420  case NT_float64:
3421  return *(const PN_float64 *)pointer;
3422 
3423  default:
3424  nassertr(false, 0.0f);
3425  }
3426 
3427  return 0.0f;
3428 }
3429 
3430 /**
3431  *
3432  */
3433 const LVecBase2f &GeomVertexColumn::Packer_color::
3434 get_data2f(const unsigned char *pointer) {
3435  if (_column->get_num_values() == 3) {
3436  const LVecBase3f &v3 = get_data3f(pointer);
3437  _v2.set(v3[0], v3[1]);
3438  return _v2;
3439  } else {
3440  const LVecBase4f &v4 = get_data4f(pointer);
3441  _v2.set(v4[0], v4[1]);
3442  return _v2;
3443  }
3444 }
3445 
3446 /**
3447  *
3448  */
3449 const LVecBase3f &GeomVertexColumn::Packer_color::
3450 get_data3f(const unsigned char *pointer) {
3451  if (_column->get_num_values() == 3) {
3452  switch (_column->get_numeric_type()) {
3453  case NT_uint8:
3454  {
3455  const uint8_t *pi = (const uint8_t *)pointer;
3456  _v3.set(pi[0], pi[1], pi[2]);
3457  _v3 /= 255.0f;
3458  }
3459  return _v3;
3460 
3461  case NT_uint16:
3462  {
3463  const uint16_t *pi = (const uint16_t *)pointer;
3464  _v3.set(pi[0], pi[1], pi[2]);
3465  _v3 /= 65535.0f;
3466  }
3467  return _v3;
3468 
3469  case NT_uint32:
3470  {
3471  const uint32_t *pi = (const uint32_t *)pointer;
3472  _v3.set(pi[0], pi[1], pi[2]);
3473  _v3 /= 4294967295.0f;
3474  }
3475  return _v3;
3476 
3477  case NT_packed_dcba:
3478  case NT_packed_dabc:
3479  nassertr(false, _v3);
3480  return _v3;
3481 
3482  case NT_float32:
3483  {
3484  const PN_float32 *pi = (const PN_float32 *)pointer;
3485  _v3.set(pi[0], pi[1], pi[2]);
3486  }
3487  return _v3;
3488 
3489  case NT_float64:
3490  {
3491  const PN_float64 *pi = (const PN_float64 *)pointer;
3492  _v3.set(pi[0], pi[1], pi[2]);
3493  }
3494  return _v3;
3495 
3496  case NT_stdfloat:
3497  case NT_int8:
3498  case NT_int16:
3499  case NT_int32:
3500  nassertr(false, _v3);
3501  return _v3;
3502 
3503  case NT_packed_ufloat:
3504  {
3505  uint32_t dword = *(const uint32_t *)pointer;
3506  _v3.set(GeomVertexData::unpack_ufloat_a(dword),
3509  }
3510  return _v3;
3511  }
3512  } else {
3513  const LVecBase4f &v4 = get_data4f(pointer);
3514  _v3.set(v4[0], v4[1], v4[2]);
3515  return _v3;
3516  }
3517 
3518  return _v3;
3519 }
3520 
3521 /**
3522  *
3523  */
3524 const LVecBase4f &GeomVertexColumn::Packer_color::
3525 get_data4f(const unsigned char *pointer) {
3526  if (_column->get_num_values() == 3) {
3527  const LVecBase3f &v3 = get_data3f(pointer);
3528  _v4.set(v3[0], v3[1], v3[2], 1.0f);
3529  return _v4;
3530  } else {
3531  switch (_column->get_numeric_type()) {
3532  case NT_uint8:
3533  {
3534  const uint8_t *pi = (const uint8_t *)pointer;
3535  _v4.set(pi[0], pi[1], pi[2], pi[3]);
3536  _v4 /= 255.0f;
3537  }
3538  return _v4;
3539 
3540  case NT_uint16:
3541  {
3542  const uint16_t *pi = (const uint16_t *)pointer;
3543  _v4.set(pi[0], pi[1], pi[2], pi[3]);
3544  _v4 /= 65535.0f;
3545  }
3546  return _v4;
3547 
3548  case NT_uint32:
3549  {
3550  const uint32_t *pi = (const uint32_t *)pointer;
3551  _v4.set(pi[0], pi[1], pi[2], pi[3]);
3552  _v4 /= 4294967295.0f;
3553  }
3554  return _v4;
3555 
3556  case NT_packed_dcba:
3557  {
3558  uint32_t dword = *(const uint32_t *)pointer;
3559  _v4.set(GeomVertexData::unpack_abcd_d(dword),
3563  _v4 /= 255.0f;
3564  }
3565  return _v4;
3566 
3567  case NT_packed_dabc:
3568  {
3569  uint32_t dword = *(const uint32_t *)pointer;
3570  _v4.set(GeomVertexData::unpack_abcd_b(dword),
3574  _v4 /= 255.0f;
3575  }
3576  return _v4;
3577 
3578  case NT_float32:
3579  {
3580  const PN_float32 *pi = (const PN_float32 *)pointer;
3581  _v4.set(pi[0], pi[1], pi[2], pi[3]);
3582  }
3583  return _v4;
3584 
3585  case NT_float64:
3586  {
3587  const PN_float64 *pi = (const PN_float64 *)pointer;
3588  _v4.set(pi[0], pi[1], pi[2], pi[3]);
3589  }
3590  return _v4;
3591 
3592  case NT_stdfloat:
3593  case NT_int8:
3594  case NT_int16:
3595  case NT_int32:
3596  case NT_packed_ufloat:
3597  nassertr(false, _v4);
3598  return _v4;
3599  }
3600  }
3601 
3602  return _v4;
3603 }
3604 
3605 /**
3606  *
3607  */
3608 double GeomVertexColumn::Packer_color::
3609 get_data1d(const unsigned char *pointer) {
3610  switch (_column->get_numeric_type()) {
3611  case NT_uint8:
3612  return (*(const uint8_t *)pointer) / 255.0;
3613 
3614  case NT_uint16:
3615  return (*(const uint16_t *)pointer) / 65535.0;
3616 
3617  case NT_uint32:
3618  return (*(const uint32_t *)pointer) / 4294967295.0;
3619 
3620  case NT_packed_dcba:
3621  {
3622  uint32_t dword = *(const uint32_t *)pointer;
3623  return GeomVertexData::unpack_abcd_d(dword) / 255.0;
3624  }
3625 
3626  case NT_packed_dabc:
3627  {
3628  uint32_t dword = *(const uint32_t *)pointer;
3629  return GeomVertexData::unpack_abcd_b(dword) / 255.0;
3630  }
3631 
3632  case NT_float32:
3633  return *(const PN_float32 *)pointer;
3634 
3635  case NT_float64:
3636  return *(const PN_float64 *)pointer;
3637 
3638  default:
3639  nassertr(false, 0.0);
3640  }
3641 
3642  return 0.0;
3643 }
3644 
3645 /**
3646  *
3647  */
3648 const LVecBase2d &GeomVertexColumn::Packer_color::
3649 get_data2d(const unsigned char *pointer) {
3650  if (_column->get_num_values() == 3) {
3651  const LVecBase3d &v3 = get_data3d(pointer);
3652  _v2d.set(v3[0], v3[1]);
3653  return _v2d;
3654  } else {
3655  const LVecBase4d &v4 = get_data4d(pointer);
3656  _v2d.set(v4[0], v4[1]);
3657  return _v2d;
3658  }
3659 }
3660 
3661 /**
3662  *
3663  */
3664 const LVecBase3d &GeomVertexColumn::Packer_color::
3665 get_data3d(const unsigned char *pointer) {
3666  if (_column->get_num_values() == 3) {
3667  switch (_column->get_numeric_type()) {
3668  case NT_uint8:
3669  {
3670  const uint8_t *pi = (const uint8_t *)pointer;
3671  _v3d.set(pi[0], pi[1], pi[2]);
3672  _v3d /= 255.0;
3673  }
3674  return _v3d;
3675 
3676  case NT_uint16:
3677  {
3678  const uint16_t *pi = (const uint16_t *)pointer;
3679  _v3d.set(pi[0], pi[1], pi[2]);
3680  _v3d /= 65535.0;
3681  }
3682  return _v3d;
3683 
3684  case NT_uint32:
3685  {
3686  const uint32_t *pi = (const uint32_t *)pointer;
3687  _v3d.set(pi[0], pi[1], pi[2]);
3688  _v3d /= 4294967295.0;
3689  }
3690  return _v3d;
3691 
3692  case NT_packed_dcba:
3693  case NT_packed_dabc:
3694  nassertr(false, _v3d);
3695  return _v3d;
3696 
3697  case NT_float32:
3698  {
3699  const PN_float32 *pi = (const PN_float32 *)pointer;
3700  _v3d.set(pi[0], pi[1], pi[2]);
3701  }
3702  return _v3d;
3703 
3704  case NT_float64:
3705  {
3706  const PN_float64 *pi = (const PN_float64 *)pointer;
3707  _v3d.set(pi[0], pi[1], pi[2]);
3708  }
3709  return _v3d;
3710 
3711  case NT_stdfloat:
3712  case NT_int8:
3713  case NT_int16:
3714  case NT_int32:
3715  nassertr(false, _v3d);
3716  return _v3d;
3717 
3718  case NT_packed_ufloat:
3719  {
3720  uint32_t dword = *(const uint32_t *)pointer;
3721  _v3d.set(GeomVertexData::unpack_ufloat_a(dword),
3724  }
3725  return _v3d;
3726  }
3727  } else {
3728  const LVecBase4d &v4 = get_data4d(pointer);
3729  _v3d.set(v4[0], v4[1], v4[2]);
3730  return _v3d;
3731  }
3732 
3733  return _v3d;
3734 }
3735 
3736 /**
3737  *
3738  */
3739 const LVecBase4d &GeomVertexColumn::Packer_color::
3740 get_data4d(const unsigned char *pointer) {
3741  if (_column->get_num_values() == 3) {
3742  const LVecBase3d &v3 = get_data3d(pointer);
3743  _v4d.set(v3[0], v3[1], v3[2], 1.0);
3744  return _v4d;
3745  } else {
3746  switch (_column->get_numeric_type()) {
3747  case NT_uint8:
3748  {
3749  const uint8_t *pi = (const uint8_t *)pointer;
3750  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
3751  _v4d /= 255.0;
3752  }
3753  return _v4d;
3754 
3755  case NT_uint16:
3756  {
3757  const uint16_t *pi = (const uint16_t *)pointer;
3758  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
3759  _v4d /= 65535.0;
3760  }
3761  return _v4d;
3762 
3763  case NT_uint32:
3764  {
3765  const uint32_t *pi = (const uint32_t *)pointer;
3766  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
3767  _v4d /= 4294967295.0;
3768  }
3769  return _v4d;
3770 
3771  case NT_packed_dcba:
3772  {
3773  uint32_t dword = *(const uint32_t *)pointer;
3774  _v4d.set(GeomVertexData::unpack_abcd_d(dword),
3778  _v4d /= 255.0;
3779  }
3780  return _v4d;
3781 
3782  case NT_packed_dabc:
3783  {
3784  uint32_t dword = *(const uint32_t *)pointer;
3785  _v4d.set(GeomVertexData::unpack_abcd_b(dword),
3789  _v4d /= 255.0;
3790  }
3791  return _v4d;
3792 
3793  case NT_float32:
3794  {
3795  const PN_float32 *pi = (const PN_float32 *)pointer;
3796  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
3797  }
3798  return _v4d;
3799 
3800  case NT_float64:
3801  {
3802  const PN_float64 *pi = (const PN_float64 *)pointer;
3803  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
3804  }
3805  return _v4d;
3806 
3807  case NT_stdfloat:
3808  case NT_int8:
3809  case NT_int16:
3810  case NT_int32:
3811  case NT_packed_ufloat:
3812  nassertr(false, _v4d);
3813  return _v4d;
3814  }
3815  }
3816 
3817  return _v4d;
3818 }
3819 
3820 /**
3821  *
3822  */
3823 void GeomVertexColumn::Packer_color::
3824 set_data1f(unsigned char *pointer, float data) {
3825  if (_column->get_num_values() == 3) {
3826  set_data3f(pointer, LVecBase3f(data, 0.0f, 0.0f));
3827  } else {
3828  set_data4f(pointer, LVecBase4f(data, 0.0f, 0.0f, 1.0f));
3829  }
3830 }
3831 
3832 /**
3833  *
3834  */
3835 void GeomVertexColumn::Packer_color::
3836 set_data2f(unsigned char *pointer, const LVecBase2f &data) {
3837  if (_column->get_num_values() == 3) {
3838  set_data3f(pointer, LVecBase3f(data[0], data[1], 0.0f));
3839  } else {
3840  set_data4f(pointer, LVecBase4f(data[0], data[1], 0.0f, 1.0f));
3841  }
3842 }
3843 
3844 /**
3845  *
3846  */
3847 void GeomVertexColumn::Packer_color::
3848 set_data3f(unsigned char *pointer, const LVecBase3f &data) {
3849  if (_column->get_num_values() == 3) {
3850  switch (_column->get_numeric_type()) {
3851  case NT_uint8:
3852  {
3853  LVecBase3f scaled = data * 255.0f;
3854  uint8_t *pi = (uint8_t *)pointer;
3855  pi[0] = (unsigned int)scaled[0];
3856  pi[1] = (unsigned int)scaled[1];
3857  pi[2] = (unsigned int)scaled[2];
3858  }
3859  break;
3860 
3861  case NT_uint16:
3862  {
3863  LVecBase3f scaled = data * 65535.0f;
3864  uint16_t *pi = (uint16_t *)pointer;
3865  pi[0] = (unsigned int)scaled[0];
3866  pi[1] = (unsigned int)scaled[1];
3867  pi[2] = (unsigned int)scaled[2];
3868  }
3869  break;
3870 
3871  case NT_uint32:
3872  {
3873  LVecBase3f scaled = data * 4294967295.0f;
3874  uint32_t *pi = (uint32_t *)pointer;
3875  pi[0] = (unsigned int)scaled[0];
3876  pi[1] = (unsigned int)scaled[1];
3877  pi[2] = (unsigned int)scaled[2];
3878  }
3879  break;
3880 
3881  case NT_packed_dcba:
3882  {
3883  LVecBase3f scaled = data * 255.0f;
3884  *(uint32_t *)pointer = GeomVertexData::pack_abcd(
3885  1.0f, scaled[2], scaled[1], scaled[0]);
3886  }
3887  break;
3888 
3889  case NT_packed_dabc:
3890  {
3891  LVecBase3f scaled = data * 255.0f;
3892  *(uint32_t *)pointer = GeomVertexData::pack_abcd(
3893  1.0f, scaled[0], scaled[1], scaled[2]);
3894  }
3895  break;
3896 
3897  case NT_float32:
3898  {
3899  PN_float32 *pi = (PN_float32 *)pointer;
3900  pi[0] = data[0];
3901  pi[1] = data[1];
3902  pi[2] = data[2];
3903  }
3904  break;
3905 
3906  case NT_float64:
3907  {
3908  PN_float64 *pi = (PN_float64 *)pointer;
3909  pi[0] = data[0];
3910  pi[1] = data[1];
3911  pi[2] = data[2];
3912  }
3913  break;
3914 
3915  case NT_stdfloat:
3916  case NT_int8:
3917  case NT_int16:
3918  case NT_int32:
3919  nassertv(false);
3920  break;
3921 
3922  case NT_packed_ufloat:
3923  *(uint32_t *)pointer = GeomVertexData::pack_ufloat(data[0], data[1], data[2]);
3924  break;
3925  }
3926  } else {
3927  set_data4f(pointer, LVecBase4f(data[0], data[1], data[2], 1.0f));
3928  }
3929 }
3930 
3931 /**
3932  *
3933  */
3934 void GeomVertexColumn::Packer_color::
3935 set_data4f(unsigned char *pointer, const LVecBase4f &data) {
3936  if (_column->get_num_values() == 3) {
3937  set_data3f(pointer, LVecBase3f(data[0], data[1], data[2]));
3938  } else {
3939  switch (_column->get_numeric_type()) {
3940  case NT_uint8:
3941  {
3942  LVecBase4f scaled = data * 255.0f;
3943  uint8_t *pi = (uint8_t *)pointer;
3944  pi[0] = (unsigned int)scaled[0];
3945  pi[1] = (unsigned int)scaled[1];
3946  pi[2] = (unsigned int)scaled[2];
3947  pi[3] = (unsigned int)scaled[3];
3948  }
3949  break;
3950 
3951  case NT_uint16:
3952  {
3953  LVecBase4f scaled = data * 65535.0f;
3954  uint16_t *pi = (uint16_t *)pointer;
3955  pi[0] = (unsigned int)scaled[0];
3956  pi[1] = (unsigned int)scaled[1];
3957  pi[2] = (unsigned int)scaled[2];
3958  pi[3] = (unsigned int)scaled[3];
3959  }
3960  break;
3961 
3962  case NT_uint32:
3963  {
3964  LVecBase4f scaled = data * 4294967295.0f;
3965  uint32_t *pi = (uint32_t *)pointer;
3966  pi[0] = (unsigned int)scaled[0];
3967  pi[1] = (unsigned int)scaled[1];
3968  pi[2] = (unsigned int)scaled[2];
3969  pi[3] = (unsigned int)scaled[3];
3970  }
3971  break;
3972 
3973  case NT_packed_dcba:
3974  {
3975  LVecBase4f scaled = data * 255.0f;
3976  *(uint32_t *)pointer = GeomVertexData::pack_abcd(
3977  scaled[3], scaled[2], scaled[1], scaled[0]);
3978  }
3979  break;
3980 
3981  case NT_packed_dabc:
3982  {
3983  LVecBase4f scaled = data * 255.0f;
3984  *(uint32_t *)pointer = GeomVertexData::pack_abcd(
3985  scaled[3], scaled[0], scaled[1], scaled[2]);
3986  }
3987  break;
3988 
3989  case NT_float32:
3990  {
3991  PN_float32 *pi = (PN_float32 *)pointer;
3992  pi[0] = data[0];
3993  pi[1] = data[1];
3994  pi[2] = data[2];
3995  pi[3] = data[3];
3996  }
3997  break;
3998 
3999  case NT_float64:
4000  {
4001  PN_float64 *pi = (PN_float64 *)pointer;
4002  pi[0] = data[0];
4003  pi[1] = data[1];
4004  pi[2] = data[2];
4005  pi[3] = data[3];
4006  }
4007  break;
4008 
4009  case NT_stdfloat:
4010  case NT_int8:
4011  case NT_int16:
4012  case NT_int32:
4013  nassertv(false);
4014  break;
4015 
4016  case NT_packed_ufloat:
4017  nassertv(false);
4018  break;
4019  }
4020  }
4021 }
4022 
4023 /**
4024  *
4025  */
4026 void GeomVertexColumn::Packer_color::
4027 set_data1d(unsigned char *pointer, double data) {
4028  if (_column->get_num_values() == 3) {
4029  set_data3d(pointer, LVecBase3d(data, 0.0, 0.0));
4030  } else {
4031  set_data4d(pointer, LVecBase4d(data, 0.0, 0.0, 1.0));
4032  }
4033 }
4034 
4035 /**
4036  *
4037  */
4038 void GeomVertexColumn::Packer_color::
4039 set_data2d(unsigned char *pointer, const LVecBase2d &data) {
4040  if (_column->get_num_values() == 3) {
4041  set_data3d(pointer, LVecBase3d(data[0], data[1], 0.0));
4042  } else {
4043  set_data4d(pointer, LVecBase4d(data[0], data[1], 0.0, 1.0));
4044  }
4045 }
4046 
4047 /**
4048  *
4049  */
4050 void GeomVertexColumn::Packer_color::
4051 set_data3d(unsigned char *pointer, const LVecBase3d &data) {
4052  if (_column->get_num_values() == 3) {
4053  switch (_column->get_numeric_type()) {
4054  case NT_uint8:
4055  {
4056  LVecBase3d scaled = data * 255.0;
4057  uint8_t *pi = (uint8_t *)pointer;
4058  pi[0] = (unsigned int)scaled[0];
4059  pi[1] = (unsigned int)scaled[1];
4060  pi[2] = (unsigned int)scaled[2];
4061  }
4062  break;
4063 
4064  case NT_uint16:
4065  {
4066  LVecBase3d scaled = data * 65535.0;
4067  uint16_t *pi = (uint16_t *)pointer;
4068  pi[0] = (unsigned int)scaled[0];
4069  pi[1] = (unsigned int)scaled[1];
4070  pi[2] = (unsigned int)scaled[2];
4071  }
4072  break;
4073 
4074  case NT_uint32:
4075  {
4076  LVecBase3d scaled = data * 4294967295.0;
4077  uint32_t *pi = (uint32_t *)pointer;
4078  pi[0] = (unsigned int)scaled[0];
4079  pi[1] = (unsigned int)scaled[1];
4080  pi[2] = (unsigned int)scaled[2];
4081  }
4082  break;
4083 
4084  case NT_packed_dcba:
4085  {
4086  LVecBase3d scaled = data * 255.0;
4087  *(uint32_t *)pointer = GeomVertexData::pack_abcd(
4088  1.0, scaled[2], scaled[1], scaled[0]);
4089  }
4090  break;
4091 
4092  case NT_packed_dabc:
4093  {
4094  LVecBase3d scaled = data * 255.0;
4095  *(uint32_t *)pointer = GeomVertexData::pack_abcd(
4096  1.0, scaled[0], scaled[1], scaled[2]);
4097  }
4098  break;
4099 
4100  case NT_float32:
4101  {
4102  PN_float32 *pi = (PN_float32 *)pointer;
4103  pi[0] = data[0];
4104  pi[1] = data[1];
4105  pi[2] = data[2];
4106  }
4107  break;
4108 
4109  case NT_float64:
4110  {
4111  PN_float64 *pi = (PN_float64 *)pointer;
4112  pi[0] = data[0];
4113  pi[1] = data[1];
4114  pi[2] = data[2];
4115  }
4116  break;
4117 
4118  case NT_stdfloat:
4119  case NT_int8:
4120  case NT_int16:
4121  case NT_int32:
4122  nassertv(false);
4123  break;
4124 
4125  case NT_packed_ufloat:
4126  *(uint32_t *)pointer = GeomVertexData::pack_ufloat(data[0], data[1], data[2]);
4127  break;
4128  }
4129  } else {
4130  set_data4d(pointer, LVecBase4d(data[0], data[1], data[2], 1.0f));
4131  }
4132 }
4133 
4134 /**
4135  *
4136  */
4137 void GeomVertexColumn::Packer_color::
4138 set_data4d(unsigned char *pointer, const LVecBase4d &data) {
4139  if (_column->get_num_values() == 3) {
4140  set_data3d(pointer, LVecBase3d(data[0], data[1], data[2]));
4141  } else {
4142  switch (_column->get_numeric_type()) {
4143  case NT_uint8:
4144  {
4145  LVecBase4d scaled = data * 255.0;
4146  uint8_t *pi = (uint8_t *)pointer;
4147  pi[0] = (unsigned int)scaled[0];
4148  pi[1] = (unsigned int)scaled[1];
4149  pi[2] = (unsigned int)scaled[2];
4150  pi[3] = (unsigned int)scaled[3];
4151  }
4152  break;
4153 
4154  case NT_uint16:
4155  {
4156  LVecBase4d scaled = data * 65535.0;
4157  uint16_t *pi = (uint16_t *)pointer;
4158  pi[0] = (unsigned int)scaled[0];
4159  pi[1] = (unsigned int)scaled[1];
4160  pi[2] = (unsigned int)scaled[2];
4161  pi[3] = (unsigned int)scaled[3];
4162  }
4163  break;
4164 
4165  case NT_uint32:
4166  {
4167  LVecBase4d scaled = data * 4294967295.0;
4168  uint32_t *pi = (uint32_t *)pointer;
4169  pi[0] = (unsigned int)scaled[0];
4170  pi[1] = (unsigned int)scaled[1];
4171  pi[2] = (unsigned int)scaled[2];
4172  pi[3] = (unsigned int)scaled[3];
4173  }
4174  break;
4175 
4176  case NT_packed_dcba:
4177  {
4178  LVecBase4d scaled = data * 255.0;
4179  *(uint32_t *)pointer = GeomVertexData::pack_abcd(
4180  scaled[3], scaled[2], scaled[1], scaled[0]);
4181  }
4182  break;
4183 
4184  case NT_packed_dabc:
4185  {
4186  LVecBase4d scaled = data * 255.0;
4187  *(uint32_t *)pointer = GeomVertexData::pack_abcd(
4188  scaled[3], scaled[0], scaled[1], scaled[2]);
4189  }
4190  break;
4191 
4192  case NT_float32:
4193  {
4194  PN_float32 *pi = (PN_float32 *)pointer;
4195  pi[0] = data[0];
4196  pi[1] = data[1];
4197  pi[2] = data[2];
4198  pi[3] = data[3];
4199  }
4200  break;
4201 
4202  case NT_float64:
4203  {
4204  PN_float64 *pi = (PN_float64 *)pointer;
4205  pi[0] = data[0];
4206  pi[1] = data[1];
4207  pi[2] = data[2];
4208  pi[3] = data[3];
4209  }
4210  break;
4211 
4212  case NT_stdfloat:
4213  case NT_int8:
4214  case NT_int16:
4215  case NT_int32:
4216  nassertv(false);
4217  break;
4218 
4219  case NT_packed_ufloat:
4220  nassertv(false);
4221  break;
4222  }
4223  }
4224 }
4225 
4226 /**
4227  *
4228  */
4229 const LVecBase3f &GeomVertexColumn::Packer_float32_3::
4230 get_data3f(const unsigned char *pointer) {
4231  const PN_float32 *pi = (const PN_float32 *)pointer;
4232  _v3.set(pi[0], pi[1], pi[2]);
4233  return _v3;
4234 }
4235 
4236 /**
4237  *
4238  */
4239 void GeomVertexColumn::Packer_float32_3::
4240 set_data3f(unsigned char *pointer, const LVecBase3f &data) {
4241  PN_float32 *pi = (PN_float32 *)pointer;
4242  pi[0] = data[0];
4243  pi[1] = data[1];
4244  pi[2] = data[2];
4245 }
4246 
4247 /**
4248  *
4249  */
4250 const LVecBase2f &GeomVertexColumn::Packer_point_float32_2::
4251 get_data2f(const unsigned char *pointer) {
4252  const PN_float32 *pi = (const PN_float32 *)pointer;
4253  _v2.set(pi[0], pi[1]);
4254  return _v2;
4255 }
4256 
4257 /**
4258  *
4259  */
4260 void GeomVertexColumn::Packer_point_float32_2::
4261 set_data2f(unsigned char *pointer, const LVecBase2f &data) {
4262  PN_float32 *pi = (PN_float32 *)pointer;
4263  pi[0] = data[0];
4264  pi[1] = data[1];
4265 }
4266 
4267 /**
4268  *
4269  */
4270 const LVecBase3f &GeomVertexColumn::Packer_point_float32_3::
4271 get_data3f(const unsigned char *pointer) {
4272  const PN_float32 *pi = (const PN_float32 *)pointer;
4273  _v3.set(pi[0], pi[1], pi[2]);
4274  return _v3;
4275 }
4276 
4277 /**
4278  *
4279  */
4280 void GeomVertexColumn::Packer_point_float32_3::
4281 set_data3f(unsigned char *pointer, const LVecBase3f &data) {
4282  PN_float32 *pi = (PN_float32 *)pointer;
4283  pi[0] = data[0];
4284  pi[1] = data[1];
4285  pi[2] = data[2];
4286 }
4287 
4288 /**
4289  *
4290  */
4291 const LVecBase4f &GeomVertexColumn::Packer_point_float32_4::
4292 get_data4f(const unsigned char *pointer) {
4293  const PN_float32 *pi = (const PN_float32 *)pointer;
4294  _v4.set(pi[0], pi[1], pi[2], pi[3]);
4295  return _v4;
4296 }
4297 
4298 /**
4299  *
4300  */
4301 void GeomVertexColumn::Packer_point_float32_4::
4302 set_data4f(unsigned char *pointer, const LVecBase4f &data) {
4303  PN_float32 *pi = (PN_float32 *)pointer;
4304  pi[0] = data[0];
4305  pi[1] = data[1];
4306  pi[2] = data[2];
4307  pi[3] = data[3];
4308 }
4309 
4310 /**
4311  *
4312  */
4313 const LVecBase3f &GeomVertexColumn::Packer_nativefloat_3::
4314 get_data3f(const unsigned char *pointer) {
4315  return *(const LVecBase3f *)pointer;
4316 }
4317 
4318 /**
4319  *
4320  */
4321 const LVecBase2f &GeomVertexColumn::Packer_point_nativefloat_2::
4322 get_data2f(const unsigned char *pointer) {
4323  return *(const LVecBase2f *)pointer;
4324 }
4325 
4326 /**
4327  *
4328  */
4329 const LVecBase3f &GeomVertexColumn::Packer_point_nativefloat_3::
4330 get_data3f(const unsigned char *pointer) {
4331  return *(const LVecBase3f *)pointer;
4332 }
4333 
4334 /**
4335  *
4336  */
4337 const LVecBase4f &GeomVertexColumn::Packer_point_nativefloat_4::
4338 get_data4f(const unsigned char *pointer) {
4339  return *(const LVecBase4f *)pointer;
4340 }
4341 
4342 /**
4343  *
4344  */
4345 const LVecBase3d &GeomVertexColumn::Packer_float64_3::
4346 get_data3d(const unsigned char *pointer) {
4347  const PN_float64 *pi = (const PN_float64 *)pointer;
4348  _v3d.set(pi[0], pi[1], pi[2]);
4349  return _v3d;
4350 }
4351 
4352 /**
4353  *
4354  */
4355 void GeomVertexColumn::Packer_float64_3::
4356 set_data3d(unsigned char *pointer, const LVecBase3d &data) {
4357  PN_float64 *pi = (PN_float64 *)pointer;
4358  pi[0] = data[0];
4359  pi[1] = data[1];
4360  pi[2] = data[2];
4361 }
4362 
4363 /**
4364  *
4365  */
4366 const LVecBase2d &GeomVertexColumn::Packer_point_float64_2::
4367 get_data2d(const unsigned char *pointer) {
4368  const PN_float64 *pi = (const PN_float64 *)pointer;
4369  _v2d.set(pi[0], pi[1]);
4370  return _v2d;
4371 }
4372 
4373 /**
4374  *
4375  */
4376 void GeomVertexColumn::Packer_point_float64_2::
4377 set_data2d(unsigned char *pointer, const LVecBase2d &data) {
4378  PN_float64 *pi = (PN_float64 *)pointer;
4379  pi[0] = data[0];
4380  pi[1] = data[1];
4381 }
4382 
4383 /**
4384  *
4385  */
4386 const LVecBase3d &GeomVertexColumn::Packer_point_float64_3::
4387 get_data3d(const unsigned char *pointer) {
4388  const PN_float64 *pi = (const PN_float64 *)pointer;
4389  _v3d.set(pi[0], pi[1], pi[2]);
4390  return _v3d;
4391 }
4392 
4393 /**
4394  *
4395  */
4396 void GeomVertexColumn::Packer_point_float64_3::
4397 set_data3d(unsigned char *pointer, const LVecBase3d &data) {
4398  PN_float64 *pi = (PN_float64 *)pointer;
4399  pi[0] = data[0];
4400  pi[1] = data[1];
4401  pi[2] = data[2];
4402 }
4403 
4404 /**
4405  *
4406  */
4407 const LVecBase4d &GeomVertexColumn::Packer_point_float64_4::
4408 get_data4d(const unsigned char *pointer) {
4409  const PN_float64 *pi = (const PN_float64 *)pointer;
4410  _v4d.set(pi[0], pi[1], pi[2], pi[3]);
4411  return _v4d;
4412 }
4413 
4414 /**
4415  *
4416  */
4417 void GeomVertexColumn::Packer_point_float64_4::
4418 set_data4d(unsigned char *pointer, const LVecBase4d &data) {
4419  PN_float64 *pi = (PN_float64 *)pointer;
4420  pi[0] = data[0];
4421  pi[1] = data[1];
4422  pi[2] = data[2];
4423  pi[3] = data[3];
4424 }
4425 
4426 /**
4427  *
4428  */
4429 const LVecBase3d &GeomVertexColumn::Packer_nativedouble_3::
4430 get_data3d(const unsigned char *pointer) {
4431  return *(const LVecBase3d *)pointer;
4432 }
4433 
4434 /**
4435  *
4436  */
4437 const LVecBase2d &GeomVertexColumn::Packer_point_nativedouble_2::
4438 get_data2d(const unsigned char *pointer) {
4439  return *(const LVecBase2d *)pointer;
4440 }
4441 
4442 /**
4443  *
4444  */
4445 const LVecBase3d &GeomVertexColumn::Packer_point_nativedouble_3::
4446 get_data3d(const unsigned char *pointer) {
4447  return *(const LVecBase3d *)pointer;
4448 }
4449 
4450 /**
4451  *
4452  */
4453 const LVecBase4d &GeomVertexColumn::Packer_point_nativedouble_4::
4454 get_data4d(const unsigned char *pointer) {
4455  return *(const LVecBase4d *)pointer;
4456 }
4457 
4458 /**
4459  *
4460  */
4461 const LVecBase4f &GeomVertexColumn::Packer_argb_packed::
4462 get_data4f(const unsigned char *pointer) {
4463  uint32_t dword = *(const uint32_t *)pointer;
4464  _v4.set(GeomVertexData::unpack_abcd_b(dword),
4468  _v4 /= 255.0f;
4469  return _v4;
4470 }
4471 
4472 /**
4473  *
4474  */
4475 void GeomVertexColumn::Packer_argb_packed::
4476 set_data4f(unsigned char *pointer, const LVecBase4f &data) {
4477  // when packing an argb, we want to make sure we cap the input values at 1
4478  // since going above one will cause the value to be truncated.
4479  *(uint32_t *)pointer = GeomVertexData::pack_abcd
4480  ((unsigned int)(min(max(data[3], 0.0f), 1.0f) * 255.0f),
4481  (unsigned int)(min(max(data[0], 0.0f), 1.0f) * 255.0f),
4482  (unsigned int)(min(max(data[1], 0.0f), 1.0f) * 255.0f),
4483  (unsigned int)(min(max(data[2], 0.0f), 1.0f) * 255.0f));
4484 }
4485 
4486 /**
4487  *
4488  */
4489 const LVecBase4f &GeomVertexColumn::Packer_rgba_uint8_4::
4490 get_data4f(const unsigned char *pointer) {
4491  _v4.set((float)pointer[0], (float)pointer[1],
4492  (float)pointer[2], (float)pointer[3]);
4493  _v4 /= 255.0f;
4494  return _v4;
4495 }
4496 
4497 /**
4498  *
4499  */
4500 void GeomVertexColumn::Packer_rgba_uint8_4::
4501 set_data4f(unsigned char *pointer, const LVecBase4f &data) {
4502  pointer[0] = (unsigned int)(min(max(data[0], 0.0f), 1.0f) * 255.0f);
4503  pointer[1] = (unsigned int)(min(max(data[1], 0.0f), 1.0f) * 255.0f);
4504  pointer[2] = (unsigned int)(min(max(data[2], 0.0f), 1.0f) * 255.0f);
4505  pointer[3] = (unsigned int)(min(max(data[3], 0.0f), 1.0f) * 255.0f);
4506 }
4507 
4508 /**
4509  *
4510  */
4511 const LVecBase4f &GeomVertexColumn::Packer_rgba_float32_4::
4512 get_data4f(const unsigned char *pointer) {
4513  const PN_float32 *pi = (const PN_float32 *)pointer;
4514  _v4.set(pi[0], pi[1], pi[2], pi[3]);
4515  return _v4;
4516 }
4517 
4518 /**
4519  *
4520  */
4521 void GeomVertexColumn::Packer_rgba_float32_4::
4522 set_data4f(unsigned char *pointer, const LVecBase4f &data) {
4523  PN_float32 *pi = (PN_float32 *)pointer;
4524  pi[0] = data[0];
4525  pi[1] = data[1];
4526  pi[2] = data[2];
4527  pi[3] = data[3];
4528 }
4529 
4530 /**
4531  *
4532  */
4533 const LVecBase4f &GeomVertexColumn::Packer_rgba_nativefloat_4::
4534 get_data4f(const unsigned char *pointer) {
4535  return *(const LVecBase4f *)pointer;
4536 }
4537 
4538 /**
4539  *
4540  */
4541 int GeomVertexColumn::Packer_uint16_1::
4542 get_data1i(const unsigned char *pointer) {
4543  return *(const uint16_t *)pointer;
4544 }
4545 
4546 /**
4547  *
4548  */
4549 void GeomVertexColumn::Packer_uint16_1::
4550 set_data1i(unsigned char *pointer, int data) {
4551  *(uint16_t *)pointer = data;
4552  nassertv(*(uint16_t *)pointer == data);
4553 }
static unsigned int unpack_abcd_d(uint32_t data)
Returns the fourth packed value from a DirectX-style NT_packed_abcd.
Contents get_contents() const
Returns the token representing the semantic meaning of the stored value.
uint8_t get_uint8()
Extracts an unsigned 8-bit integer.
void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is called by make_from_bam to read in all of the relevant data from the BamFil...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:110
void set_contents(Contents contents)
Changes the semantic meaning of an existing column.
NumericType get_numeric_type() const
Returns the token representing the numeric type of the data storage.
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:35
static unsigned int unpack_abcd_b(uint32_t data)
Returns the second packed value from a DirectX-style NT_packed_abcd.
void set_start(int start)
Changes the start byte of an existing column.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being written.
Definition: bamWriter.I:59
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:63
void set_num_components(int num_components)
Changes the number of components of an existing column.
void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
static unsigned int unpack_abcd_c(uint32_t data)
Returns the third packed value from a DirectX-style NT_packed_abcd.
static float unpack_ufloat_a(uint32_t data)
Unpacks an unsigned float11 value from an uint32.
int get_file_minor_ver() const
Returns the minor version number of the Bam file currently being read.
Definition: bamReader.I:83
This defines how a single column is interleaved within a vertex array stored within a Geom.
void add_uint16(uint16_t value)
Adds an unsigned 16-bit integer to the datagram.
Definition: datagram.I:85
static float unpack_ufloat_b(uint32_t data)
Unpacks an unsigned float11 value from an uint32.
static uint32_t pack_abcd(unsigned int a, unsigned int b, unsigned int c, unsigned int d)
Packs four values in a DirectX-style NT_packed_abcd value.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_num_values() const
Returns the number of numeric values of the column: the number of distinct numeric values that go int...
void set_name(InternalName *name)
Replaces the name of an existing column.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Encodes a string name in a hash table, mapping it to a pointer.
Definition: internalName.h:38
static uint32_t pack_ufloat(float a, float b, float c)
Packs three float values in an unsigned 32-bit int.
static unsigned int unpack_abcd_a(uint32_t data)
Returns the first packed value from a DirectX-style NT_packed_abcd.
void set_numeric_type(NumericType numeric_type)
Changes the numeric type an existing column.
void set_column_alignment(int column_alignment)
Changes the column alignment of an existing column.
uint16_t get_uint16()
Extracts an unsigned 16-bit integer.
bool read_pointer(DatagramIterator &scan)
The interface for reading a pointer to another object from a Bam file.
Definition: bamReader.cxx:610
void add_uint8(uint8_t value)
Adds an unsigned 8-bit integer to the datagram.
Definition: datagram.I:50
A class to retrieve the individual data elements previously stored in a Datagram.
const InternalName * get_name() const
Returns the name of this particular data field, e.g.
int get_num_components() const
Returns the number of components of the column: the number of instances of the NumericType in each el...
static float unpack_ufloat_c(uint32_t data)
Unpacks an unsigned float10 value from an uint32.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
int complete_pointers(TypedWritable **plist, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void write_pointer(Datagram &packet, const TypedWritable *dest)
The interface for writing a pointer to another object to a Bam file.
Definition: bamWriter.cxx:317
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.