Merge pull request #522 from barfowl/primvarRefiner

Moved primvar interpolation methods to new Far::PrimvarRefiner class
This commit is contained in:
Jeremy Cowles 2015-05-24 22:18:26 -07:00
commit d335c7249e
13 changed files with 1309 additions and 1210 deletions

View File

@ -53,6 +53,7 @@ GLFWmonitor* g_primary=0;
#include <far/patchTableFactory.h>
#include <far/stencilTable.h>
#include <far/stencilTableFactory.h>
#include <far/primvarRefiner.h>
#include <common/vtr_utils.h>
@ -651,7 +652,7 @@ createFarGLMesh(Shape * shape, int maxlevel) {
float const * ptr = &shape->uvs[i*2];
values[i].SetPosition(ptr[0], ptr[1], 0.0f);
}
refiner->InterpolateFaceVarying(values, values + nCoarseValues);
Far::PrimvarRefiner(*refiner).InterpolateFaceVarying(values, values + nCoarseValues);
}
}
@ -703,7 +704,7 @@ createFarGLMesh(Shape * shape, int maxlevel) {
// TopologyRefiner interpolation
//
// populate buffer with Far interpolated vertex data
refiner->Interpolate(verts, verts + ncoarseverts);
Far::PrimvarRefiner(*refiner).Interpolate(verts, verts + ncoarseverts);
//printf(" %f ms (interpolate)\n", float(s.GetElapsed())*1000.0f);
//printf(" %f ms (total)\n", float(s.GetTotalElapsed())*1000.0f);

View File

@ -62,6 +62,7 @@
// OpenSubdiv includes
#include <far/topologyRefinerFactory.h>
#include <far/stencilTableFactory.h>
#include <far/primvarRefiner.h>
#include <osd/mesh.h>
#include <osd/cpuVertexBuffer.h>
@ -658,7 +659,7 @@ MayaPolySmooth::compute( const MPlug& plug, MDataBlock& data ) {
std::vector<Vertex> refinedVerts(
refiner->GetNumVerticesTotal() - refiner->GetLevel(0).GetNumVertices());
refiner->Interpolate(controlVerts, &refinedVerts.at(0));
OpenSubdiv::Far::PrimvarRefiner(*refiner).Interpolate(controlVerts, &refinedVerts.at(0));
// == Convert subdivided OpenSubdiv mesh to MFnMesh Data outputMesh =============

View File

@ -59,6 +59,7 @@ set(PUBLIC_HEADER_FILES
patchMap.h
patchTable.h
patchTableFactory.h
primvarRefiner.h
ptexIndices.h
stencilTable.h
stencilTableFactory.h

File diff suppressed because it is too large Load Diff

View File

@ -29,6 +29,7 @@
#include "../far/patchTableFactory.h"
#include "../far/patchMap.h"
#include "../far/topologyRefiner.h"
#include "../far/primvarRefiner.h"
#include <cassert>
#include <algorithm>
@ -76,16 +77,18 @@ StencilTableFactory::Create(TopologyRefiner const & refiner,
//
// Interpolate stencils for each refinement level using
// TopologyRefiner::InterpolateLevel<>()
// PrimvarRefiner::InterpolateLevel<>()
//
PrimvarRefiner primvarRefiner(refiner);
Internal::StencilBuilder::Index srcIndex(&builder, 0);
Internal::StencilBuilder::Index dstIndex(&builder,
refiner.GetLevel(0).GetNumVertices());
for (int level=1; level<=maxlevel; ++level) {
if (not interpolateVarying) {
refiner.Interpolate(level, srcIndex, dstIndex);
primvarRefiner.Interpolate(level, srcIndex, dstIndex);
} else {
refiner.InterpolateVarying(level, srcIndex, dstIndex);
primvarRefiner.InterpolateVarying(level, srcIndex, dstIndex);
}
srcIndex = dstIndex;

File diff suppressed because it is too large Load Diff

View File

@ -61,7 +61,7 @@ InterpolateFVarData(OpenSubdiv::Far::TopologyRefiner & refiner,
memcpy(&buffer[0], &shape.uvs[0], shape.uvs.size()*sizeof(float));
refiner.InterpolateFaceVarying(
OpenSubdiv::Far::PrimvarRefiner(refiner).InterpolateFaceVarying(
&buffer[0], &buffer[numValues0], channel);
// we only keep the highest level of refinement !
@ -78,6 +78,7 @@ InterpolateFVarData(OpenSubdiv::Far::TopologyRefiner & refiner,
memcpy(src, &shape.uvs[0], shape.uvs.size()*sizeof(float));
refiner.InterpolateFaceVarying(src, dst, channel);
OpenSubdiv::Far::PrimvarRefiner(refiner).InterpolateFaceVarying(
src, dst, channel);
}
}

View File

@ -26,6 +26,7 @@
#define VTR_UTILS_H
#include <far/topologyRefinerFactory.h>
#include <far/primvarRefiner.h>
#include <far/types.h>
#include "../../regression/common/shape_utils.h"
@ -162,7 +163,9 @@ InterpolateVtrVertexData(const char *shapeStr, Scheme scheme, int maxlevel,
}
T * verts = &data[0];
refiner->Interpolate(verts, verts+refiner->GetLevel(0).GetNumVertices());
OpenSubdiv::Far::PrimvarRefiner(*refiner).Interpolate(
verts, verts+refiner->GetLevel(0).GetNumVertices());
delete shape;
return refiner;

View File

@ -31,6 +31,7 @@
//
#include <opensubdiv/far/topologyRefinerFactory.h>
#include <opensubdiv/far/primvarRefiner.h>
#include <cstdio>
@ -143,8 +144,7 @@ int main(int, char **) {
// Interpolate vertex primvar data
refiner->Interpolate(verts, verts + nCoarseVerts);
Far::PrimvarRefiner(*refiner).Interpolate(verts, verts + nCoarseVerts);
{ // Output OBJ of the highest level refined -----------

View File

@ -43,6 +43,7 @@
#include <opensubdiv/far/topologyRefinerFactory.h>
#include <opensubdiv/far/primvarRefiner.h>
//------------------------------------------------------------------------------
@ -448,8 +449,7 @@ int main(int, char **) {
// Interpolate vertex primvar data
refiner->Interpolate(verts, verts + nCoarseVerts);
Far::PrimvarRefiner(*refiner).Interpolate(verts, verts + nCoarseVerts);
{ // Output OBJ of the highest level refined -----------

View File

@ -32,6 +32,7 @@
//
#include <opensubdiv/far/topologyRefinerFactory.h>
#include <opensubdiv/far/primvarRefiner.h>
#include <cstdio>
@ -155,11 +156,11 @@ int main(int, char **) {
verts[i].SetColor(g_colors[i][0], g_colors[i][1], g_colors[i][2]);
}
// Interpolate all primvar data - not that this will perform both 'vertex' and
// 'varying' interpolation at once by calling each specialized method in our
// Vertex class with the appropriate weights.
refiner->Interpolate(verts, verts + nCoarseVerts);
Far::PrimvarRefiner(*refiner).Interpolate(verts, verts + nCoarseVerts);
{ // Visualization with Maya : print a MEL script that generates colored

View File

@ -34,6 +34,7 @@
//
#include <opensubdiv/far/topologyRefinerFactory.h>
#include <opensubdiv/far/primvarRefiner.h>
#include <cstdio>
@ -194,9 +195,9 @@ int main(int, char **) {
// Uniformly refine the topolgy up to 'maxlevel'
// note: fullTopologyInLastLevel must be true to work with face-varying data
{
Far::TopologyRefiner::UniformOptions options(maxlevel);
options.fullTopologyInLastLevel = true;
refiner->RefineUniform(options);
Far::TopologyRefiner::UniformOptions refineOptions(maxlevel);
refineOptions.fullTopologyInLastLevel = true;
refiner->RefineUniform(refineOptions);
}
// Allocate & interpolate the 'vertex' primvar data (see tutorial 2 for
@ -209,7 +210,7 @@ int main(int, char **) {
verts[i].SetPosition(g_verts[i][0], g_verts[i][1], g_verts[i][2]);
}
refiner->Interpolate(verts, verts + nCoarseVerts);
Far::PrimvarRefiner(*refiner).Interpolate(verts, verts + nCoarseVerts);
// Allocate & interpolate the 'face-varying' primvar data
@ -224,7 +225,7 @@ int main(int, char **) {
fvVerts[i].v = g_uvs[i][1];
}
refiner->InterpolateFaceVarying(fvVerts, fvVerts + nCoarseFVVerts, channel);
Far::PrimvarRefiner(*refiner).InterpolateFaceVarying(fvVerts, fvVerts + nCoarseFVVerts, channel);
{ // Output OBJ of the highest level refined -----------

View File

@ -41,6 +41,7 @@
//
#include <opensubdiv/far/topologyRefinerFactory.h>
#include <opensubdiv/far/primvarRefiner.h>
#include <opensubdiv/far/patchTableFactory.h>
#include <opensubdiv/far/endCapGregoryBasisPatchFactory.h>
#include <opensubdiv/far/patchMap.h>
@ -152,7 +153,7 @@ int main(int, char **) {
// Interpolate vertex primvar data : they are the control vertices
// of the limit patches (see far_tutorial_0 for details)
refiner->Interpolate(&verts[0], &verts[g_nverts]);
Far::PrimvarRefiner(*refiner).Interpolate(&verts[0], &verts[g_nverts]);
// Generate a set of Far::PatchTable that we will use to evaluate the