|
@@ -34,6 +34,7 @@ GeomVertexArrayFormat::
|
|
|
GeomVertexArrayFormat() :
|
|
GeomVertexArrayFormat() :
|
|
|
_is_registered(false),
|
|
_is_registered(false),
|
|
|
_stride(0),
|
|
_stride(0),
|
|
|
|
|
+ _column_alignment(vertex_column_alignment),
|
|
|
_total_bytes(0),
|
|
_total_bytes(0),
|
|
|
_pad_to(1),
|
|
_pad_to(1),
|
|
|
_columns_unsorted(false)
|
|
_columns_unsorted(false)
|
|
@@ -51,6 +52,7 @@ GeomVertexArrayFormat(InternalName *name0, int num_components0,
|
|
|
GeomVertexArrayFormat::Contents contents0) :
|
|
GeomVertexArrayFormat::Contents contents0) :
|
|
|
_is_registered(false),
|
|
_is_registered(false),
|
|
|
_stride(0),
|
|
_stride(0),
|
|
|
|
|
+ _column_alignment(vertex_column_alignment),
|
|
|
_total_bytes(0),
|
|
_total_bytes(0),
|
|
|
_pad_to(1),
|
|
_pad_to(1),
|
|
|
_columns_unsorted(false)
|
|
_columns_unsorted(false)
|
|
@@ -72,6 +74,7 @@ GeomVertexArrayFormat(InternalName *name0, int num_components0,
|
|
|
GeomVertexArrayFormat::Contents contents1) :
|
|
GeomVertexArrayFormat::Contents contents1) :
|
|
|
_is_registered(false),
|
|
_is_registered(false),
|
|
|
_stride(0),
|
|
_stride(0),
|
|
|
|
|
+ _column_alignment(vertex_column_alignment),
|
|
|
_total_bytes(0),
|
|
_total_bytes(0),
|
|
|
_pad_to(1),
|
|
_pad_to(1),
|
|
|
_columns_unsorted(false)
|
|
_columns_unsorted(false)
|
|
@@ -97,6 +100,7 @@ GeomVertexArrayFormat(InternalName *name0, int num_components0,
|
|
|
GeomVertexArrayFormat::Contents contents2) :
|
|
GeomVertexArrayFormat::Contents contents2) :
|
|
|
_is_registered(false),
|
|
_is_registered(false),
|
|
|
_stride(0),
|
|
_stride(0),
|
|
|
|
|
+ _column_alignment(vertex_column_alignment),
|
|
|
_total_bytes(0),
|
|
_total_bytes(0),
|
|
|
_pad_to(1),
|
|
_pad_to(1),
|
|
|
_columns_unsorted(false)
|
|
_columns_unsorted(false)
|
|
@@ -126,6 +130,7 @@ GeomVertexArrayFormat(InternalName *name0, int num_components0,
|
|
|
GeomVertexArrayFormat::Contents contents3) :
|
|
GeomVertexArrayFormat::Contents contents3) :
|
|
|
_is_registered(false),
|
|
_is_registered(false),
|
|
|
_stride(0),
|
|
_stride(0),
|
|
|
|
|
+ _column_alignment(vertex_column_alignment),
|
|
|
_total_bytes(0),
|
|
_total_bytes(0),
|
|
|
_pad_to(1),
|
|
_pad_to(1),
|
|
|
_columns_unsorted(false)
|
|
_columns_unsorted(false)
|
|
@@ -145,6 +150,7 @@ GeomVertexArrayFormat::
|
|
|
GeomVertexArrayFormat(const GeomVertexArrayFormat ©) :
|
|
GeomVertexArrayFormat(const GeomVertexArrayFormat ©) :
|
|
|
_is_registered(false),
|
|
_is_registered(false),
|
|
|
_stride(copy._stride),
|
|
_stride(copy._stride),
|
|
|
|
|
+ _column_alignment(copy._column_alignment),
|
|
|
_total_bytes(copy._total_bytes),
|
|
_total_bytes(copy._total_bytes),
|
|
|
_pad_to(copy._pad_to),
|
|
_pad_to(copy._pad_to),
|
|
|
_columns_unsorted(copy._columns_unsorted)
|
|
_columns_unsorted(copy._columns_unsorted)
|
|
@@ -164,6 +170,7 @@ void GeomVertexArrayFormat::
|
|
|
operator = (const GeomVertexArrayFormat ©) {
|
|
operator = (const GeomVertexArrayFormat ©) {
|
|
|
nassertv(!_is_registered);
|
|
nassertv(!_is_registered);
|
|
|
_stride = copy._stride;
|
|
_stride = copy._stride;
|
|
|
|
|
+ _column_alignment = copy._column_alignment;
|
|
|
_total_bytes = copy._total_bytes;
|
|
_total_bytes = copy._total_bytes;
|
|
|
_pad_to = copy._pad_to;
|
|
_pad_to = copy._pad_to;
|
|
|
|
|
|
|
@@ -233,6 +240,10 @@ add_column(InternalName *name, int num_components,
|
|
|
GeomVertexArrayFormat::Contents contents, int start) {
|
|
GeomVertexArrayFormat::Contents contents, int start) {
|
|
|
if (start < 0) {
|
|
if (start < 0) {
|
|
|
start = _total_bytes;
|
|
start = _total_bytes;
|
|
|
|
|
+ if (_column_alignment > 1) {
|
|
|
|
|
+ // Round up to the next multiple of _column_alignment.
|
|
|
|
|
+ start = ((start + (_column_alignment - 1)) / _column_alignment) * _column_alignment;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
GeomVertexColumn temp_column
|
|
GeomVertexColumn temp_column
|
|
|
(name, num_components, numeric_type, contents, 0);
|
|
(name, num_components, numeric_type, contents, 0);
|
|
@@ -275,9 +286,19 @@ add_column(const GeomVertexColumn &column) {
|
|
|
orig_column = get_column(column.get_start(), column.get_total_bytes());
|
|
orig_column = get_column(column.get_start(), column.get_total_bytes());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- _total_bytes = max(_total_bytes, column.get_start() + column.get_total_bytes());
|
|
|
|
|
|
|
+ int column_bytes = column.get_total_bytes();
|
|
|
|
|
+ if (_column_alignment > 1 && (column.get_start() % _column_alignment == 0)) {
|
|
|
|
|
+ // Round up to the next multiple of _column_alignment.
|
|
|
|
|
+ column_bytes = ((column_bytes + _column_alignment - 1) / _column_alignment) * _column_alignment;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ _total_bytes = max(_total_bytes, column.get_start() + column_bytes);
|
|
|
_pad_to = max(_pad_to, column.get_component_bytes());
|
|
_pad_to = max(_pad_to, column.get_component_bytes());
|
|
|
- _stride = max(_stride, ((_total_bytes + _pad_to - 1) / _pad_to) * _pad_to);
|
|
|
|
|
|
|
+ _stride = max(_stride, _total_bytes);
|
|
|
|
|
+ _stride = ((_stride + _pad_to - 1) / _pad_to) * _pad_to;
|
|
|
|
|
+ if (_column_alignment > 1) {
|
|
|
|
|
+ _stride = ((_stride + _column_alignment - 1) / _column_alignment) * _column_alignment;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
GeomVertexColumn *new_column = new GeomVertexColumn(column);
|
|
GeomVertexColumn *new_column = new GeomVertexColumn(column);
|
|
|
|
|
|
|
@@ -554,6 +575,14 @@ compare_to(const GeomVertexArrayFormat &other) const {
|
|
|
if (_stride != other._stride) {
|
|
if (_stride != other._stride) {
|
|
|
return _stride - other._stride;
|
|
return _stride - other._stride;
|
|
|
}
|
|
}
|
|
|
|
|
+ /*
|
|
|
|
|
+ // We don't compare column_alignment. That's a setting used only
|
|
|
|
|
+ // when constructing the format, and no longer relevant after it's
|
|
|
|
|
+ // been constructed.
|
|
|
|
|
+ if (_column_alignment != other._column_alignment) {
|
|
|
|
|
+ return _column_alignment - other._column_alignment;
|
|
|
|
|
+ }
|
|
|
|
|
+ */
|
|
|
if (_total_bytes != other._total_bytes) {
|
|
if (_total_bytes != other._total_bytes) {
|
|
|
return _total_bytes - other._total_bytes;
|
|
return _total_bytes - other._total_bytes;
|
|
|
}
|
|
}
|
|
@@ -731,6 +760,7 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
|
|
TypedWritableReferenceCount::fillin(scan, manager);
|
|
TypedWritableReferenceCount::fillin(scan, manager);
|
|
|
nassertv(!_is_registered);
|
|
nassertv(!_is_registered);
|
|
|
|
|
|
|
|
|
|
+ // Maybe we should record _column_alignment, but we don't.
|
|
|
_stride = scan.get_uint16();
|
|
_stride = scan.get_uint16();
|
|
|
_total_bytes = scan.get_uint16();
|
|
_total_bytes = scan.get_uint16();
|
|
|
_pad_to = scan.get_uint8();
|
|
_pad_to = scan.get_uint8();
|