From 3757eb120bb8104c5eebb4e82255fdbe7faa975a Mon Sep 17 00:00:00 2001 From: David G Yu Date: Fri, 18 Jan 2019 18:21:13 -0800 Subject: [PATCH] Updated glStencilViewer for Loop patches Also, changed sample initialization for triangle refinement to keep sample locations within base triangles. --- examples/glStencilViewer/glStencilViewer.cpp | 36 ++++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/examples/glStencilViewer/glStencilViewer.cpp b/examples/glStencilViewer/glStencilViewer.cpp index d93c7dfe..69d4a0ec 100644 --- a/examples/glStencilViewer/glStencilViewer.cpp +++ b/examples/glStencilViewer/glStencilViewer.cpp @@ -298,6 +298,8 @@ createMesh(ShapeDesc const & shapeDesc, int level) { // create Far mesh (topology) OpenSubdiv::Sdc::SchemeType sdctype = GetSdcType(*shape); OpenSubdiv::Sdc::Options sdcoptions = GetSdcOptions(*shape); + OpenSubdiv::Sdc::Split sdcsplit = + Sdc::SchemeTypeTraits::GetTopologicalSplitType(sdctype); OpenSubdiv::Far::TopologyRefiner * refiner = OpenSubdiv::Far::TopologyRefinerFactory::Create(*shape, @@ -357,8 +359,15 @@ createMesh(ShapeDesc const & shapeDesc, int level) { larray.t = vPtr; for (int j=0; j= 1.0f)) { + // Keep locations within the triangular parametric domain + u = 1.0f - u; + v = 1.0f - v; + } + *uPtr = u; + *vPtr = v; } } @@ -1052,21 +1061,36 @@ callbackErrorGLFW(int error, const char* description) { int main(int argc, char **argv) { bool fullscreen = false; - + Scheme defaultScheme = kCatmark; std::string str; + for (int i = 1; i < argc; ++i) { + if (!strcmp(argv[i], "-u")) { + g_adaptive = false; + } if (!strcmp(argv[i], "-d")) { g_isolationLevel = atoi(argv[++i]); - } else if (!strcmp(argv[i], "-f")) { + } + else if (!strcmp(argv[i], "-f")) { fullscreen = true; - } else { + } + else if (!strcmp(argv[i], "-bilinear")) { + defaultScheme = kBilinear; + } + else if (!strcmp(argv[i], "-catmark")) { + defaultScheme = kCatmark; + } + else if (!strcmp(argv[i], "-loop")) { + defaultScheme = kLoop; + } + else { std::ifstream ifs(argv[1]); if (ifs) { std::stringstream ss; ss << ifs.rdbuf(); ifs.close(); str = ss.str(); - g_defaultShapes.push_back(ShapeDesc(argv[1], str.c_str(), kCatmark)); + g_defaultShapes.push_back(ShapeDesc(argv[1], str.c_str(), defaultScheme)); } } }