Blender
V4.3
source
blender
io
usd
hydra
usd_scene_delegate.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2011-2022 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
5
#include "
usd_scene_delegate.hh
"
6
7
#include "
BLI_fileops.h
"
8
#include "
BLI_path_utils.hh
"
9
#include "
BLI_string.h
"
10
11
#include "
BKE_appdir.hh
"
12
#include "
BKE_report.hh
"
13
14
#include "
DEG_depsgraph_query.hh
"
15
16
#include "
WM_api.hh
"
17
#include "
WM_types.hh
"
18
19
#include "
usd.hh
"
20
#include "
usd_private.hh
"
21
22
using namespace
blender::io::usd
;
23
24
namespace
blender::io::hydra
{
25
26
USDSceneDelegate::USDSceneDelegate
(pxr::HdRenderIndex *render_index,
27
pxr::SdfPath
const
&delegate_id,
28
const
bool
use_materialx)
29
: render_index_(render_index), delegate_id_(delegate_id), use_materialx(use_materialx)
30
{
31
/* Temporary directory to write any additional files to, like image or VDB files. */
32
char
unique_name
[
FILE_MAXFILE
];
33
SNPRINTF
(
unique_name
,
"%p"
,
this
);
34
35
char
dir_path[
FILE_MAX
];
36
BLI_path_join
(
37
dir_path,
sizeof
(dir_path),
BKE_tempdir_session
(),
"usd_scene_delegate"
,
unique_name
);
38
BLI_dir_create_recursive
(dir_path);
39
40
char
file_path[
FILE_MAX
];
41
BLI_path_join
(file_path,
sizeof
(file_path), dir_path,
"scene.usdc"
);
42
43
temp_dir_ = dir_path;
44
temp_file_ = file_path;
45
}
46
47
USDSceneDelegate::~USDSceneDelegate
()
48
{
49
BLI_delete
(temp_dir_.c_str(),
true
,
true
);
50
}
51
52
void
USDSceneDelegate::populate
(Depsgraph *
depsgraph
)
53
{
54
USDExportParams
params
;
55
params
.use_instancing =
true
;
56
params
.relative_paths =
false
;
/* Unnecessary. */
57
params
.export_textures =
false
;
/* Don't copy all textures, is slow. */
58
params
.export_subdiv =
USD_SUBDIV_TESSELLATE
;
59
params
.evaluation_mode =
DEG_get_mode
(
depsgraph
);
60
params
.generate_preview_surface = !use_materialx;
61
params
.generate_materialx_network = use_materialx;
62
63
/* NOTE: Since the reports list will be `nullptr` here, reports generated by export code from
64
* this call will only be printed to console. */
65
wmJobWorkerStatus
worker_status = {};
66
ReportList
worker_reports = {};
67
BKE_reports_init
(&worker_reports,
RPT_PRINT
|
RPT_STORE
);
68
worker_status.
reports
= &worker_reports;
69
params
.worker_status = &worker_status;
70
71
/* Create clean directory for export. */
72
BLI_delete
(temp_dir_.c_str(),
true
,
true
);
73
BLI_dir_create_recursive
(temp_dir_.c_str());
74
75
/* Free previous delegate and stage first to save memory. */
76
delegate_.reset();
77
stage_.Reset();
78
79
/* Convert depsgraph to stage + additional file in temp directory. */
80
stage_ =
io::usd::export_to_stage
(
params
,
depsgraph
, temp_file_.c_str());
81
delegate_ = std::make_unique<pxr::UsdImagingDelegate>(render_index_, delegate_id_);
82
delegate_->Populate(stage_->GetPseudoRoot());
83
84
WM_reports_from_reports_move
(
nullptr
, &worker_reports);
85
86
BKE_reports_free
(&worker_reports);
87
}
88
89
}
// namespace blender::io::hydra
BKE_appdir.hh
BKE_report.hh
BKE_reports_free
void BKE_reports_free(ReportList *reports)
Definition
report.cc:69
BKE_reports_init
void BKE_reports_init(ReportList *reports, int flag)
Definition
report.cc:54
BLI_fileops.h
File and directory operations.
BLI_dir_create_recursive
bool BLI_dir_create_recursive(const char *dirname) ATTR_NONNULL()
Definition
fileops_c.cc:391
BLI_delete
int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL()
Definition
fileops_c.cc:1189
BLI_path_utils.hh
FILE_MAXFILE
#define FILE_MAXFILE
Definition
BLI_path_utils.hh:656
FILE_MAX
#define FILE_MAX
Definition
BLI_path_utils.hh:657
BLI_path_join
#define BLI_path_join(...)
Definition
BLI_path_utils.hh:368
BLI_string.h
SNPRINTF
#define SNPRINTF(dst, format,...)
Definition
BLI_string.h:597
DEG_depsgraph_query.hh
DEG_get_mode
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
Definition
depsgraph_query.cc:101
RPT_PRINT
@ RPT_PRINT
Definition
DNA_windowmanager_types.h:85
RPT_STORE
@ RPT_STORE
Definition
DNA_windowmanager_types.h:86
WM_api.hh
WM_types.hh
blender::io::hydra::USDSceneDelegate::populate
void populate(Depsgraph *depsgraph)
Definition
usd_scene_delegate.cc:52
blender::io::hydra::USDSceneDelegate::~USDSceneDelegate
~USDSceneDelegate()
Definition
usd_scene_delegate.cc:47
blender::io::hydra::USDSceneDelegate::USDSceneDelegate
USDSceneDelegate(pxr::HdRenderIndex *render_index, pxr::SdfPath const &delegate_id, bool use_materialx)
Definition
usd_scene_delegate.cc:26
depsgraph
const Depsgraph * depsgraph
Definition
deg_eval_copy_on_write.cc:494
params
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
Definition
interface_widgets.cc:1055
blender::io::hydra
Definition
io/usd/hydra/curves.cc:24
blender::io::usd
Definition
usd_armature_utils.cc:17
blender::io::usd::USD_SUBDIV_TESSELLATE
@ USD_SUBDIV_TESSELLATE
Definition
usd.hh:83
blender::io::usd::export_to_stage
pxr::UsdStageRefPtr export_to_stage(const USDExportParams ¶ms, Depsgraph *depsgraph, const char *filepath)
Definition
usd_capi_export.cc:383
unique_name
static void unique_name(bNode *node)
Definition
node_texture_output.cc:51
ReportList
Definition
DNA_windowmanager_types.h:110
blender::io::usd::USDExportParams
Definition
usd.hh:116
wmJobWorkerStatus
Definition
WM_types.hh:963
wmJobWorkerStatus::reports
ReportList * reports
Definition
WM_types.hh:985
BKE_tempdir_session
void * BKE_tempdir_session
Definition
stubs.c:38
usd.hh
usd_private.hh
usd_scene_delegate.hh
WM_reports_from_reports_move
void WM_reports_from_reports_move(wmWindowManager *wm, ReportList *reports)
Definition
wm_event_system.cc:995
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0