diff --git a/panda/src/gobj/geomVertexData.cxx b/panda/src/gobj/geomVertexData.cxx index 5715ec3953..f822fb6f07 100644 --- a/panda/src/gobj/geomVertexData.cxx +++ b/panda/src/gobj/geomVertexData.cxx @@ -1187,6 +1187,46 @@ 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::do_set_color // Access: Private, Static diff --git a/panda/src/gobj/geomVertexData.h b/panda/src/gobj/geomVertexData.h index bddeb44b1b..47dac76c28 100644 --- a/panda/src/gobj/geomVertexData.h +++ b/panda/src/gobj/geomVertexData.h @@ -163,6 +163,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,