From d38d683d0aa1937ad83de4cc9f96b4d15277827a Mon Sep 17 00:00:00 2001 From: George ElKoura Date: Mon, 30 Mar 2015 18:49:26 -0700 Subject: [PATCH] Make sure to update the _maxEdgeFaces in the child from the parent level before we do any further population from the parent as that may further modify the child's _maxEdgeFaces. When _maxEdgeFaces is incorrect we may end up with stack corruption problems when Far::TopologyRefiner::interpolateChildVertsFromEdges() goes to use this data to allocate some stack space. --- opensubdiv/vtr/quadRefinement.cpp | 7 +++++-- opensubdiv/vtr/triRefinement.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/opensubdiv/vtr/quadRefinement.cpp b/opensubdiv/vtr/quadRefinement.cpp index cd743b8d..0490052f 100644 --- a/opensubdiv/vtr/quadRefinement.cpp +++ b/opensubdiv/vtr/quadRefinement.cpp @@ -373,6 +373,11 @@ QuadRefinement::populateEdgeFaceRelation() { child._edgeFaceIndices.resize( childEdgeFaceIndexSizeEstimate); child._edgeFaceLocalIndices.resize(childEdgeFaceIndexSizeEstimate); + // Update _maxEdgeFaces from the parent level before calling the + // populateEdgeFacesFromParent methods below, as these may further + // update _maxEdgeFaces. + child._maxEdgeFaces = parent._maxEdgeFaces; + populateEdgeFacesFromParentFaces(); populateEdgeFacesFromParentEdges(); @@ -382,8 +387,6 @@ QuadRefinement::populateEdgeFaceRelation() { child.getOffsetOfEdgeFaces(child.getNumEdges()-1); child._edgeFaceIndices.resize( childEdgeFaceIndexSizeEstimate); child._edgeFaceLocalIndices.resize(childEdgeFaceIndexSizeEstimate); - - child._maxEdgeFaces = parent._maxEdgeFaces; } void diff --git a/opensubdiv/vtr/triRefinement.cpp b/opensubdiv/vtr/triRefinement.cpp index 7e54cc20..7c848af9 100644 --- a/opensubdiv/vtr/triRefinement.cpp +++ b/opensubdiv/vtr/triRefinement.cpp @@ -366,6 +366,11 @@ TriRefinement::populateEdgeFaceRelation() { _child->_edgeFaceIndices.resize(childEdgeFaceIndexSizeEstimate); _child->_edgeFaceLocalIndices.resize(childEdgeFaceIndexSizeEstimate); + // Update _maxEdgeFaces from the parent level before calling the + // populateEdgeFacesFromParent methods below, as these may further + // update _maxEdgeFaces. + _child->_maxEdgeFaces = _parent->_maxEdgeFaces; + populateEdgeFacesFromParentFaces(); populateEdgeFacesFromParentEdges(); @@ -375,8 +380,6 @@ TriRefinement::populateEdgeFaceRelation() { _child->getOffsetOfEdgeFaces(_child->getNumEdges()-1); _child->_edgeFaceIndices.resize(childEdgeFaceIndexSizeEstimate); _child->_edgeFaceLocalIndices.resize(childEdgeFaceIndexSizeEstimate); - - _child->_maxEdgeFaces = _parent->_maxEdgeFaces; } void