Blender V4.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"
11#include "usd_hash_types.hh"
12#include "usd_reader_prim.hh"
13
14#include <pxr/usd/usdGeom/imageable.h>
15#include <pxr/usd/usdLux/domeLight.h>
16
17#include <string>
18
19struct Collection;
20struct ImportSettings;
21struct Main;
22struct ReportList;
23
24namespace blender::io::usd {
25
26class USDPointInstancerReader;
27
33
35
37
38 protected:
39 pxr::UsdStageRefPtr stage_;
42
44
45 /* USD dome lights are converted to a world material,
46 * rather than light objects, so are handled differently */
48
49 /* USD material prim paths encountered during stage
50 * traversal, for importing unused materials. */
52
53 /* Readers for scene-graph instance prototypes. */
55
56 /* Readers for point instancer prototypes. */
58
59 public:
60 USDStageReader(pxr::UsdStageRefPtr stage,
62 const ImportSettings &settings);
63
65
66 USDPrimReader *create_reader_if_allowed(const pxr::UsdPrim &prim);
67
68 USDPrimReader *create_reader(const pxr::UsdPrim &prim);
69
70 void collect_readers();
71
77 void process_armature_modifiers() const;
78
79 /* Convert every material prim on the stage to a Blender
80 * material, including materials not used by any geometry.
81 * Note that collect_readers() must be called before calling
82 * import_all_materials(). */
83 void import_all_materials(struct Main *bmain);
84
85 /* Add fake users for any imported materials with no
86 * users. This is typically required when importing all
87 * materials. */
89
90 bool valid() const;
91
92 pxr::UsdStageRefPtr stage()
93 {
94 return stage_;
95 }
96 const USDImportParams &params() const
97 {
98 return params_;
99 }
100
102 {
103 return settings_;
104 }
105
108 {
110 }
111
113 void clear_readers();
114
116 {
117 return readers_;
118 };
119
121 {
122 return dome_lights_;
123 };
124
125 void sort_readers();
126
130 void create_proto_collections(Main *bmain, Collection *parent_collection);
131
132 private:
150 USDPrimReader *collect_readers(const pxr::UsdPrim &prim,
151 const UsdPathSet &pruned_prims,
152 bool defined_prims_only,
154
162 bool include_by_visibility(const pxr::UsdGeomImageable &imageable) const;
163
171 bool include_by_purpose(const pxr::UsdGeomImageable &imageable) const;
172
177 bool is_primitive_prim(const pxr::UsdPrim &prim) const;
178
186 UsdPathSet collect_point_instancer_proto_paths() const;
187 void collect_point_instancer_proto_paths(const pxr::UsdPrim &prim, UsdPathSet &r_paths) const;
188
195 void create_point_instancer_proto_readers(const UsdPathSet &proto_paths);
196};
197
198}; // namespace blender::io::usd
USDPrimReader * create_reader(const pxr::UsdPrim &prim)
blender::Vector< pxr::UsdLuxDomeLight > dome_lights_
const USDImportParams & params() const
USDPrimReader * create_reader_if_allowed(const pxr::UsdPrim &prim)
blender::Vector< USDPrimReader * > readers_
const ImportSettings & settings() const
const blender::Vector< USDPrimReader * > & readers() const
blender::Vector< std::string > material_paths_
const blender::Vector< pxr::UsdLuxDomeLight > & dome_lights() const
void create_proto_collections(Main *bmain, Collection *parent_collection)
USDStageReader(pxr::UsdStageRefPtr stage, const USDImportParams &params, const ImportSettings &settings)
void import_all_materials(struct Main *bmain)
wmJobWorkerStatus * worker_status
Definition usd.hh:228
ReportList * reports
Definition WM_types.hh:985