diff options
Diffstat (limited to 'intern/opensubdiv')
-rw-r--r-- | intern/opensubdiv/opensubdiv_converter.cc | 48 | ||||
-rw-r--r-- | intern/opensubdiv/opensubdiv_converter_capi.h | 15 | ||||
-rw-r--r-- | intern/opensubdiv/opensubdiv_evaluator_capi.cc | 3 |
3 files changed, 48 insertions, 18 deletions
diff --git a/intern/opensubdiv/opensubdiv_converter.cc b/intern/opensubdiv/opensubdiv_converter.cc index ea41a56768f..fec15b118ae 100644 --- a/intern/opensubdiv/opensubdiv_converter.cc +++ b/intern/opensubdiv/opensubdiv_converter.cc @@ -542,7 +542,7 @@ namespace { OpenSubdiv::Sdc::SchemeType get_capi_scheme_type(OpenSubdiv_SchemeType type) { - switch(type) { + switch (type) { case OSD_SCHEME_BILINEAR: return OpenSubdiv::Sdc::SCHEME_BILINEAR; case OSD_SCHEME_CATMARK: @@ -550,10 +550,29 @@ OpenSubdiv::Sdc::SchemeType get_capi_scheme_type(OpenSubdiv_SchemeType type) case OSD_SCHEME_LOOP: return OpenSubdiv::Sdc::SCHEME_LOOP; } - assert(!"Unknown sceme type passed via C-API"); + assert(!"Unknown scheme type passed via C-API"); return OpenSubdiv::Sdc::SCHEME_CATMARK; } +OpenSubdiv::Sdc::Options::FVarLinearInterpolation +get_capi_fvar_linear_interpolation( + OpenSubdiv_FVarLinearInterpolation linear_interpolation) +{ + typedef OpenSubdiv::Sdc::Options Options; + switch (linear_interpolation) { + case OSD_FVAR_LINEAR_INTERPOLATION_NONE: + return Options::FVAR_LINEAR_NONE; + case OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY: + return Options::FVAR_LINEAR_CORNERS_ONLY; + case OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES: + return Options::FVAR_LINEAR_BOUNDARIES; + case OSD_FVAR_LINEAR_INTERPOLATION_ALL: + return Options::FVAR_LINEAR_ALL; + } + assert(!"Unknown fvar linear interpolation passed via C-API"); + return Options::FVAR_LINEAR_NONE; +} + } /* namespace */ struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_createTopologyRefinerDescr( @@ -562,17 +581,15 @@ struct OpenSubdiv_TopologyRefinerDescr *openSubdiv_createTopologyRefinerDescr( typedef OpenSubdiv::Sdc::Options Options; using OpenSubdiv::Far::TopologyRefinerFactory; - OpenSubdiv::Sdc::SchemeType scheme_type = - get_capi_scheme_type(converter->get_type(converter)); + const OpenSubdiv::Sdc::SchemeType scheme_type = + get_capi_scheme_type(converter->get_scheme_type(converter)); + const Options::FVarLinearInterpolation linear_interpolation = + get_capi_fvar_linear_interpolation( + converter->get_fvar_linear_interpolation(converter)); Options options; options.SetVtxBoundaryInterpolation(Options::VTX_BOUNDARY_EDGE_ONLY); options.SetCreasingMethod(Options::CREASE_UNIFORM); - if (converter->get_subdiv_uvs(converter)) { - options.SetFVarLinearInterpolation(Options::FVAR_LINEAR_CORNERS_ONLY); - } - else { - options.SetFVarLinearInterpolation(Options::FVAR_LINEAR_ALL); - } + options.SetFVarLinearInterpolation(linear_interpolation); TopologyRefinerFactory<TopologyRefinerData>::Options topology_options(scheme_type, options); @@ -663,14 +680,17 @@ int openSubdiv_topologyRefnerCompareConverter( const int num_faces = base_level.GetNumFaces(); /* Quick preliminary check. */ OpenSubdiv::Sdc::SchemeType scheme_type = - get_capi_scheme_type(converter->get_type(converter)); + get_capi_scheme_type(converter->get_scheme_type(converter)); if (scheme_type != refiner->GetSchemeType()) { return false; } const Options options = refiner->GetSchemeOptions(); - Options::FVarLinearInterpolation interp = options.GetFVarLinearInterpolation(); - const bool subdiv_uvs = (interp != Options::FVAR_LINEAR_ALL); - if (converter->get_subdiv_uvs(converter) != subdiv_uvs) { + const Options::FVarLinearInterpolation interp = + options.GetFVarLinearInterpolation(); + const Options::FVarLinearInterpolation new_interp = + get_capi_fvar_linear_interpolation( + converter->get_fvar_linear_interpolation(converter)); + if (new_interp != interp) { return false; } if (converter->get_num_verts(converter) != num_verts || diff --git a/intern/opensubdiv/opensubdiv_converter_capi.h b/intern/opensubdiv/opensubdiv_converter_capi.h index 6eda6ae5d8a..ea4f20c5961 100644 --- a/intern/opensubdiv/opensubdiv_converter_capi.h +++ b/intern/opensubdiv/opensubdiv_converter_capi.h @@ -41,13 +41,22 @@ typedef enum OpenSubdiv_SchemeType { OSD_SCHEME_LOOP, } OpenSubdiv_SchemeType; +typedef enum OpenSubdiv_FVarLinearInterpolation { + OSD_FVAR_LINEAR_INTERPOLATION_NONE, + OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY, + OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES, + OSD_FVAR_LINEAR_INTERPOLATION_ALL, +} OpenSubdiv_FVarLinearInterpolation; + typedef struct OpenSubdiv_Converter { /* TODO(sergey): Needs to be implemented. */ /* OpenSubdiv::Sdc::Options get_options() const; */ - OpenSubdiv_SchemeType (*get_type)(const OpenSubdiv_Converter *converter); + OpenSubdiv_SchemeType (*get_scheme_type)( + const OpenSubdiv_Converter *converter); - bool (*get_subdiv_uvs)(const OpenSubdiv_Converter *converter); + OpenSubdiv_FVarLinearInterpolation (*get_fvar_linear_interpolation)( + const OpenSubdiv_Converter *converter); int (*get_num_faces)(const OpenSubdiv_Converter *converter); int (*get_num_edges)(const OpenSubdiv_Converter *converter); @@ -86,7 +95,6 @@ typedef struct OpenSubdiv_Converter { int *vert_faces); /* Face-varying data. */ - int (*get_num_uv_layers)(const OpenSubdiv_Converter *converter); void (*precalc_uv_layer)(const OpenSubdiv_Converter *converter, int layer); @@ -99,6 +107,7 @@ typedef struct OpenSubdiv_Converter { int face, int corner); + /* User data associated with this converter. */ void (*free_user_data)(const OpenSubdiv_Converter *converter); void *user_data; } OpenSubdiv_Converter; diff --git a/intern/opensubdiv/opensubdiv_evaluator_capi.cc b/intern/opensubdiv/opensubdiv_evaluator_capi.cc index c4a128213dd..049c0aad3bf 100644 --- a/intern/opensubdiv/opensubdiv_evaluator_capi.cc +++ b/intern/opensubdiv/opensubdiv_evaluator_capi.cc @@ -42,6 +42,7 @@ #include <opensubdiv/osd/types.h> #include "opensubdiv_intern.h" +#include "opensubdiv_topology_refiner.h" #include "MEM_guardedalloc.h" @@ -341,7 +342,7 @@ OpenSubdiv_EvaluatorDescr *openSubdiv_createEvaluatorDescr( int subsurf_level) { /* TODO(sergey): Look into re-using refiner with GLMesh. */ - TopologyRefiner *refiner = (TopologyRefiner *)topology_refiner; + TopologyRefiner *refiner = topology_refiner->osd_refiner; if(refiner == NULL) { /* Happens on bad topology. */ return NULL; |