Replacing use of old Far::TopologyRefiner methods with Far::TopologyLevel

This commit is contained in:
barfowl 2015-05-21 19:52:25 -07:00
parent 2b33de38f8
commit 6d5b29c2dc
24 changed files with 180 additions and 138 deletions

View File

@ -236,12 +236,14 @@ calcNormals(OpenSubdiv::Far::TopologyRefiner * refiner,
typedef OpenSubdiv::Far::ConstIndexArray IndexArray;
// calc normal vectors
int nverts = refiner->GetNumVertices(0),
nfaces = refiner->GetNumFaces(0);
OpenSubdiv::Far::TopologyLevel const & refBaseLevel = refiner->GetLevel(0);
int nverts = refBaseLevel.GetNumVertices(),
nfaces = refBaseLevel.GetNumFaces();
for (int face = 0; face < nfaces; ++face) {
IndexArray fverts = refiner->GetFaceVertices(0, face);
IndexArray fverts = refBaseLevel.GetFaceVertices(face);
float const * p0 = &pos[fverts[0]*3],
* p1 = &pos[fverts[1]*3],
@ -704,12 +706,13 @@ createOsdMesh(int level, int kernel) {
OpenSubdiv::Far::TopologyRefinerFactory<Shape>::Options(sdctype, sdcoptions));
// save coarse topology (used for coarse mesh drawing)
OpenSubdiv::Far::TopologyLevel const & refBaseLevel = refiner->GetLevel(0);
// create cage edge index
int nedges = refiner->GetNumEdges(0);
int nedges = refBaseLevel.GetNumEdges();
std::vector<int> edgeIndices(nedges*2);
for(int i=0; i<nedges; ++i) {
IndexArray verts = refiner->GetEdgeVertices(0, i);
IndexArray verts = refBaseLevel.GetEdgeVertices(i);
edgeIndices[i*2 ]=verts[0];
edgeIndices[i*2+1]=verts[1];
}

View File

@ -277,22 +277,24 @@ createOsdMesh(ShapeDesc const & shapeDesc, int level, int kernel, Scheme scheme=
Far::TopologyRefinerFactory<Shape>::Options(sdctype, sdcoptions));
// save coarse topology (used for coarse mesh drawing)
int nedges = refiner->GetNumEdges(0),
nverts = refiner->GetNumVertices(0);
Far::TopologyLevel const & refBaseLevel = refiner->GetLevel(0);
int nedges = refBaseLevel.GetNumEdges(),
nverts = refBaseLevel.GetNumVertices();
g_coarseEdges.resize(nedges*2);
g_coarseEdgeSharpness.resize(nedges);
g_coarseVertexSharpness.resize(nverts);
for(int i=0; i<nedges; ++i) {
IndexArray verts = refiner->GetEdgeVertices(0, i);
IndexArray verts = refBaseLevel.GetEdgeVertices(i);
g_coarseEdges[i*2 ]=verts[0];
g_coarseEdges[i*2+1]=verts[1];
g_coarseEdgeSharpness[i]=refiner->GetEdgeSharpness(0, i);
g_coarseEdgeSharpness[i]=refBaseLevel.GetEdgeSharpness(i);
}
for(int i=0; i<nverts; ++i) {
g_coarseVertexSharpness[i]=refiner->GetVertexSharpness(0, i);
g_coarseVertexSharpness[i]=refBaseLevel.GetVertexSharpness(i);
}
g_orgPositions=shape->verts;

View File

@ -212,7 +212,7 @@ createVertNumbers(OpenSubdiv::Far::TopologyRefiner const & refiner,
if (refiner.IsUniform()) {
for (int i=0; i<maxlevel; ++i) {
firstvert += refiner.GetNumVertices(i);
firstvert += refiner.GetLevel(i).GetNumVertices();
}
}
@ -225,7 +225,7 @@ createVertNumbers(OpenSubdiv::Far::TopologyRefiner const & refiner,
} else {
for (int level=0, vert=0; level<=refiner.GetMaxLevel(); ++level) {
for (int i=0; i<refiner.GetNumVertices(level); ++i, ++vert) {
for (int i=0; i<refiner.GetLevel(level).GetNumVertices(); ++i, ++vert) {
snprintf(buf, 16, "%d", i);
g_font->Print3D(vertexBuffer[vert].GetPos(), buf, 1);
}
@ -245,16 +245,17 @@ createEdgeNumbers(OpenSubdiv::Far::TopologyRefiner const & refiner,
firstvert = 0;
for (int i=0; i<maxlevel; ++i) {
firstvert += refiner.GetNumVertices(i);
firstvert += refiner.GetLevel(i).GetNumVertices();
}
OpenSubdiv::Far::TopologyLevel const & refLastLevel = refiner.GetLevel(maxlevel);
static char buf[16];
for (int i=0; i<refiner.GetNumEdges(maxlevel); ++i) {
for (int i=0; i<refLastLevel.GetNumEdges(); ++i) {
Vertex center(0.0f, 0.0f, 0.0f);
OpenSubdiv::Far::ConstIndexArray const verts =
refiner.GetEdgeVertices(maxlevel, i);
OpenSubdiv::Far::ConstIndexArray const verts = refLastLevel.GetEdgeVertices(i);
assert(verts.size()==2);
center.AddWithWeight(vertexBuffer[firstvert+verts[0]], 0.5f);
@ -266,7 +267,7 @@ createEdgeNumbers(OpenSubdiv::Far::TopologyRefiner const & refiner,
}
if (sharpness) {
float sharpness = refiner.GetEdgeSharpness(maxlevel, i);
float sharpness = refLastLevel.GetEdgeSharpness(i);
if (sharpness>0.0f) {
snprintf(buf, 16, "%g", sharpness);
g_font->Print3D(center.GetPos(), buf, std::min(8,(int)sharpness+4));
@ -289,15 +290,16 @@ createFaceNumbers(OpenSubdiv::Far::TopologyRefiner const & refiner,
firstvert = 0;
for (int i=0; i<maxlevel; ++i) {
firstvert += refiner.GetNumVertices(i);
firstvert += refiner.GetLevel(i).GetNumVertices();
}
for (int face=0; face<refiner.GetNumFaces(maxlevel); ++face) {
OpenSubdiv::Far::TopologyLevel const & refLastLevel = refiner.GetLevel(maxlevel);
for (int face=0; face<refLastLevel.GetNumFaces(); ++face) {
Vertex center(0.0f, 0.0f, 0.0f);
OpenSubdiv::Far::ConstIndexArray const verts =
refiner.GetFaceVertices(maxlevel, face);
OpenSubdiv::Far::ConstIndexArray const verts = refLastLevel.GetFaceVertices(face);
float weight = 1.0f / (float)verts.size();
@ -310,19 +312,20 @@ createFaceNumbers(OpenSubdiv::Far::TopologyRefiner const & refiner,
}
} else {
int maxlevel = refiner.GetMaxLevel(),
// patch = refiner.GetNumFaces(0),
firstvert = refiner.GetNumVertices(0);
// patch = refiner.GetLevel(0).GetNumFaces(),
firstvert = refiner.GetLevel(0).GetNumVertices();
for (int level=1; level<=maxlevel; ++level) {
int nfaces = refiner.GetNumFaces(level);
OpenSubdiv::Far::TopologyLevel const & refLevel = refiner.GetLevel(level);
int nfaces = refLevel.GetNumFaces();
for (int face=0; face<nfaces; ++face /*, ++patch */) {
Vertex center(0.0f, 0.0f, 0.0f);
OpenSubdiv::Far::ConstIndexArray const verts =
refiner.GetFaceVertices(level, face);
OpenSubdiv::Far::ConstIndexArray const verts = refLevel.GetFaceVertices(face);
float weight = 1.0f / (float)verts.size();
@ -332,7 +335,7 @@ createFaceNumbers(OpenSubdiv::Far::TopologyRefiner const & refiner,
snprintf(buf, 16, "%d", face);
g_font->Print3D(center.GetPos(), buf, 2);
}
firstvert+=refiner.GetNumVertices(level);
firstvert+=refLevel.GetNumVertices();
}
}
}

View File

@ -265,15 +265,18 @@ GLMesh::initializeBuffers(Options options,
typedef OpenSubdiv::Far::ConstIndexArray IndexArray;
int maxlevel = refiner.GetMaxLevel(),
nverts = refiner.GetNumVertices(maxlevel),
nedges = refiner.GetNumEdges(maxlevel),
nfaces = refiner.GetNumFaces(maxlevel),
int maxlevel = refiner.GetMaxLevel();
OpenSubdiv::Far::TopologyLevel const & refLastLevel = refiner.GetLevel(maxlevel);
int nverts = refLastLevel.GetNumVertices(maxlevel),
nedges = refLastLevel.GetNumEdges(maxlevel),
nfaces = refLastLevel.GetNumFaces(maxlevel),
firstvert = 0;
for (int i=0; i<maxlevel; ++i) {
firstvert += refiner.GetNumVertices(i);
firstvert += refiner.GetLevel(i).GetNumVertices();
}
float const * vertData = &vertexData[firstvert*3];
@ -287,31 +290,33 @@ GLMesh::initializeBuffers(Options options,
// set colors
if (options.vertColorMode==VERTCOLOR_BY_LEVEL) {
for (int level=0, ofs=3; level<=refiner.GetMaxLevel(); ++level) {
for (int vert=0; vert<refiner.GetNumVertices(level); ++vert, ofs+=6) {
for (int level=0, ofs=3; level<=maxlevel; ++level) {
for (int vert=0; vert<refiner.GetLevel(level).GetNumVertices(); ++vert, ofs+=6) {
setColorByLevel(level, &vbo[ofs]);
}
}
} else if (options.vertColorMode==VERTCOLOR_BY_SHARPNESS) {
for (int vert=0, ofs=3; vert<refiner.GetNumVertices(maxlevel); ++vert, ofs+=6) {
setColorBySharpness(refiner.GetVertexSharpness(maxlevel, vert), &vbo[ofs]);
for (int vert=0, ofs=3; vert<refLastLevel.GetNumVertices(); ++vert, ofs+=6) {
setColorBySharpness(refLastLevel.GetVertexSharpness(vert), &vbo[ofs]);
}
} else if (options.vertColorMode==VERTCOLOR_BY_PARENT_TYPE) {
int ofs=3;
if (maxlevel>0) {
for (int vert=0; vert<refiner.GetNumFaces(maxlevel-1); ++vert, ofs+=6) {
OpenSubdiv::Far::TopologyLevel const & refPrevLevel = refiner.GetLevel(maxlevel-1);
for (int vert=0; vert<refPrevLevel.GetNumFaces(); ++vert, ofs+=6) {
memcpy(&vbo[ofs], g_parentTypeColors[1], sizeof(float)*3);
}
for (int vert=0; vert<refiner.GetNumEdges(maxlevel-1); ++vert, ofs+=6) {
for (int vert=0; vert<refPrevLevel.GetNumEdges(); ++vert, ofs+=6) {
memcpy(&vbo[ofs], g_parentTypeColors[2], sizeof(float)*3);
}
for (int vert=0; vert<refiner.GetNumVertices(maxlevel-1); ++vert, ofs+=6) {
for (int vert=0; vert<refPrevLevel.GetNumVertices(); ++vert, ofs+=6) {
memcpy(&vbo[ofs], g_parentTypeColors[3], sizeof(float)*3);
}
} else {
for (int vert=0; vert<refiner.GetNumVertices(maxlevel); ++vert, ofs+=6) {
for (int vert=0; vert<refLastLevel.GetNumVertices(); ++vert, ofs+=6) {
memcpy(&vbo[ofs], g_parentTypeColors[0], sizeof(float)*3);
}
}
@ -337,7 +342,7 @@ GLMesh::initializeBuffers(Options options,
eao[edge*2 ] = edge*2;
eao[edge*2+1] = edge*2+1;
IndexArray const verts = refiner.GetEdgeVertices(maxlevel, edge);
IndexArray const verts = refLastLevel.GetEdgeVertices(edge);
float * v0 = &vbo[edge*2*6],
* v1 = v0+6;
@ -353,7 +358,7 @@ GLMesh::initializeBuffers(Options options,
setColorByLevel(maxlevel, v1+3);
} else if (options.edgeColorMode==EDGECOLOR_BY_SHARPNESS) {
float sharpness = refiner.GetEdgeSharpness(maxlevel, edge);
float sharpness = refLastLevel.GetEdgeSharpness(edge);
setColorBySharpness(sharpness, v0+3);
setColorBySharpness(sharpness, v1+3);
} else {
@ -372,7 +377,7 @@ GLMesh::initializeBuffers(Options options,
memcpy(&vbo[0], vertData, nverts*sizeof(float)*3);
int nfaceverts = refiner.GetNumFaceVertices(maxlevel);
int nfaceverts = refLastLevel.GetNumFaceVertices();
std::vector<int> & eao = _eao[COMP_FACE];
eao.resize(nfaceverts);
@ -381,7 +386,7 @@ GLMesh::initializeBuffers(Options options,
for (int face=0, ofs=0; face<nfaces; ++face) {
IndexArray fverts = refiner.GetFaceVertices(maxlevel, face);
IndexArray fverts = refLastLevel.GetFaceVertices(face);
for (int vert=0; vert<fverts.size(); ++vert) {
eao[ofs++] = fverts[vert];
}
@ -421,7 +426,7 @@ GLMesh::InitializeFVar(Options options, TopologyRefiner const & refiner,
if (options.vertColorMode==VERTCOLOR_BY_LEVEL) {
for (int level=0, ofs=3; level<=refiner.GetMaxLevel(); ++level) {
for (int vert=0; vert<refiner.GetNumFVarValues(level); ++vert, ofs+=6) {
for (int vert=0; vert<refiner.GetLevel(level).GetNumFVarValues(channel); ++vert, ofs+=6) {
assert(ofs<(int)vbo.size());
setColorByLevel(level, &vbo[ofs]);
}
@ -604,7 +609,7 @@ GLMesh::initializeBuffers(Options options, TopologyRefiner const & refiner,
if (options.vertColorMode==VERTCOLOR_BY_LEVEL) {
for (int level=0, ofs=3; level<=refiner.GetMaxLevel(); ++level) {
for (int vert=0; vert<refiner.GetNumVertices(level); ++vert, ofs+=6) {
for (int vert=0; vert<refiner.GetLevel(level).GetNumVertices(); ++vert, ofs+=6) {
assert(ofs<(int)vbo.size());
setColorByLevel(level, &vbo[ofs]);
}

View File

@ -178,22 +178,24 @@ createCoarseMesh(OpenSubdiv::Far::TopologyRefiner const & refiner) {
typedef OpenSubdiv::Far::ConstIndexArray IndexArray;
// save coarse topology (used for coarse mesh drawing)
int nedges = refiner.GetNumEdges(0),
nverts = refiner.GetNumVertices(0);
OpenSubdiv::Far::TopologyLevel const & refBaseLevel = refiner.GetLevel(0);
int nedges = refBaseLevel.GetNumEdges(),
nverts = refBaseLevel.GetNumVertices();
g_coarseEdges.resize(nedges*2);
g_coarseEdgeSharpness.resize(nedges);
g_coarseVertexSharpness.resize(nverts);
for(int i=0; i<nedges; ++i) {
IndexArray verts = refiner.GetEdgeVertices(0, i);
IndexArray verts = refBaseLevel.GetEdgeVertices(i);
g_coarseEdges[i*2 ]=verts[0];
g_coarseEdges[i*2+1]=verts[1];
g_coarseEdgeSharpness[i]=refiner.GetEdgeSharpness(0, i);
g_coarseEdgeSharpness[i]=refBaseLevel.GetEdgeSharpness(i);
}
for(int i=0; i<nverts; ++i) {
g_coarseVertexSharpness[i]=refiner.GetVertexSharpness(0, i);
g_coarseVertexSharpness[i]=refBaseLevel.GetVertexSharpness(i);
}
// assign a randomly generated color for each vertex ofthe mesh
@ -258,7 +260,7 @@ updateGeom() {
if (! g_topologyRefiner) return;
// note that for patch eval we need coarse+refined combined buffer.
int nCoarseVertices = g_topologyRefiner->GetNumVertices(0);
int nCoarseVertices = g_topologyRefiner->GetLevel(0).GetNumVertices();
Osd::CpuEvaluator::EvalStencils(g_vertexData,
Osd::VertexBufferDescriptor(0, 3, 3),
g_vertexData,

View File

@ -70,14 +70,15 @@ STParticles::STParticles(Refiner const & refiner, int nparticles, bool centered)
{ // initialize topology adjacency
_adjacency.resize(nptexfaces);
int nfaces = refiner.GetNumFaces(0),
OpenSubdiv::Far::TopologyLevel const & refBaseLevel = refiner.GetLevel(0);
int nfaces = refBaseLevel.GetNumFaces(),
adjfaces[4],
adjedges[4];
for (int face=0, ptexface=0; face<nfaces; ++face) {
OpenSubdiv::Far::ConstIndexArray fverts =
refiner.GetFaceVertices(0, face);
OpenSubdiv::Far::ConstIndexArray fverts = refBaseLevel.GetFaceVertices(face);
if (fverts.size()==4) {
ptexIndices.GetAdjacency(refiner, face, 0, adjfaces, adjedges);

View File

@ -280,13 +280,15 @@ calcNormals(OpenSubdiv::Far::TopologyRefiner const & refiner,
typedef OpenSubdiv::Far::ConstIndexArray IndexArray;
OpenSubdiv::Far::TopologyLevel const & refBaseLevel = refiner.GetLevel(0);
// calc normal vectors
int nverts = (int)pos.size()/3;
int nfaces = refiner.GetNumFaces(0);
int nfaces = refBaseLevel.GetNumFaces();
for (int face = 0; face < nfaces; ++face) {
IndexArray fverts = refiner.GetFaceVertices(0, face);
IndexArray fverts = refBaseLevel.GetFaceVertices(face);
assert(fverts.size()>=2);
@ -366,22 +368,23 @@ createOsdMesh(ShapeDesc const & shapeDesc, int level, Scheme scheme = kCatmark)
OpenSubdiv::Far::TopologyRefinerFactory<Shape>::Options(sdctype, sdcoptions));
// save coarse topology (used for coarse mesh drawing)
int nedges = refiner->GetNumEdges(0),
nverts = refiner->GetNumVertices(0);
OpenSubdiv::Far::TopologyLeve const & refBaseLevel = refiner->GetLevel(0);
int nedges = refBaseLevel.GetNumEdges(),
nverts = refBaseLevel.GetNumVertices();
g_coarseEdges.resize(nedges*2);
g_coarseEdgeSharpness.resize(nedges);
g_coarseVertexSharpness.resize(nverts);
for(int i=0; i<nedges; ++i) {
IndexArray verts = refiner->GetEdgeVertices(0, i);
IndexArray verts = refBaseLevel.GetEdgeVertices(i);
g_coarseEdges[i*2 ]=verts[0];
g_coarseEdges[i*2+1]=verts[1];
g_coarseEdgeSharpness[i]=refiner->GetEdgeSharpness(0, i);
g_coarseEdgeSharpness[i]=refBaseLevel.GetEdgeSharpness(i);
}
for(int i=0; i<nverts; ++i) {
g_coarseVertexSharpness[i]=refiner->GetVertexSharpness(0, i);
g_coarseVertexSharpness[i]=refBaseLevel.GetVertexSharpness(i);
}
g_orgPositions=shape->verts;

View File

@ -322,13 +322,15 @@ calcNormals(OpenSubdiv::Far::TopologyRefiner * refiner,
typedef OpenSubdiv::Far::ConstIndexArray IndexArray;
OpenSubdiv::Far::TopologyLevel const & refBaseLevel = refiner->GetLevel(0);
// calc normal vectors
int nverts = refiner->GetNumVertices(0),
nfaces = refiner->GetNumFaces(0);
int nverts = refBaseLevel.GetNumVertices(),
nfaces = refBaseLevel.GetNumFaces();
for (int face = 0; face < nfaces; ++face) {
IndexArray fverts = refiner->GetFaceVertices(0, face);
IndexArray fverts = refBaseLevel.GetFaceVertices(face);
float const * p0 = &pos[fverts[0]*3],
* p1 = &pos[fverts[1]*3],
@ -907,10 +909,12 @@ createOsdMesh(int level, int kernel) {
// save coarse topology (used for coarse mesh drawing)
// create cage edge index
int nedges = refiner->GetNumEdges(0);
OpenSubdiv::Far::TopologyLevel const & refBaseLevel = refiner->GetLevel(0);
int nedges = refBaseLevel.GetNumEdges();
std::vector<int> edgeIndices(nedges*2);
for(int i=0; i<nedges; ++i) {
IndexArray verts = refiner->GetEdgeVertices(0, i);
IndexArray verts = refBaseLevel.GetEdgeVertices(i);
edgeIndices[i*2 ]=verts[0];
edgeIndices[i*2+1]=verts[1];
}

View File

@ -165,7 +165,7 @@ SceneBase::createStencilTable(Shape const *shape, int level, bool varying,
}
}
}
int numControlVertices = refiner->GetNumVertices(0);
int numControlVertices = refiner->GetLevel(0).GetNumVertices();
_stencilTableSize = createMeshRefiner(vertexStencils, varyingStencils,
numControlVertices);

View File

@ -284,22 +284,24 @@ createMesh(ShapeDesc const & shapeDesc, int level) {
OpenSubdiv::Far::TopologyRefinerFactory<Shape>::Options(sdctype, sdcoptions));
// save coarse topology (used for coarse mesh drawing)
int nedges = refiner->GetNumEdges(0),
nverts = refiner->GetNumVertices(0);
OpenSubdiv::Far::TopologyLevel const & refBaseLevel = refiner->GetLevel(0);
int nedges = refBaseLevel.GetNumEdges(),
nverts = refBaseLevel.GetNumVertices();
g_coarseEdges.resize(nedges*2);
g_coarseEdgeSharpness.resize(nedges);
g_coarseVertexSharpness.resize(nverts);
for(int i=0; i<nedges; ++i) {
IndexArray verts = refiner->GetEdgeVertices(0, i);
IndexArray verts = refBaseLevel.GetEdgeVertices(i);
g_coarseEdges[i*2 ]=verts[0];
g_coarseEdges[i*2+1]=verts[1];
g_coarseEdgeSharpness[i]=refiner->GetEdgeSharpness(0, i);
g_coarseEdgeSharpness[i]=refBaseLevel.GetEdgeSharpness(i);
}
for(int i=0; i<nverts; ++i) {
g_coarseVertexSharpness[i]=refiner->GetVertexSharpness(0, i);
g_coarseVertexSharpness[i]=refBaseLevel.GetVertexSharpness(i);
}
g_orgPositions=shape->verts;

View File

@ -533,22 +533,24 @@ createOsdMesh(ShapeDesc const & shapeDesc, int level, int kernel, Scheme scheme=
Far::TopologyRefinerFactory<Shape>::Options(sdctype, sdcoptions));
// save coarse topology (used for coarse mesh drawing)
int nedges = refiner->GetNumEdges(0),
nverts = refiner->GetNumVertices(0);
OpenSubdiv::Far::TopologyLevel const & refBaseLevel = refiner->GetLevel(0);
int nedges = refBaseLevel.GetNumEdges(),
nverts = refBaseLevel.GetNumVertices();
g_coarseEdges.resize(nedges*2);
g_coarseEdgeSharpness.resize(nedges);
g_coarseVertexSharpness.resize(nverts);
for(int i=0; i<nedges; ++i) {
IndexArray verts = refiner->GetEdgeVertices(0, i);
IndexArray verts = refBaseLevel.GetEdgeVertices(i);
g_coarseEdges[i*2 ]=verts[0];
g_coarseEdges[i*2+1]=verts[1];
g_coarseEdgeSharpness[i]=refiner->GetEdgeSharpness(0, i);
g_coarseEdgeSharpness[i]=refBaseLevel.GetEdgeSharpness(i);
}
for(int i=0; i<nverts; ++i) {
g_coarseVertexSharpness[i]=refiner->GetVertexSharpness(0, i);
g_coarseVertexSharpness[i]=refBaseLevel.GetVertexSharpness(i);
}
g_orgPositions=shape->verts;

View File

@ -524,7 +524,10 @@ convertToMayaMeshData(OpenSubdiv::Far::TopologyRefiner const & refiner,
typedef OpenSubdiv::Far::ConstIndexArray IndexArray;
int maxlevel = refiner.GetMaxLevel(),
nfaces = refiner.GetNumFaces(maxlevel);
OpenSubdiv::Far::TopologyLevel const & refLastLevel = refiner.GetLevel(maxLevel);
int nfaces = refLastLevel.GetNumFaces();
// Init Maya Data
@ -537,18 +540,18 @@ convertToMayaMeshData(OpenSubdiv::Far::TopologyRefiner const & refiner,
// -- Face Connects
MIntArray faceConnects(nfaces*4);
for (int face=0, idx=0; face < nfaces; ++face) {
IndexArray fverts = refiner.GetFaceVertices(maxlevel, face);
IndexArray fverts = refLastLevel.GetFaceVertices(face);
for (int vert=0; vert < fverts.size(); ++vert) {
faceConnects[idx++] = fverts[vert];
}
}
// -- Points
MFloatPointArray points(refiner.GetNumVertices(maxlevel));
MFloatPointArray points(refLastLevel.GetNumVertices());
Vertex const * v = &vertexBuffer.at(0);
for (int level=1; level<=maxlevel; ++level) {
int nverts = refiner.GetNumVertices(level);
int nverts = refiner.GetLevel(level).GetNumVertices();
if (level==maxlevel) {
for (int vert=0; vert < nverts; ++vert, ++v) {
points.set(vert, v->position[0], v->position[1], v->position[2]);
@ -652,7 +655,7 @@ MayaPolySmooth::compute( const MPlug& plug, MDataBlock& data ) {
reinterpret_cast<Vertex const *>(inMeshFn.getRawPoints(&status));
std::vector<Vertex> refinedVerts(
refiner->GetNumVerticesTotal() - refiner->GetNumVertices(0));
refiner->GetNumVerticesTotal() - refiner->GetLevel(0).GetNumVertices());
refiner->Interpolate(controlVerts, &refinedVerts.at(0));
@ -669,7 +672,7 @@ MayaPolySmooth::compute( const MPlug& plug, MDataBlock& data ) {
// Propagate objectGroups from inMesh to outMesh (for per-facet shading, etc)
status = createSmoothMesh_objectGroups(inMeshFn, inMeshDat,
newMeshData, subdivisionLevel, refiner->GetNumFaces(subdivisionLevel));
newMeshData, subdivisionLevel, refiner->GetLevel(subdivisionLevel).GetNumFaces());
// Write to output plug
MDataHandle outMeshH = data.outputValue(a_output, &status);

View File

@ -70,10 +70,11 @@ GetReorderedHbrVertexData(
{ // Populate base level
// note : topological ordering is identical between Hbr and Vtr
// for the base level
OpenSubdiv::Far::TopologyLevel const & refBaseLevel = refiner.GetLevel(0);
int nfaces = refiner.GetNumFaces(0),
nedges = refiner.GetNumEdges(0),
nverts = refiner.GetNumVertices(0);
int nfaces = refBaseLevel.GetNumFaces(),
nedges = refBaseLevel.GetNumEdges(),
nverts = refBaseLevel.GetNumVertices();
maps[0].faces.resize(nfaces, 0);
maps[0].edges.resize(nedges, 0);
@ -85,7 +86,7 @@ GetReorderedHbrVertexData(
for (int edge = 0; edge <nedges; ++edge) {
ConstIndexArray vtrVerts = refiner.GetEdgeVertices(0, edge);
ConstIndexArray vtrVerts = refBaseLevel.GetEdgeVertices(edge);
Hvertex const * v0 = hmesh.GetVertex(vtrVerts[0]),
* v1 = hmesh.GetVertex(vtrVerts[1]);
@ -110,16 +111,19 @@ GetReorderedHbrVertexData(
LevelMap & previous = maps[level-1],
& current = maps[level];
current.faces.resize(refiner.GetNumFaces(level), 0);
current.edges.resize(refiner.GetNumEdges(level), 0);
current.verts.resize(refiner.GetNumVertices(level), 0);
OpenSubdiv::Far::TopologyLevel const & refLevel = refiner.GetLevel(level);
OpenSubdiv::Far::TopologyLevel const & refPrevLevel = refiner.GetLevel(level-1);
for (int face=0; face < refiner.GetNumFaces(level-1); ++face) {
current.faces.resize(refLevel.GetNumFaces(), 0);
current.edges.resize(refLevel.GetNumEdges(), 0);
current.verts.resize(refLevel.GetNumVertices(), 0);
for (int face=0; face < refPrevLevel.GetNumFaces(); ++face) {
// populate child faces
Hface * f = previous.faces[face];
ConstIndexArray childFaces = refiner.GetFaceChildFaces(level-1, face);
ConstIndexArray childFaces = refPrevLevel.GetFaceChildFaces(face);
for (int i=0; i<childFaces.size(); ++i) {
current.faces[childFaces[i]] = f->GetChild(i);
}
@ -127,33 +131,33 @@ GetReorderedHbrVertexData(
// populate child face-verts -- when present (none for Loop subdivision)
if (!schemeIsLoop) {
Hvertex * v = f->Subdivide();
Index childVert = refiner.GetFaceChildVertex(level-1, face);
Index childVert = refPrevLevel.GetFaceChildVertex(face);
assert(v->GetParentFace());
current.verts[childVert] = v;
}
}
for (int edge=0; edge < refiner.GetNumEdges(level-1); ++edge) {
for (int edge=0; edge < refPrevLevel.GetNumEdges(); ++edge) {
// populate child edge-verts
Index childVert = refiner.GetEdgeChildVertex(level-1,edge);
Index childVert = refPrevLevel.GetEdgeChildVertex(edge);
Hhalfedge * e = previous.edges[edge];
Hvertex * v = e->Subdivide();
assert(v->GetParentEdge());
current.verts[childVert] = v;
}
for (int vert = 0; vert < refiner.GetNumVertices(level-1); ++vert) {
for (int vert = 0; vert < refPrevLevel.GetNumVertices(); ++vert) {
// populate child vert-verts
Index childVert = refiner.GetVertexChildVertex(level-1, vert);
Index childVert = refPrevLevel.GetVertexChildVertex(vert);
Hvertex * v = previous.verts[vert]->Subdivide();
current.verts[childVert] = v;
assert(v->GetParentVertex());
}
// populate child edges
for (int edge=0; edge < refiner.GetNumEdges(level); ++edge) {
for (int edge=0; edge < refLevel.GetNumEdges(); ++edge) {
ConstIndexArray vtrVerts = refiner.GetEdgeVertices(level, edge);
ConstIndexArray vtrVerts = refLevel.GetEdgeVertices(edge);
Hvertex const * v0 = current.verts[vtrVerts[0]],
* v1 = current.verts[vtrVerts[1]];
@ -166,7 +170,7 @@ GetReorderedHbrVertexData(
assert(e);
current.edges[edge] = e;
}
ecount += refiner.GetNumEdges(level-1);
ecount += refPrevLevel.GetNumEdges();
}
}
};

View File

@ -46,7 +46,7 @@ InterpolateFVarData(OpenSubdiv::Far::TopologyRefiner & refiner,
fvarWidth = 2;
int numValuesTotal = refiner.GetNumFVarValuesTotal(channel),
numValues0 = refiner.GetNumFVarValues(0, channel);
numValues0 = refiner.GetLevel(0).GetNumFVarValues(channel);
if (shape.uvs.empty() or numValuesTotal<=0) {
return;
@ -57,7 +57,7 @@ InterpolateFVarData(OpenSubdiv::Far::TopologyRefiner & refiner,
std::vector<FVarVertex> buffer(numValuesTotal);
int maxlevel = refiner.GetMaxLevel(),
numValuesM = refiner.GetNumFVarValues(maxlevel, channel);
numValuesM = refiner.GetLevel(maxlevel).GetNumFVarValues(channel);
memcpy(&buffer[0], &shape.uvs[0], shape.uvs.size()*sizeof(float));

View File

@ -155,14 +155,14 @@ InterpolateVtrVertexData(const char *shapeStr, Scheme scheme, int maxlevel,
// populate coarse mesh positions
data.resize(refiner->GetNumVerticesTotal());
for (int i=0; i<refiner->GetNumVertices(0); i++) {
for (int i=0; i<refiner->GetLevel(0).GetNumVertices(); i++) {
data[i].SetPosition(shape->verts[i*3+0],
shape->verts[i*3+1],
shape->verts[i*3+2]);
}
T * verts = &data[0];
refiner->Interpolate(verts, verts+refiner->GetNumVertices(0));
refiner->Interpolate(verts, verts+refiner->GetLevel(0).GetNumVertices());
delete shape;
return refiner;
@ -204,7 +204,7 @@ TopologyRefinerFactory<Shape>::assignComponentTopology(
Far::TopologyRefiner & refiner, Shape const & shape) {
{ // Face relations:
int nfaces = refiner.GetNumFaces(0);
int nfaces = refiner.GetLevel(0).GetNumFaces();
for (int i=0, ofs=0; i < nfaces; ++i) {
@ -235,7 +235,7 @@ TopologyRefinerFactory<Shape>::assignFaceVaryingTopology(
// UV layyout (we only parse 1 channel)
if (not shape.faceuvs.empty()) {
int nfaces = refiner.GetNumFaces(0),
int nfaces = refiner.GetLevel(0).GetNumFaces(),
channel = refiner.createBaseFVarChannel( (int)shape.uvs.size()/2 );
for (int i=0, ofs=0; i < nfaces; ++i) {
@ -273,7 +273,7 @@ TopologyRefinerFactory<Shape>::assignComponentTags(
for (int j=0; j<(int)t->intargs.size()-1; j += 2) {
OpenSubdiv::Vtr::Index edge = refiner.FindEdge(/*level*/0, t->intargs[j], t->intargs[j+1]);
OpenSubdiv::Vtr::Index edge = refiner.GetLevel(0).FindEdge(t->intargs[j], t->intargs[j+1]);
if (edge==OpenSubdiv::Vtr::INDEX_INVALID) {
printf("cannot find edge for crease tag (%d,%d)\n", t->intargs[j], t->intargs[j+1] );
return false;
@ -287,7 +287,7 @@ TopologyRefinerFactory<Shape>::assignComponentTags(
for (int j=0; j<(int)t->intargs.size(); ++j) {
int vertex = t->intargs[j];
if (vertex<0 or vertex>=refiner.GetNumVertices(/*level*/0)) {
if (vertex<0 or vertex>=refiner.GetLevel(0).GetNumVertices()) {
printf("cannot find vertex for corner tag (%d)\n", vertex );
return false;
} else {

View File

@ -284,7 +284,7 @@ checkMeshCPU( FarTopologyRefiner *refiner,
vb,
Osd::VertexBufferDescriptor(0, 3, 3),
vb,
Osd::VertexBufferDescriptor(refiner->GetNumVertices(0)*3, 3, 3),
Osd::VertexBufferDescriptor(refiner->GetLevel(0).GetNumVertices()*3, 3, 3),
vertexStencils);
int result = checkVertexBuffer(*refiner, refmesh, vb->BindCpuBuffer(),
@ -316,7 +316,7 @@ checkMeshCPUGL(FarTopologyRefiner *refiner,
vb,
Osd::VertexBufferDescriptor(0, 3, 3),
vb,
Osd::VertexBufferDescriptor(refiner->GetNumVertices(0)*3, 3, 3),
Osd::VertexBufferDescriptor(refiner->GetLevel(0).GetNumVertices()*3, 3, 3),
vertexStencils);
int result = checkVertexBuffer(*refiner, refmesh,

View File

@ -149,23 +149,25 @@ int main(int, char **) {
{ // Output OBJ of the highest level refined -----------
Far::TopologyLevel const & refLastLevel = refiner->GetLevel(maxlevel);
// Print vertex positions
for (int level=0, firstVert=0; level<=maxlevel; ++level) {
if (level==maxlevel) {
for (int vert=0; vert<refiner->GetNumVertices(maxlevel); ++vert) {
for (int vert=0; vert<refLastLevel.GetNumVertices(); ++vert) {
float const * pos = verts[firstVert+vert].GetPosition();
printf("v %f %f %f\n", pos[0], pos[1], pos[2]);
}
} else {
firstVert += refiner->GetNumVertices(level);
firstVert += refiner->GetLevel(level).GetNumVertices();
}
}
// Print faces
for (int face=0; face<refiner->GetNumFaces(maxlevel); ++face) {
for (int face=0; face<refLastLevel.GetNumFaces(); ++face) {
Far::ConstIndexArray fverts = refiner->GetFaceVertices(maxlevel, face);
Far::ConstIndexArray fverts = refLastLevel.GetFaceVertices(face);
// all refined Catmark faces should be quads
assert(fverts.size()==4);

View File

@ -454,23 +454,25 @@ int main(int, char **) {
{ // Output OBJ of the highest level refined -----------
Far::TopologyLevel const & refLastLevel = refiner->GetLevel(maxlevel);
// Print vertex positions
for (int level=0, firstVert=0; level<=maxlevel; ++level) {
if (level==maxlevel) {
for (int vert=0; vert<refiner->GetNumVertices(maxlevel); ++vert) {
for (int vert=0; vert<refLastLevel.GetNumVertices(); ++vert) {
float const * pos = verts[firstVert+vert].GetPosition();
printf("v %f %f %f\n", pos[0], pos[1], pos[2]);
}
} else {
firstVert += refiner->GetNumVertices(level);
firstVert += refiner->GetLevel(level).GetNumVertices();
}
}
// Print faces
for (int face=0; face<refiner->GetNumFaces(maxlevel); ++face) {
for (int face=0; face<refLastLevel.GetNumFaces(); ++face) {
Far::ConstIndexArray fverts = refiner->GetFaceVertices(maxlevel, face);
Far::ConstIndexArray fverts = refLastLevel.GetFaceVertices(face);
// all refined Catmark faces should be quads
assert(fverts.size()==4);

View File

@ -339,7 +339,7 @@ FarTopologyRefinerFactory<OsdHbrConverter>::assignComponentTopology(
OsdHbrConverter::EdgeMap & edges = const_cast<OsdHbrConverter &>(conv).GetEdges();
{ // Face relations:
int nfaces = refiner.GetNumFaces(/*level*/0);
int nfaces = refiner.GetLevel(0).GetNumFaces();
for (int i=0; i < nfaces; ++i) {
IndexArray dstFaceVerts = refiner.setBaseFaceVertices(i);
@ -377,7 +377,7 @@ FarTopologyRefinerFactory<OsdHbrConverter>::assignComponentTopology(
}
{ // Vert relations
for (int i=0; i<refiner.GetNumVertices(/*level*/0); ++i) {
for (int i=0; i<refiner.GetLevel(0).GetNumVertices(); ++i) {
OsdHbrVertex const * v = hmesh.GetVertex(i);
@ -451,7 +451,7 @@ FarTopologyRefinerFactory<OsdHbrConverter>::assignComponentTags(
}
// Initialize vertex sharpness
for (int i=0; i<refiner.GetNumVertices(/*level*/0); ++i) {
for (int i=0; i<refiner.GetLevel(0).GetNumVertices(); ++i) {
refiner.setBaseVertexSharpness(i, hmesh.GetVertex(i)->GetSharpness());
}

View File

@ -166,11 +166,11 @@ int main(int, char **) {
// particles at the location of the refined vertices (don't forget to
// turn shading on in the viewport to see the colors)
int nverts = refiner->GetNumVertices(maxlevel);
int nverts = refiner->GetLevel(maxlevel).GetNumVertices();
// Position the 'verts' pointer to the first vertex of our 'maxlevel' level
for (int level=0; level<maxlevel; ++level) {
verts += refiner->GetNumVertices(level);
verts += refiner->GetLevel(level).GetNumVertices();
}
// Output particle positions

View File

@ -214,7 +214,7 @@ int main(int, char **) {
// Allocate & interpolate the 'face-varying' primvar data
int channel = 0,
nCoarseFVVerts = refiner->GetNumFVarValues(0, channel);
nCoarseFVVerts = refiner->GetLevel(0).GetNumFVarValues(channel);
std::vector<FVarVertex> fvBuffer(refiner->GetNumFVarValuesTotal(channel));
FVarVertex * fvVerts = &fvBuffer[0];
@ -229,16 +229,18 @@ int main(int, char **) {
{ // Output OBJ of the highest level refined -----------
Far::TopologyLevel const & refLastLevel = refiner->GetLevel(maxlevel).
// Print vertex positions
for (int level=0, firstVert=0; level<=maxlevel; ++level) {
if (level==maxlevel) {
for (int vert=0; vert<refiner->GetNumVertices(level); ++vert) {
for (int vert=0; vert<refLastLevel.GetNumVertices(); ++vert) {
float const * pos = verts[firstVert+vert].GetPosition();
printf("v %f %f %f\n", pos[0], pos[1], pos[2]);
}
} else {
firstVert += refiner->GetNumVertices(level);
firstVert += refiner->GetLevel(level).GetNumVertices();
}
}
@ -246,21 +248,21 @@ int main(int, char **) {
for (int level=0, firstVert=0; level<=maxlevel; ++level) {
if (level==maxlevel) {
for (int vert=0; vert<refiner->GetNumFVarValues(level, channel); ++vert) {
for (int vert=0; vert<refLastLevel.GetNumFVarValues(channel); ++vert) {
FVarVertex const & uv = fvVerts[firstVert+vert];
printf("vt %f %f\n", uv.u, uv.v);
}
} else {
firstVert += refiner->GetNumFVarValues(level, channel);
firstVert += refiner->GetLevel(level).GetNumFVarValues(channel);
}
}
// Print faces
for (int face=0; face<refiner->GetNumFaces(maxlevel); ++face) {
for (int face=0; face<refLastLevel.GetNumFaces(); ++face) {
Far::ConstIndexArray fverts = refiner->GetFaceVertices(maxlevel, face),
fvverts = refiner->GetFVarFaceValues(maxlevel, face, channel);
Far::ConstIndexArray fverts = refLastLevel.GetFaceVertices(face),
fvverts = refLastLevel.GetFVarFaceValues(face, channel);
// all refined Catmark faces should be quads
assert(fverts.size()==4 and fvverts.size()==4);

View File

@ -121,7 +121,7 @@ int main(int, char **) {
int maxlevel = 4;
refiner->RefineUniform(Far::TopologyRefiner::UniformOptions(maxlevel));
int nverts = refiner->GetNumVertices(maxlevel);
int nverts = refiner->GetLevel(maxlevel).GetNumVertices();
// Use the Far::StencilTables factory to create discrete stencil tables
Far::StencilTablesFactory::Options options;

View File

@ -150,7 +150,7 @@ int main(int, char **) {
int start = 0, end = 0; // stencils batches for each level of subdivision
for (int level=0; level<maxlevel; ++level) {
int nverts = refiner->GetNumVertices(level+1);
int nverts = refiner->GetLevel(level+1).GetNumVertices();
Vertex const * srcVerts = reinterpret_cast<Vertex *>(g_verts);
if (level>0) {
@ -180,9 +180,11 @@ int main(int, char **) {
// Print vertex positions
for (int level=1, firstvert=0; level<=maxlevel; ++level) {
Far::TopologyLevel conat & refLevel = refiner->GetLevel(level);
printf("g level_%d\n", level);
int nverts = refiner->GetNumVertices(level);
int nverts = refLevel.GetNumVertices();
for (int vert=0; vert<nverts; ++vert) {
float const * pos = verts[vert].GetPosition();
printf("v %f %f %f\n", pos[0], pos[1], pos[2]);
@ -190,9 +192,9 @@ int main(int, char **) {
verts += nverts;
// Print faces
for (int face=0; face<refiner->GetNumFaces(level); ++face) {
for (int face=0; face<refLevel.GetNumFaces(); ++face) {
Far::ConstIndexArray fverts = refiner->GetFaceVertices(level, face);
Far::ConstIndexArray fverts = refLevel.GetFaceVertices(face);
// all refined Catmark faces should be quads
assert(fverts.size()==4);

View File

@ -87,7 +87,7 @@ int main(int, char **) {
stencilTables = Far::StencilTablesFactory::Create(*refiner, options);
nCoarseVerts = refiner->GetNumVertices(0);
nCoarseVerts = refiner->GetLevel(0).GetNumVertices();
nRefinedVerts = stencilTables->GetNumStencils();
// We are done with Far: cleanup tables