fix: Collada Exporter: improve usage of viewlayer and depsgraph
authorGaia Clary <gaia.clary@machinimatrix.org>
Tue, 27 Nov 2018 11:14:03 +0000 (12:14 +0100)
committerGaia Clary <gaia.clary@machinimatrix.org>
Tue, 27 Nov 2018 11:22:30 +0000 (12:22 +0100)
* The exporter now gets the view layer from the context
  instead of the depsgraph.
* The depsgrap is now fetched only on demand since the graph
  is not always needed for exporting (currently only for armature exports).

source/blender/collada/BlenderContext.cpp

index 536d517bd6e7c928d0063df2deeee3e1c2bd77f2..fcfd92416498530827c91286d20e02bee242a21b 100644 (file)
   */
 
 #include "BlenderContext.h"
+#include "BKE_scene.h"
 
 BlenderContext::BlenderContext(bContext *C)
 {
        context = C;
        main = CTX_data_main(C);
-       depsgraph = CTX_data_depsgraph(C);
        scene = CTX_data_scene(C);
-       view_layer = DEG_get_evaluated_view_layer(depsgraph);
+       view_layer = CTX_data_view_layer(C);
+       depsgraph = nullptr; // create only when needed
 }
 
 bContext *BlenderContext::get_context()
@@ -42,6 +43,9 @@ bContext *BlenderContext::get_context()
 
 Depsgraph *BlenderContext::get_depsgraph()
 {
+       if (!depsgraph) {
+               depsgraph = BKE_scene_get_depsgraph(scene, view_layer, true);
+       }
        return depsgraph;
 }