mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-12-01 07:40:07 +00:00
Merge pull request #522 from barfowl/primvarRefiner
Moved primvar interpolation methods to new Far::PrimvarRefiner class
This commit is contained in:
commit
d335c7249e
@ -53,6 +53,7 @@ GLFWmonitor* g_primary=0;
|
|||||||
#include <far/patchTableFactory.h>
|
#include <far/patchTableFactory.h>
|
||||||
#include <far/stencilTable.h>
|
#include <far/stencilTable.h>
|
||||||
#include <far/stencilTableFactory.h>
|
#include <far/stencilTableFactory.h>
|
||||||
|
#include <far/primvarRefiner.h>
|
||||||
|
|
||||||
#include <common/vtr_utils.h>
|
#include <common/vtr_utils.h>
|
||||||
|
|
||||||
@ -651,7 +652,7 @@ createFarGLMesh(Shape * shape, int maxlevel) {
|
|||||||
float const * ptr = &shape->uvs[i*2];
|
float const * ptr = &shape->uvs[i*2];
|
||||||
values[i].SetPosition(ptr[0], ptr[1], 0.0f);
|
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
|
// TopologyRefiner interpolation
|
||||||
//
|
//
|
||||||
// populate buffer with Far interpolated vertex data
|
// 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 (interpolate)\n", float(s.GetElapsed())*1000.0f);
|
||||||
//printf(" %f ms (total)\n", float(s.GetTotalElapsed())*1000.0f);
|
//printf(" %f ms (total)\n", float(s.GetTotalElapsed())*1000.0f);
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@
|
|||||||
// OpenSubdiv includes
|
// OpenSubdiv includes
|
||||||
#include <far/topologyRefinerFactory.h>
|
#include <far/topologyRefinerFactory.h>
|
||||||
#include <far/stencilTableFactory.h>
|
#include <far/stencilTableFactory.h>
|
||||||
|
#include <far/primvarRefiner.h>
|
||||||
|
|
||||||
#include <osd/mesh.h>
|
#include <osd/mesh.h>
|
||||||
#include <osd/cpuVertexBuffer.h>
|
#include <osd/cpuVertexBuffer.h>
|
||||||
@ -658,7 +659,7 @@ MayaPolySmooth::compute( const MPlug& plug, MDataBlock& data ) {
|
|||||||
std::vector<Vertex> refinedVerts(
|
std::vector<Vertex> refinedVerts(
|
||||||
refiner->GetNumVerticesTotal() - refiner->GetLevel(0).GetNumVertices());
|
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 =============
|
// == Convert subdivided OpenSubdiv mesh to MFnMesh Data outputMesh =============
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ set(PUBLIC_HEADER_FILES
|
|||||||
patchMap.h
|
patchMap.h
|
||||||
patchTable.h
|
patchTable.h
|
||||||
patchTableFactory.h
|
patchTableFactory.h
|
||||||
|
primvarRefiner.h
|
||||||
ptexIndices.h
|
ptexIndices.h
|
||||||
stencilTable.h
|
stencilTable.h
|
||||||
stencilTableFactory.h
|
stencilTableFactory.h
|
||||||
|
1265
opensubdiv/far/primvarRefiner.h
Normal file
1265
opensubdiv/far/primvarRefiner.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -29,6 +29,7 @@
|
|||||||
#include "../far/patchTableFactory.h"
|
#include "../far/patchTableFactory.h"
|
||||||
#include "../far/patchMap.h"
|
#include "../far/patchMap.h"
|
||||||
#include "../far/topologyRefiner.h"
|
#include "../far/topologyRefiner.h"
|
||||||
|
#include "../far/primvarRefiner.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -76,16 +77,18 @@ StencilTableFactory::Create(TopologyRefiner const & refiner,
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Interpolate stencils for each refinement level using
|
// Interpolate stencils for each refinement level using
|
||||||
// TopologyRefiner::InterpolateLevel<>()
|
// PrimvarRefiner::InterpolateLevel<>()
|
||||||
//
|
//
|
||||||
|
PrimvarRefiner primvarRefiner(refiner);
|
||||||
|
|
||||||
Internal::StencilBuilder::Index srcIndex(&builder, 0);
|
Internal::StencilBuilder::Index srcIndex(&builder, 0);
|
||||||
Internal::StencilBuilder::Index dstIndex(&builder,
|
Internal::StencilBuilder::Index dstIndex(&builder,
|
||||||
refiner.GetLevel(0).GetNumVertices());
|
refiner.GetLevel(0).GetNumVertices());
|
||||||
for (int level=1; level<=maxlevel; ++level) {
|
for (int level=1; level<=maxlevel; ++level) {
|
||||||
if (not interpolateVarying) {
|
if (not interpolateVarying) {
|
||||||
refiner.Interpolate(level, srcIndex, dstIndex);
|
primvarRefiner.Interpolate(level, srcIndex, dstIndex);
|
||||||
} else {
|
} else {
|
||||||
refiner.InterpolateVarying(level, srcIndex, dstIndex);
|
primvarRefiner.InterpolateVarying(level, srcIndex, dstIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
srcIndex = dstIndex;
|
srcIndex = dstIndex;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -61,7 +61,7 @@ InterpolateFVarData(OpenSubdiv::Far::TopologyRefiner & refiner,
|
|||||||
|
|
||||||
memcpy(&buffer[0], &shape.uvs[0], shape.uvs.size()*sizeof(float));
|
memcpy(&buffer[0], &shape.uvs[0], shape.uvs.size()*sizeof(float));
|
||||||
|
|
||||||
refiner.InterpolateFaceVarying(
|
OpenSubdiv::Far::PrimvarRefiner(refiner).InterpolateFaceVarying(
|
||||||
&buffer[0], &buffer[numValues0], channel);
|
&buffer[0], &buffer[numValues0], channel);
|
||||||
|
|
||||||
// we only keep the highest level of refinement !
|
// 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));
|
memcpy(src, &shape.uvs[0], shape.uvs.size()*sizeof(float));
|
||||||
|
|
||||||
refiner.InterpolateFaceVarying(src, dst, channel);
|
OpenSubdiv::Far::PrimvarRefiner(refiner).InterpolateFaceVarying(
|
||||||
|
src, dst, channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#define VTR_UTILS_H
|
#define VTR_UTILS_H
|
||||||
|
|
||||||
#include <far/topologyRefinerFactory.h>
|
#include <far/topologyRefinerFactory.h>
|
||||||
|
#include <far/primvarRefiner.h>
|
||||||
#include <far/types.h>
|
#include <far/types.h>
|
||||||
|
|
||||||
#include "../../regression/common/shape_utils.h"
|
#include "../../regression/common/shape_utils.h"
|
||||||
@ -162,7 +163,9 @@ InterpolateVtrVertexData(const char *shapeStr, Scheme scheme, int maxlevel,
|
|||||||
}
|
}
|
||||||
|
|
||||||
T * verts = &data[0];
|
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;
|
delete shape;
|
||||||
return refiner;
|
return refiner;
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <opensubdiv/far/topologyRefinerFactory.h>
|
#include <opensubdiv/far/topologyRefinerFactory.h>
|
||||||
|
#include <opensubdiv/far/primvarRefiner.h>
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
@ -143,8 +144,7 @@ int main(int, char **) {
|
|||||||
|
|
||||||
|
|
||||||
// Interpolate vertex primvar data
|
// Interpolate vertex primvar data
|
||||||
refiner->Interpolate(verts, verts + nCoarseVerts);
|
Far::PrimvarRefiner(*refiner).Interpolate(verts, verts + nCoarseVerts);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ // Output OBJ of the highest level refined -----------
|
{ // Output OBJ of the highest level refined -----------
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <opensubdiv/far/topologyRefinerFactory.h>
|
#include <opensubdiv/far/topologyRefinerFactory.h>
|
||||||
|
#include <opensubdiv/far/primvarRefiner.h>
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -448,8 +449,7 @@ int main(int, char **) {
|
|||||||
|
|
||||||
|
|
||||||
// Interpolate vertex primvar data
|
// Interpolate vertex primvar data
|
||||||
refiner->Interpolate(verts, verts + nCoarseVerts);
|
Far::PrimvarRefiner(*refiner).Interpolate(verts, verts + nCoarseVerts);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{ // Output OBJ of the highest level refined -----------
|
{ // Output OBJ of the highest level refined -----------
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <opensubdiv/far/topologyRefinerFactory.h>
|
#include <opensubdiv/far/topologyRefinerFactory.h>
|
||||||
|
#include <opensubdiv/far/primvarRefiner.h>
|
||||||
|
|
||||||
#include <cstdio>
|
#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]);
|
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
|
// Interpolate all primvar data - not that this will perform both 'vertex' and
|
||||||
// 'varying' interpolation at once by calling each specialized method in our
|
// 'varying' interpolation at once by calling each specialized method in our
|
||||||
// Vertex class with the appropriate weights.
|
// 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
|
{ // Visualization with Maya : print a MEL script that generates colored
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <opensubdiv/far/topologyRefinerFactory.h>
|
#include <opensubdiv/far/topologyRefinerFactory.h>
|
||||||
|
#include <opensubdiv/far/primvarRefiner.h>
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
@ -194,9 +195,9 @@ int main(int, char **) {
|
|||||||
// Uniformly refine the topolgy up to 'maxlevel'
|
// Uniformly refine the topolgy up to 'maxlevel'
|
||||||
// note: fullTopologyInLastLevel must be true to work with face-varying data
|
// note: fullTopologyInLastLevel must be true to work with face-varying data
|
||||||
{
|
{
|
||||||
Far::TopologyRefiner::UniformOptions options(maxlevel);
|
Far::TopologyRefiner::UniformOptions refineOptions(maxlevel);
|
||||||
options.fullTopologyInLastLevel = true;
|
refineOptions.fullTopologyInLastLevel = true;
|
||||||
refiner->RefineUniform(options);
|
refiner->RefineUniform(refineOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate & interpolate the 'vertex' primvar data (see tutorial 2 for
|
// 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]);
|
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
|
// Allocate & interpolate the 'face-varying' primvar data
|
||||||
@ -224,7 +225,7 @@ int main(int, char **) {
|
|||||||
fvVerts[i].v = g_uvs[i][1];
|
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 -----------
|
{ // Output OBJ of the highest level refined -----------
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <opensubdiv/far/topologyRefinerFactory.h>
|
#include <opensubdiv/far/topologyRefinerFactory.h>
|
||||||
|
#include <opensubdiv/far/primvarRefiner.h>
|
||||||
#include <opensubdiv/far/patchTableFactory.h>
|
#include <opensubdiv/far/patchTableFactory.h>
|
||||||
#include <opensubdiv/far/endCapGregoryBasisPatchFactory.h>
|
#include <opensubdiv/far/endCapGregoryBasisPatchFactory.h>
|
||||||
#include <opensubdiv/far/patchMap.h>
|
#include <opensubdiv/far/patchMap.h>
|
||||||
@ -152,7 +153,7 @@ int main(int, char **) {
|
|||||||
|
|
||||||
// Interpolate vertex primvar data : they are the control vertices
|
// Interpolate vertex primvar data : they are the control vertices
|
||||||
// of the limit patches (see far_tutorial_0 for details)
|
// 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
|
// Generate a set of Far::PatchTable that we will use to evaluate the
|
||||||
|
Loading…
Reference in New Issue
Block a user