mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-11-23 12:10:08 +00:00
Fix face-varying code in examples / tutorials to reflect changes in commit 4d84dfd7be
This commit is contained in:
parent
4d84dfd7be
commit
c30087cb52
@ -85,8 +85,8 @@ int g_currentShape = 0;
|
||||
int g_frame = 0,
|
||||
g_repeatCount = 0;
|
||||
|
||||
OpenSubdiv::Sdc::Options::FVarBoundaryInterpolation g_fvarBoundary =
|
||||
OpenSubdiv::Sdc::Options::FVAR_BOUNDARY_BILINEAR;
|
||||
OpenSubdiv::Sdc::Options::FVarLinearInterpolation g_fvarBoundary =
|
||||
OpenSubdiv::Sdc::Options::FVAR_LINEAR_ALL;
|
||||
|
||||
// GUI variables
|
||||
int g_fullscreen = 0,
|
||||
@ -316,7 +316,7 @@ createOsdMesh(ShapeDesc const & shapeDesc, int level, Scheme scheme = kCatmark)
|
||||
OpenSubdiv::Sdc::Type sdctype = GetSdcType(*shape);
|
||||
OpenSubdiv::Sdc::Options sdcoptions = GetSdcOptions(*shape);
|
||||
|
||||
sdcoptions.SetFVarBoundaryInterpolation(g_fvarBoundary);
|
||||
sdcoptions.SetFVarLinearInterpolation(g_fvarBoundary);
|
||||
|
||||
OpenSubdiv::Far::TopologyRefiner * refiner =
|
||||
OpenSubdiv::Far::TopologyRefinerFactory<Shape>::Create(sdctype, sdcoptions, *shape);
|
||||
@ -1101,20 +1101,24 @@ callbackBoundary(int b) {
|
||||
|
||||
switch (b) {
|
||||
|
||||
case SdcOptions::FVAR_BOUNDARY_BILINEAR :
|
||||
g_fvarBoundary = SdcOptions::FVAR_BOUNDARY_BILINEAR; break;
|
||||
case SdcOptions::FVAR_LINEAR_NONE :
|
||||
g_fvarBoundary = SdcOptions::FVAR_LINEAR_NONE; break;
|
||||
|
||||
case SdcOptions::FVAR_BOUNDARY_EDGE_ONLY :
|
||||
g_fvarBoundary = SdcOptions::FVAR_BOUNDARY_EDGE_ONLY; break;
|
||||
case SdcOptions::FVAR_LINEAR_CORNERS_ONLY :
|
||||
g_fvarBoundary = SdcOptions::FVAR_LINEAR_CORNERS_ONLY; break;
|
||||
|
||||
case SdcOptions::FVAR_BOUNDARY_EDGE_AND_CORNER :
|
||||
g_fvarBoundary = SdcOptions::FVAR_BOUNDARY_EDGE_AND_CORNER; break;
|
||||
case SdcOptions::FVAR_LINEAR_CORNERS_PLUS1 :
|
||||
g_fvarBoundary = SdcOptions::FVAR_LINEAR_CORNERS_PLUS1; break;
|
||||
|
||||
case SdcOptions::FVAR_BOUNDARY_EDGE_AND_CORNER_PROP :
|
||||
g_fvarBoundary = SdcOptions::FVAR_BOUNDARY_EDGE_AND_CORNER_PROP; break;
|
||||
case SdcOptions::FVAR_LINEAR_CORNERS_PLUS2 :
|
||||
g_fvarBoundary = SdcOptions::FVAR_LINEAR_CORNERS_PLUS2; break;
|
||||
|
||||
case SdcOptions::FVAR_LINEAR_BOUNDARIES :
|
||||
g_fvarBoundary = SdcOptions::FVAR_LINEAR_BOUNDARIES; break;
|
||||
|
||||
case SdcOptions::FVAR_LINEAR_ALL :
|
||||
g_fvarBoundary = SdcOptions::FVAR_LINEAR_ALL; break;
|
||||
|
||||
case SdcOptions::FVAR_BOUNDARY_ALWAYS_SHARP :
|
||||
g_fvarBoundary = SdcOptions::FVAR_BOUNDARY_ALWAYS_SHARP; break;
|
||||
}
|
||||
rebuildOsdMesh();
|
||||
}
|
||||
@ -1132,7 +1136,7 @@ initHUD() {
|
||||
|
||||
g_hud.SetFrameBuffer(new GLFrameBuffer);
|
||||
|
||||
int shading_pulldown = g_hud.AddPullDown("Shading (W)", 300, 10, 250, callbackDisplayStyle, 'w');
|
||||
int shading_pulldown = g_hud.AddPullDown("Shading (W)", 375, 10, 250, callbackDisplayStyle, 'w');
|
||||
g_hud.AddPullDownButton(shading_pulldown, "Wire", kWire, g_displayStyle==kWire);
|
||||
g_hud.AddPullDownButton(shading_pulldown, "Shaded", kShaded, g_displayStyle==kShaded);
|
||||
g_hud.AddPullDownButton(shading_pulldown, "Wire+Shaded", kWireShaded, g_displayStyle==kWireShaded);
|
||||
@ -1149,16 +1153,18 @@ initHUD() {
|
||||
typedef OpenSubdiv::Sdc::Options SdcOptions;
|
||||
|
||||
int boundary_pulldown = g_hud.AddPullDown("Boundary (B)", 10, 10, 250, callbackBoundary, 'b');
|
||||
g_hud.AddPullDownButton(boundary_pulldown, "Bilinear",
|
||||
SdcOptions::FVAR_BOUNDARY_BILINEAR, g_fvarBoundary==SdcOptions::FVAR_BOUNDARY_BILINEAR);
|
||||
g_hud.AddPullDownButton(boundary_pulldown, "Edge Only",
|
||||
SdcOptions::FVAR_BOUNDARY_EDGE_ONLY, g_fvarBoundary==SdcOptions::FVAR_BOUNDARY_EDGE_ONLY);
|
||||
g_hud.AddPullDownButton(boundary_pulldown, "Edge Corner",
|
||||
SdcOptions::FVAR_BOUNDARY_EDGE_AND_CORNER, g_fvarBoundary==SdcOptions::FVAR_BOUNDARY_EDGE_AND_CORNER);
|
||||
g_hud.AddPullDownButton(boundary_pulldown, "Edge Corner (Propagate)",
|
||||
SdcOptions::FVAR_BOUNDARY_EDGE_AND_CORNER_PROP, g_fvarBoundary==SdcOptions::FVAR_BOUNDARY_EDGE_AND_CORNER_PROP);
|
||||
g_hud.AddPullDownButton(boundary_pulldown, "Always Sharp",
|
||||
SdcOptions::FVAR_BOUNDARY_ALWAYS_SHARP, g_fvarBoundary==SdcOptions::FVAR_BOUNDARY_ALWAYS_SHARP);
|
||||
g_hud.AddPullDownButton(boundary_pulldown, "None (edge only)",
|
||||
SdcOptions::FVAR_LINEAR_NONE, g_fvarBoundary==SdcOptions::FVAR_LINEAR_NONE);
|
||||
g_hud.AddPullDownButton(boundary_pulldown, "Corners Only",
|
||||
SdcOptions::FVAR_LINEAR_CORNERS_ONLY, g_fvarBoundary==SdcOptions::FVAR_LINEAR_CORNERS_ONLY);
|
||||
g_hud.AddPullDownButton(boundary_pulldown, "Corners 1 (edge corner)",
|
||||
SdcOptions::FVAR_LINEAR_CORNERS_PLUS1, g_fvarBoundary==SdcOptions::FVAR_LINEAR_CORNERS_PLUS1);
|
||||
g_hud.AddPullDownButton(boundary_pulldown, "Corners 2 (edge corner prop)",
|
||||
SdcOptions::FVAR_LINEAR_CORNERS_PLUS2, g_fvarBoundary==SdcOptions::FVAR_LINEAR_CORNERS_PLUS2);
|
||||
g_hud.AddPullDownButton(boundary_pulldown, "Boundaries (always sharp)",
|
||||
SdcOptions::FVAR_LINEAR_BOUNDARIES, g_fvarBoundary==SdcOptions::FVAR_LINEAR_BOUNDARIES);
|
||||
g_hud.AddPullDownButton(boundary_pulldown, "All (bilinear)",
|
||||
SdcOptions::FVAR_LINEAR_ALL, g_fvarBoundary==SdcOptions::FVAR_LINEAR_ALL);
|
||||
|
||||
int pulldown_handle = g_hud.AddPullDown("Shape (N)", -300, 10, 300, callbackModel, 'n');
|
||||
for (int i = 0; i < (int)g_defaultShapes.size(); ++i) {
|
||||
|
@ -117,20 +117,26 @@ ConvertMayaVVarBoundary(short boundaryMethod) {
|
||||
return Sdc::VVAR_BOUNDARY_NONE;
|
||||
}
|
||||
|
||||
static OpenSubdiv::Sdc::Options::FVarBoundaryInterpolation
|
||||
ConvertMayaFVarBoundary(short boundaryMethod) {
|
||||
// XXXX note: This function converts the options exposed in Maya's GUI which are
|
||||
// based on prman legacy face-varying boundary interpolation rules.
|
||||
// As a result, some OpenSubdiv 3.0 FVar interpolation rules are not
|
||||
// exposed, and the some of the ones exposed fix incorrect behavior
|
||||
// from legacy prman code, so the results are not 100% backward compatible.
|
||||
static OpenSubdiv::Sdc::Options::FVarLinearInterpolation
|
||||
ConvertMayaFVarBoundary(short boundaryMethod, bool propagateCorner) {
|
||||
|
||||
typedef OpenSubdiv::Sdc::Options Sdc;
|
||||
|
||||
switch (boundaryMethod) {
|
||||
case k_BoundaryMethod_InterpolateBoundaryNone : return Sdc::FVAR_BOUNDARY_BILINEAR;
|
||||
case k_BoundaryMethod_InterpolateBoundaryEdgeOnly : return Sdc::FVAR_BOUNDARY_EDGE_ONLY;
|
||||
case k_BoundaryMethod_InterpolateBoundaryEdgeAndCorner : return Sdc::FVAR_BOUNDARY_EDGE_AND_CORNER;
|
||||
case k_BoundaryMethod_InterpolateBoundaryAlwaysSharp : return Sdc::FVAR_BOUNDARY_ALWAYS_SHARP;
|
||||
case k_BoundaryMethod_InterpolateBoundaryNone : return Sdc::FVAR_LINEAR_ALL;
|
||||
case k_BoundaryMethod_InterpolateBoundaryEdgeOnly : return Sdc::FVAR_LINEAR_NONE;
|
||||
case k_BoundaryMethod_InterpolateBoundaryEdgeAndCorner :
|
||||
return propagateCorner ? Sdc::FVAR_LINEAR_CORNERS_PLUS2 : Sdc::FVAR_LINEAR_CORNERS_PLUS1;
|
||||
case k_BoundaryMethod_InterpolateBoundaryAlwaysSharp : return Sdc::FVAR_LINEAR_BOUNDARIES;
|
||||
default: ;
|
||||
}
|
||||
MGlobal::displayError("FVar InterpolateBoundaryMethod value out of range. Using \"none\"");
|
||||
return Sdc::FVAR_BOUNDARY_BILINEAR;
|
||||
return Sdc::FVAR_LINEAR_ALL;
|
||||
}
|
||||
|
||||
// ====================================
|
||||
@ -609,7 +615,7 @@ MayaPolySmooth::compute( const MPlug& plug, MDataBlock& data ) {
|
||||
MObject inMeshObj = data.inputValue(a_inputPolymesh).asMesh();
|
||||
short vertBoundaryMethod = data.inputValue(a_vertBoundaryMethod).asShort();
|
||||
short fvarBoundaryMethod = data.inputValue(a_fvarBoundaryMethod).asShort();
|
||||
//XXXX bool fvarPropCorners = data.inputValue(a_fvarPropagateCorners).asBool();
|
||||
bool fvarPropCorners = data.inputValue(a_fvarPropagateCorners).asBool();
|
||||
bool smoothTriangles = data.inputValue(a_smoothTriangles).asBool();
|
||||
short creaseMethodVal = data.inputValue(a_creaseMethod).asShort();
|
||||
|
||||
@ -628,7 +634,7 @@ MayaPolySmooth::compute( const MPlug& plug, MDataBlock& data ) {
|
||||
//
|
||||
OpenSubdiv::Sdc::Options options;
|
||||
options.SetVVarBoundaryInterpolation(ConvertMayaVVarBoundary(vertBoundaryMethod));
|
||||
options.SetFVarBoundaryInterpolation(ConvertMayaFVarBoundary(fvarBoundaryMethod));
|
||||
options.SetFVarLinearInterpolation(ConvertMayaFVarBoundary(fvarBoundaryMethod, fvarPropCorners));
|
||||
options.SetCreasingMethod(creaseMethodVal ?
|
||||
OpenSubdiv::Sdc::Options::CREASE_CHAIKIN : OpenSubdiv::Sdc::Options::CREASE_UNIFORM);
|
||||
options.SetTriangleSubdivision(smoothTriangles ?
|
||||
|
@ -78,10 +78,12 @@ GetSdcOptions(Shape const & shape) {
|
||||
continue;
|
||||
}
|
||||
switch( t->intargs[0] ) {
|
||||
case 0 : result.SetFVarBoundaryInterpolation(Options::FVAR_BOUNDARY_BILINEAR); break;
|
||||
case 1 : result.SetFVarBoundaryInterpolation(Options::FVAR_BOUNDARY_EDGE_AND_CORNER); break;
|
||||
case 2 : result.SetFVarBoundaryInterpolation(Options::FVAR_BOUNDARY_EDGE_ONLY); break;
|
||||
case 3 : result.SetFVarBoundaryInterpolation(Options::FVAR_BOUNDARY_ALWAYS_SHARP); break;
|
||||
case 0 : result.SetFVarLinearInterpolation(Options::FVAR_LINEAR_NONE); break;
|
||||
case 1 : result.SetFVarLinearInterpolation(Options::FVAR_LINEAR_CORNERS_ONLY); break;
|
||||
case 2 : result.SetFVarLinearInterpolation(Options::FVAR_LINEAR_CORNERS_PLUS1); break;
|
||||
case 3 : result.SetFVarLinearInterpolation(Options::FVAR_LINEAR_CORNERS_PLUS2); break;
|
||||
case 4 : result.SetFVarLinearInterpolation(Options::FVAR_LINEAR_BOUNDARIES); break;
|
||||
case 5 : result.SetFVarLinearInterpolation(Options::FVAR_LINEAR_ALL); break;
|
||||
default: printf("unknown interpolate boundary : %d\n", t->intargs[0] ); break;
|
||||
}
|
||||
} else if (t->name=="facevaryingpropagatecorners") {
|
||||
|
@ -168,7 +168,7 @@ int main(int, char **) {
|
||||
|
||||
Sdc::Options options;
|
||||
options.SetVVarBoundaryInterpolation(Sdc::Options::VVAR_BOUNDARY_EDGE_ONLY);
|
||||
options.SetFVarBoundaryInterpolation(Sdc::Options::FVAR_BOUNDARY_BILINEAR);
|
||||
options.SetFVarLinearInterpolation(Sdc::Options::FVAR_LINEAR_NONE);
|
||||
|
||||
// Populate a topology descriptor with our raw data
|
||||
Descriptor desc;
|
||||
|
Loading…
Reference in New Issue
Block a user