Blender V5.3
usd_hierarchy_iterator.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2019 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4#pragma once
5
7#include "usd.hh"
9#include "usd_skel_convert.hh"
10
11#include <string>
12
13#include <pxr/usd/usd/common.h>
14#include <pxr/usd/usd/timeCode.h>
15
16namespace blender {
17
18struct Depsgraph;
19struct Main;
20struct Object;
21
22namespace io::usd {
23
24using io::AbstractHierarchyIterator;
25using io::AbstractHierarchyWriter;
26using io::HierarchyContext;
27
29 private:
30 const pxr::UsdStageRefPtr stage_;
31 pxr::UsdTimeCode export_time_;
32 const USDExportParams &params_;
33
34 ObjExportMap armature_export_map_;
35 ObjExportMap skinned_mesh_export_map_;
36 ObjExportMap shape_key_mesh_export_map_;
37
38 /*
39 * The field below is mutable because it is used to keep track
40 * of what the exporter is doing. This is necessary even when all
41 * the other export settings are to remain const.
42 */
43
44 /* Map a USD prim path to a list of Blender IDs associated with that prim.
45 * This map is updated by writers during stage export. */
46 mutable Map<pxr::SdfPath, Vector<ID *>> exported_prim_map_;
47
48 /* Map prototype_paths[instancer path] = [
49 * (proto_path_1, proto_object_1), (proto_path_2, proto_object_2), ... ] */
51
52 public:
54 Depsgraph *depsgraph,
55 pxr::UsdStageRefPtr stage,
56 const USDExportParams &params);
57
58 void set_export_frame(float frame_nr);
59
60 std::string make_valid_name(const std::string &name) const override;
61
62 void process_usd_skel() const;
63
64 /* Get the USD stage being exported to. */
65 pxr::UsdStageRefPtr get_stage() const;
66
67 /* Get the mapping of exported objects to their USD prim paths. */
69
70 /* Add an ID to the prim map for a given USD path. */
71 void add_to_prim_map(const pxr::SdfPath &usd_path, const ID *id) const;
72
73 protected:
74 bool mark_as_weak_export(const Object *object) const override;
76
81
82 void release_writer(AbstractHierarchyWriter *writer) override;
83
84 bool include_data_writers(const HierarchyContext *context) const override;
85 bool include_child_writers(const HierarchyContext *context) const override;
86
87 private:
88 USDExporterContext create_usd_export_context(const HierarchyContext *context);
89 USDExporterContext create_point_instancer_context(
90 const HierarchyContext *context, const USDExporterContext &usd_export_context) const;
91
92 void add_usd_skel_export_mapping(const Object *obj, const pxr::SdfPath &usd_path);
93};
94
95} // namespace io::usd
96} // namespace blender
AbstractHierarchyIterator(Main *bmain, Depsgraph *depsgraph)
bool mark_as_weak_export(const Object *object) const override
AbstractHierarchyWriter * create_data_writer(const HierarchyContext *context) override
void add_to_prim_map(const pxr::SdfPath &usd_path, const ID *id) const
void release_writer(AbstractHierarchyWriter *writer) override
bool determine_point_instancers(const HierarchyContext *context)
AbstractHierarchyWriter * create_particle_writer(const HierarchyContext *context) override
USDHierarchyIterator(Main *bmain, Depsgraph *depsgraph, pxr::UsdStageRefPtr stage, const USDExportParams &params)
const Map< pxr::SdfPath, Vector< ID * > > & get_exported_prim_map() const
AbstractHierarchyWriter * create_hair_writer(const HierarchyContext *context) override
bool include_child_writers(const HierarchyContext *context) const override
bool include_data_writers(const HierarchyContext *context) const override
std::string make_valid_name(const std::string &name) const override
AbstractHierarchyWriter * create_transform_writer(const HierarchyContext *context) override
Map< const Object *, pxr::SdfPath > ObjExportMap
BMesh Iterators.