From a2a8e7121081404e35d9aa4769b17ebf23f83f11 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 31 Oct 2018 17:46:22 +0100 Subject: OpenSubdiv: API, expose vertex boundary interpolation option Only affects internal API, bout could be exposed as an option for the compatibility reasons with other software. Is a part of some ongoing development of multires, but might or might not be used. --- .../internal/opensubdiv_converter_factory.cc | 24 +++++++++++++++++++++- intern/opensubdiv/opensubdiv_capi_type.h | 9 ++++++++ intern/opensubdiv/opensubdiv_converter_capi.h | 2 ++ 3 files changed, 34 insertions(+), 1 deletion(-) (limited to 'intern/opensubdiv') diff --git a/intern/opensubdiv/internal/opensubdiv_converter_factory.cc b/intern/opensubdiv/internal/opensubdiv_converter_factory.cc index 901a421314a..4f3fb1462f3 100644 --- a/intern/opensubdiv/internal/opensubdiv_converter_factory.cc +++ b/intern/opensubdiv/internal/opensubdiv_converter_factory.cc @@ -441,6 +441,26 @@ inline void TopologyRefinerFactory::reportInvalidTopology( namespace opensubdiv_capi { +namespace { + +OpenSubdiv::Sdc::Options::VtxBoundaryInterpolation +getVtxBoundaryInterpolationFromCAPI( + OpenSubdiv_VtxBoundaryInterpolation boundary_interpolation) { + using OpenSubdiv::Sdc::Options; + switch (boundary_interpolation) { + case OSD_VTX_BOUNDARY_NONE: + return Options::VTX_BOUNDARY_NONE; + case OSD_VTX_BOUNDARY_EDGE_ONLY: + return Options::VTX_BOUNDARY_EDGE_ONLY; + case OSD_VTX_BOUNDARY_EDGE_AND_CORNER: + return Options::VTX_BOUNDARY_EDGE_AND_CORNER; + } + assert(!"Unknown veretx boundary interpolation."); + return Options::VTX_BOUNDARY_EDGE_ONLY; +} + +} // namespace + OpenSubdiv::Far::TopologyRefiner* createOSDTopologyRefinerFromConverter( OpenSubdiv_Converter* converter) { using OpenSubdiv::Sdc::Options; @@ -451,7 +471,9 @@ OpenSubdiv::Far::TopologyRefiner* createOSDTopologyRefinerFromConverter( getFVarLinearInterpolationFromCAPI( converter->getFVarLinearInterpolation(converter)); Options options; - options.SetVtxBoundaryInterpolation(Options::VTX_BOUNDARY_EDGE_ONLY); + options.SetVtxBoundaryInterpolation( + getVtxBoundaryInterpolationFromCAPI( + converter->getVtxBoundaryInterpolation(converter))); options.SetCreasingMethod(Options::CREASE_UNIFORM); options.SetFVarLinearInterpolation(linear_interpolation); diff --git a/intern/opensubdiv/opensubdiv_capi_type.h b/intern/opensubdiv/opensubdiv_capi_type.h index b326e53e168..57f62fd9888 100644 --- a/intern/opensubdiv/opensubdiv_capi_type.h +++ b/intern/opensubdiv/opensubdiv_capi_type.h @@ -40,6 +40,15 @@ typedef enum OpenSubdiv_SchemeType { OSD_SCHEME_LOOP, } OpenSubdiv_SchemeType; +typedef enum OpenSubdiv_VtxBoundaryInterpolation { + // Do not interpolate boundaries + OSD_VTX_BOUNDARY_NONE, + // Sharpen edges. + OSD_VTX_BOUNDARY_EDGE_ONLY, + // sharpen edges and corners, + OSD_VTX_BOUNDARY_EDGE_AND_CORNER, +} OpenSubdiv_VtxBoundaryInterpolation; + typedef enum OpenSubdiv_FVarLinearInterpolation { OSD_FVAR_LINEAR_INTERPOLATION_NONE, OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY, diff --git a/intern/opensubdiv/opensubdiv_converter_capi.h b/intern/opensubdiv/opensubdiv_converter_capi.h index 9f559ee208b..389e16e0f3f 100644 --- a/intern/opensubdiv/opensubdiv_converter_capi.h +++ b/intern/opensubdiv/opensubdiv_converter_capi.h @@ -31,6 +31,8 @@ typedef struct OpenSubdiv_Converter { OpenSubdiv_SchemeType (*getSchemeType)( const struct OpenSubdiv_Converter* converter); + OpenSubdiv_VtxBoundaryInterpolation (*getVtxBoundaryInterpolation)( + const struct OpenSubdiv_Converter* converter); OpenSubdiv_FVarLinearInterpolation (*getFVarLinearInterpolation)( const struct OpenSubdiv_Converter* converter); -- cgit v1.2.3