Add Options structs to Far::TopologyRefiner refinement methods

- fix all splash damage to tutorials / examples...
This commit is contained in:
manuelk 2014-12-23 10:07:24 -08:00
parent 13f148aac8
commit 5944ada0f9
7 changed files with 87 additions and 36 deletions

View File

@ -317,9 +317,17 @@ createMesh(ShapeDesc const & shapeDesc, int isolationLevel) {
g_orgPositions=shape->verts;
if (g_bilinear) {
refiner->RefineUniform(isolationLevel, /*full topo*/ true);
Far::TopologyRefiner::UniformOptions options;
options.fullTopologyInLastLevel = true;
refiner->RefineUniform(isolationLevel, options);
} else {
refiner->RefineAdaptive(isolationLevel, /*full topo*/ false);
Far::TopologyRefiner::AdaptiveOptions options;
options.fullTopologyInLastLevel = false;
options.useSingleCreasePatch = false;
refiner->RefineAdaptive(isolationLevel, options);
}
int nfaces = refiner->GetNumPtexFaces();

View File

@ -663,9 +663,16 @@ createVtrMesh(Shape * shape, int maxlevel) {
OpenSubdiv::Far::TopologyRefinerFactory<Shape>::Create(sdctype, sdcoptions, *shape);
if (g_Adaptive) {
refiner->RefineAdaptive(maxlevel, /*fullTopology*/true);
OpenSubdiv::Far::TopologyRefiner::AdaptiveOptions options;
options.fullTopologyInLastLevel = true;
options.useSingleCreasePatch = false;
refiner->RefineAdaptive(maxlevel, options);
} else {
refiner->RefineUniform(maxlevel, /*fullTopology*/true);
OpenSubdiv::Far::TopologyRefiner::UniformOptions options;
options.fullTopologyInLastLevel = true;
refiner->RefineUniform(maxlevel, options);
}
//

View File

@ -317,7 +317,7 @@ TopologyRefiner::GetPtexAdjacency(int face, int quadrant,
// Main refinement method -- allocating and initializing levels and refinements:
//
void
TopologyRefiner::RefineUniform(int maxLevel, bool fullTopology) {
TopologyRefiner::RefineUniform(int maxLevel, UniformOptions options) {
assert(_levels[0]->getNumVertices() > 0); // Make sure the base level has been initialized
@ -336,7 +336,8 @@ TopologyRefiner::RefineUniform(int maxLevel, bool fullTopology) {
refineOptions._sparse = false;
for (int i = 1; i <= maxLevel; ++i) {
refineOptions._faceTopologyOnly = fullTopology ? false : (i == maxLevel);
refineOptions._faceTopologyOnly =
options.fullTopologyInLastLevel ? false : (i == maxLevel);
Vtr::Level& parentLevel = getLevel(i-1);
Vtr::Level& childLevel = *(new Vtr::Level);
@ -356,7 +357,7 @@ TopologyRefiner::RefineUniform(int maxLevel, bool fullTopology) {
void
TopologyRefiner::RefineAdaptive(int subdivLevel, bool fullTopology, bool useSingleCreasePatch) {
TopologyRefiner::RefineAdaptive(int subdivLevel, AdaptiveOptions options ) {
assert(_levels[0]->getNumVertices() > 0); // Make sure the base level has been initialized
@ -365,7 +366,7 @@ TopologyRefiner::RefineAdaptive(int subdivLevel, bool fullTopology, bool useSing
//
_isUniform = false;
_maxLevel = subdivLevel;
_useSingleCreasePatch = useSingleCreasePatch;
_useSingleCreasePatch = options.useSingleCreasePatch;
//
// Initialize refinement options for Vtr:
@ -373,7 +374,7 @@ TopologyRefiner::RefineAdaptive(int subdivLevel, bool fullTopology, bool useSing
Vtr::Refinement::Options refineOptions;
refineOptions._sparse = true;
refineOptions._faceTopologyOnly = !fullTopology;
refineOptions._faceTopologyOnly = not options.fullTopologyInLastLevel;
Sdc::Split splitType = (_subdivType == Sdc::TYPE_LOOP) ? Sdc::SPLIT_TO_TRIS : Sdc::SPLIT_TO_QUADS;

View File

@ -72,7 +72,7 @@ public:
/// \brief Returns true if uniform subdivision has been applied
bool IsUniform() const { return _isUniform; }
/// \ brief Returns true if faces have been tagged as holes
bool HasHoles() const { return _hasHoles; }
@ -94,34 +94,55 @@ public:
int GetNumFaceVerticesTotal() const;
//@{
/// @name High level refinement and related methods
/// @name High-level refinement and related methods
///
// XXXX barfowl -- need some variants here for different refinement
// options, i.e. single refine method plus struct
// RefineOptions
//
// Uniform refinement
//
/// \brief Uniform refinement options
struct UniformOptions {
UniformOptions() :
fullTopologyInLastLevel(false) { }
unsigned int fullTopologyInLastLevel:1; ///< Skip secondary topological relationships
///< at the highest level of refinement.
};
/// \brief Refine the topology uniformly
///
/// @param maxLevel Highest level of subdivision refinement
/// @param maxLevel Highest level of subdivision refinement
///
/// @param fullTopologyInLastLevel Skip secondary topological relationships
/// at the highest level of refinement.
/// @param options Options controlling the creation of the tables
///
void RefineUniform(int maxLevel, bool fullTopologyInLastLevel = false);
void RefineUniform(int maxLevel, UniformOptions options=UniformOptions());
//
// Adaptive refinement
//
/// \brief Adaptive refinement options
struct AdaptiveOptions {
AdaptiveOptions() :
fullTopologyInLastLevel(false),
useSingleCreasePatch(false) { }
unsigned int fullTopologyInLastLevel:1, ///< Skip secondary topological relationships
///< at the highest level of refinement.
useSingleCreasePatch:1; ///< Use 'single-crease' patch and stop
///< isolation where applicable
};
/// \brief Feature Adaptive topology refinement
///
/// @param maxLevel Highest level of subdivision refinement
/// @param maxLevel Highest level of subdivision refinement
///
/// @param fullTopologyInLastLevel Skip secondary topological relationships
/// at the highest level of refinement.
/// @param options Options controlling the creation of the tables
///
/// @param useSingleCreasePatch Use single crease patch and stop isolation if it's applicable
///
void RefineAdaptive(int maxLevel, bool fullTopologyInLastLevel = false, bool useSingleCreasePatch = false);
void RefineAdaptive(int maxLevel, AdaptiveOptions options=AdaptiveOptions());
/// \brief Unrefine the topology (keep control cage)
void Unrefine();
@ -519,7 +540,7 @@ protected:
// Optionally available to get/set sharpness values:
float& baseEdgeSharpness(Index e) { return _levels[0]->getEdgeSharpness(e); }
float& baseVertexSharpness(Index v) { return _levels[0]->getVertexSharpness(v); }
void setBaseFaceHole(Index f, bool b) { _levels[0]->setHole(f, b); _hasHoles |= b; }
// Face-varying modifiers for constructing face-varying channels:

View File

@ -101,9 +101,16 @@ protected:
bool fullTopologyInLastLevel = refiner.GetNumFVarChannels()>0;
if (adaptive) {
refiner.RefineAdaptive(level, fullTopologyInLastLevel, singleCreasePatch);
Far::TopologyRefiner::AdaptiveOptions options;
options.fullTopologyInLastLevel = fullTopologyInLastLevel;
options.useSingleCreasePatch = singleCreasePatch;
refiner.RefineAdaptive(level, options);
} else {
refiner.RefineUniform(level, fullTopologyInLastLevel);
Far::TopologyRefiner::UniformOptions options;
options.fullTopologyInLastLevel = fullTopologyInLastLevel;
refiner.RefineUniform(level, options);
}
}
};

View File

@ -141,21 +141,24 @@ interpolateHbrVertexData(ShapeDesc const & desc, int maxlevel) {
}
//------------------------------------------------------------------------------
typedef OpenSubdiv::Far::TopologyRefiner FarTopoloyRefiner;
typedef OpenSubdiv::Far::TopologyRefinerFactory<Shape> FarTopoloyRefinerFactory;
typedef OpenSubdiv::Far::TopologyRefiner FarTopologyRefiner;
typedef OpenSubdiv::Far::TopologyRefinerFactory<Shape> FarTopologyRefinerFactory;
static FarTopoloyRefiner *
static FarTopologyRefiner *
interpolateVtrVertexData(ShapeDesc const & desc, int maxlevel, std::vector<xyzVV> & data) {
// Vtr interpolation
Shape * shape = Shape::parseObj(desc.data.c_str(), desc.scheme);
FarTopoloyRefiner * refiner =
FarTopoloyRefinerFactory::Create(
FarTopologyRefiner * refiner =
FarTopologyRefinerFactory::Create(
GetSdcType(*shape), GetSdcOptions(*shape), *shape);
assert(refiner);
refiner->RefineUniform(maxlevel, true /*full topology*/ );
FarTopologyRefiner::UniformOptions options;
options.fullTopologyInLastLevel=true;
refiner->RefineUniform(maxlevel, options);
// populate coarse mesh positions
data.resize(refiner->GetNumVerticesTotal());
@ -200,7 +203,7 @@ struct Mapper {
std::vector<LevelMap> maps;
Mapper(FarTopoloyRefiner * refiner, Hmesh * hmesh) {
Mapper(FarTopologyRefiner * refiner, Hmesh * hmesh) {
assert(refiner and hmesh);
@ -330,7 +333,7 @@ checkMesh(ShapeDesc const & desc, int maxlevel) {
Hmesh * hmesh =
interpolateHbrVertexData(desc, maxlevel);
FarTopoloyRefiner * refiner =
FarTopologyRefiner * refiner =
interpolateVtrVertexData(desc, maxlevel, vtrVertexData);
{ // copy Hbr vertex data into a re-ordered buffer (for easier comparison)

View File

@ -191,8 +191,12 @@ int main(int, char **) {
// Uniformly refine the topolgy up to 'maxlevel'
// note: fullTopologyInLastLevel must be true to work with face-varying data
refiner->RefineUniform( maxlevel, /*fullTopology*/ true );
{
Far::TopologyRefiner::UniformOptions options;
options.fullTopologyInLastLevel = true;
refiner->RefineUniform( maxlevel, options );
}
// Allocate & interpolate the 'vertex' primvar data (see tutorial 2 for
// more details).