add set_vertex_membership, make map accessors non-inline

This commit is contained in:
David Rose 2003-07-21 21:04:46 +00:00
parent 84f82d6074
commit ba4ec85c60
5 changed files with 131 additions and 98 deletions

View File

@ -505,6 +505,38 @@ get_vertex_membership(const EggVertex *vert) const {
}
}
////////////////////////////////////////////////////////////////////
// Function: EggGroup::set_vertex_membership
// Access: Public
// Description: Explicitly sets the net membership of the indicated
// vertex in this group to the given value.
////////////////////////////////////////////////////////////////////
void EggGroup::
set_vertex_membership(EggVertex *vert, double membership) {
if (membership == 0.0) {
unref_vertex(vert);
return;
}
VertexRef::iterator vri = _vref.find(vert);
if (vri != _vref.end()) {
// The vertex was already being reffed; just change its membership
// amount.
(*vri).second = membership;
} else {
// The vertex was not already reffed; ref it.
_vref[vert] = membership;
bool inserted = vert->_gref.insert(this).second;
// Did the group not exist previously in the vertex's gref list?
// If it was there already, we must be out of sync between
// vertices and groups.
nassertv(inserted);
}
}
////////////////////////////////////////////////////////////////////
// Function: EggGroup::steal_vrefs
// Access: Public

View File

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

View File

@ -206,98 +206,6 @@ get_external_index() const {
}
////////////////////////////////////////////////////////////////////
// Function: EggVertex::gref_begin
// Access: Public
// Description: Returns an iterator that can, in conjunction with
// gref_end(), be used to traverse the entire set of
// groups that reference this vertex. Each iterator
// returns a pointer to a group.
//
// This interface is not safe to use outside of
// PANDAEGG.DLL.
////////////////////////////////////////////////////////////////////
INLINE EggVertex::GroupRef::const_iterator EggVertex::
gref_begin() const {
return _gref.begin();
}
////////////////////////////////////////////////////////////////////
// Function: EggVertex::gref_end
// Access: Public
// Description: Returns an iterator that can, in conjunction with
// gref_begin(), be used to traverse the entire set of
// groups that reference this vertex. Each iterator
// returns a pointer to a group.
//
// This interface is not safe to use outside of
// PANDAEGG.DLL.
////////////////////////////////////////////////////////////////////
INLINE EggVertex::GroupRef::const_iterator EggVertex::
gref_end() const {
return _gref.end();
}
////////////////////////////////////////////////////////////////////
// Function: EggVertex::gref_size
// Access: Public
// Description: Returns the number of elements between gref_begin()
// and gref_end().
//
// This interface is not safe to use outside of
// PANDAEGG.DLL.
////////////////////////////////////////////////////////////////////
INLINE EggVertex::GroupRef::size_type EggVertex::
gref_size() const {
return _gref.size();
}
////////////////////////////////////////////////////////////////////
// Function: EggVertex::pref_begin
// Access: Public
// Description: Returns an iterator that can, in conjunction with
// pref_end(), be used to traverse the entire set of
// primitives that reference this vertex. Each iterator
// returns a pointer to a primitive.
//
// This interface is not safe to use outside of
// PANDAEGG.DLL.
////////////////////////////////////////////////////////////////////
INLINE EggVertex::PrimitiveRef::const_iterator EggVertex::
pref_begin() const {
return _pref.begin();
}
////////////////////////////////////////////////////////////////////
// Function: EggVertex::pref_end
// Access: Public
// Description: Returns an iterator that can, in conjunction with
// pref_begin(), be used to traverse the entire set of
// primitives that reference this vertex. Each iterator
// returns a pointer to a primitive.
//
// This interface is not safe to use outside of
// PANDAEGG.DLL.
////////////////////////////////////////////////////////////////////
INLINE EggVertex::PrimitiveRef::const_iterator EggVertex::
pref_end() const {
return _pref.end();
}
////////////////////////////////////////////////////////////////////
// Function: EggVertex::pref_size
// Access: Public
// Description: Returns the number of elements between pref_begin()
// and pref_end().
//
// This interface is not safe to use outside of
// PANDAEGG.DLL.
////////////////////////////////////////////////////////////////////
INLINE EggVertex::GroupRef::size_type EggVertex::
pref_size() const {
return _pref.size();
}

