[Bf-blender-cvs] [db2168dcd1c] usd-importer-T81257-merge: USD Import: remove usd_util files.
makowalski
noreply at git.blender.org
Fri Mar 12 03:01:42 CET 2021
Commit: db2168dcd1c066cec8e73a50204a19f95b434e0d
Author: makowalski
Date: Thu Mar 11 20:54:36 2021 -0500
Branches: usd-importer-T81257-merge
https://developer.blender.org/rBdb2168dcd1c066cec8e73a50204a19f95b434e0d
USD Import: remove usd_util files.
Moved the two create_reader() implementations from usd_util.(h|cc)
to static functions in UsdStageReader and removed the usd_util
files from the project.
===================================================================
M source/blender/io/usd/CMakeLists.txt
M source/blender/io/usd/intern/usd_capi.cc
M source/blender/io/usd/intern/usd_reader_light.cc
M source/blender/io/usd/intern/usd_reader_stage.cc
M source/blender/io/usd/intern/usd_reader_stage.h
D source/blender/io/usd/intern/usd_util.cc
D source/blender/io/usd/intern/usd_util.h
===================================================================
diff --git a/source/blender/io/usd/CMakeLists.txt b/source/blender/io/usd/CMakeLists.txt
index 94565b5e52f..73c5279cd0f 100644
--- a/source/blender/io/usd/CMakeLists.txt
+++ b/source/blender/io/usd/CMakeLists.txt
@@ -63,8 +63,6 @@ set(SRC
intern/usd_writer_metaball.cc
intern/usd_writer_transform.cc
- intern/usd_util.cc
-
intern/usd_reader_camera.cc
intern/usd_reader_curve.cc
intern/usd_reader_geom.cc
@@ -89,8 +87,6 @@ set(SRC
intern/usd_writer_metaball.h
intern/usd_writer_transform.h
- intern/usd_util.h
-
intern/usd_reader_camera.h
intern/usd_reader_curve.h
intern/usd_reader_geom.h
diff --git a/source/blender/io/usd/intern/usd_capi.cc b/source/blender/io/usd/intern/usd_capi.cc
index 25ecbff01b4..3742d96ed90 100644
--- a/source/blender/io/usd/intern/usd_capi.cc
+++ b/source/blender/io/usd/intern/usd_capi.cc
@@ -74,7 +74,6 @@
#include "usd_reader_geom.h"
#include "usd_reader_prim.h"
-#include "usd_util.h"
#include <iostream>
@@ -889,7 +888,7 @@ CacheReader *CacheReader_open_usd_object(USDStageHandle *handle,
}
// TODO: The handle does not have the proper import params or settings
- USDPrimReader *usd_reader = create_reader(archive, prim);
+ USDPrimReader *usd_reader = USDStageReader::create_reader(archive, prim);
if (usd_reader == NULL) {
/* This object is not supported */
diff --git a/source/blender/io/usd/intern/usd_reader_light.cc b/source/blender/io/usd/intern/usd_reader_light.cc
index 0112ac53425..65a7d33b2e9 100644
--- a/source/blender/io/usd/intern/usd_reader_light.cc
+++ b/source/blender/io/usd/intern/usd_reader_light.cc
@@ -16,7 +16,6 @@
#include "usd_reader_light.h"
#include "usd_reader_prim.h"
-#include "usd_util.h"
extern "C" {
#include "DNA_cachefile_types.h"
diff --git a/source/blender/io/usd/intern/usd_reader_stage.cc b/source/blender/io/usd/intern/usd_reader_stage.cc
index cc52847592f..13492f94c19 100644
--- a/source/blender/io/usd/intern/usd_reader_stage.cc
+++ b/source/blender/io/usd/intern/usd_reader_stage.cc
@@ -20,11 +20,21 @@
#include "usd_reader_stage.h"
#include "usd_reader_camera.h"
#include "usd_reader_curve.h"
+#include "usd_reader_instance.h"
+#include "usd_reader_light.h"
#include "usd_reader_mesh.h"
+#include "usd_reader_nurbs.h"
#include "usd_reader_prim.h"
+#include "usd_reader_volume.h"
#include "usd_reader_xform.h"
-#include "usd_util.h"
+#include <pxr/pxr.h>
+#include <pxr/usd/usdGeom/camera.h>
+#include <pxr/usd/usdGeom/curves.h>
+#include <pxr/usd/usdGeom/mesh.h>
+#include <pxr/usd/usdGeom/nurbsCurves.h>
+#include <pxr/usd/usdGeom/scope.h>
+#include <pxr/usd/usdLux/light.h>
extern "C" {
#include "DEG_depsgraph.h"
@@ -73,6 +83,70 @@ bool USDStageReader::valid() const
return stage_;
}
+USDPrimReader *USDStageReader::create_reader(const pxr::UsdPrim &prim,
+ const USDImportParams ¶ms,
+ ImportSettings &settings)
+{
+ USDPrimReader *reader = nullptr;
+
+ if (params.use_instancing && prim.IsInstance()) {
+ reader = new USDInstanceReader(prim, params, settings);
+ }
+ else if (params.import_cameras && prim.IsA<pxr::UsdGeomCamera>()) {
+ reader = new USDCameraReader(prim, params, settings);
+ }
+ else if (params.import_curves && prim.IsA<pxr::UsdGeomBasisCurves>()) {
+ reader = new USDCurvesReader(prim, params, settings);
+ }
+ else if (params.import_curves && prim.IsA<pxr::UsdGeomNurbsCurves>()) {
+ reader = new USDNurbsReader(prim, params, settings);
+ }
+ else if (params.import_meshes && prim.IsA<pxr::UsdGeomMesh>()) {
+ reader = new USDMeshReader(prim, params, settings);
+ }
+ else if (params.import_lights && prim.IsA<pxr::UsdLuxLight>()) {
+ reader = new USDLightReader(prim, params, settings);
+ }
+ else if (params.import_volumes && prim.IsA<pxr::UsdVolVolume>()) {
+ reader = new USDVolumeReader(prim, params, settings);
+ }
+ else if (prim.IsA<pxr::UsdGeomImageable>()) {
+ reader = new USDXformReader(prim, params, settings);
+ }
+
+ return reader;
+}
+
+// TODO(makowalski): The handle does not have the proper import params or settings
+USDPrimReader *USDStageReader::create_reader(class USDStageReader *archive,
+ const pxr::UsdPrim &prim)
+{
+ USDPrimReader *reader = nullptr;
+
+ if (prim.IsA<pxr::UsdGeomCamera>()) {
+ reader = new USDCameraReader(prim, archive->params(), archive->settings());
+ }
+ else if (prim.IsA<pxr::UsdGeomBasisCurves>()) {
+ reader = new USDCurvesReader(prim, archive->params(), archive->settings());
+ }
+ else if (prim.IsA<pxr::UsdGeomNurbsCurves>()) {
+ reader = new USDNurbsReader(prim, archive->params(), archive->settings());
+ }
+ else if (prim.IsA<pxr::UsdGeomMesh>()) {
+ reader = new USDMeshReader(prim, archive->params(), archive->settings());
+ }
+ else if (prim.IsA<pxr::UsdLuxLight>()) {
+ reader = new USDLightReader(prim, archive->params(), archive->settings());
+ }
+ else if (prim.IsA<pxr::UsdVolVolume>()) {
+ reader = new USDVolumeReader(prim, archive->params(), archive->settings());
+ }
+ else if (prim.IsA<pxr::UsdGeomImageable>()) {
+ reader = new USDXformReader(prim, archive->params(), archive->settings());
+ }
+ return reader;
+}
+
/* Returns true if the given prim should be excluded from the
* traversal because it's invisible. */
bool _prune_by_visibility(const pxr::UsdGeomImageable &imageable, const USDImportParams ¶ms)
@@ -140,7 +214,7 @@ static USDPrimReader *_handlePrim(Main *bmain,
// or the root prims of scenegraph 'master' prototypes
// from being added.
if (!(prim.IsPseudoRoot() || prim.IsMaster())) {
- reader = blender::io::usd::create_reader(prim, params, settings);
+ reader = USDStageReader::create_reader(prim, params, settings);
if (reader == NULL)
return NULL;
diff --git a/source/blender/io/usd/intern/usd_reader_stage.h b/source/blender/io/usd/intern/usd_reader_stage.h
index 88a6c8c5723..5c7c5bf91d4 100644
--- a/source/blender/io/usd/intern/usd_reader_stage.h
+++ b/source/blender/io/usd/intern/usd_reader_stage.h
@@ -57,6 +57,15 @@ class USDStageReader {
USDStageReader(struct Main *bmain, const char *filename);
~USDStageReader();
+ static USDPrimReader *create_reader(const pxr::UsdPrim &prim,
+ const USDImportParams ¶ms,
+ ImportSettings &settings);
+
+ // This version of create_reader() does not filter by primitive type. I.e.,
+ // it will convert any prim to a reader, if possible, regardless of the
+ // primitive types specified by the user in the import options.
+ static USDPrimReader *create_reader(class USDStageReader *archive, const pxr::UsdPrim &prim);
+
std::vector<USDPrimReader *> collect_readers(struct Main *bmain,
const USDImportParams ¶ms,
ImportSettings &settings);
diff --git a/source/blender/io/usd/intern/usd_util.cc b/source/blender/io/usd/intern/usd_util.cc
deleted file mode 100644
index 1562c324b10..00000000000
--- a/source/blender/io/usd/intern/usd_util.cc
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * 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) 2019 Blender Foundation.
- * All rights reserved.
- */
-#include "usd_util.h"
-#include "usd_hierarchy_iterator.h"
-
-#include "usd_reader_camera.h"
-#include "usd_reader_curve.h"
-#include "usd_reader_geom.h"
-#include "usd_reader_instance.h"
-#include "usd_reader_light.h"
-#include "usd_reader_mesh.h"
-#include "usd_reader_nurbs.h"
-#include "usd_reader_prim.h"
-#include "usd_reader_stage.h"
-#include "usd_reader_volume.h"
-#include "usd_reader_xform.h"
-
-extern "C" {
-#include "BKE_animsys.h"
-#include "BKE_colorband.h"
-#include "BKE_colortools.h"
-#include "BKE_key.h"
-#include "BKE_node.h"
-
-#include "DNA_color_types.h"
-#include "DNA_light_types.h"
-#include "DNA_modifier_types.h"
-#include "DNA_node_types.h"
-
-#include "WM_api.h"
-#include "WM_types.h"
-
-#include "BKE_blender_version.h"
-#include "BKE_cachefile.h"
-#include "BKE_cdderivedmesh.h"
-#include "BKE_context.h"
-#include "BKE_curve.h"
-#include "BKE_global.h"
-#include "BKE_image.h"
-#include "BKE_layer.h"
-#include "BKE_light.h"
-#include "BKE_main.h"
-#include "BKE_node.h"
-#include "BKE_scene.h"
-#include "BKE_world.h"
-
-#include "BLI_fileops.h"
-#include "BLI_linklist.h"
-#include "BLI_listbase.h"
-#include "BLI_math.h"
-#include "BLI_path_util.h"
-#include "BLI_string.h"
-#include "BLI_threads.h"
-#include "BLI_utildefines.h"
-}
-#include "MEM_guardedalloc.h"
-
-#include <algorithm>
-#include <cctype>
-#include <string>
-#include <utility>
-
-#include <pxr/base/tf/stringUtils.h>
-#include <pxr/pxr.h>
-#include <pxr/usd/usdGeom/camera.h>
-#include <pxr/usd/usdGeom/curves.h>
-#include <pxr/usd/usdGeom/mesh.h>
-#include <pxr/usd/usdGeom/nurbsCurves.h>
-#include <pxr/usd/usdGeom/scope.h>
-#include <pxr/usd/usdLux/light.h>
-
-namespace blender::io::usd {
-
-USDPrimReader *create_reader(const pxr::UsdPrim &prim,
- const USDImportParams ¶ms,
- ImportSettings &settings)
-{
- USDPrimReader *reader = nullptr;
-
- if (params.use_instancing && prim.IsInstance()) {
- reader = new USDInstanceReader(prim, params, settings);
- }
- else if (params.import_cameras && prim.IsA<pxr::UsdGeomCamera>()) {
- reader = new USDCameraReader(prim, param
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list