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')
-rw-r--r--source/blender/alembic/CMakeLists.txt2
-rw-r--r--source/blender/alembic/intern/abc_camera.cc5
-rw-r--r--source/blender/alembic/intern/abc_camera.h3
-rw-r--r--source/blender/alembic/intern/abc_curves.cc5
-rw-r--r--source/blender/alembic/intern/abc_curves.h3
-rw-r--r--source/blender/alembic/intern/abc_exporter.cc138
-rw-r--r--source/blender/alembic/intern/abc_exporter.h24
-rw-r--r--source/blender/alembic/intern/abc_hair.cc11
-rw-r--r--source/blender/alembic/intern/abc_hair.h3
-rw-r--r--source/blender/alembic/intern/abc_mball.cc12
-rw-r--r--source/blender/alembic/intern/abc_mball.h1
-rw-r--r--source/blender/alembic/intern/abc_mesh.cc14
-rw-r--r--source/blender/alembic/intern/abc_mesh.h3
-rw-r--r--source/blender/alembic/intern/abc_nurbs.cc5
-rw-r--r--source/blender/alembic/intern/abc_nurbs.h3
-rw-r--r--source/blender/alembic/intern/abc_object.cc5
-rw-r--r--source/blender/alembic/intern/abc_object.h4
-rw-r--r--source/blender/alembic/intern/abc_points.cc6
-rw-r--r--source/blender/alembic/intern/abc_points.h3
-rw-r--r--source/blender/alembic/intern/abc_transform.cc5
-rw-r--r--source/blender/alembic/intern/abc_transform.h4
-rw-r--r--source/blender/alembic/intern/abc_util.cc36
-rw-r--r--source/blender/alembic/intern/abc_util.h4
-rw-r--r--source/blender/alembic/intern/alembic_capi.cc62
24 files changed, 207 insertions, 154 deletions
diff --git a/source/blender/alembic/CMakeLists.txt b/source/blender/alembic/CMakeLists.txt
index fb08887c076..d3b5e189292 100644
--- a/source/blender/alembic/CMakeLists.txt
+++ b/source/blender/alembic/CMakeLists.txt
@@ -29,11 +29,11 @@ set(INC
../blenlib
../blenloader
../bmesh
+ ../depsgraph
../editors/include
../makesdna
../makesrna
../windowmanager
- ../depsgraph
../../../intern/guardedalloc
../../../intern/utfconv
)
diff --git a/source/blender/alembic/intern/abc_camera.cc b/source/blender/alembic/intern/abc_camera.cc
index 16416205983..4c91b9a6252 100644
--- a/source/blender/alembic/intern/abc_camera.cc
+++ b/source/blender/alembic/intern/abc_camera.cc
@@ -49,12 +49,13 @@ using Alembic::AbcGeom::kWrapExisting;
/* ************************************************************************** */
-AbcCameraWriter::AbcCameraWriter(Scene *scene,
+AbcCameraWriter::AbcCameraWriter(Depsgraph *depsgraph,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
{
OCamera camera(parent->alembicXform(), m_name, m_time_sampling);
m_camera_schema = camera.getSchema();
diff --git a/source/blender/alembic/intern/abc_camera.h b/source/blender/alembic/intern/abc_camera.h
index 16c5cccd5ea..a839ca947ca 100644
--- a/source/blender/alembic/intern/abc_camera.h
+++ b/source/blender/alembic/intern/abc_camera.h
@@ -35,7 +35,8 @@ class AbcCameraWriter : public AbcObjectWriter {
Alembic::AbcGeom::OFloatProperty m_eye_separation;
public:
- AbcCameraWriter(Scene *scene,
+ AbcCameraWriter(Depsgraph *depsgraph,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
diff --git a/source/blender/alembic/intern/abc_curves.cc b/source/blender/alembic/intern/abc_curves.cc
index f73fe957fea..41c1dacabc0 100644
--- a/source/blender/alembic/intern/abc_curves.cc
+++ b/source/blender/alembic/intern/abc_curves.cc
@@ -71,12 +71,13 @@ using Alembic::AbcGeom::OV2fGeomParam;
/* ************************************************************************** */
-AbcCurveWriter::AbcCurveWriter(Scene *scene,
+AbcCurveWriter::AbcCurveWriter(Depsgraph *depsgraph,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
{
OCurves curves(parent->alembicXform(), m_name, m_time_sampling);
m_schema = curves.getSchema();
diff --git a/source/blender/alembic/intern/abc_curves.h b/source/blender/alembic/intern/abc_curves.h
index a9231f947b2..1e7180bbb1f 100644
--- a/source/blender/alembic/intern/abc_curves.h
+++ b/source/blender/alembic/intern/abc_curves.h
@@ -36,7 +36,8 @@ class AbcCurveWriter : public AbcObjectWriter {
Alembic::AbcGeom::OCurvesSchema::Sample m_sample;
public:
- AbcCurveWriter(Scene *scene,
+ AbcCurveWriter(Depsgraph *depsgraph,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc
index 946b89213e6..f06959762d5 100644
--- a/source/blender/alembic/intern/abc_exporter.cc
+++ b/source/blender/alembic/intern/abc_exporter.cc
@@ -136,45 +136,48 @@ static bool object_type_is_exportable(Scene *scene, Object *ob)
/**
* Returns whether this object should be exported into the Alembic file.
*
- * \param settings: export settings, used for options like 'selected only'.
- * \param ob: the object in question.
+ * \param settings export settings, used for options like 'selected only'.
+ * \param ob the object's base in question.
* \param is_duplicated: Normally false; true when the object is instanced
* into the scene by a dupli-object (e.g. part of a dupligroup).
* This ignores selection and layer visibility,
* and assumes that the dupli-object itself (e.g. the group-instantiating empty) is exported.
*/
-static bool export_object(const ExportSettings * const settings, Object *ob,
+static bool export_object(const ExportSettings * const settings, const Base * const ob_base,
bool is_duplicated)
{
if (!is_duplicated) {
/* These two tests only make sense when the object isn't being instanced
* into the scene. When it is, its exportability is determined by
* its dupli-object and the DupliObject::no_draw property. */
- if (settings->selected_only && !parent_selected(ob)) {
+ if (settings->selected_only && !object_selected(ob_base)) {
return false;
}
-
- if (settings->visible_layers_only && !(settings->scene->lay & ob->lay)) {
+ // FIXME Sybren: handle these cleanly (maybe just remove code), now using active scene layer instead.
+ if (settings->visible_layers_only && (ob_base->flag & BASE_VISIBLED) == 0) {
return false;
}
}
- if (settings->renderable_only && (ob->restrictflag & OB_RESTRICT_RENDER)) {
- return false;
- }
+ // if (settings->renderable_only && (ob->restrictflag & OB_RESTRICT_RENDER)) {
+ // return false;
+ // }
return true;
}
/* ************************************************************************** */
-AbcExporter::AbcExporter(Main *bmain, Scene *scene, const char *filename, ExportSettings &settings)
+AbcExporter::AbcExporter(Main *bmain, Scene *scene,
+ Depsgraph *depsgraph,
+ const char *filename, ExportSettings &settings)
: m_bmain(bmain)
, m_settings(settings)
, m_filename(filename)
, m_trans_sampling_index(0)
, m_shape_sampling_index(0)
, m_scene(scene)
+ , m_depsgraph(depsgraph)
, m_writer(NULL)
{}
@@ -249,13 +252,13 @@ void AbcExporter::getFrameSet(unsigned int nr_of_samples,
}
}
-void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled)
+void AbcExporter::operator()(float &progress, bool &was_canceled)
{
std::string scene_name;
- if (bmain->name[0] != '\0') {
+ if (m_bmain->name[0] != '\0') {
char scene_file_name[FILE_MAX];
- BLI_strncpy(scene_file_name, bmain->name, FILE_MAX);
+ BLI_strncpy(scene_file_name, m_bmain->name, FILE_MAX);
scene_name = scene_file_name;
}
else {
@@ -294,8 +297,8 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled)
OBox3dProperty archive_bounds_prop = Alembic::AbcGeom::CreateOArchiveBounds(m_writer->archive(), m_trans_sampling_index);
- createTransformWritersHierarchy(bmain->eval_ctx);
- createShapeWriters(bmain->eval_ctx);
+ createTransformWritersHierarchy(m_depsgraph);
+ createShapeWriters(m_depsgraph);
/* Make a list of frames to export. */
@@ -328,7 +331,7 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled)
const double frame = *begin;
/* 'frame' is offset by start frame, so need to cancel the offset. */
- setCurrentFrame(bmain, frame);
+ setCurrentFrame(m_bmain, frame);
if (shape_frames.count(frame) != 0) {
for (int i = 0, e = m_shapes.size(); i != e; ++i) {
@@ -357,42 +360,45 @@ void AbcExporter::operator()(Main *bmain, float &progress, bool &was_canceled)
}
}
-void AbcExporter::createTransformWritersHierarchy(EvaluationContext *eval_ctx)
+void AbcExporter::createTransformWritersHierarchy(Depsgraph *depsgraph)
{
- Base *base = static_cast<Base *>(m_scene->base.first);
-
- while (base) {
+ for (Base *base = static_cast<Base *>(m_settings.view_layer->object_bases.first); base; base = base->next) {
Object *ob = base->object;
- switch (ob->type) {
- case OB_LAMP:
- case OB_LATTICE:
- case OB_SPEAKER:
- /* We do not export transforms for objects of these classes. */
- break;
- default:
- exploreTransform(eval_ctx, ob, ob->parent);
+ if (export_object(&m_settings, base, false)) {
+ switch (ob->type) {
+ case OB_LAMP:
+ case OB_LATTICE:
+ case OB_SPEAKER:
+ /* We do not export transforms for objects of these classes. */
+ break;
+ default:
+ exploreTransform(depsgraph, base, ob->parent, NULL);
+ }
}
-
- base = base->next;
}
}
-void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent)
+void AbcExporter::exploreTransform(Depsgraph *depsgraph, Base *ob_base, Object *parent, Object *dupliObParent)
{
+ Object *ob = ob_base->object;
+
/* If an object isn't exported itself, its duplilist shouldn't be
* exported either. */
- if (!export_object(&m_settings, ob, dupliObParent != NULL)) {
+ if (!export_object(&m_settings, ob_base, dupliObParent != NULL)) {
return;
}
if (object_type_is_exportable(m_scene, ob)) {
- createTransformWriter(ob, parent, dupliObParent);
+ createTransformWriter(depsgraph, ob, parent, dupliObParent);
}
- ListBase *lb = object_duplilist(eval_ctx, m_scene, ob);
+ ListBase *lb = object_duplilist(depsgraph, m_scene, ob);
if (lb) {
+ Base fake_base = *ob_base; // copy flags (like selection state) from the real object.
+ fake_base.next = fake_base.prev = NULL;
+
DupliObject *link = static_cast<DupliObject *>(lb->first);
Object *dupli_ob = NULL;
Object *dupli_parent = NULL;
@@ -407,7 +413,8 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Object *ob, Obje
dupli_ob = link->ob;
dupli_parent = (dupli_ob->parent) ? dupli_ob->parent : ob;
- exploreTransform(eval_ctx, dupli_ob, dupli_parent, ob);
+ fake_base.object = dupli_ob;
+ exploreTransform(depsgraph, &fake_base, dupli_parent, ob);
}
}
}
@@ -415,7 +422,7 @@ void AbcExporter::exploreTransform(EvaluationContext *eval_ctx, Object *ob, Obje
free_object_duplilist(lb);
}
-AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *parent, Object *dupliObParent)
+AbcTransformWriter * AbcExporter::createTransformWriter(Depsgraph *depsgraph, Object *ob, Object *parent, Object *dupliObParent)
{
/* An object should not be its own parent, or we'll get infinite loops. */
BLI_assert(ob != parent);
@@ -450,29 +457,29 @@ AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *pare
* return the parent's AbcTransformWriter pointer. */
if (parent->parent) {
if (parent == dupliObParent) {
- parent_writer = createTransformWriter(parent, parent->parent, NULL);
+ parent_writer = createTransformWriter(depsgraph, parent, parent->parent, NULL);
}
else {
- parent_writer = createTransformWriter(parent, parent->parent, dupliObParent);
+ parent_writer = createTransformWriter(depsgraph, parent, parent->parent, dupliObParent);
}
}
else if (parent == dupliObParent) {
if (dupliObParent->parent == NULL) {
- parent_writer = createTransformWriter(parent, NULL, NULL);
+ parent_writer = createTransformWriter(depsgraph, parent, NULL, NULL);
}
else {
- parent_writer = createTransformWriter(parent, dupliObParent->parent, dupliObParent->parent);
+ parent_writer = createTransformWriter(depsgraph, parent, dupliObParent->parent, dupliObParent->parent);
}
}
else {
- parent_writer = createTransformWriter(parent, dupliObParent, dupliObParent);
+ parent_writer = createTransformWriter(depsgraph, parent, dupliObParent, dupliObParent);
}
BLI_assert(parent_writer);
alembic_parent = parent_writer->alembicXform();
}
- my_writer = new AbcTransformWriter(ob, alembic_parent, parent_writer,
+ my_writer = new AbcTransformWriter(depsgraph, ob, alembic_parent, parent_writer,
m_trans_sampling_index, m_settings);
/* When flattening, the matrix of the dupliobject has to be added. */
@@ -484,31 +491,30 @@ AbcTransformWriter * AbcExporter::createTransformWriter(Object *ob, Object *pare
return my_writer;
}
-void AbcExporter::createShapeWriters(EvaluationContext *eval_ctx)
+void AbcExporter::createShapeWriters(Depsgraph *depsgraph)
{
- Base *base = static_cast<Base *>(m_scene->base.first);
-
- while (base) {
- Object *ob = base->object;
- exploreObject(eval_ctx, ob, NULL);
-
- base = base->next;
+ for (Base *base = static_cast<Base *>(m_settings.view_layer->object_bases.first); base; base = base->next) {
+ exploreObject(depsgraph, base, NULL);
}
}
-void AbcExporter::exploreObject(EvaluationContext *eval_ctx, Object *ob, Object *dupliObParent)
+void AbcExporter::exploreObject(Depsgraph *depsgraph, Base *ob_base, Object *dupliObParent)
{
/* If an object isn't exported itself, its duplilist shouldn't be
* exported either. */
- if (!export_object(&m_settings, ob, dupliObParent != NULL)) {
+ if (!export_object(&m_settings, ob_base, dupliObParent != NULL)) {
return;
}
- createShapeWriter(ob, dupliObParent);
+ createShapeWriter(ob_base, dupliObParent);
- ListBase *lb = object_duplilist(eval_ctx, m_scene, ob);
+ Object *ob = ob_base->object;
+ ListBase *lb = object_duplilist(depsgraph, m_scene, ob);
if (lb) {
+ Base fake_base = *ob_base; // copy flags (like selection state) from the real object.
+ fake_base.next = fake_base.prev = NULL;
+
DupliObject *link = static_cast<DupliObject *>(lb->first);
for (; link; link = link->next) {
@@ -516,9 +522,9 @@ void AbcExporter::exploreObject(EvaluationContext *eval_ctx, Object *ob, Object
if (m_settings.renderable_only && link->no_draw) {
continue;
}
-
if (link->type == OB_DUPLIGROUP) {
- exploreObject(eval_ctx, link->ob, ob);
+ fake_base.object = link->ob;
+ exploreObject(depsgraph, &fake_base, ob);
}
}
}
@@ -541,16 +547,18 @@ void AbcExporter::createParticleSystemsWriters(Object *ob, AbcTransformWriter *x
if (m_settings.export_hair && psys->part->type == PART_HAIR) {
m_settings.export_child_hairs = true;
- m_shapes.push_back(new AbcHairWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
+ m_shapes.push_back(new AbcHairWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
}
else if (m_settings.export_particles && psys->part->type == PART_EMITTER) {
- m_shapes.push_back(new AbcPointsWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
+ m_shapes.push_back(new AbcPointsWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings, psys));
}
}
}
-void AbcExporter::createShapeWriter(Object *ob, Object *dupliObParent)
+void AbcExporter::createShapeWriter(Base *ob_base, Object *dupliObParent)
{
+ Object *ob = ob_base->object;
+
if (!object_type_is_exportable(m_scene, ob)) {
return;
}
@@ -582,7 +590,7 @@ void AbcExporter::createShapeWriter(Object *ob, Object *dupliObParent)
return;
}
- m_shapes.push_back(new AbcMeshWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings));
+ m_shapes.push_back(new AbcMeshWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings));
break;
}
case OB_SURF:
@@ -593,7 +601,7 @@ void AbcExporter::createShapeWriter(Object *ob, Object *dupliObParent)
return;
}
- m_shapes.push_back(new AbcNurbsWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings));
+ m_shapes.push_back(new AbcNurbsWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings));
break;
}
case OB_CURVE:
@@ -604,7 +612,7 @@ void AbcExporter::createShapeWriter(Object *ob, Object *dupliObParent)
return;
}
- m_shapes.push_back(new AbcCurveWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings));
+ m_shapes.push_back(new AbcCurveWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings));
break;
}
case OB_CAMERA:
@@ -612,7 +620,7 @@ void AbcExporter::createShapeWriter(Object *ob, Object *dupliObParent)
Camera *cam = static_cast<Camera *>(ob->data);
if (cam->type == CAM_PERSP) {
- m_shapes.push_back(new AbcCameraWriter(m_scene, ob, xform, m_shape_sampling_index, m_settings));
+ m_shapes.push_back(new AbcCameraWriter(m_depsgraph, m_scene, ob, xform, m_shape_sampling_index, m_settings));
}
break;
@@ -625,7 +633,7 @@ void AbcExporter::createShapeWriter(Object *ob, Object *dupliObParent)
}
m_shapes.push_back(new AbcMBallWriter(
- m_bmain, m_scene, ob, xform,
+ m_bmain, m_depsgraph, m_scene, ob, xform,
m_shape_sampling_index, m_settings));
break;
}
@@ -647,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, m_scene->lay);
+ BKE_scene_graph_update_for_newframe(m_depsgraph, bmain);
}
diff --git a/source/blender/alembic/intern/abc_exporter.h b/source/blender/alembic/intern/abc_exporter.h
index 280682b2896..c891824a114 100644
--- a/source/blender/alembic/intern/abc_exporter.h
+++ b/source/blender/alembic/intern/abc_exporter.h
@@ -34,15 +34,19 @@ class AbcObjectWriter;
class AbcTransformWriter;
class ArchiveWriter;
-struct EvaluationContext;
+struct Depsgraph;
struct Main;
struct Object;
struct Scene;
+struct ViewLayer;
+struct Base;
struct ExportSettings {
ExportSettings();
Scene *scene;
+ ViewLayer *view_layer; // Scene layer to export; all its objects will be exported, unless selected_only=true
+ Depsgraph *depsgraph;
SimpleLogger logger;
bool selected_only;
@@ -89,6 +93,7 @@ class AbcExporter {
unsigned int m_trans_sampling_index, m_shape_sampling_index;
Scene *m_scene;
+ Depsgraph *m_depsgraph;
ArchiveWriter *m_writer;
@@ -99,10 +104,11 @@ class AbcExporter {
std::vector<AbcObjectWriter *> m_shapes;
public:
- AbcExporter(Main *bmain, Scene *scene, const char *filename, ExportSettings &settings);
+ AbcExporter(Main *bmain, Scene *scene, Depsgraph *depsgraph,
+ const char *filename, ExportSettings &settings);
~AbcExporter();
- void operator()(Main *bmain, float &progress, bool &was_canceled);
+ void operator()(float &progress, bool &was_canceled);
protected:
void getShutterSamples(unsigned int nr_of_samples,
@@ -113,12 +119,12 @@ protected:
private:
Alembic::Abc::TimeSamplingPtr createTimeSampling(double step);
- void createTransformWritersHierarchy(EvaluationContext *eval_ctx);
- AbcTransformWriter * createTransformWriter(Object *ob, Object *parent, Object *dupliObParent);
- void exploreTransform(EvaluationContext *eval_ctx, Object *ob, Object *parent, Object *dupliObParent = NULL);
- void exploreObject(EvaluationContext *eval_ctx, Object *ob, Object *dupliObParent);
- void createShapeWriters(EvaluationContext *eval_ctx);
- void createShapeWriter(Object *ob, Object *dupliObParent);
+ void createTransformWritersHierarchy(Depsgraph *depsgraph);
+ AbcTransformWriter * createTransformWriter(Depsgraph *depsgraph, Object *ob, Object *parent, Object *dupliObParent);
+ void exploreTransform(Depsgraph *depsgraph, Base *ob_base, Object *parent, Object *dupliObParent);
+ void exploreObject(Depsgraph *depsgraph, Base *ob_base, Object *dupliObParent);
+ void createShapeWriters(Depsgraph *depsgraph);
+ void createShapeWriter(Base *ob_base, Object *dupliObParent);
void createParticleSystemsWriters(Object *ob, AbcTransformWriter *xform);
AbcTransformWriter *getXForm(const std::string &name);
diff --git a/source/blender/alembic/intern/abc_hair.cc b/source/blender/alembic/intern/abc_hair.cc
index 0208da8a6d7..b31a185e39b 100644
--- a/source/blender/alembic/intern/abc_hair.cc
+++ b/source/blender/alembic/intern/abc_hair.cc
@@ -49,13 +49,14 @@ using Alembic::AbcGeom::OV2fGeomParam;
/* ************************************************************************** */
-AbcHairWriter::AbcHairWriter(Scene *scene,
+AbcHairWriter::AbcHairWriter(Depsgraph *depsgraph,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings,
ParticleSystem *psys)
- : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
, m_uv_warning_shown(false)
{
m_psys = psys;
@@ -76,7 +77,7 @@ void AbcHairWriter::do_write()
return;
}
- DerivedMesh *dm = mesh_create_derived_render(m_scene, m_object, CD_MASK_MESH);
+ DerivedMesh *dm = mesh_create_derived_render(m_depsgraph, m_scene, m_object, CD_MASK_MESH);
DM_ensure_tessface(dm);
std::vector<Imath::V3f> verts;
@@ -164,7 +165,7 @@ void AbcHairWriter::write_hair_sample(DerivedMesh *dm,
psys_interpolate_uvs(tface, face->v4, pa->fuv, r_uv);
uv_values.push_back(Imath::V2f(r_uv[0], r_uv[1]));
- psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, normal, NULL, NULL, NULL, NULL);
+ psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, normal, NULL, NULL, NULL);
copy_yup_from_zup(tmp_nor.getValue(), normal);
norm_values.push_back(tmp_nor);
@@ -272,7 +273,7 @@ void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm,
psys_interpolate_uvs(tface, face->v4, pc->fuv, r_uv);
uv_values.push_back(Imath::V2f(r_uv[0], r_uv[1]));
- psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, tmpnor, NULL, NULL, NULL, NULL);
+ psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, tmpnor, NULL, NULL, NULL);
/* Convert Z-up to Y-up. */
norm_values.push_back(Imath::V3f(tmpnor[0], tmpnor[2], -tmpnor[1]));
diff --git a/source/blender/alembic/intern/abc_hair.h b/source/blender/alembic/intern/abc_hair.h
index 61f5fe361f8..5627f7726e6 100644
--- a/source/blender/alembic/intern/abc_hair.h
+++ b/source/blender/alembic/intern/abc_hair.h
@@ -40,7 +40,8 @@ class AbcHairWriter : public AbcObjectWriter {
bool m_uv_warning_shown;
public:
- AbcHairWriter(Scene *scene,
+ AbcHairWriter(Depsgraph *depsgraph,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
diff --git a/source/blender/alembic/intern/abc_mball.cc b/source/blender/alembic/intern/abc_mball.cc
index 1ef7b757577..1df55712abe 100644
--- a/source/blender/alembic/intern/abc_mball.cc
+++ b/source/blender/alembic/intern/abc_mball.cc
@@ -30,7 +30,6 @@ extern "C" {
#include "DNA_object_types.h"
#include "BKE_curve.h"
-#include "BKE_depsgraph.h"
#include "BKE_displist.h"
#include "BKE_main.h"
#include "BKE_mball.h"
@@ -43,12 +42,13 @@ extern "C" {
AbcMBallWriter::AbcMBallWriter(
Main *bmain,
+ Depsgraph *depsgraph,
Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
, m_bmain(bmain)
{
m_is_animated = isAnimated();
@@ -58,7 +58,7 @@ AbcMBallWriter::AbcMBallWriter(
sizeof(CurveCache),
"CurveCache for AbcMBallWriter");
- m_mesh_writer = new AbcMeshWriter(scene, m_mesh_ob, parent,
+ m_mesh_writer = new AbcMeshWriter(depsgraph, scene, m_mesh_ob, parent,
time_sampling, settings);
m_mesh_writer->setIsAnimated(m_is_animated);
}
@@ -97,13 +97,11 @@ void AbcMBallWriter::do_write()
id_us_min(&tmpmesh->id);
ListBase disp = {NULL, NULL};
- /* TODO(sergey): This is gonna to work for until EvaluationContext
+ /* TODO(sergey): This is gonna to work for until Depsgraph
* only contains for_render flag. As soon as CoW is
* implemented, this is to be rethinked.
*/
- EvaluationContext eval_ctx;
- DEG_evaluation_context_init(&eval_ctx, DAG_EVAL_RENDER);
- BKE_displist_make_mball_forRender(&eval_ctx, m_scene, m_object, &disp);
+ BKE_displist_make_mball_forRender(m_depsgraph, m_scene, m_object, &disp);
BKE_mesh_from_metaball(&disp, tmpmesh);
BKE_displist_free(&disp);
diff --git a/source/blender/alembic/intern/abc_mball.h b/source/blender/alembic/intern/abc_mball.h
index 9b943698416..19bf7dc054d 100644
--- a/source/blender/alembic/intern/abc_mball.h
+++ b/source/blender/alembic/intern/abc_mball.h
@@ -42,6 +42,7 @@ class AbcMBallWriter : public AbcObjectWriter {
public:
AbcMBallWriter(
Main *bmain,
+ Depsgraph *depsgraph,
Scene *scene,
Object *ob,
AbcTransformWriter *parent,
diff --git a/source/blender/alembic/intern/abc_mesh.cc b/source/blender/alembic/intern/abc_mesh.cc
index 90e95542a9a..52d14f84728 100644
--- a/source/blender/alembic/intern/abc_mesh.cc
+++ b/source/blender/alembic/intern/abc_mesh.cc
@@ -38,7 +38,6 @@ extern "C" {
#include "BLI_string.h"
#include "BKE_cdderivedmesh.h"
-#include "BKE_depsgraph.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
@@ -287,12 +286,13 @@ static ModifierData *get_liquid_sim_modifier(Scene *scene, Object *ob)
/* ************************************************************************** */
-AbcMeshWriter::AbcMeshWriter(Scene *scene,
+AbcMeshWriter::AbcMeshWriter(Depsgraph *depsgraph,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
{
m_is_animated = isAnimated();
m_subsurf_mod = NULL;
@@ -525,7 +525,7 @@ DerivedMesh *AbcMeshWriter::getFinalMesh()
m_subsurf_mod->mode |= eModifierMode_DisableTemporary;
}
- DerivedMesh *dm = mesh_create_derived_render(m_scene, m_object, CD_MASK_MESH);
+ DerivedMesh *dm = mesh_create_derived_render(m_depsgraph, m_scene, m_object, CD_MASK_MESH);
if (m_subsurf_mod) {
m_subsurf_mod->mode &= ~eModifierMode_DisableTemporary;
@@ -923,12 +923,6 @@ static void *add_customdata_cb(void *user_data, const char *name, int data_type)
numloops = dm->getNumLoops(dm);
cd_ptr = CustomData_add_layer_named(loopdata, cd_data_type, CD_DEFAULT,
NULL, numloops, name);
- if (cd_data_type == CD_MLOOPUV) {
- CustomData_add_layer_named(dm->getPolyDataLayout(dm),
- CD_MTEXPOLY, CD_DEFAULT,
- NULL, numloops, name);
- }
-
return cd_ptr;
}
diff --git a/source/blender/alembic/intern/abc_mesh.h b/source/blender/alembic/intern/abc_mesh.h
index 77c352d7cd3..c57123cda4c 100644
--- a/source/blender/alembic/intern/abc_mesh.h
+++ b/source/blender/alembic/intern/abc_mesh.h
@@ -50,7 +50,8 @@ class AbcMeshWriter : public AbcObjectWriter {
bool m_is_subd;
public:
- AbcMeshWriter(Scene *scene,
+ AbcMeshWriter(Depsgraph *depsgraph,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
diff --git a/source/blender/alembic/intern/abc_nurbs.cc b/source/blender/alembic/intern/abc_nurbs.cc
index eaef06fd6d1..1f042d0bafc 100644
--- a/source/blender/alembic/intern/abc_nurbs.cc
+++ b/source/blender/alembic/intern/abc_nurbs.cc
@@ -60,12 +60,13 @@ using Alembic::AbcGeom::ONuPatchSchema;
/* ************************************************************************** */
-AbcNurbsWriter::AbcNurbsWriter(Scene *scene,
+AbcNurbsWriter::AbcNurbsWriter(Depsgraph *depsgraph,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
{
m_is_animated = isAnimated();
diff --git a/source/blender/alembic/intern/abc_nurbs.h b/source/blender/alembic/intern/abc_nurbs.h
index abe460a8988..d2422345c3f 100644
--- a/source/blender/alembic/intern/abc_nurbs.h
+++ b/source/blender/alembic/intern/abc_nurbs.h
@@ -32,7 +32,8 @@ class AbcNurbsWriter : public AbcObjectWriter {
bool m_is_animated;
public:
- AbcNurbsWriter(Scene *scene,
+ AbcNurbsWriter(Depsgraph *depsgraph,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
diff --git a/source/blender/alembic/intern/abc_object.cc b/source/blender/alembic/intern/abc_object.cc
index ddedcf6dcbc..85bda9aa8eb 100644
--- a/source/blender/alembic/intern/abc_object.cc
+++ b/source/blender/alembic/intern/abc_object.cc
@@ -32,7 +32,6 @@ extern "C" {
#include "DNA_space_types.h" /* for FILE_MAX */
#include "BKE_constraint.h"
-#include "BKE_depsgraph.h"
#include "BKE_idprop.h"
#include "BKE_library.h"
#include "BKE_modifier.h"
@@ -59,13 +58,15 @@ using Alembic::AbcGeom::OStringProperty;
/* ************************************************************************** */
-AbcObjectWriter::AbcObjectWriter(Scene *scene,
+AbcObjectWriter::AbcObjectWriter(Depsgraph *depsgraph,
+ Scene *scene,
Object *ob,
uint32_t time_sampling,
ExportSettings &settings,
AbcObjectWriter *parent)
: m_object(ob)
, m_settings(settings)
+ , m_depsgraph(depsgraph)
, m_scene(scene)
, m_time_sampling(time_sampling)
, m_first_frame(true)
diff --git a/source/blender/alembic/intern/abc_object.h b/source/blender/alembic/intern/abc_object.h
index 852ef451f23..d41088bdcad 100644
--- a/source/blender/alembic/intern/abc_object.h
+++ b/source/blender/alembic/intern/abc_object.h
@@ -44,6 +44,7 @@ protected:
Object *m_object;
ExportSettings &m_settings;
+ Depsgraph *m_depsgraph;
Scene *m_scene;
uint32_t m_time_sampling;
@@ -56,7 +57,8 @@ protected:
std::string m_name;
public:
- AbcObjectWriter(Scene *scene,
+ AbcObjectWriter(Depsgraph *depsgraph,
+ Scene *scene,
Object *ob,
uint32_t time_sampling,
ExportSettings &settings,
diff --git a/source/blender/alembic/intern/abc_points.cc b/source/blender/alembic/intern/abc_points.cc
index 80567cd6bf0..6f52ccec4a7 100644
--- a/source/blender/alembic/intern/abc_points.cc
+++ b/source/blender/alembic/intern/abc_points.cc
@@ -58,13 +58,14 @@ using Alembic::AbcGeom::OPointsSchema;
/* ************************************************************************** */
-AbcPointsWriter::AbcPointsWriter(Scene *scene,
+AbcPointsWriter::AbcPointsWriter(Depsgraph *depsgraph,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
ExportSettings &settings,
ParticleSystem *psys)
- : AbcObjectWriter(scene, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(depsgraph, scene, ob, time_sampling, settings, parent)
{
m_psys = psys;
@@ -86,6 +87,7 @@ void AbcPointsWriter::do_write()
ParticleKey state;
ParticleSimulationData sim;
+ sim.depsgraph = m_depsgraph;
sim.scene = m_scene;
sim.ob = m_object;
sim.psys = m_psys;
diff --git a/source/blender/alembic/intern/abc_points.h b/source/blender/alembic/intern/abc_points.h
index 369a802d763..1ac8792ede1 100644
--- a/source/blender/alembic/intern/abc_points.h
+++ b/source/blender/alembic/intern/abc_points.h
@@ -38,7 +38,8 @@ class AbcPointsWriter : public AbcObjectWriter {
ParticleSystem *m_psys;
public:
- AbcPointsWriter(Scene *scene,
+ AbcPointsWriter(Depsgraph *depsgraph,
+ Scene *scene,
Object *ob,
AbcTransformWriter *parent,
uint32_t time_sampling,
diff --git a/source/blender/alembic/intern/abc_transform.cc b/source/blender/alembic/intern/abc_transform.cc
index 5392387663f..e5da367b9a9 100644
--- a/source/blender/alembic/intern/abc_transform.cc
+++ b/source/blender/alembic/intern/abc_transform.cc
@@ -57,12 +57,13 @@ static bool has_parent_camera(Object *ob)
/* ************************************************************************** */
-AbcTransformWriter::AbcTransformWriter(Object *ob,
+AbcTransformWriter::AbcTransformWriter(Depsgraph *depsgraph,
+ Object *ob,
const OObject &abc_parent,
AbcTransformWriter *parent,
unsigned int time_sampling,
ExportSettings &settings)
- : AbcObjectWriter(NULL, ob, time_sampling, settings, parent)
+ : AbcObjectWriter(depsgraph, NULL, ob, time_sampling, settings, parent)
, m_proxy_from(NULL)
{
m_is_animated = hasAnimation(m_object);
diff --git a/source/blender/alembic/intern/abc_transform.h b/source/blender/alembic/intern/abc_transform.h
index 753a4247e9f..91420b28f93 100644
--- a/source/blender/alembic/intern/abc_transform.h
+++ b/source/blender/alembic/intern/abc_transform.h
@@ -37,14 +37,14 @@ class AbcTransformWriter : public AbcObjectWriter {
Alembic::Abc::M44d m_matrix;
bool m_is_animated;
- bool m_visible;
bool m_inherits_xform;
public:
Object *m_proxy_from;
public:
- AbcTransformWriter(Object *ob,
+ AbcTransformWriter(Depsgraph *depsgraph,
+ Object *ob,
const Alembic::AbcGeom::OObject &abc_parent,
AbcTransformWriter *parent,
unsigned int time_sampling,
diff --git a/source/blender/alembic/intern/abc_util.cc b/source/blender/alembic/intern/abc_util.cc
index 24a508e8292..8bdc7ae3455 100644
--- a/source/blender/alembic/intern/abc_util.cc
+++ b/source/blender/alembic/intern/abc_util.cc
@@ -35,6 +35,7 @@
extern "C" {
#include "DNA_object_types.h"
+#include "DNA_layer_types.h"
#include "BLI_math.h"
@@ -60,6 +61,15 @@ std::string get_id_name(const ID * const id)
return name;
}
+/**
+ * @brief get_object_dag_path_name returns the name under which the object
+ * will be exported in the Alembic file. It is of the form
+ * "[../grandparent/]parent/object" if dupli_parent is NULL, or
+ * "dupli_parent/[../grandparent/]parent/object" otherwise.
+ * @param ob
+ * @param dupli_parent
+ * @return
+ */
std::string get_object_dag_path_name(const Object * const ob, Object *dupli_parent)
{
std::string name = get_id_name(ob);
@@ -78,31 +88,9 @@ std::string get_object_dag_path_name(const Object * const ob, Object *dupli_pare
return name;
}
-bool object_selected(Object *ob)
-{
- return ob->flag & SELECT;
-}
-
-bool parent_selected(Object *ob)
+bool object_selected(const Base * const ob_base)
{
- if (object_selected(ob)) {
- return true;
- }
-
- bool do_export = false;
-
- Object *parent = ob->parent;
-
- while (parent != NULL) {
- if (object_selected(parent)) {
- do_export = true;
- break;
- }
-
- parent = parent->parent;
- }
-
- return do_export;
+ return ob_base->flag & SELECT;
}
Imath::M44d convert_matrix(float mat[4][4])
diff --git a/source/blender/alembic/intern/abc_util.h b/source/blender/alembic/intern/abc_util.h
index 2526958111a..fcc3b19c48b 100644
--- a/source/blender/alembic/intern/abc_util.h
+++ b/source/blender/alembic/intern/abc_util.h
@@ -48,13 +48,13 @@ struct ImportSettings;
struct ID;
struct Object;
+struct Base;
std::string get_id_name(const ID * const id);
std::string get_id_name(const Object * const ob);
std::string get_object_dag_path_name(const Object * const ob, Object *dupli_parent);
-bool object_selected(Object *ob);
-bool parent_selected(Object *ob);
+bool object_selected(const Base * const ob_base);
Imath::M44d convert_matrix(float mat[4][4]);
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);