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:55:31 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-08-17 18:56:05 +0300
commit271361e31f9e4bdd222b78833a42a5b268da3e89 (patch)
treed53bdeb9072706e20e1c6bd74a08c788726626ee /source/blender/io/common
parenta95f8635967360e07ecb556e2b82099880ec1e63 (diff)
IO: Add test for iterating over invisible objects
Add a test that checks invisible objects are iterated over by the `IO::AbstractHierarchyIterator` class, when a suitable depsgraph is given. No functional changes.
Diffstat (limited to 'source/blender/io/common')
-rw-r--r--source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc50
1 files changed, 47 insertions, 3 deletions
diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc
index cbb2e63a99f..57bc68d25bf 100644
--- a/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc
+++ b/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc
@@ -20,8 +20,11 @@
#include "tests/blendfile_loading_base_test.h"
+#include "BKE_scene.h"
#include "BLI_math.h"
+#include "BLO_readfile.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
#include "DNA_object_types.h"
#include <map>
@@ -99,7 +102,7 @@ class TestingHierarchyIterator : public AbstractHierarchyIterator {
}
};
-class USDHierarchyIteratorTest : public BlendfileLoadingBaseTest {
+class AbstractHierarchyIteratorTest : public BlendfileLoadingBaseTest {
protected:
TestingHierarchyIterator *iterator;
@@ -131,7 +134,7 @@ class USDHierarchyIteratorTest : public BlendfileLoadingBaseTest {
}
};
-TEST_F(USDHierarchyIteratorTest, ExportHierarchyTest)
+TEST_F(AbstractHierarchyIteratorTest, ExportHierarchyTest)
{
/* Load the test blend file. */
if (!blendfile_load("usd/usd_hierarchy_export_test.blend")) {
@@ -206,7 +209,7 @@ TEST_F(USDHierarchyIteratorTest, ExportHierarchyTest)
EXPECT_EQ(expected_data, iterator->data_writers);
}
-TEST_F(USDHierarchyIteratorTest, ExportSubsetTest)
+TEST_F(AbstractHierarchyIteratorTest, ExportSubsetTest)
{
// The scene has no hair or particle systems, and this is already covered by ExportHierarchyTest,
// so not included here. Update this test when hair & particle systems are included.
@@ -317,4 +320,45 @@ TEST_F(USDHierarchyIteratorTest, ExportSubsetTest)
EXPECT_EQ(expected_transforms, iterator->transform_writers);
EXPECT_EQ(expected_data, iterator->data_writers);
}
+
+/* Test class that constructs a depsgraph in such a way that it includes invisible objects. */
+class AbstractHierarchyIteratorInvisibleTest : public AbstractHierarchyIteratorTest {
+ protected:
+ void depsgraph_create(eEvaluationMode depsgraph_evaluation_mode) override
+ {
+ depsgraph = DEG_graph_new(
+ bfile->main, bfile->curscene, bfile->cur_view_layer, depsgraph_evaluation_mode);
+ DEG_graph_build_for_all_objects(
+ depsgraph, bfile->main, bfile->curscene, bfile->cur_view_layer);
+ BKE_scene_graph_update_tagged(depsgraph, bfile->main);
+ }
+};
+
+TEST_F(AbstractHierarchyIteratorInvisibleTest, ExportInvisibleTest)
+{
+ if (!blendfile_load("alembic/visibility.blend")) {
+ return;
+ }
+ depsgraph_create(DAG_EVAL_RENDER);
+ iterator_create();
+
+ iterator->iterate_and_write();
+
+ // Mapping from object name to set of export paths.
+ used_writers expected_transforms = {{"OBInvisibleAnimatedCube", {"/InvisibleAnimatedCube"}},
+ {"OBInvisibleCube", {"/InvisibleCube"}},
+ {"OBVisibleCube", {"/VisibleCube"}}};
+ EXPECT_EQ(expected_transforms, iterator->transform_writers);
+
+ used_writers expected_data = {{"OBInvisibleAnimatedCube", {"/InvisibleAnimatedCube/Cube"}},
+ {"OBInvisibleCube", {"/InvisibleCube/Cube"}},
+ {"OBVisibleCube", {"/VisibleCube/Cube"}}};
+
+ EXPECT_EQ(expected_data, iterator->data_writers);
+
+ // The scene has no hair or particle systems.
+ EXPECT_EQ(0, iterator->hair_writers.size());
+ EXPECT_EQ(0, iterator->particle_writers.size());
+}
+
} // namespace blender::io