Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/alembic/intern/alembic_capi.cc')
-rw-r--r--source/blender/alembic/intern/alembic_capi.cc62
1 files changed, 52 insertions, 10 deletions
diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc
index 0d2316ce7d9..35877f9f5a8 100644
--- a/source/blender/alembic/intern/alembic_capi.cc
+++ b/source/blender/alembic/intern/alembic_capi.cc
@@ -48,12 +48,15 @@ extern "C" {
#include "BKE_cdderivedmesh.h"
#include "BKE_context.h"
#include "BKE_curve.h"
-#include "BKE_depsgraph.h"
#include "BKE_global.h"
+#include "BKE_layer.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_scene.h"
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+
/* SpaceType struct has a member called 'new' which obviously conflicts with C++
* so temporarily redefining the new keyword to make it compile. */
#define new extern_new
@@ -228,6 +231,8 @@ static void find_iobject(const IObject &object, IObject &ret,
struct ExportJobData {
Scene *scene;
+ ViewLayer *view_layer;
+ Depsgraph *depsgraph;
Main *bmain;
char filename[1024];
@@ -259,18 +264,17 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo
try {
Scene *scene = data->scene;
- AbcExporter exporter(data->bmain, scene, data->filename, data->settings);
+ AbcExporter exporter(data->bmain, scene, data->depsgraph, data->filename, data->settings);
const int orig_frame = CFRA;
data->was_canceled = false;
- exporter(data->bmain, *data->progress, data->was_canceled);
+ exporter(*data->progress, data->was_canceled);
if (CFRA != orig_frame) {
CFRA = orig_frame;
- BKE_scene_update_for_newframe(data->bmain->eval_ctx, data->bmain,
- scene, scene->lay);
+ BKE_scene_graph_update_for_newframe(data->depsgraph, data->bmain);
}
data->export_ok = !data->was_canceled;
@@ -308,7 +312,10 @@ bool ABC_export(
bool as_background_job)
{
ExportJobData *job = static_cast<ExportJobData *>(MEM_mallocN(sizeof(ExportJobData), "ExportJobData"));
+
job->scene = scene;
+ job->view_layer = CTX_data_view_layer(C);
+ job->depsgraph = CTX_data_depsgraph(C);
job->bmain = CTX_data_main(C);
job->export_ok = false;
BLI_strncpy(job->filename, filepath, 1024);
@@ -330,13 +337,25 @@ 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
+ * a specific collection for Alembic I/O, which can then be toggled
+ * between "real" objects and cached Alembic files. */
+ job->settings.view_layer = CTX_data_view_layer(C);
+
job->settings.frame_start = params->frame_start;
job->settings.frame_end = params->frame_end;
job->settings.frame_samples_xform = params->frame_samples_xform;
job->settings.frame_samples_shape = params->frame_samples_shape;
job->settings.shutter_open = params->shutter_open;
job->settings.shutter_close = params->shutter_close;
+
+ /* Sybren: For now this is ignored, until we can get selection
+ * detection working through Base pointers (instead of ob->flags). */
job->settings.selected_only = params->selected_only;
+
job->settings.export_face_sets = params->face_sets;
job->settings.export_normals = params->normals;
job->settings.export_uvs = params->uvs;
@@ -345,8 +364,13 @@ bool ABC_export(
job->settings.export_particles = params->export_particles;
job->settings.apply_subdiv = params->apply_subdiv;
job->settings.flatten_hierarchy = params->flatten_hierarchy;
+
+ /* Sybren: visible_layer & renderable only is ignored for now,
+ * to be replaced with collections later in the 2.8 dev process
+ * (also see note above). */
job->settings.visible_layers_only = params->visible_layers_only;
job->settings.renderable_only = params->renderable_only;
+
job->settings.use_subdiv_schema = params->use_subdiv_schema;
job->settings.export_ogawa = (params->compression_type == ABC_ARCHIVE_OGAWA);
job->settings.pack_uv = params->packuv;
@@ -606,6 +630,7 @@ enum {
struct ImportJobData {
Main *bmain;
Scene *scene;
+ ViewLayer *view_layer;
char filename[1024];
ImportSettings settings;
@@ -621,6 +646,7 @@ struct ImportJobData {
bool import_ok;
};
+#if 0
ABC_INLINE bool is_mesh_and_strands(const IObject &object)
{
bool has_mesh = false;
@@ -651,6 +677,7 @@ ABC_INLINE bool is_mesh_and_strands(const IObject &object)
return has_mesh && has_curve;
}
+#endif
static void import_startjob(void *user_data, short *stop, short *do_update, float *progress)
{
@@ -807,20 +834,34 @@ static void import_endjob(void *user_data)
else {
/* Add object to scene. */
Base *base;
+ LayerCollection *lc;
+ ViewLayer *view_layer = data->view_layer;
- BKE_scene_base_deselect_all(data->scene);
+ BKE_view_layer_base_deselect_all(view_layer);
+
+ lc = BKE_layer_collection_get_active(view_layer);
+ if (lc == NULL) {
+ BLI_assert(BLI_listbase_count_at_most(&view_layer->layer_collections, 1) == 0);
+ /* when there is no collection linked to this ViewLayer, create one */
+ SceneCollection *sc = BKE_collection_add(&data->scene->id, NULL, COLLECTION_TYPE_NONE, NULL);
+ lc = BKE_collection_link(view_layer, sc);
+ }
for (iter = data->readers.begin(); iter != data->readers.end(); ++iter) {
Object *ob = (*iter)->object();
ob->lay = data->scene->lay;
- base = BKE_scene_base_add(data->scene, ob);
- BKE_scene_base_select(data->scene, base);
+ BKE_collection_object_add(&data->scene->id, lc->scene_collection, ob);
+
+ base = BKE_view_layer_base_find(view_layer, ob);
+ BKE_view_layer_base_select(view_layer, base);
- DAG_id_tag_update_ex(data->bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
+ DEG_id_tag_update_ex(data->bmain, &ob->id,
+ OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME | DEG_TAG_BASE_FLAGS_UPDATE);
}
- DAG_relations_tag_update(data->bmain);
+ DEG_id_tag_update(&data->scene->id, DEG_TAG_BASE_FLAGS_UPDATE);
+ DEG_relations_tag_update(data->bmain);
}
for (iter = data->readers.begin(); iter != data->readers.end(); ++iter) {
@@ -863,6 +904,7 @@ bool ABC_import(bContext *C, const char *filepath, float scale, bool is_sequence
ImportJobData *job = new ImportJobData();
job->bmain = CTX_data_main(C);
job->scene = CTX_data_scene(C);
+ job->view_layer = CTX_data_view_layer(C);
job->import_ok = false;
BLI_strncpy(job->filename, filepath, 1024);