mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-11-23 20:20:09 +00:00
Merge pull request #795 from davidgyu/endCapStorageFix
Fixed residual memory consumed by end cap stencils
This commit is contained in:
commit
a4f4357110
@ -1304,14 +1304,14 @@ PatchTableFactory::populateAdaptivePatches(
|
||||
|
||||
// finalize end patches
|
||||
if (localPointStencils and localPointStencils->GetNumStencils() > 0) {
|
||||
localPointStencils->generateOffsets();
|
||||
localPointStencils->finalize();
|
||||
} else {
|
||||
delete localPointStencils;
|
||||
localPointStencils = NULL;
|
||||
}
|
||||
|
||||
if (localPointVaryingStencils and localPointVaryingStencils->GetNumStencils() > 0) {
|
||||
localPointVaryingStencils->generateOffsets();
|
||||
localPointVaryingStencils->finalize();
|
||||
} else {
|
||||
delete localPointVaryingStencils;
|
||||
localPointVaryingStencils = NULL;
|
||||
|
@ -208,6 +208,12 @@ protected:
|
||||
// Reserves the table arrays (factory helper)
|
||||
void reserve(int nstencils, int nelems);
|
||||
|
||||
// Reallocates the table arrays to remove excess capacity (factory helper)
|
||||
void shrinkToFit();
|
||||
|
||||
// Performs any final operations on internal tables (factory helper)
|
||||
void finalize();
|
||||
|
||||
protected:
|
||||
StencilTable() : _numControlVertices(0) {}
|
||||
StencilTable(int numControlVerts)
|
||||
@ -419,6 +425,19 @@ StencilTable::reserve(int nstencils, int nelems) {
|
||||
_weights.reserve(nelems);
|
||||
}
|
||||
|
||||
inline void
|
||||
StencilTable::shrinkToFit() {
|
||||
std::vector<int>(_sizes).swap(_sizes);
|
||||
std::vector<Index>(_indices).swap(_indices);
|
||||
std::vector<float>(_weights).swap(_weights);
|
||||
}
|
||||
|
||||
inline void
|
||||
StencilTable::finalize() {
|
||||
shrinkToFit();
|
||||
generateOffsets();
|
||||
}
|
||||
|
||||
// Returns a Stencil at index i in the table
|
||||
inline Stencil
|
||||
StencilTable::GetStencil(Index i) const {
|
||||
|
Loading…
Reference in New Issue
Block a user