IO: Move Abstract Hierarchy Iterator into `io/common`

The goal of the `AbstractHierarchyIterator` class (and supporting
classes) was to use it in different exporters. It shouldn't be part of
the USD module + namespace any more, now that it will also be used in
the upcoming Alembic exporter rewrite.

The source files are moved into `io/common`, which is compiled & linked
into a new library `bf_io_common`. The unittests are still inside the
`tests/gtests/usd` directory. They should be moved to a separate test
module too, but that will be delayed until after T73268 has been
resolved.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D7669
This commit is contained in:
Sybren A. Stüvel 2020-05-08 16:17:08 +02:00
parent b1ce4ca40c
commit 084c5d6c7e
Notes: blender-bot 2023-02-14 10:21:11 +01:00
Referenced by commit a138bf57c9, Tests: move tests from USD test directory into `io/common` and `io/usd`
11 changed files with 75 additions and 13 deletions

View File

@ -18,6 +18,8 @@
# All rights reserved.
# ***** END GPL LICENSE BLOCK *****
add_subdirectory(common)
if(WITH_ALEMBIC)
add_subdirectory(alembic)
endif()

View File

@ -20,6 +20,7 @@
set(INC
.
../common
../../blenkernel
../../blenlib
../../blenloader
@ -92,6 +93,7 @@ set(SRC
set(LIB
bf_blenkernel
bf_blenlib
bf_io_common
${ALEMBIC_LIBRARIES}
${OPENEXR_LIBRARIES}

View File

@ -0,0 +1,45 @@
# ***** BEGIN GPL LICENSE BLOCK *****
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2020, Blender Foundation
# All rights reserved.
# ***** END GPL LICENSE BLOCK *****
set(INC
.
../../blenkernel
../../blenlib
../../depsgraph
../../makesdna
)
set(INC_SYS
)
set(SRC
intern/abstract_hierarchy_iterator.cc
IO_abstract_hierarchy_iterator.h
)
set(LIB
bf_blenkernel
bf_blenlib
)
blender_add_lib(bf_io_common "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
target_link_libraries(bf_io_common INTERFACE)

View File

@ -48,7 +48,8 @@ struct Object;
struct ParticleSystem;
struct ViewLayer;
namespace USD {
namespace blender {
namespace io {
class AbstractHierarchyWriter;
@ -258,6 +259,7 @@ class AbstractHierarchyIterator {
virtual void delete_object_writer(AbstractHierarchyWriter *writer) = 0;
};
} // namespace USD
} // namespace io
} // namespace blender
#endif /* __ABSTRACT_HIERARCHY_ITERATOR_H__ */

View File

@ -16,7 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
#include "abstract_hierarchy_iterator.h"
#include "IO_abstract_hierarchy_iterator.h"
#include <iostream>
#include <limits.h>
@ -41,7 +41,8 @@
#include "DEG_depsgraph_query.h"
namespace USD {
namespace blender {
namespace io {
const HierarchyContext *HierarchyContext::root()
{
@ -649,4 +650,5 @@ bool AbstractHierarchyIterator::should_visit_dupli_object(const DupliObject *dup
return !dupli_object->no_draw;
}
} // namespace USD
} // namespace io
} // namespace blender

View File

@ -32,6 +32,7 @@ add_definitions(-DPXR_STATIC)
set(INC
.
../common
../../blenkernel
../../blenlib
../../blenloader
@ -52,7 +53,6 @@ set(INC_SYS
)
set(SRC
intern/abstract_hierarchy_iterator.cc
intern/usd_capi.cc
intern/usd_hierarchy_iterator.cc
intern/usd_writer_abstract.cc
@ -64,7 +64,6 @@ set(SRC
intern/usd_writer_transform.cc
usd.h
intern/abstract_hierarchy_iterator.h
intern/usd_exporter_context.h
intern/usd_hierarchy_iterator.h
intern/usd_writer_abstract.h
@ -79,6 +78,7 @@ set(SRC
set(LIB
bf_blenkernel
bf_blenlib
bf_io_common
)
list(APPEND LIB

View File

@ -19,7 +19,7 @@
#ifndef __USD_HIERARCHY_ITERATOR_H__
#define __USD_HIERARCHY_ITERATOR_H__
#include "abstract_hierarchy_iterator.h"
#include "IO_abstract_hierarchy_iterator.h"
#include "usd.h"
#include "usd_exporter_context.h"
@ -34,6 +34,10 @@ struct Object;
namespace USD {
using blender::io::AbstractHierarchyIterator;
using blender::io::AbstractHierarchyWriter;
using blender::io::HierarchyContext;
class USDHierarchyIterator : public AbstractHierarchyIterator {
private:
const pxr::UsdStageRefPtr stage_;

View File

@ -19,7 +19,7 @@
#ifndef __USD_WRITER_ABSTRACT_H__
#define __USD_WRITER_ABSTRACT_H__
#include "abstract_hierarchy_iterator.h"
#include "IO_abstract_hierarchy_iterator.h"
#include "usd_exporter_context.h"
#include <pxr/usd/sdf/path.h>
@ -38,6 +38,9 @@ struct Object;
namespace USD {
using blender::io::AbstractHierarchyWriter;
using blender::io::HierarchyContext;
class USDAbstractWriter : public AbstractHierarchyWriter {
protected:
const USDExporterContext usd_export_context_;

View File

@ -35,6 +35,7 @@ set(INC
..
../../../source/blender/blenlib
../../../source/blender/blenkernel
../../../source/blender/io/common
../../../source/blender/io/usd
../../../source/blender/makesdna
../../../source/blender/depsgraph
@ -52,6 +53,7 @@ set(LIB
bf_gpu
bf_usd
bf_io_common
${BOOST_LIBRARIES}
${TBB_LIBRARIES}

View File

@ -16,8 +16,8 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
#include "IO_abstract_hierarchy_iterator.h"
#include "blenloader/blendfile_loading_base_test.h"
#include "intern/abstract_hierarchy_iterator.h"
extern "C" {
#include "BLI_math.h"
@ -32,7 +32,7 @@ extern "C" {
* multiple times with different export paths, hence the set. */
typedef std::map<std::string, std::set<std::string>> created_writers;
using namespace USD;
using namespace blender::io;
class TestHierarchyWriter : public AbstractHierarchyWriter {
public:

View File

@ -16,7 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
#include "intern/abstract_hierarchy_iterator.h"
#include "IO_abstract_hierarchy_iterator.h"
#include "testing/testing.h"
@ -24,7 +24,7 @@ extern "C" {
#include "BLI_utildefines.h"
}
using namespace USD;
using namespace blender::io;
class HierarchyContextOrderTest : public testing::Test {
};