Add variant of transform_vertices that accepts a SparseArray

This commit is contained in:
rdb 2015-12-26 13:54:53 +01:00
parent 7d9b5d61f9
commit 86faaae9f8
2 changed files with 40 additions and 0 deletions

View File

@ -1196,6 +1196,45 @@ transform_vertices(const LMatrix4 &mat, int begin_row, int end_row) {
}
}
////////////////////////////////////////////////////////////////////
// Function: GeomVertexData::transform_vertices
// Access: Published
// Description: Applies the indicated transform matrix to all of the
// vertices mentioned in the sparse array. The
// transform is applied to all "point" and "vector"
// type columns described in the format.
////////////////////////////////////////////////////////////////////
void GeomVertexData::
transform_vertices(const LMatrix4 &mat, const SparseArray &rows) {
if (rows.is_zero()) {
// Trivial no-op.
return;
}
const GeomVertexFormat *format = get_format();
size_t ci;
for (ci = 0; ci < format->get_num_points(); ci++) {
GeomVertexRewriter data(this, format->get_point(ci));
for (size_t i = 0; i < rows.get_num_subranges(); ++i) {
int begin_row = rows.get_subrange_begin(i);
int end_row = rows.get_subrange_end(i);
do_transform_point_column(format, data, mat, begin_row, end_row);
}
}
for (ci = 0; ci < format->get_num_vectors(); ci++) {
GeomVertexRewriter data(this, format->get_vector(ci));
for (size_t i = 0; i < rows.get_num_subranges(); ++i) {
int begin_row = rows.get_subrange_begin(i);
int end_row = rows.get_subrange_end(i);
do_transform_vector_column(format, data, mat, begin_row, end_row);
}
}
}
////////////////////////////////////////////////////////////////////
// Function: GeomVertexData::bytewise_copy
// Access: Private, Static

View File

@ -156,6 +156,7 @@ PUBLISHED:
void clear_animated_vertices();
void transform_vertices(const LMatrix4 &mat);
void transform_vertices(const LMatrix4 &mat, int begin_row, int end_row);
void transform_vertices(const LMatrix4 &mat, const SparseArray &rows);
PT(GeomVertexData)
replace_column(InternalName *name, int num_components,