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:
authorSybren A. Stüvel <sybren@blender.org>2020-08-17 17:58:09 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-08-17 18:56:05 +0300
commita95f8635967360e07ecb556e2b82099880ec1e63 (patch)
treebd978790bcb23007fbc52c0e80205a6c82fcc0df /source/blender/io
parentfd3086833afea8b414506de6bb9ab6a5beaa7faa (diff)
Fix T75936: Alembic, allow exporting of invisible objects
Add a new depsgraph builder class that includes invisible objects and use that in the Alembic exporter. Alembic supports three options for visibility, "visible", "inherited", and "hidden". This means that parents can be hidden and still have visible children (contrary to USD, where invisibility is used to prune an entire scene graph subtree). Because of this, the visibility is stored on the transform node, as that represents the Object in Blender and thus keeps the Alembic file as close to Blender's own structure as possible. Reviewed By: Sergey Differential Revision: https://developer.blender.org/D8595
Diffstat (limited to 'source/blender/io')
-rw-r--r--source/blender/io/alembic/exporter/abc_export_capi.cc12
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_abstract.cc16
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_abstract.h5
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_mesh.cc5
-rw-r--r--source/blender/io/alembic/exporter/abc_writer_transform.cc2
-rw-r--r--source/blender/io/common/intern/abstract_hierarchy_iterator.cc4
6 files changed, 38 insertions, 6 deletions
diff --git a/source/blender/io/alembic/exporter/abc_export_capi.cc b/source/blender/io/alembic/exporter/abc_export_capi.cc
index 8c5f3d89870..c4966a965eb 100644
--- a/source/blender/io/alembic/exporter/abc_export_capi.cc
+++ b/source/blender/io/alembic/exporter/abc_export_capi.cc
@@ -67,11 +67,17 @@ namespace io {
namespace alembic {
// Construct the depsgraph for exporting.
-static void build_depsgraph(Depsgraph *depsgraph, Main *bmain)
+static void build_depsgraph(Depsgraph *depsgraph, Main *bmain, const bool visible_objects_only)
{
Scene *scene = DEG_get_input_scene(depsgraph);
ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
- DEG_graph_build_from_view_layer(depsgraph, bmain, scene, view_layer);
+
+ if (visible_objects_only) {
+ DEG_graph_build_from_view_layer(depsgraph, bmain, scene, view_layer);
+ }
+ else {
+ DEG_graph_build_for_all_objects(depsgraph, bmain, scene, view_layer);
+ }
}
static void export_startjob(void *customdata,
@@ -91,7 +97,7 @@ static void export_startjob(void *customdata,
*progress = 0.0f;
*do_update = true;
- build_depsgraph(data->depsgraph, data->bmain);
+ build_depsgraph(data->depsgraph, data->bmain, data->params.visible_objects_only);
SubdivModifierDisabler subdiv_disabler(data->depsgraph);
if (!data->params.apply_subdiv) {
subdiv_disabler.disable_modifiers();
diff --git a/source/blender/io/alembic/exporter/abc_writer_abstract.cc b/source/blender/io/alembic/exporter/abc_writer_abstract.cc
index e43b394e27f..84527a12e85 100644
--- a/source/blender/io/alembic/exporter/abc_writer_abstract.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_abstract.cc
@@ -25,6 +25,10 @@
#include "DNA_modifier_types.h"
+#include "DEG_depsgraph.h"
+
+#include <Alembic/AbcGeom/Visibility.h>
+
#include "CLG_log.h"
static CLG_LogRef LOG = {"io.alembic"};
@@ -96,6 +100,18 @@ void ABCAbstractWriter::update_bounding_box(Object *object)
bounding_box_.max.z = -bb->vec[0][1];
}
+void ABCAbstractWriter::write_visibility(const HierarchyContext &context)
+{
+ const bool is_visible = context.is_object_visible(DAG_EVAL_RENDER);
+ Alembic::Abc::OObject abc_object = get_alembic_object();
+
+ if (!abc_visibility_.valid()) {
+ abc_visibility_ = Alembic::AbcGeom::CreateVisibilityProperty(abc_object, timesample_index_);
+ }
+ abc_visibility_.set(is_visible ? Alembic::AbcGeom::kVisibilityVisible :
+ Alembic::AbcGeom::kVisibilityHidden);
+}
+
} // namespace alembic
} // namespace io
} // namespace blender
diff --git a/source/blender/io/alembic/exporter/abc_writer_abstract.h b/source/blender/io/alembic/exporter/abc_writer_abstract.h
index a83373a567a..f46409b7902 100644
--- a/source/blender/io/alembic/exporter/abc_writer_abstract.h
+++ b/source/blender/io/alembic/exporter/abc_writer_abstract.h
@@ -43,6 +43,9 @@ class ABCAbstractWriter : public AbstractHierarchyWriter {
uint32_t timesample_index_;
Imath::Box3d bounding_box_;
+ /* Visibility of this writer's data in Alembic. */
+ Alembic::Abc::OCharProperty abc_visibility_;
+
public:
explicit ABCAbstractWriter(const ABCWriterConstructorArgs &args);
virtual ~ABCAbstractWriter();
@@ -70,6 +73,8 @@ class ABCAbstractWriter : public AbstractHierarchyWriter {
virtual void do_write(HierarchyContext &context) = 0;
virtual void update_bounding_box(Object *object);
+
+ void write_visibility(const HierarchyContext &context);
};
} // namespace alembic
diff --git a/source/blender/io/alembic/exporter/abc_writer_mesh.cc b/source/blender/io/alembic/exporter/abc_writer_mesh.cc
index 5c005164bcc..517f0212712 100644
--- a/source/blender/io/alembic/exporter/abc_writer_mesh.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_mesh.cc
@@ -159,7 +159,10 @@ ModifierData *ABCGenericMeshWriter::get_liquid_sim_modifier(Scene *scene, Object
bool ABCGenericMeshWriter::is_supported(const HierarchyContext *context) const
{
- return context->is_object_visible(DAG_EVAL_RENDER);
+ if (args_.export_params->visible_objects_only) {
+ return context->is_object_visible(DAG_EVAL_RENDER);
+ }
+ return true;
}
void ABCGenericMeshWriter::do_write(HierarchyContext &context)
diff --git a/source/blender/io/alembic/exporter/abc_writer_transform.cc b/source/blender/io/alembic/exporter/abc_writer_transform.cc
index 39af99c142c..7694066a13d 100644
--- a/source/blender/io/alembic/exporter/abc_writer_transform.cc
+++ b/source/blender/io/alembic/exporter/abc_writer_transform.cc
@@ -92,6 +92,8 @@ void ABCTransformWriter::do_write(HierarchyContext &context)
xform_sample.setMatrix(convert_matrix_datatype(parent_relative_matrix));
xform_sample.setInheritsXforms(true);
abc_xform_schema_.set(xform_sample);
+
+ write_visibility(context);
}
const OObject ABCTransformWriter::get_alembic_object() const
diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc
index 93e7e677118..d825625cafc 100644
--- a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc
@@ -80,7 +80,7 @@ void HierarchyContext::mark_as_not_instanced()
bool HierarchyContext::is_object_visible(const enum eEvaluationMode evaluation_mode) const
{
- bool is_dupli = duplicator != nullptr;
+ const bool is_dupli = duplicator != nullptr;
int base_flag;
if (is_dupli) {
@@ -92,7 +92,7 @@ bool HierarchyContext::is_object_visible(const enum eEvaluationMode evaluation_m
object->base_flag = duplicator->base_flag | BASE_FROM_DUPLI;
}
- int visibility = BKE_object_visibility(object, evaluation_mode);
+ const int visibility = BKE_object_visibility(object, evaluation_mode);
if (is_dupli) {
object->base_flag = base_flag;