View File

@ -294,6 +294,52 @@ transform(const LMatrix4d &mat) {
}
////////////////////////////////////////////////////////////////////
// Function: EggVertex::gref_begin
// Access: Public
// Description: Returns an iterator that can, in conjunction with
// gref_end(), be used to traverse the entire set of
// groups that reference this vertex. Each iterator
// returns a pointer to a group.
//
// This interface is not safe to use outside of
// PANDAEGG.DLL.
////////////////////////////////////////////////////////////////////
EggVertex::GroupRef::const_iterator EggVertex::
gref_begin() const {
return _gref.begin();
}
////////////////////////////////////////////////////////////////////
// Function: EggVertex::gref_end
// Access: Public
// Description: Returns an iterator that can, in conjunction with
// gref_begin(), be used to traverse the entire set of
// groups that reference this vertex. Each iterator
// returns a pointer to a group.
//
// This interface is not safe to use outside of
// PANDAEGG.DLL.
////////////////////////////////////////////////////////////////////
EggVertex::GroupRef::const_iterator EggVertex::
gref_end() const {
return _gref.end();
}
////////////////////////////////////////////////////////////////////
// Function: EggVertex::gref_size
// Access: Public
// Description: Returns the number of elements between gref_begin()
// and gref_end().
//
// This interface is not safe to use outside of
// PANDAEGG.DLL.
////////////////////////////////////////////////////////////////////
EggVertex::GroupRef::size_type EggVertex::
gref_size() const {
return _gref.size();
}
////////////////////////////////////////////////////////////////////
// Function: EggVertex::has_gref
// Access: Public
@ -359,6 +405,52 @@ clear_grefs() {
nassertv(_gref.empty());
}
////////////////////////////////////////////////////////////////////
// Function: EggVertex::pref_begin
// Access: Public
// Description: Returns an iterator that can, in conjunction with
// pref_end(), be used to traverse the entire set of
// primitives that reference this vertex. Each iterator
// returns a pointer to a primitive.
//
// This interface is not safe to use outside of
// PANDAEGG.DLL.
////////////////////////////////////////////////////////////////////
EggVertex::PrimitiveRef::const_iterator EggVertex::
pref_begin() const {
return _pref.begin();
}
////////////////////////////////////////////////////////////////////
// Function: EggVertex::pref_end
// Access: Public
// Description: Returns an iterator that can, in conjunction with
// pref_begin(), be used to traverse the entire set of
// primitives that reference this vertex. Each iterator
// returns a pointer to a primitive.
//
// This interface is not safe to use outside of
// PANDAEGG.DLL.
////////////////////////////////////////////////////////////////////
EggVertex::PrimitiveRef::const_iterator EggVertex::
pref_end() const {
return _pref.end();
}
////////////////////////////////////////////////////////////////////
// Function: EggVertex::pref_size
// Access: Public
// Description: Returns the number of elements between pref_begin()
// and pref_end().
//
// This interface is not safe to use outside of
// PANDAEGG.DLL.
////////////////////////////////////////////////////////////////////
EggVertex::GroupRef::size_type EggVertex::
pref_size() const {
return _pref.size();
}
////////////////////////////////////////////////////////////////////
// Function: EggVertex::has_pref
// Access: Public

View File

@ -84,17 +84,17 @@ public:
void transform(const LMatrix4d &mat);
INLINE GroupRef::const_iterator gref_begin() const;
INLINE GroupRef::const_iterator gref_end() const;
INLINE GroupRef::size_type gref_size() const;
GroupRef::const_iterator gref_begin() const;
GroupRef::const_iterator gref_end() const;
GroupRef::size_type gref_size() const;
bool has_gref(const EggGroup *group) const;
void copy_grefs_from(const EggVertex &other);
void clear_grefs();
INLINE PrimitiveRef::const_iterator pref_begin() const;
INLINE PrimitiveRef::const_iterator pref_end() const;
INLINE PrimitiveRef::size_type pref_size() const;
PrimitiveRef::const_iterator pref_begin() const;
PrimitiveRef::const_iterator pref_end() const;
PrimitiveRef::size_type pref_size() const;
int has_pref(const EggPrimitive *prim) const;
#ifndef NDEBUG