From 397b886289d339dfafa4b183c34b947bef791256 Mon Sep 17 00:00:00 2001 From: David Rose Date: Sun, 20 Jul 2003 15:50:00 +0000 Subject: [PATCH] add steal_vrefs --- panda/src/egg/eggGroup.cxx | 20 ++++++++++++++++++++ panda/src/egg/eggGroup.h | 1 + 2 files changed, 21 insertions(+) diff --git a/panda/src/egg/eggGroup.cxx b/panda/src/egg/eggGroup.cxx index bc504c15cc..3116d85879 100644 --- a/panda/src/egg/eggGroup.cxx +++ b/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 diff --git a/panda/src/egg/eggGroup.h b/panda/src/egg/eggGroup.h index 27ff40bb60..b0bf95e39a 100644 --- a/panda/src/egg/eggGroup.h +++ b/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;