22 INLINE GeomVertexColumn::
33 INLINE GeomVertexColumn::
35 NumericType numeric_type, Contents contents,
36 int start,
int column_alignment) :
38 _num_components(num_components),
39 _numeric_type(numeric_type),
42 _column_alignment(column_alignment),
53 INLINE GeomVertexColumn::
56 _num_components(copy._num_components),
57 _numeric_type(copy._numeric_type),
58 _contents(copy._contents),
60 _column_alignment(copy._column_alignment),
71 INLINE GeomVertexColumn::
100 return _num_components;
127 return _num_elements;
138 return _numeric_type;
176 return _column_alignment;
188 return _element_stride;
199 return _component_bytes;
246 return (_start < start_byte + num_bytes &&
247 _start + _total_bytes > start_byte);
261 return (_num_components == other._num_components &&
262 _numeric_type == other._numeric_type &&
263 _contents == other._contents);
275 return (_num_components == 1 &&
276 _numeric_type == NT_packed_dabc &&
277 _contents == C_color);
289 return (_num_components == 4 &&
290 _numeric_type == NT_uint8 &&
291 _contents == C_color);
302 if (_name != other._name) {
303 return _name < other._name ? -1 : 1;
305 if (_num_components != other._num_components) {
306 return _num_components - other._num_components;
308 if (_numeric_type != other._numeric_type) {
309 return (
int)_numeric_type - (int)other._numeric_type;
311 if (_contents != other._contents) {
312 return (
int)_contents - (int)other._contents;
314 if (_start != other._start) {
315 return _start - other._start;
317 if (_column_alignment != other._column_alignment) {
318 return _column_alignment - other._column_alignment;
339 INLINE
bool GeomVertexColumn::
354 if (_start != other._start) {
355 return _start < other._start;
357 if (_total_bytes < other._total_bytes) {
358 return _total_bytes < other._total_bytes;
377 INLINE
float GeomVertexColumn::Packer::
378 maybe_scale_color_f(
unsigned int value) {
379 if (_column->get_contents() == C_color) {
380 return (
float)value / 255.0f;
392 INLINE
void GeomVertexColumn::Packer::
393 maybe_scale_color_f(
unsigned int a,
unsigned int b) {
394 if (_column->get_contents() == C_color) {
395 _v2.set((
float)a / 255.0f,
398 _v2.set((
float)a, (
float)b);
408 INLINE
void GeomVertexColumn::Packer::
409 maybe_scale_color_f(
unsigned int a,
unsigned int b,
unsigned int c) {
410 if (_column->get_contents() == C_color) {
411 _v3.set((
float)a / 255.0f,
415 _v3.set((
float)a, (
float)b, (
float)c);
425 INLINE
void GeomVertexColumn::Packer::
426 maybe_scale_color_f(
unsigned int a,
unsigned int b,
unsigned int c,
428 if (_column->get_contents() == C_color) {
429 _v4.set((
float)a / 255.0f,
434 _v4.set((
float)a, (
float)b, (
float)c, (
float)d);
446 INLINE
unsigned int GeomVertexColumn::Packer::
447 maybe_unscale_color_f(
float data) {
448 if (_column->get_contents() == C_color) {
449 return (
unsigned int)(data * 255.0f);
451 return (
unsigned int)data;
462 INLINE
void GeomVertexColumn::Packer::
463 maybe_unscale_color_f(
const LVecBase2f &data) {
464 if (_column->get_contents() == C_color) {
465 _a = (
unsigned int)(data[0] * 255.0f);
466 _b = (
unsigned int)(data[1] * 255.0f);
468 _a = (
unsigned int)data[0];
469 _b = (
unsigned int)data[1];
480 INLINE
void GeomVertexColumn::Packer::
481 maybe_unscale_color_f(
const LVecBase3f &data) {
482 if (_column->get_contents() == C_color) {
483 _a = (
unsigned int)(data[0] * 255.0f);
484 _b = (
unsigned int)(data[1] * 255.0f);
485 _c = (
unsigned int)(data[2] * 255.0f);
487 _a = (
unsigned int)data[0];
488 _b = (
unsigned int)data[1];
489 _c = (
unsigned int)data[2];
500 INLINE
void GeomVertexColumn::Packer::
501 maybe_unscale_color_f(
const LVecBase4f &data) {
502 if (_column->get_contents() == C_color) {
503 _a = (
unsigned int)(data[0] * 255.0f);
504 _b = (
unsigned int)(data[1] * 255.0f);
505 _c = (
unsigned int)(data[2] * 255.0f);
506 _d = (
unsigned int)(data[3] * 255.0f);
508 _a = (
unsigned int)data[0];
509 _b = (
unsigned int)data[1];
510 _c = (
unsigned int)data[2];
511 _d = (
unsigned int)data[3];
523 INLINE
double GeomVertexColumn::Packer::
524 maybe_scale_color_d(
unsigned int value) {
525 if (_column->get_contents() == C_color) {
526 return (
double)value / 255.0;
528 return (
double)value;
538 INLINE
void GeomVertexColumn::Packer::
539 maybe_scale_color_d(
unsigned int a,
unsigned int b) {
540 if (_column->get_contents() == C_color) {
541 _v2d.set((
double)a / 255.0,
544 _v2d.set((
double)a, (
double)b);
554 INLINE
void GeomVertexColumn::Packer::
555 maybe_scale_color_d(
unsigned int a,
unsigned int b,
unsigned int c) {
556 if (_column->get_contents() == C_color) {
557 _v3d.set((
double)a / 255.0,
561 _v3d.set((
double)a, (
double)b, (
double)c);
571 INLINE
void GeomVertexColumn::Packer::
572 maybe_scale_color_d(
unsigned int a,
unsigned int b,
unsigned int c,
574 if (_column->get_contents() == C_color) {
575 _v4d.set((
double)a / 255.0,
580 _v4d.set((
double)a, (
double)b, (
double)c, (
double)d);
592 INLINE
unsigned int GeomVertexColumn::Packer::
593 maybe_unscale_color_d(
double data) {
594 if (_column->get_contents() == C_color) {
595 return (
unsigned int)(data * 255.0);
597 return (
unsigned int)data;
608 INLINE
void GeomVertexColumn::Packer::
609 maybe_unscale_color_d(
const LVecBase2d &data) {
610 if (_column->get_contents() == C_color) {
611 _a = (
unsigned int)(data[0] * 255.0);
612 _b = (
unsigned int)(data[1] * 255.0);
614 _a = (
unsigned int)data[0];
615 _b = (
unsigned int)data[1];
626 INLINE
void GeomVertexColumn::Packer::
627 maybe_unscale_color_d(
const LVecBase3d &data) {
628 if (_column->get_contents() == C_color) {
629 _a = (
unsigned int)(data[0] * 255.0);
630 _b = (
unsigned int)(data[1] * 255.0);
631 _c = (
unsigned int)(data[2] * 255.0);
633 _a = (
unsigned int)data[0];
634 _b = (
unsigned int)data[1];
635 _c = (
unsigned int)data[2];
646 INLINE
void GeomVertexColumn::Packer::
647 maybe_unscale_color_d(
const LVecBase4d &data) {
648 if (_column->get_contents() == C_color) {
649 _a = (
unsigned int)(data[0] * 255.0);
650 _b = (
unsigned int)(data[1] * 255.0);
651 _c = (
unsigned int)(data[2] * 255.0);
652 _d = (
unsigned int)(data[3] * 255.0);
654 _a = (
unsigned int)data[0];
655 _b = (
unsigned int)data[1];
656 _c = (
unsigned int)data[2];
657 _d = (
unsigned int)data[3];
bool is_uint8_rgba() const
Returns true if this column is the standard OpenGL representation of 4-component color: C_color...
This is the base class for all three-component vectors and points.
This is a const pointer to an InternalName, and should be used in lieu of a CPT(InternalName) in func...
bool overlaps_with(int start_byte, int num_bytes) const
Returns true if this column overlaps with any of the bytes in the indicated range, false if it does not.
Contents get_contents() const
Returns the token representing the semantic meaning of the stored value.
This is the base class for all two-component vectors and points.
NumericType get_numeric_type() const
Returns the token representing the numeric type of the data storage.
bool is_bytewise_equivalent(const GeomVertexColumn &other) const
Returns true if the data store of this column is exactly the same as that of the other, irrespective of name or start position within the record.
bool has_homogeneous_coord() const
Returns true if this Contents type is one that includes a homogeneous coordinate in the fourth compon...
bool is_packed_argb() const
Returns true if this column is the standard DirectX representation of 4-component color: C_color...
This is the base class for all three-component vectors and points.
This defines how a single column is interleaved within a vertex array stored within a Geom...
int get_num_elements() const
Returns the number of times this column is repeated.
bool operator==(const GeomVertexColumn &other) const
Returns true if the two columns are exactly equivalent, false otherwise.
int get_element_stride() const
This value is only relevant for matrix types.
int get_num_values() const
Returns the number of numeric values of the column: the number of distinct numeric values that go int...
bool operator<(const GeomVertexColumn &other) const
This is used to put columns in order within a particular GeomVertexArrayFormat.
int get_column_alignment() const
Returns the alignment requirements for this column.
This is the base class for all two-component vectors and points.
This is the base class for all three-component vectors and points.
int get_start() const
Returns the byte within the array record at which this column starts.
This is the base class for all three-component vectors and points.
int get_component_bytes() const
Returns the number of bytes used by each component (that is, by one element of the numeric type)...
const InternalName * get_name() const
Returns the name of this particular data field, e.g.
int get_total_bytes() const
Returns the number of bytes used by each element of the column: component_bytes * num_components...
int get_num_components() const
Returns the number of components of the column: the number of instances of the NumericType in each el...
int compare_to(const GeomVertexColumn &other) const
This is used to unquify columns, and hence formats, for the GeomVertexFormat registry.