浏览代码

add steal_vrefs

David Rose 22 年之前
父节点
当前提交
397b886289
共有 2 个文件被更改,包括 21 次插入0 次删除
  1. 20 0
      panda/src/egg/eggGroup.cxx
  2. 1 0
      panda/src/egg/eggGroup.h

+ 20 - 0
panda/src/egg/eggGroup.cxx

@@ -505,6 +505,26 @@ get_vertex_membership(const EggVertex *vert) const {
   }
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: EggGroup::steal_vrefs
+//       Access: Public
+//  Description: Moves all of the vertex references from the indicated
+//               other group into this one.  If a given vertex was
+//               previously shared by both groups, the relative
+//               memberships will be summed.
+////////////////////////////////////////////////////////////////////
+void EggGroup::
+steal_vrefs(EggGroup *other) {
+  nassertv(other != this);
+  VertexRef::const_iterator vri;
+  for (vri = other->vref_begin(); vri != other->vref_end(); ++vri) {
+    EggVertex *vert = (*vri).first;
+    double membership = (*vri).second;
+    ref_vertex(vert, membership);
+  }
+  other->unref_all_vertices();
+}
+
 
 #ifndef NDEBUG
 

+ 1 - 0
panda/src/egg/eggGroup.h

@@ -198,6 +198,7 @@ public:
   void unref_vertex(EggVertex *vert);
   void unref_all_vertices();
   double get_vertex_membership(const EggVertex *vert) const;
+  void steal_vrefs(EggGroup *other);
 
   INLINE VertexRef::const_iterator vref_begin() const;
   INLINE VertexRef::const_iterator vref_end() const;