Fix compilation with older OpenSubdiv libraries
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 16 Jul 2018 10:55:39 +0000 (12:55 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 16 Jul 2018 10:55:39 +0000 (12:55 +0200)
Only fixes compilation error, the functionality will be limited.

Currently we don't care that much, since all the work is done in
the branch anyway.

Later on when we'll know which fixes we need to apply on top of
latest OpenSubdiv library we will call a library upgrade.

intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc

index 595df3eaa75a1568eac2f1a846e0e6dc349eaeda..d593518405fef81794ca8e6a880514bacaafb6ca 100644 (file)
@@ -34,6 +34,7 @@
 #include <opensubdiv/osd/cpuVertexBuffer.h>
 #include <opensubdiv/osd/mesh.h>
 #include <opensubdiv/osd/types.h>
+#include <opensubdiv/version.h>
 
 #include "MEM_guardedalloc.h"
 
@@ -52,6 +53,13 @@ using OpenSubdiv::Far::StencilTable;
 using OpenSubdiv::Far::StencilTableFactory;
 using OpenSubdiv::Far::TopologyRefiner;
 
+// TODO(sergey): Remove after official requirement bump for OSD version.
+#if OPENSUBDIV_VERSION_NUMBER >= 30200
+#  define OPENSUBDIV_HAS_FVAR_EVALUATION
+#else
+#  undef OPENSUBDIV_HAS_FVAR_EVALUATION
+#endif
+
 namespace opensubdiv_capi {
 
 namespace {
@@ -652,6 +660,7 @@ OpenSubdiv_EvaluatorInternal* openSubdiv_createEvaluatorInternal(
       StencilTableFactory::Create(*refiner, varying_stencil_options);
   // Face warying stencil.
   const StencilTable* face_varying_stencils = NULL;
+#ifdef OPENSUBDIV_HAS_FVAR_EVALUATION
   if (has_face_varying_data) {
     StencilTableFactory::Options face_varying_stencil_options;
     face_varying_stencil_options.generateOffsets = true;
@@ -664,6 +673,7 @@ OpenSubdiv_EvaluatorInternal* openSubdiv_createEvaluatorInternal(
     face_varying_stencils =
         StencilTableFactory::Create(*refiner, face_varying_stencil_options);
   }
+#endif
   // Generate bi-cubic patch table for the limit surface.
   // TODO(sergey): Ideally we would want to expose end-cap settings via
   // C-API to make it more generic. Currently it matches old Blender's
@@ -694,6 +704,7 @@ OpenSubdiv_EvaluatorInternal* openSubdiv_createEvaluatorInternal(
     delete varying_stencils;
     varying_stencils = table;
   }
+#ifdef OPENSUBDIV_HAS_FVAR_EVALUATION
   const StencilTable* local_point_face_varying_stencil_table =
       patch_table->GetLocalPointFaceVaryingStencilTable();
   if (local_point_face_varying_stencil_table != NULL) {
@@ -705,6 +716,7 @@ OpenSubdiv_EvaluatorInternal* openSubdiv_createEvaluatorInternal(
       delete face_varying_stencils;
       face_varying_stencils = table;
   }
+#endif
   // Create OpenSubdiv's CPU side evaluator.
   // TODO(sergey): Make it possible to use different evaluators.
   opensubdiv_capi::CpuEvalOutput* eval_output =