From c2e8148efc1b81f8eccb457d9a0447b0ae6ec963 Mon Sep 17 00:00:00 2001 From: manuelk Date: Tue, 25 Nov 2014 11:48:49 -0800 Subject: [PATCH] Fix a Far::StencilTablesFactory crash bug on 'perfect' topology Torii (and other planar topologies) are made entirely of regular b-spline patches and do not generate sub-patches through adaptive isolation: we need to make sure that we construct stencil tables with singular stencils for the coarse vertices instead of returning empty tables (and crash in the limit stencils factory) --- opensubdiv/far/stencilTablesFactory.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/opensubdiv/far/stencilTablesFactory.cpp b/opensubdiv/far/stencilTablesFactory.cpp index 8a648372..cc4604da 100644 --- a/opensubdiv/far/stencilTablesFactory.cpp +++ b/opensubdiv/far/stencilTablesFactory.cpp @@ -61,11 +61,11 @@ StencilTablesFactory::Create(TopologyRefiner const & refiner, StencilTables * result = new StencilTables; int maxlevel = std::min(int(options.maxLevel), refiner.GetMaxLevel()); - if (maxlevel==0) { + if (maxlevel==0 and (not options.generateControlVerts)) { return result; } - // maxsize reflects the size of the default supporting basis factorized + // 'maxsize' reflects the size of the default supporting basis factorized // in the stencils, with a little bit of head-room. Each subdivision scheme // has a set valence for 'regular' vertices, which drives the size of the // supporting basis of control-vertices. The goal is to reduce the number @@ -101,7 +101,7 @@ StencilTablesFactory::Create(TopologyRefiner const & refiner, StencilAllocator * srcAlloc = &allocators[0], * dstAlloc = &allocators[1]; - /// + // // Interpolate stencils for each refinement level using // TopologyRefiner::InterpolateLevel<>() // @@ -220,11 +220,11 @@ StencilTablesFactory::Create(int numTables, StencilTables const ** tables) { StencilTables const & st = *tables[i]; int nstencils = st.GetNumStencils(), - nelems = (int)st._indices.size(); + nelems = (int)st._indices.size(); memcpy(sizes, &st._sizes[0], nstencils*sizeof(unsigned char)); memcpy(indices, &st._indices[0], nelems*sizeof(Index)); memcpy(weights, &st._weights[0], nelems*sizeof(float)); - + sizes += nstencils; indices += nelems; weights += nelems;