|
|
@@ -102,62 +102,61 @@ remove_primitive(const qpGeomPrimitive *primitive) {
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: qpGeomVertexCacheManager::record_data
|
|
|
+// Function: qpGeomVertexCacheManager::record_geom
|
|
|
// Access: Private
|
|
|
// Description: Records a new entry in the cache, or marks a cache
|
|
|
// hit for a previous entry in the cache. This should
|
|
|
-// only be called by GeomVertexData.
|
|
|
+// only be called by Geom.
|
|
|
//
|
|
|
// The cache manager will not hold a reference on the
|
|
|
-// GeomVertexData pointer; if it destructs, it should
|
|
|
-// call remove_data() to remove itself from the cache.
|
|
|
+// Geom pointer; if it destructs, it should call
|
|
|
+// remove_geom() to remove itself from the cache.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE void qpGeomVertexCacheManager::
|
|
|
-record_data(const qpGeomVertexData *source, const qpGeomVertexFormat *modifier,
|
|
|
+record_geom(const qpGeom *source, const qpGeomMunger *modifier,
|
|
|
int result_size) {
|
|
|
record_entry(Entry(source, modifier, result_size));
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: qpGeomVertexCacheManager::remove_data
|
|
|
+// Function: qpGeomVertexCacheManager::remove_geom
|
|
|
// Access: Private
|
|
|
// Description: Removes an entry from the cache, if it is there.
|
|
|
// Quietly ignores it if it is not. This should only be
|
|
|
// called by GeomVertexData.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE void qpGeomVertexCacheManager::
|
|
|
-remove_data(const qpGeomVertexData *source,
|
|
|
- const qpGeomVertexFormat *modifier) {
|
|
|
+remove_geom(const qpGeom *source, const qpGeomMunger *modifier) {
|
|
|
remove_entry(Entry(source, modifier, 0));
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: qpGeomVertexCacheManager::record_geom
|
|
|
+// Function: qpGeomVertexCacheManager::dequeue_entry
|
|
|
// Access: Private
|
|
|
-// Description: Records a new entry in the cache, or marks a cache
|
|
|
-// hit for a previous entry in the cache. This should
|
|
|
-// only be called by Geom.
|
|
|
-//
|
|
|
-// The cache manager will not hold a reference on the
|
|
|
-// Geom pointer; if it destructs, it should
|
|
|
-// call remove_geom() to remove itself from the cache.
|
|
|
+// Description: Removes an Entry record from the doubly-linked list.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE void qpGeomVertexCacheManager::
|
|
|
-record_geom(const qpGeom *source, const qpGeomMunger *modifier,
|
|
|
- int result_size) {
|
|
|
- record_entry(Entry(source, modifier, result_size));
|
|
|
+dequeue_entry(qpGeomVertexCacheManager::Entry *entry) {
|
|
|
+ nassertv(entry->_prev->_next == entry &&
|
|
|
+ entry->_next->_prev == entry);
|
|
|
+ entry->_prev->_next = entry->_next;
|
|
|
+ entry->_next->_prev = entry->_prev;
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
-// Function: qpGeomVertexCacheManager::remove_geom
|
|
|
+// Function: qpGeomVertexCacheManager::enqueue_entry
|
|
|
// Access: Private
|
|
|
-// Description: Removes an entry from the cache, if it is there.
|
|
|
-// Quietly ignores it if it is not. This should only be
|
|
|
-// called by Geom.
|
|
|
+// Description: Adds an Entry record to the tail of the doubly-linked
|
|
|
+// list.
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE void qpGeomVertexCacheManager::
|
|
|
-remove_geom(const qpGeom *source, const qpGeomMunger *modifier) {
|
|
|
- remove_entry(Entry(source, modifier, 0));
|
|
|
+enqueue_entry(qpGeomVertexCacheManager::Entry *entry) {
|
|
|
+ nassertv(_list->_prev->_next == _list &&
|
|
|
+ _list->_next->_prev == _list);
|
|
|
+ entry->_prev = _list->_prev;
|
|
|
+ entry->_next = _list;
|
|
|
+ entry->_prev->_next = entry;
|
|
|
+ _list->_prev = entry;
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
@@ -166,12 +165,10 @@ remove_geom(const qpGeom *source, const qpGeomMunger *modifier) {
|
|
|
// Description:
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE qpGeomVertexCacheManager::Entry::
|
|
|
-Entry(const qpGeomMunger *munger, int result_size) :
|
|
|
- _cache_type(CT_munger),
|
|
|
- _result_size(result_size)
|
|
|
+Entry() :
|
|
|
+ _cache_type(CT_none),
|
|
|
+ _result_size(0)
|
|
|
{
|
|
|
- _u._munger = munger;
|
|
|
- _u._munger->ref();
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
@@ -180,11 +177,12 @@ Entry(const qpGeomMunger *munger, int result_size) :
|
|
|
// Description:
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE qpGeomVertexCacheManager::Entry::
|
|
|
-Entry(const qpGeomPrimitive *primitive, int result_size) :
|
|
|
- _cache_type(CT_primitive),
|
|
|
+Entry(const qpGeomMunger *munger, int result_size) :
|
|
|
+ _cache_type(CT_munger),
|
|
|
_result_size(result_size)
|
|
|
{
|
|
|
- _u._primitive = primitive;
|
|
|
+ _u._munger = munger;
|
|
|
+ _u._munger->ref();
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
@@ -193,13 +191,11 @@ Entry(const qpGeomPrimitive *primitive, int result_size) :
|
|
|
// Description:
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE qpGeomVertexCacheManager::Entry::
|
|
|
-Entry(const qpGeomVertexData *source, const qpGeomVertexFormat *modifier,
|
|
|
- int result_size) :
|
|
|
- _cache_type(CT_data),
|
|
|
+Entry(const qpGeomPrimitive *primitive, int result_size) :
|
|
|
+ _cache_type(CT_primitive),
|
|
|
_result_size(result_size)
|
|
|
{
|
|
|
- _u._data._source = source;
|
|
|
- _u._data._modifier = modifier;
|
|
|
+ _u._primitive = primitive;
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
@@ -208,7 +204,8 @@ Entry(const qpGeomVertexData *source, const qpGeomVertexFormat *modifier,
|
|
|
// Description:
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE qpGeomVertexCacheManager::Entry::
|
|
|
-Entry(const qpGeom *source, const qpGeomMunger *modifier, int result_size) :
|
|
|
+Entry(const qpGeom *source, const qpGeomMunger *modifier,
|
|
|
+ int result_size) :
|
|
|
_cache_type(CT_geom),
|
|
|
_result_size(result_size)
|
|
|
{
|
|
|
@@ -269,19 +266,22 @@ INLINE qpGeomVertexCacheManager::Entry::
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
INLINE bool qpGeomVertexCacheManager::Entry::
|
|
|
operator < (const qpGeomVertexCacheManager::Entry &other) const {
|
|
|
+ if (_cache_type != other._cache_type) {
|
|
|
+ return (int)_cache_type < (int)other._cache_type;
|
|
|
+ }
|
|
|
+
|
|
|
switch (_cache_type) {
|
|
|
+ case CT_none:
|
|
|
+ // We shouldn't be adding the end-of-list token to the index.
|
|
|
+ nassertr(false, false);
|
|
|
+ return false;
|
|
|
+
|
|
|
case CT_munger:
|
|
|
return _u._munger < other._u._munger;
|
|
|
|
|
|
case CT_primitive:
|
|
|
return _u._primitive < other._u._primitive;
|
|
|
|
|
|
- case CT_data:
|
|
|
- if (_u._data._source != other._u._data._source) {
|
|
|
- return _u._data._source < other._u._data._source;
|
|
|
- }
|
|
|
- return _u._data._modifier < other._u._data._modifier;
|
|
|
-
|
|
|
case CT_geom:
|
|
|
if (_u._geom._source != other._u._geom._source) {
|
|
|
return _u._geom._source < other._u._geom._source;
|
|
|
@@ -289,7 +289,7 @@ operator < (const qpGeomVertexCacheManager::Entry &other) const {
|
|
|
return _u._geom._modifier < other._u._geom._modifier;
|
|
|
}
|
|
|
|
|
|
- return 0;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
INLINE ostream &
|