Cleanup: USD, move code from USD to blender::io::usd namespace

No functional changes.
This commit is contained in:
2020-06-23 11:07:44 +02:00
parent 309cfbceaa
commit 13a5b954c3
18 changed files with 117 additions and 41 deletions

View File

@@ -44,7 +44,9 @@
#include "WM_api.h"
#include "WM_types.h"
namespace USD {
namespace blender {
namespace io {
namespace usd {
struct ExportJobData {
Main *bmain;
@@ -157,7 +159,9 @@ static void export_endjob(void *customdata)
WM_set_locked_interface(data->wm, false);
}
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender
bool USD_export(bContext *C,
const char *filepath,
@@ -167,8 +171,8 @@ bool USD_export(bContext *C,
ViewLayer *view_layer = CTX_data_view_layer(C);
Scene *scene = CTX_data_scene(C);
USD::ExportJobData *job = static_cast<USD::ExportJobData *>(
MEM_mallocN(sizeof(USD::ExportJobData), "ExportJobData"));
blender::io::usd::ExportJobData *job = static_cast<blender::io::usd::ExportJobData *>(
MEM_mallocN(sizeof(blender::io::usd::ExportJobData), "ExportJobData"));
job->bmain = CTX_data_main(C);
job->wm = CTX_wm_manager(C);
@@ -186,7 +190,11 @@ bool USD_export(bContext *C,
/* setup job */
WM_jobs_customdata_set(wm_job, job, MEM_freeN);
WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_FRAME, NC_SCENE | ND_FRAME);
WM_jobs_callbacks(wm_job, USD::export_startjob, nullptr, nullptr, USD::export_endjob);
WM_jobs_callbacks(wm_job,
blender::io::usd::export_startjob,
nullptr,
nullptr,
blender::io::usd::export_endjob);
WM_jobs_start(CTX_wm_manager(C), wm_job);
}
@@ -195,8 +203,8 @@ bool USD_export(bContext *C,
short stop = 0, do_update = 0;
float progress = 0.f;
USD::export_startjob(job, &stop, &do_update, &progress);
USD::export_endjob(job);
blender::io::usd::export_startjob(job, &stop, &do_update, &progress);
blender::io::usd::export_endjob(job);
export_ok = job->export_ok;
MEM_freeN(job);

View File

@@ -27,7 +27,9 @@
struct Depsgraph;
struct Object;
namespace USD {
namespace blender {
namespace io {
namespace usd {
class USDHierarchyIterator;
@@ -39,6 +41,8 @@ struct USDExporterContext {
const USDExportParams &export_params;
};
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender
#endif /* __USD_EXPORTER_CONTEXT_H__ */

View File

@@ -41,7 +41,9 @@
#include "DNA_layer_types.h"
#include "DNA_object_types.h"
namespace USD {
namespace blender {
namespace io {
namespace usd {
USDHierarchyIterator::USDHierarchyIterator(Depsgraph *depsgraph,
pxr::UsdStageRefPtr stage,
@@ -145,4 +147,6 @@ AbstractHierarchyWriter *USDHierarchyIterator::create_particle_writer(const Hier
return nullptr;
}
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender

View File

@@ -32,7 +32,9 @@ struct Depsgraph;
struct ID;
struct Object;
namespace USD {
namespace blender {
namespace io {
namespace usd {
using blender::io::AbstractHierarchyIterator;
using blender::io::AbstractHierarchyWriter;
@@ -70,6 +72,8 @@ class USDHierarchyIterator : public AbstractHierarchyIterator {
USDExporterContext create_usd_export_context(const HierarchyContext *context);
};
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender
#endif /* __USD_HIERARCHY_ITERATOR_H__ */

View File

@@ -32,7 +32,9 @@ static const pxr::TfToken roughness("roughness", pxr::TfToken::Immortal);
static const pxr::TfToken surface("surface", pxr::TfToken::Immortal);
} // namespace usdtokens
namespace USD {
namespace blender {
namespace io {
namespace usd {
USDAbstractWriter::USDAbstractWriter(const USDExporterContext &usd_export_context)
: usd_export_context_(usd_export_context),
@@ -112,4 +114,6 @@ pxr::UsdShadeMaterial USDAbstractWriter::ensure_usd_material(Material *material)
return usd_material;
}
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender

View File

@@ -36,7 +36,9 @@
struct Material;
struct Object;
namespace USD {
namespace blender {
namespace io {
namespace usd {
using blender::io::AbstractHierarchyWriter;
using blender::io::HierarchyContext;
@@ -73,6 +75,8 @@ class USDAbstractWriter : public AbstractHierarchyWriter {
pxr::UsdShadeMaterial ensure_usd_material(Material *material);
};
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender
#endif /* __USD_WRITER_ABSTRACT_H__ */

View File

@@ -28,7 +28,9 @@
#include "DNA_camera_types.h"
#include "DNA_scene_types.h"
namespace USD {
namespace blender {
namespace io {
namespace usd {
USDCameraWriter::USDCameraWriter(const USDExporterContext &ctx) : USDAbstractWriter(ctx)
{
@@ -106,4 +108,6 @@ void USDCameraWriter::do_write(HierarchyContext &context)
}
}
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender

View File

@@ -21,7 +21,9 @@
#include "usd_writer_abstract.h"
namespace USD {
namespace blender {
namespace io {
namespace usd {
/* Writer for writing camera data to UsdGeomCamera. */
class USDCameraWriter : public USDAbstractWriter {
@@ -33,6 +35,8 @@ class USDCameraWriter : public USDAbstractWriter {
virtual void do_write(HierarchyContext &context) override;
};
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender
#endif /* __USD_WRITER_CAMERA_H__ */

View File

@@ -26,7 +26,9 @@
#include "DNA_particle_types.h"
namespace USD {
namespace blender {
namespace io {
namespace usd {
USDHairWriter::USDHairWriter(const USDExporterContext &ctx) : USDAbstractWriter(ctx)
{
@@ -85,4 +87,6 @@ bool USDHairWriter::check_is_animated(const HierarchyContext &) const
return true;
}
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender

View File

@@ -21,7 +21,9 @@
#include "usd_writer_abstract.h"
namespace USD {
namespace blender {
namespace io {
namespace usd {
/* Writer for writing hair particle data as USD curves. */
class USDHairWriter : public USDAbstractWriter {
@@ -33,6 +35,8 @@ class USDHairWriter : public USDAbstractWriter {
virtual bool check_is_animated(const HierarchyContext &context) const override;
};
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender
#endif /* __USD_WRITER_HAIR_H__ */

View File

@@ -30,7 +30,9 @@
#include "DNA_light_types.h"
#include "DNA_object_types.h"
namespace USD {
namespace blender {
namespace io {
namespace usd {
USDLightWriter::USDLightWriter(const USDExporterContext &ctx) : USDAbstractWriter(ctx)
{
@@ -107,4 +109,6 @@ void USDLightWriter::do_write(HierarchyContext &context)
usd_light.CreateSpecularAttr().Set(light->spec_fac, timecode);
}
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender

View File

@@ -21,7 +21,9 @@
#include "usd_writer_abstract.h"
namespace USD {
namespace blender {
namespace io {
namespace usd {
class USDLightWriter : public USDAbstractWriter {
public:
@@ -32,6 +34,8 @@ class USDLightWriter : public USDAbstractWriter {
virtual void do_write(HierarchyContext &context) override;
};
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender
#endif /* __USD_WRITER_LIGHT_H__ */

View File

@@ -42,7 +42,9 @@
#include "DNA_object_fluidsim_types.h"
#include "DNA_particle_types.h"
namespace USD {
namespace blender {
namespace io {
namespace usd {
USDGenericMeshWriter::USDGenericMeshWriter(const USDExporterContext &ctx) : USDAbstractWriter(ctx)
{
@@ -484,4 +486,6 @@ Mesh *USDMeshWriter::get_export_mesh(Object *object_eval, bool & /*r_needsfree*/
return BKE_object_get_evaluated_mesh(object_eval);
}
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender

View File

@@ -23,7 +23,9 @@
#include <pxr/usd/usdGeom/mesh.h>
namespace USD {
namespace blender {
namespace io {
namespace usd {
struct USDMeshData;
@@ -61,6 +63,8 @@ class USDMeshWriter : public USDGenericMeshWriter {
virtual Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override;
};
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender
#endif /* __USD_WRITER_MESH_H__ */

View File

@@ -34,7 +34,9 @@
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
namespace USD {
namespace blender {
namespace io {
namespace usd {
USDMetaballWriter::USDMetaballWriter(const USDExporterContext &ctx) : USDGenericMeshWriter(ctx)
{
@@ -76,4 +78,6 @@ bool USDMetaballWriter::is_basis_ball(Scene *scene, Object *ob) const
return ob == basis_ob;
}
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender

View File

@@ -21,7 +21,9 @@
#include "usd_writer_mesh.h"
namespace USD {
namespace blender {
namespace io {
namespace usd {
class USDMetaballWriter : public USDGenericMeshWriter {
public:
@@ -37,6 +39,8 @@ class USDMetaballWriter : public USDGenericMeshWriter {
bool is_basis_ball(Scene *scene, Object *ob) const;
};
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender
#endif /* __USD_WRITER_METABALL_H__ */

View File

@@ -28,7 +28,9 @@
#include "DNA_layer_types.h"
namespace USD {
namespace blender {
namespace io {
namespace usd {
USDTransformWriter::USDTransformWriter(const USDExporterContext &ctx) : USDAbstractWriter(ctx)
{
@@ -59,4 +61,6 @@ bool USDTransformWriter::check_is_animated(const HierarchyContext &context) cons
return BKE_object_moves_in_time(context.object, context.animation_check_include_parent);
}
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender

View File

@@ -23,7 +23,9 @@
#include <pxr/usd/usdGeom/xform.h>
namespace USD {
namespace blender {
namespace io {
namespace usd {
class USDTransformWriter : public USDAbstractWriter {
private:
@@ -37,6 +39,8 @@ class USDTransformWriter : public USDAbstractWriter {
bool check_is_animated(const HierarchyContext &context) const override;
};
} // namespace USD
} // namespace usd
} // namespace io
} // namespace blender
#endif /* __USD_WRITER_TRANSFORM_H__ */