Browse Source

Merge remote-tracking branch 'origin/release/1.9.x'

Conflicts:
	panda/src/gobj/geomVertexData.cxx
rdb 10 years ago
parent
commit
46fe58a87a
2 changed files with 41 additions and 0 deletions
  1. 40 0
      panda/src/gobj/geomVertexData.cxx
  2. 1 0
      panda/src/gobj/geomVertexData.h

+ 40 - 0
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

+ 1 - 0
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,