瀏覽代碼

PfmFile::merge()

David Rose 14 年之前
父節點
當前提交
948ce27815
共有 2 個文件被更改,包括 26 次插入0 次删除
  1. 25 0
      panda/src/grutil/pfmFile.cxx
  2. 1 0
      panda/src/grutil/pfmFile.h

+ 25 - 0
panda/src/grutil/pfmFile.cxx

@@ -569,6 +569,31 @@ project(const Lens *lens) {
   }
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: PfmFile::merge
+//       Access: Published
+//  Description: Wherever there is missing data in this PfmFile (that
+//               is, wherever has_point() returns false), copy data
+//               from the other PfmFile, which must be exactly the
+//               same dimensions as this one.
+////////////////////////////////////////////////////////////////////
+void PfmFile::
+merge(const PfmFile &other) {
+  nassertv(is_valid() && other.is_valid());
+  nassertv(other._x_size == _x_size && other._y_size == _y_size);
+
+  if (!_zero_special) {
+    // Trivial no-op.
+    return;
+  }
+
+  for (size_t i = 0; i < _table.size(); ++i) {
+    if (_table[i] == LPoint3::zero()) {
+      _table[i] = other._table[i];
+    }
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: PfmFile::compute_planar_bounds
 //       Access: Published

+ 1 - 0
panda/src/grutil/pfmFile.h

@@ -64,6 +64,7 @@ PUBLISHED:
   BLOCKING void reverse_rows();
   BLOCKING void xform(const LMatrix4 &transform);
   BLOCKING void project(const Lens *lens);
+  BLOCKING void merge(const PfmFile &other);
 
   BLOCKING PT(BoundingHexahedron) compute_planar_bounds(double point_dist, double sample_radius) const;