Depsgraph: Use explicit depsgraph in alembic module
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 3 Nov 2017 11:02:39 +0000 (12:02 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 3 Nov 2017 11:02:39 +0000 (12:02 +0100)
source/blender/alembic/intern/abc_exporter.cc
source/blender/alembic/intern/abc_exporter.h
source/blender/alembic/intern/alembic_capi.cc
tests/gtests/alembic/abc_export_test.cc

index 5635e3a94203df20c0e5acba2a4834d6b101adee..51e2e7040f9cbfdb801fe635d7f2a54db398b323 100644 (file)
@@ -168,7 +168,8 @@ static bool export_object(const ExportSettings * const settings, const Base * co
 
 /* ************************************************************************** */
 
-AbcExporter::AbcExporter(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, const char *filename, ExportSettings &settings)
+AbcExporter::AbcExporter(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Depsgraph *depsgraph,
+                         const char *filename, ExportSettings &settings)
     : m_bmain(bmain)
     , m_settings(settings)
     , m_filename(filename)
@@ -176,6 +177,7 @@ AbcExporter::AbcExporter(Main *bmain, EvaluationContext *eval_ctx, Scene *scene,
     , m_shape_sampling_index(0)
     , m_eval_ctx(eval_ctx)
     , m_scene(scene)
+    , m_depsgraph(depsgraph)
     , m_writer(NULL)
 {}
 
@@ -653,5 +655,5 @@ void AbcExporter::setCurrentFrame(Main *bmain, double t)
 {
        m_scene->r.cfra = static_cast<int>(t);
        m_scene->r.subframe = static_cast<float>(t) - m_scene->r.cfra;
-       BKE_scene_update_for_newframe(bmain->eval_ctx, bmain, m_scene);
+       BKE_scene_graph_update_for_newframe(bmain->eval_ctx, m_depsgraph, bmain, m_scene);
 }
index 7e32178bc208a205796cf37ba12434f8773b43bd..d0f3964abd59829d67c4fba84669d54c17d00aea 100644 (file)
@@ -35,6 +35,7 @@ class AbcTransformWriter;
 class ArchiveWriter;
 
 struct EvaluationContext;
+struct Depsgraph;
 struct Main;
 struct Object;
 struct Scene;
@@ -46,6 +47,7 @@ struct ExportSettings {
 
        Scene *scene;
        SceneLayer *sl;  // Scene layer to export; all its objects will be exported, unless selected_only=true
+       Depsgraph *depsgraph;
        SimpleLogger logger;
 
        bool selected_only;
@@ -93,6 +95,7 @@ class AbcExporter {
 
        EvaluationContext *m_eval_ctx;
        Scene *m_scene;
+       Depsgraph *m_depsgraph;
 
        ArchiveWriter *m_writer;
 
@@ -103,7 +106,8 @@ class AbcExporter {
        std::vector<AbcObjectWriter *> m_shapes;
 
 public:
-       AbcExporter(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, const char *filename, ExportSettings &settings);
+       AbcExporter(Main *bmain, EvaluationContext *eval_ctx, Scene *scene, Depsgraph *depsgraph,
+                   const char *filename, ExportSettings &settings);
        ~AbcExporter();
 
        void operator()(Main *bmain, float &progress, bool &was_canceled);
index 730a574e6497dc23efdc318011b7694556208fcb..c8735df21d5d66e338321ad55897b16bb1951af5 100644 (file)
@@ -232,6 +232,7 @@ static void find_iobject(const IObject &object, IObject &ret,
 struct ExportJobData {
        EvaluationContext eval_ctx;
        Scene *scene;
+       Depsgraph *depsgraph;
        Main *bmain;
 
        char filename[1024];
@@ -263,7 +264,7 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo
 
        try {
                Scene *scene = data->scene;
-               AbcExporter exporter(data->bmain, &data->eval_ctx, scene, data->filename, data->settings);
+               AbcExporter exporter(data->bmain, &data->eval_ctx, scene, data->depsgraph, data->filename, data->settings);
 
                const int orig_frame = CFRA;
 
@@ -315,6 +316,7 @@ bool ABC_export(
        CTX_data_eval_ctx(C, &job->eval_ctx);
 
        job->scene = scene;
+       job->depsgraph = CTX_data_depsgraph(C);
        job->bmain = CTX_data_main(C);
        job->export_ok = false;
        BLI_strncpy(job->filename, filepath, 1024);
@@ -336,6 +338,7 @@ bool ABC_export(
         * hardcore refactoring. */
        new (&job->settings) ExportSettings();
        job->settings.scene = job->scene;
+       job->settings.depsgraph = job->depsgraph;
 
        /* Sybren: for now we only export the active scene layer.
         * Later in the 2.8 development process this may be replaced by using
index 6fc976b8a553604f8e0f9a6267426ef9270e365f..b5ef1a194e91faba54e6d341878f03c1ff3d361d 100644 (file)
@@ -15,11 +15,11 @@ extern "C" {
 
 class TestableAbcExporter : public AbcExporter {
 public:
-       TestableAbcExporter(Main *bmain, Scene *scene, const char *filename, ExportSettings &settings)
-           : AbcExporter(bmain, &eval_ctx, scene, filename, settings)
+       TestableAbcExporter(Main *bmain, EvaluationContext *eval_ctx,
+                           Scene *scene, Depsgraph *depsgraph,
+                           const char *filename, ExportSettings &settings)
+           : AbcExporter(bmain, eval_ctx, scene, depsgraph, filename, settings)
        {
-               /* TODO(sergey): Pass scene layer somehow? */
-               DEG_evaluation_context_init(&eval_ctx, DAG_EVAL_VIEWPORT);
        }
 
        void getShutterSamples(unsigned int nr_of_samples,
@@ -33,8 +33,6 @@ public:
                         std::set<double> &frames) {
                AbcExporter::getFrameSet(nr_of_samples, frames);
        }
-
-       EvaluationContext eval_ctx;
 };
 
 class AlembicExportTest : public testing::Test
@@ -42,8 +40,9 @@ class AlembicExportTest : public testing::Test
 protected:
        ExportSettings settings;
        Scene scene;
-       TestableAbcExporter *exporter;
        EvaluationContext eval_ctx;
+       Depsgraph *depsgraph;
+       TestableAbcExporter *exporter;
        Main *bmain;
 
        virtual void SetUp()
@@ -57,19 +56,24 @@ protected:
 
                bmain = BKE_main_new();
 
+               /* TODO(sergey): Pass scene layer somehow? */
+               DEG_evaluation_context_init(&eval_ctx, DAG_EVAL_VIEWPORT);
+               depsgraph = DEG_graph_new();
+
                exporter = NULL;
        }
 
        virtual void TearDown()
        {
                BKE_main_free(bmain);
+               DEG_graph_free(depsgraph);
                delete exporter;
        }
 
        // Call after setting up the settings.
        void createExporter()
        {
-               exporter = new TestableAbcExporter(bmain, &scene, "somefile.abc", settings);
+               exporter = new TestableAbcExporter(bmain, &eval_ctx, &scene, depsgraph, "somefile.abc", settings);
        }
 };