Blender V5.3
usd_reader_stage.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 Tangent Animation and. NVIDIA Corporation. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4#pragma once
5
6#include "BLI_map.hh"
7#include "BLI_set.hh"
8#include "BLI_vector.hh"
9
10#include "usd.hh"
12#include "usd_reader_prim.hh"
13
14#include <pxr/usd/usdGeom/imageable.h>
15struct ImportSettings;
16namespace blender {
17
18struct Collection;
19struct Main;
20struct ReportList;
21
22namespace io::usd {
23
25
31
33
35
36 protected:
37 pxr::UsdStageRefPtr stage_;
40
42
43 /* USD dome lights are converted to a world material,
44 * rather than light objects, so are handled differently */
46
47 /* USD material prim paths encountered during stage
48 * traversal, for importing unused materials. */
50
51 /* Readers for scene-graph instance prototypes. */
53
54 /* Readers for point instancer prototypes. */
56
57 public:
58 USDStageReader(pxr::UsdStageRefPtr stage,
60 const std::function<CacheFile *()> &get_cache_file_fn = {});
61
63
64 USDPrimReader *create_reader_if_allowed(const pxr::UsdPrim &prim);
65
66 USDPrimReader *create_reader(const pxr::UsdPrim &prim);
67
68 void collect_readers();
69
75 void process_armature_modifiers() const;
76
77 /* Convert every material prim on the stage to a Blender
78 * material, including materials not used by any geometry.
79 * Note that collect_readers() must be called before calling
80 * import_all_materials(). */
81 void import_all_materials(struct Main *bmain);
82
83 /* Add fake users for any imported materials with no
84 * users. This is typically required when importing all
85 * materials. */
87
93
99 void call_material_import_hooks(struct Main *bmain) const;
100
101 bool valid() const;
102
103 pxr::UsdStageRefPtr stage()
104 {
105 return stage_;
106 }
107 const USDImportParams &params() const
108 {
109 return params_;
110 }
111
113 {
114 return settings_;
115 }
116
118 ReportList *reports() const;
119
121 void clear_readers();
122
124 {
125 return readers_;
126 };
127
132
133 void sort_readers();
134
138 void create_proto_collections(Main *bmain, Collection *parent_collection);
139
140 private:
158 USDPrimReader *collect_readers(const pxr::UsdPrim &prim,
159 const UsdPathSet &pruned_prims,
160 bool defined_prims_only,
161 Vector<USDPrimReader *> &r_readers);
162
170 bool include_by_visibility(const pxr::UsdGeomImageable &imageable) const;
171
179 bool include_by_purpose(const pxr::UsdGeomImageable &imageable) const;
180
186 bool merge_with_parent(USDPrimReader *reader) const;
187
192 bool is_primitive_prim(const pxr::UsdPrim &prim) const;
193
201 UsdPathSet collect_point_instancer_proto_paths() const;
202 void collect_point_instancer_proto_paths(const pxr::UsdPrim &prim, UsdPathSet &r_paths) const;
203
210 void create_point_instancer_proto_readers(const UsdPathSet &proto_paths);
211};
212
213}; // namespace io::usd
214
215} // namespace blender
Vector< pxr::SdfPath > material_paths_
const USDImportParams & params() const
USDPrimReader * create_reader_if_allowed(const pxr::UsdPrim &prim)
const ImportSettings & settings() const
const Vector< USDDomeLightReader * > & dome_light_readers() const
USDStageReader(pxr::UsdStageRefPtr stage, const USDImportParams &params, const std::function< CacheFile *()> &get_cache_file_fn={})
const Vector< USDPrimReader * > & readers() const
void create_proto_collections(Main *bmain, Collection *parent_collection)
Vector< USDDomeLightReader * > dome_light_readers_
Vector< USDPrimReader * > readers_
void import_all_materials(struct Main *bmain)
AbcObjectReader * create_reader(const AbcReaderConstructorArgs &args)
Definition abc_util.cc:162
Map< pxr::SdfPath, Vector< USDPrimReader * > > ProtoReaderMap
bool call_material_import_hooks(pxr::UsdStageRefPtr stage, Material *material, const pxr::UsdShadeMaterial &usd_material, const USDImportParams &import_params, ReportList *reports)
Definition usd_hook.cc:667
Set< pxr::SdfPath > UsdPathSet
BMesh Iterators.