mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2025-01-12 09:20:17 +00:00
Fix Far to handle disconnected vertices in an Hbr mesh.
Also: - change our shape parser to skip non-manifold faces (print a warning) - add a 'fan' non-manifold test shape to the glViewer fixes #233
This commit is contained in:
parent
a68bad450d
commit
9e9fd5c021
@ -382,6 +382,9 @@ initializeShapes( ) {
|
||||
#include <shapes/catmark_edgeonly.h>
|
||||
g_defaultShapes.push_back(SimpleShape(catmark_edgeonly, "catmark_edgeonly", kCatmark));
|
||||
|
||||
#include <shapes/catmark_fan.h>
|
||||
g_defaultShapes.push_back(SimpleShape(catmark_fan, "catmark_fan", kCatmark));
|
||||
|
||||
#include <shapes/catmark_gregory_test1.h>
|
||||
g_defaultShapes.push_back(SimpleShape(catmark_gregory_test1, "catmark_gregory_test1", kCatmark));
|
||||
|
||||
|
@ -427,6 +427,11 @@ FarMeshFactory<T,U>::refineAdaptive( HbrMesh<T> * mesh, int maxIsolate ) {
|
||||
for (int i=0; i<ncoarseverts; ++i) {
|
||||
HbrVertex<T> * v = mesh->GetVertex(i);
|
||||
|
||||
// Non manifold topology may leave un-connected vertices that need to be skipped
|
||||
if (not v->IsConnected()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Tag non-BSpline vertices for refinement
|
||||
if (not vertexIsBSpline(v, false)) {
|
||||
v->_adaptiveFlags.isTagged=true;
|
||||
|
@ -868,7 +868,7 @@ FarPatchTablesFactory<T>::Create( int maxlevel, int maxvalence, bool requireFVar
|
||||
// feature adaptive refinement can generate un-connected face-vertices
|
||||
// that have a valence of 0
|
||||
if (not v->IsConnected()) {
|
||||
assert( v->GetParentFace() );
|
||||
//assert( v->GetParentFace() );
|
||||
table[offset] = 0;
|
||||
continue;
|
||||
}
|
||||
|
@ -145,6 +145,10 @@ FarSubdivisionTablesFactory<T,U>::FarSubdivisionTablesFactory( HbrMesh<T> const
|
||||
HbrVertex<T> * v = mesh->GetVertex(i);
|
||||
assert(v);
|
||||
|
||||
if (not v->IsConnected()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int depth = getVertexDepth( v );
|
||||
|
||||
if (depth>maxlevel)
|
||||
@ -192,6 +196,11 @@ FarSubdivisionTablesFactory<T,U>::FarSubdivisionTablesFactory( HbrMesh<T> const
|
||||
HbrVertex<T> * v = mesh->GetVertex(i);
|
||||
assert(v);
|
||||
|
||||
if (not v->IsConnected()) {
|
||||
remapTable[ v->GetID() ] = v->GetID();
|
||||
continue;
|
||||
}
|
||||
|
||||
int depth = getVertexDepth( v );
|
||||
|
||||
if (depth>maxlevel)
|
||||
|
@ -798,6 +798,8 @@ createTopology( shape const * sh, OpenSubdiv::HbrMesh<T> * mesh, Scheme scheme)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
bool valid = true;
|
||||
|
||||
for(int j=0;j<nv;j++) {
|
||||
OpenSubdiv::HbrVertex<T> * origin = mesh->GetVertex( fv[j] );
|
||||
OpenSubdiv::HbrVertex<T> * destination = mesh->GetVertex( fv[(j+1)%nv] );
|
||||
@ -805,34 +807,42 @@ createTopology( shape const * sh, OpenSubdiv::HbrMesh<T> * mesh, Scheme scheme)
|
||||
|
||||
if(origin==NULL || destination==NULL) {
|
||||
printf(" An edge was specified that connected a nonexistent vertex\n");
|
||||
exit(1);
|
||||
valid=false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(origin == destination) {
|
||||
printf(" An edge was specified that connected a vertex to itself\n");
|
||||
exit(1);
|
||||
valid=false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(opposite && opposite->GetOpposite() ) {
|
||||
printf(" A non-manifold edge incident to more than 2 faces was found\n");
|
||||
exit(1);
|
||||
valid=false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(origin->GetEdge(destination)) {
|
||||
printf(" An edge connecting two vertices was specified more than once."
|
||||
" It's likely that an incident face was flipped\n");
|
||||
exit(1);
|
||||
valid=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (valid) {
|
||||
|
||||
OpenSubdiv::HbrFace<T> * face = mesh->NewFace(nv, (int *)fv, 0);
|
||||
|
||||
face->SetPtexIndex(ptxidx);
|
||||
|
||||
if ( (scheme==kCatmark or scheme==kBilinear) and nv != 4 )
|
||||
if ( (scheme==kCatmark or scheme==kBilinear) and nv != 4 ) {
|
||||
ptxidx+=nv;
|
||||
else
|
||||
} else {
|
||||
ptxidx++;
|
||||
}
|
||||
}
|
||||
|
||||
fv+=nv;
|
||||
}
|
||||
@ -846,7 +856,6 @@ createTopology( shape const * sh, OpenSubdiv::HbrMesh<T> * mesh, Scheme scheme)
|
||||
// check for disconnected vertices
|
||||
if (mesh->GetNumDisconnectedVertices()) {
|
||||
printf("The specified subdivmesh contains disconnected surface components.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
51
regression/shapes/catmark_fan.h
Normal file
51
regression/shapes/catmark_fan.h
Normal file
@ -0,0 +1,51 @@
|
||||
//
|
||||
// Copyright 2013 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
static const std::string catmark_fan =
|
||||
"# This file uses centimeters as units for non-parametric coordinates.\n"
|
||||
"\n"
|
||||
"v -1.000000 0.000000 -1.000000\n"
|
||||
"v -1.000000 0.000000 0.000000\n"
|
||||
"v 0.000000 0.000000 0.000000\n"
|
||||
"v 0.000000 0.000000 -1.000000\n"
|
||||
"v 1.000000 0.000000 0.000000\n"
|
||||
"v 1.000000 0.000000 -1.000000\n"
|
||||
"v 0.000000 1.000000 0.000000\n"
|
||||
"v 0.000000 1.000000 -1.000000\n"
|
||||
"vt 0.000000 0.000000\n"
|
||||
"vt 1.000000 0.000000\n"
|
||||
"vt 1.000000 1.000000\n"
|
||||
"vt 0.000000 1.000000\n"
|
||||
"vt 0.000000 0.000000\n"
|
||||
"vt 1.000000 0.000000\n"
|
||||
"vt 1.000000 1.000000\n"
|
||||
"vt 0.000000 1.000000\n"
|
||||
"vt 0.000000 0.000000\n"
|
||||
"vt 1.000000 0.000000\n"
|
||||
"vt 1.000000 1.000000\n"
|
||||
"vt 0.000000 1.000000\n"
|
||||
"f 1/1 2/2 3/3 4/4\n"
|
||||
"f 4/5 3/6 5/7 6/8\n"
|
||||
"f 4/9 3/10 7/11 8/12\n"
|
||||
"\n";
|
Loading…
Reference in New Issue
Block a user