mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-11-25 04:50:06 +00:00
FarSubdivisionTables: fixed vertsOffsets and removed unused members.
a new function is added to avoid confusion. -GetNumVertices() returns number of vertices -GetNumVerticesTotal() returns total number of vertices includins number of lower levels. #closes 156
This commit is contained in:
parent
643b664067
commit
3df04db2cd
@ -112,6 +112,7 @@ FarBilinearSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFact
|
||||
// Prepare batch table
|
||||
batches->reserve(maxlevel*5);
|
||||
|
||||
int vertexOffset = 0;
|
||||
int F_IT_offset = 0;
|
||||
int faceTableOffset = 0;
|
||||
int edgeTableOffset = 0;
|
||||
@ -125,7 +126,7 @@ FarBilinearSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFact
|
||||
for (int level=1; level<=maxlevel; ++level) {
|
||||
|
||||
// pointer to the first vertex corresponding to this level
|
||||
int vertexOffset = tablesFactory._vertVertIdx[level-1] +
|
||||
vertexOffset = tablesFactory._vertVertIdx[level-1] +
|
||||
(int)tablesFactory._vertVertsList[level-1].size();
|
||||
result->_vertsOffsets[level] = vertexOffset;
|
||||
|
||||
@ -214,6 +215,7 @@ FarBilinearSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFact
|
||||
}
|
||||
V_ITa += nVertVertices;
|
||||
}
|
||||
result->_vertsOffsets[maxlevel+1] = vertexOffset;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -116,6 +116,7 @@ FarCatmarkSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFacto
|
||||
// Prepare batch table
|
||||
batches->reserve(maxlevel*5);
|
||||
|
||||
int vertexOffset = 0;
|
||||
int F_IT_offset = 0;
|
||||
int V_IT_offset = 0;
|
||||
int faceTableOffset = 0;
|
||||
@ -133,7 +134,8 @@ FarCatmarkSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFacto
|
||||
for (int level=1; level<=maxlevel; ++level) {
|
||||
|
||||
// pointer to the first vertex corresponding to this level
|
||||
int vertexOffset = tablesFactory._vertVertIdx[level-1] + (int)tablesFactory._vertVertsList[level-1].size();
|
||||
vertexOffset = tablesFactory._vertVertIdx[level-1] +
|
||||
(int)tablesFactory._vertVertsList[level-1].size();
|
||||
result->_vertsOffsets[level] = vertexOffset;
|
||||
|
||||
// Face vertices
|
||||
@ -357,8 +359,8 @@ FarCatmarkSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFacto
|
||||
batchFactory.AppendCatmarkBatches(batches, level, vertTableOffset, vertexOffset);
|
||||
vertexOffset += nVertVertices;
|
||||
vertTableOffset += nVertVertices;
|
||||
result->_numTotalVertices = vertexOffset;
|
||||
}
|
||||
result->_vertsOffsets[maxlevel+1] = vertexOffset;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -113,6 +113,7 @@ FarLoopSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFactory,
|
||||
// Prepare batch table
|
||||
batches->reserve(maxlevel*5);
|
||||
|
||||
int vertexOffset = 0;
|
||||
int V_IT_offset = 0;
|
||||
int edgeTableOffset = 0;
|
||||
int vertTableOffset = 0;
|
||||
@ -126,7 +127,7 @@ FarLoopSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFactory,
|
||||
for (int level=1; level<=maxlevel; ++level) {
|
||||
|
||||
// pointer to the first vertex corresponding to this level
|
||||
int vertexOffset = tablesFactory._vertVertIdx[level-1] +
|
||||
vertexOffset = tablesFactory._vertVertIdx[level-1] +
|
||||
(int)tablesFactory._vertVertsList[level-1].size();
|
||||
result->_vertsOffsets[level] = vertexOffset;
|
||||
|
||||
@ -288,8 +289,8 @@ FarLoopSubdivisionTablesFactory<T,U>::Create( FarMeshFactory<T,U> * meshFactory,
|
||||
batchFactory.AppendLoopBatches(batches, level, vertTableOffset, vertexOffset);
|
||||
vertexOffset += nVertVertices;
|
||||
vertTableOffset += nVertVertices;
|
||||
result->_numTotalVertices = vertexOffset;
|
||||
}
|
||||
result->_vertsOffsets[maxlevel+1] = vertexOffset;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -774,9 +774,6 @@ FarMeshFactory<T,U>::Create( bool requirePtexCoordinate, // XXX yuck.
|
||||
assert(0);
|
||||
assert(result->_subdivisionTables);
|
||||
|
||||
const_cast<FarSubdivisionTables<U> *>(result->GetSubdivisionTables())->_numCoarseVertices=GetNumCoarseVertices();
|
||||
|
||||
|
||||
// If the vertex classes aren't place-holders, copy the data of the coarse
|
||||
// vertices into the vertex buffer.
|
||||
result->_vertices.resize( _numVertices );
|
||||
|
@ -102,7 +102,7 @@ public:
|
||||
virtual ~FarSubdivisionTables<U>() {}
|
||||
|
||||
/// Return the highest level of subdivision possible with these tables
|
||||
int GetMaxLevel() const { return (int)(_vertsOffsets.size()); }
|
||||
int GetMaxLevel() const { return (int)(_vertsOffsets.size()-1); }
|
||||
|
||||
/// Memory required to store the indexing tables
|
||||
int GetMemoryUsed() const;
|
||||
@ -114,9 +114,12 @@ public:
|
||||
/// represented by this set of FarCatmarkSubdivisionTables
|
||||
int GetFirstVertexOffset( int level ) const;
|
||||
|
||||
// Total number of vertices at a given level
|
||||
/// Number of vertices at a given level
|
||||
int GetNumVertices( int level ) const;
|
||||
|
||||
/// Total number of vertices at a given level
|
||||
int GetNumVerticesTotal( int level ) const;
|
||||
|
||||
/// Indexing tables accessors
|
||||
|
||||
/// Returns the face vertices codex table
|
||||
@ -164,34 +167,32 @@ protected:
|
||||
std::vector<float> _V_W; // weights
|
||||
|
||||
std::vector<int> _vertsOffsets; // offset to the first vertex of each level
|
||||
|
||||
unsigned int _numCoarseVertices;
|
||||
|
||||
unsigned int _numTotalVertices;
|
||||
};
|
||||
|
||||
template <class U>
|
||||
FarSubdivisionTables<U>::FarSubdivisionTables( FarMesh<U> * mesh, int maxlevel ) :
|
||||
_mesh(mesh),
|
||||
_vertsOffsets(maxlevel+1,0),
|
||||
_numCoarseVertices(0)
|
||||
_vertsOffsets(maxlevel+2, 0)
|
||||
{
|
||||
assert( maxlevel > 0 );
|
||||
}
|
||||
|
||||
template <class U> int
|
||||
FarSubdivisionTables<U>::GetFirstVertexOffset( int level ) const {
|
||||
assert(level>=0 and level<=(int)_vertsOffsets.size());
|
||||
assert(level>=0 and level<(int)_vertsOffsets.size());
|
||||
return _vertsOffsets[level];
|
||||
}
|
||||
|
||||
template <class U> int
|
||||
FarSubdivisionTables<U>::GetNumVertices( int level ) const {
|
||||
assert(level>=0 and level<=((int)_vertsOffsets.size()+1));
|
||||
if (level <= (int)_vertsOffsets.size())
|
||||
assert(level>=0 and level<((int)_vertsOffsets.size()-1));
|
||||
return _vertsOffsets[level+1] - _vertsOffsets[level];
|
||||
}
|
||||
|
||||
template <class U> int
|
||||
FarSubdivisionTables<U>::GetNumVerticesTotal( int level ) const {
|
||||
assert(level>=0 and level<((int)_vertsOffsets.size()-1));
|
||||
return _vertsOffsets[level+1];
|
||||
else
|
||||
return _numTotalVertices;
|
||||
}
|
||||
|
||||
template <class U> int
|
||||
|
Loading…
Reference in New Issue
Block a user