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/io/usd')
-rw-r--r--source/blender/io/usd/CMakeLists.txt12
-rw-r--r--source/blender/io/usd/intern/usd_capi.cc7
-rw-r--r--source/blender/io/usd/intern/usd_exporter_context.h5
-rw-r--r--source/blender/io/usd/intern/usd_hierarchy_iterator.cc8
-rw-r--r--source/blender/io/usd/intern/usd_hierarchy_iterator.h7
-rw-r--r--source/blender/io/usd/intern/usd_writer_abstract.h5
-rw-r--r--source/blender/io/usd/intern/usd_writer_camera.h5
-rw-r--r--source/blender/io/usd/intern/usd_writer_hair.cc2
-rw-r--r--source/blender/io/usd/intern/usd_writer_hair.h5
-rw-r--r--source/blender/io/usd/intern/usd_writer_light.h5
-rw-r--r--source/blender/io/usd/intern/usd_writer_mesh.cc2
-rw-r--r--source/blender/io/usd/intern/usd_writer_mesh.h5
-rw-r--r--source/blender/io/usd/intern/usd_writer_metaball.h5
-rw-r--r--source/blender/io/usd/intern/usd_writer_transform.cc3
-rw-r--r--source/blender/io/usd/intern/usd_writer_transform.h5
-rw-r--r--source/blender/io/usd/tests/usd_stage_creation_test.cc70
-rw-r--r--source/blender/io/usd/usd.h5
17 files changed, 109 insertions, 47 deletions
diff --git a/source/blender/io/usd/CMakeLists.txt b/source/blender/io/usd/CMakeLists.txt
index 19e16a5b328..79b15c60b94 100644
--- a/source/blender/io/usd/CMakeLists.txt
+++ b/source/blender/io/usd/CMakeLists.txt
@@ -109,3 +109,15 @@ else()
endif()
target_link_libraries(bf_usd INTERFACE ${TBB_LIBRARIES})
+
+if(WITH_GTESTS)
+ set(TEST_SRC
+ tests/usd_stage_creation_test.cc
+ )
+ set(TEST_INC
+ )
+ set(TEST_LIB
+ )
+ include(GTestTesting)
+ blender_add_test_lib(bf_io_usd_tests "${TEST_SRC}" "${INC};${TEST_INC}" "${INC_SYS}" "${LIB};${TEST_LIB}")
+endif()
diff --git a/source/blender/io/usd/intern/usd_capi.cc b/source/blender/io/usd/intern/usd_capi.cc
index 2d3972410a4..98aef62f38e 100644
--- a/source/blender/io/usd/intern/usd_capi.cc
+++ b/source/blender/io/usd/intern/usd_capi.cc
@@ -59,7 +59,12 @@ struct ExportJobData {
bool export_ok;
};
-static void export_startjob(void *customdata, short *stop, short *do_update, float *progress)
+static void export_startjob(void *customdata,
+ /* Cannot be const, this function implements wm_jobs_start_callback.
+ * NOLINTNEXTLINE: readability-non-const-parameter. */
+ short *stop,
+ short *do_update,
+ float *progress)
{
ExportJobData *data = static_cast<ExportJobData *>(customdata);
data->export_ok = false;
diff --git a/source/blender/io/usd/intern/usd_exporter_context.h b/source/blender/io/usd/intern/usd_exporter_context.h
index 07a9d0fc0c5..5513768b527 100644
--- a/source/blender/io/usd/intern/usd_exporter_context.h
+++ b/source/blender/io/usd/intern/usd_exporter_context.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_EXPORTER_CONTEXT_H__
-#define __USD_EXPORTER_CONTEXT_H__
+#pragma once
#include "usd.h"
@@ -44,5 +43,3 @@ struct USDExporterContext {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_EXPORTER_CONTEXT_H__ */
diff --git a/source/blender/io/usd/intern/usd_hierarchy_iterator.cc b/source/blender/io/usd/intern/usd_hierarchy_iterator.cc
index 388b588b331..39fbef70e81 100644
--- a/source/blender/io/usd/intern/usd_hierarchy_iterator.cc
+++ b/source/blender/io/usd/intern/usd_hierarchy_iterator.cc
@@ -34,6 +34,7 @@
#include "BKE_duplilist.h"
#include "BLI_assert.h"
+#include "BLI_utildefines.h"
#include "DEG_depsgraph_query.h"
@@ -60,7 +61,7 @@ bool USDHierarchyIterator::mark_as_weak_export(const Object *object) const
return false;
}
-void USDHierarchyIterator::delete_object_writer(AbstractHierarchyWriter *writer)
+void USDHierarchyIterator::release_writer(AbstractHierarchyWriter *writer)
{
delete static_cast<USDAbstractWriter *>(writer);
}
@@ -72,7 +73,7 @@ std::string USDHierarchyIterator::make_valid_name(const std::string &name) const
void USDHierarchyIterator::set_export_frame(float frame_nr)
{
- // The USD stage is already set up to have FPS timecodes per frame.
+ /* The USD stage is already set up to have FPS time-codes per frame. */
export_time_ = pxr::UsdTimeCode(frame_nr);
}
@@ -142,7 +143,8 @@ AbstractHierarchyWriter *USDHierarchyIterator::create_hair_writer(const Hierarch
return new USDHairWriter(create_usd_export_context(context));
}
-AbstractHierarchyWriter *USDHierarchyIterator::create_particle_writer(const HierarchyContext *)
+AbstractHierarchyWriter *USDHierarchyIterator::create_particle_writer(
+ const HierarchyContext *UNUSED(context))
{
return nullptr;
}
diff --git a/source/blender/io/usd/intern/usd_hierarchy_iterator.h b/source/blender/io/usd/intern/usd_hierarchy_iterator.h
index 7d750bff0cb..03e80ce735a 100644
--- a/source/blender/io/usd/intern/usd_hierarchy_iterator.h
+++ b/source/blender/io/usd/intern/usd_hierarchy_iterator.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_HIERARCHY_ITERATOR_H__
-#define __USD_HIERARCHY_ITERATOR_H__
+#pragma once
#include "IO_abstract_hierarchy_iterator.h"
#include "usd.h"
@@ -66,7 +65,7 @@ class USDHierarchyIterator : public AbstractHierarchyIterator {
virtual AbstractHierarchyWriter *create_particle_writer(
const HierarchyContext *context) override;
- virtual void delete_object_writer(AbstractHierarchyWriter *writer) override;
+ virtual void release_writer(AbstractHierarchyWriter *writer) override;
private:
USDExporterContext create_usd_export_context(const HierarchyContext *context);
@@ -75,5 +74,3 @@ class USDHierarchyIterator : public AbstractHierarchyIterator {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_HIERARCHY_ITERATOR_H__ */
diff --git a/source/blender/io/usd/intern/usd_writer_abstract.h b/source/blender/io/usd/intern/usd_writer_abstract.h
index f81cf5197af..a689deaf0d8 100644
--- a/source/blender/io/usd/intern/usd_writer_abstract.h
+++ b/source/blender/io/usd/intern/usd_writer_abstract.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_WRITER_ABSTRACT_H__
-#define __USD_WRITER_ABSTRACT_H__
+#pragma once
#include "IO_abstract_hierarchy_iterator.h"
#include "usd_exporter_context.h"
@@ -78,5 +77,3 @@ class USDAbstractWriter : public AbstractHierarchyWriter {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_WRITER_ABSTRACT_H__ */
diff --git a/source/blender/io/usd/intern/usd_writer_camera.h b/source/blender/io/usd/intern/usd_writer_camera.h
index 8b5795d7d9f..1c613d7879b 100644
--- a/source/blender/io/usd/intern/usd_writer_camera.h
+++ b/source/blender/io/usd/intern/usd_writer_camera.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_WRITER_CAMERA_H__
-#define __USD_WRITER_CAMERA_H__
+#pragma once
#include "usd_writer_abstract.h"
@@ -38,5 +37,3 @@ class USDCameraWriter : public USDAbstractWriter {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_WRITER_CAMERA_H__ */
diff --git a/source/blender/io/usd/intern/usd_writer_hair.cc b/source/blender/io/usd/intern/usd_writer_hair.cc
index 0e0256bdb69..0fd5c4ce727 100644
--- a/source/blender/io/usd/intern/usd_writer_hair.cc
+++ b/source/blender/io/usd/intern/usd_writer_hair.cc
@@ -82,7 +82,7 @@ void USDHairWriter::do_write(HierarchyContext &context)
}
}
-bool USDHairWriter::check_is_animated(const HierarchyContext &) const
+bool USDHairWriter::check_is_animated(const HierarchyContext &UNUSED(context)) const
{
return true;
}
diff --git a/source/blender/io/usd/intern/usd_writer_hair.h b/source/blender/io/usd/intern/usd_writer_hair.h
index cecacd0a355..b9a28013875 100644
--- a/source/blender/io/usd/intern/usd_writer_hair.h
+++ b/source/blender/io/usd/intern/usd_writer_hair.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_WRITER_HAIR_H__
-#define __USD_WRITER_HAIR_H__
+#pragma once
#include "usd_writer_abstract.h"
@@ -38,5 +37,3 @@ class USDHairWriter : public USDAbstractWriter {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_WRITER_HAIR_H__ */
diff --git a/source/blender/io/usd/intern/usd_writer_light.h b/source/blender/io/usd/intern/usd_writer_light.h
index 73666622af1..082050ad071 100644
--- a/source/blender/io/usd/intern/usd_writer_light.h
+++ b/source/blender/io/usd/intern/usd_writer_light.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_WRITER_LIGHT_H__
-#define __USD_WRITER_LIGHT_H__
+#pragma once
#include "usd_writer_abstract.h"
@@ -37,5 +36,3 @@ class USDLightWriter : public USDAbstractWriter {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_WRITER_LIGHT_H__ */
diff --git a/source/blender/io/usd/intern/usd_writer_mesh.cc b/source/blender/io/usd/intern/usd_writer_mesh.cc
index 29a9734f876..bd2c549e729 100644
--- a/source/blender/io/usd/intern/usd_writer_mesh.cc
+++ b/source/blender/io/usd/intern/usd_writer_mesh.cc
@@ -338,7 +338,7 @@ void USDGenericMeshWriter::assign_materials(const HierarchyContext &context,
* https://github.com/PixarAnimationStudios/USD/issues/542 for more info. */
bool mesh_material_bound = false;
pxr::UsdShadeMaterialBindingAPI material_binding_api(usd_mesh.GetPrim());
- for (short mat_num = 0; mat_num < context.object->totcol; mat_num++) {
+ for (int mat_num = 0; mat_num < context.object->totcol; mat_num++) {
Material *material = BKE_object_material_get(context.object, mat_num + 1);
if (material == nullptr) {
continue;
diff --git a/source/blender/io/usd/intern/usd_writer_mesh.h b/source/blender/io/usd/intern/usd_writer_mesh.h
index a14ceecfa53..078daa05501 100644
--- a/source/blender/io/usd/intern/usd_writer_mesh.h
+++ b/source/blender/io/usd/intern/usd_writer_mesh.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_WRITER_MESH_H__
-#define __USD_WRITER_MESH_H__
+#pragma once
#include "usd_writer_abstract.h"
@@ -66,5 +65,3 @@ class USDMeshWriter : public USDGenericMeshWriter {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_WRITER_MESH_H__ */
diff --git a/source/blender/io/usd/intern/usd_writer_metaball.h b/source/blender/io/usd/intern/usd_writer_metaball.h
index 9f51a3314a5..216f5a2638f 100644
--- a/source/blender/io/usd/intern/usd_writer_metaball.h
+++ b/source/blender/io/usd/intern/usd_writer_metaball.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2020 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_WRITER_METABALL_H__
-#define __USD_WRITER_METABALL_H__
+#pragma once
#include "usd_writer_mesh.h"
@@ -42,5 +41,3 @@ class USDMetaballWriter : public USDGenericMeshWriter {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_WRITER_METABALL_H__ */
diff --git a/source/blender/io/usd/intern/usd_writer_transform.cc b/source/blender/io/usd/intern/usd_writer_transform.cc
index 643f1a8f4b1..49983115455 100644
--- a/source/blender/io/usd/intern/usd_writer_transform.cc
+++ b/source/blender/io/usd/intern/usd_writer_transform.cc
@@ -58,6 +58,9 @@ bool USDTransformWriter::check_is_animated(const HierarchyContext &context) cons
* depsgraph whether this object instance has a time source. */
return true;
}
+ if (check_has_physics(context)) {
+ return true;
+ }
return BKE_object_moves_in_time(context.object, context.animation_check_include_parent);
}
diff --git a/source/blender/io/usd/intern/usd_writer_transform.h b/source/blender/io/usd/intern/usd_writer_transform.h
index 8b4741f1177..39a1f20e7e8 100644
--- a/source/blender/io/usd/intern/usd_writer_transform.h
+++ b/source/blender/io/usd/intern/usd_writer_transform.h
@@ -16,8 +16,7 @@
* The Original Code is Copyright (C) 2019 Blender Foundation.
* All rights reserved.
*/
-#ifndef __USD_WRITER_TRANSFORM_H__
-#define __USD_WRITER_TRANSFORM_H__
+#pragma once
#include "usd_writer_abstract.h"
@@ -42,5 +41,3 @@ class USDTransformWriter : public USDAbstractWriter {
} // namespace usd
} // namespace io
} // namespace blender
-
-#endif /* __USD_WRITER_TRANSFORM_H__ */
diff --git a/source/blender/io/usd/tests/usd_stage_creation_test.cc b/source/blender/io/usd/tests/usd_stage_creation_test.cc
new file mode 100644
index 00000000000..e6bd0bab6ce
--- /dev/null
+++ b/source/blender/io/usd/tests/usd_stage_creation_test.cc
@@ -0,0 +1,70 @@
+/*
+ * 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 "testing/testing.h"
+#include <pxr/usd/usd/stage.h>
+
+#include <string>
+
+#include "BLI_path_util.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_appdir.h"
+
+extern "C" {
+/* Workaround to make it possible to pass a path at runtime to USD. See creator.c. */
+void usd_initialise_plugin_path(const char *datafiles_usd_path);
+}
+
+namespace blender::io::usd {
+
+class USDStageCreationTest : public testing::Test {
+};
+
+TEST_F(USDStageCreationTest, JSONFileLoadingTest)
+{
+ const std::string &release_dir = blender::tests::flags_test_release_dir();
+ if (release_dir.empty()) {
+ FAIL();
+ }
+
+ char usd_datafiles_dir[FILE_MAX];
+ BLI_path_join(usd_datafiles_dir, FILE_MAX, release_dir.c_str(), "datafiles", "usd", nullptr);
+
+ usd_initialise_plugin_path(usd_datafiles_dir);
+
+ /* Simply the ability to create a USD Stage for a specific filename means that the extension
+ * has been recognized by the USD library, and that a USD plugin has been loaded to write such
+ * files. Practically, this is a test to see whether the USD JSON files can be found and
+ * loaded. */
+ std::string filename = "usd-stage-creation-test.usdc";
+ pxr::UsdStageRefPtr usd_stage = pxr::UsdStage::CreateNew(filename);
+ if (usd_stage != nullptr) {
+ /* Even though we don't call `usd_stage->SaveFile()`, a file is still created on the
+ * file-system when we call CreateNew(). It's immediately closed, though,
+ * so we can safely call `unlink()` here. */
+ unlink(filename.c_str());
+ }
+ else {
+ FAIL() << "unable to find suitable USD plugin to write " << filename
+ << "; re-run with the environment variable PXR_PATH_DEBUG non-empty to see which paths "
+ "are considered.";
+ }
+}
+
+} // namespace blender::io::usd
diff --git a/source/blender/io/usd/usd.h b/source/blender/io/usd/usd.h
index eee98521289..f2826cd1d7c 100644
--- a/source/blender/io/usd/usd.h
+++ b/source/blender/io/usd/usd.h
@@ -17,8 +17,7 @@
* All rights reserved.
*/
-#ifndef __USD_H__
-#define __USD_H__
+#pragma once
#include "DEG_depsgraph.h"
@@ -59,5 +58,3 @@ int USD_get_version(void);
#ifdef __cplusplus
}
#endif
-
-#endif /* __USD_H__ */