Blender  V3.3
usd_capi_import.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2019 Blender Foundation. All rights reserved. */
3 
4 #include "IO_types.h"
5 #include "usd.h"
6 #include "usd_common.h"
8 #include "usd_reader_geom.h"
9 #include "usd_reader_prim.h"
10 #include "usd_reader_stage.h"
11 
12 #include "BKE_appdir.h"
13 #include "BKE_blender_version.h"
14 #include "BKE_cachefile.h"
15 #include "BKE_cdderivedmesh.h"
16 #include "BKE_context.h"
17 #include "BKE_global.h"
18 #include "BKE_layer.h"
19 #include "BKE_lib_id.h"
20 #include "BKE_library.h"
21 #include "BKE_main.h"
22 #include "BKE_node.h"
23 #include "BKE_object.h"
24 #include "BKE_scene.h"
25 #include "BKE_world.h"
26 
27 #include "BLI_fileops.h"
28 #include "BLI_listbase.h"
29 #include "BLI_math_matrix.h"
30 #include "BLI_math_rotation.h"
31 #include "BLI_path_util.h"
32 #include "BLI_string.h"
33 #include "BLI_timeit.hh"
34 
35 #include "DEG_depsgraph.h"
36 #include "DEG_depsgraph_build.h"
37 #include "DEG_depsgraph_query.h"
38 
39 #include "DNA_cachefile_types.h"
40 #include "DNA_collection_types.h"
41 #include "DNA_node_types.h"
42 #include "DNA_scene_types.h"
43 #include "DNA_world_types.h"
44 
45 #include "MEM_guardedalloc.h"
46 
47 #include "WM_api.h"
48 #include "WM_types.h"
49 
50 #include <pxr/usd/usd/stage.h>
51 #include <pxr/usd/usdGeom/metrics.h>
52 #include <pxr/usd/usdGeom/scope.h>
53 #include <pxr/usd/usdGeom/tokens.h>
54 #include <pxr/usd/usdGeom/xformCommonAPI.h>
55 
56 #include <iostream>
57 
58 namespace blender::io::usd {
59 
61 {
62  return reinterpret_cast<CacheArchiveHandle *>(reader);
63 }
64 
66 {
67  return reinterpret_cast<USDStageReader *>(handle);
68 }
69 
70 static bool gather_objects_paths(const pxr::UsdPrim &object, ListBase *object_paths)
71 {
72  if (!object.IsValid()) {
73  return false;
74  }
75 
76  for (const pxr::UsdPrim &childPrim : object.GetChildren()) {
77  gather_objects_paths(childPrim, object_paths);
78  }
79 
80  void *usd_path_void = MEM_callocN(sizeof(CacheObjectPath), "CacheObjectPath");
81  CacheObjectPath *usd_path = static_cast<CacheObjectPath *>(usd_path_void);
82 
83  BLI_strncpy(usd_path->path, object.GetPrimPath().GetString().c_str(), sizeof(usd_path->path));
84  BLI_addtail(object_paths, usd_path);
85 
86  return true;
87 }
88 
89 /* Update the given import settings with the global rotation matrix to orient
90  * imported objects with Z-up, if necessary */
91 static void convert_to_z_up(pxr::UsdStageRefPtr stage, ImportSettings *r_settings)
92 {
93  if (!stage || pxr::UsdGeomGetStageUpAxis(stage) == pxr::UsdGeomTokens->z) {
94  return;
95  }
96 
97  if (!r_settings) {
98  return;
99  }
100 
101  r_settings->do_convert_mat = true;
102 
103  /* Rotate 90 degrees about the X-axis. */
104  float rmat[3][3];
105  float axis[3] = {1.0f, 0.0f, 0.0f};
107 
108  unit_m4(r_settings->conversion_mat);
109  copy_m4_m3(r_settings->conversion_mat, rmat);
110 }
111 
112 enum {
115 };
116 
122 
123  char filepath[1024];
126 
128 
129  short *stop;
130  short *do_update;
131  float *progress;
132 
135  bool import_ok;
137 };
138 
140 {
141  timeit::Nanoseconds duration = timeit::Clock::now() - data->start_time;
142  std::cout << "USD import of '" << data->filepath << "' took ";
143  timeit::print_duration(duration);
144  std::cout << '\n';
145 }
146 
147 static void import_startjob(void *customdata, short *stop, short *do_update, float *progress)
148 {
149  ImportJobData *data = static_cast<ImportJobData *>(customdata);
150 
151  data->stop = stop;
152  data->do_update = do_update;
153  data->progress = progress;
154  data->was_canceled = false;
155  data->archive = nullptr;
156  data->start_time = timeit::Clock::now();
157 
158  WM_set_locked_interface(data->wm, true);
159  G.is_break = false;
160 
161  if (data->params.create_collection) {
162  char display_name[1024];
164  display_name, strlen(data->filepath), BLI_path_basename(data->filepath));
165  Collection *import_collection = BKE_collection_add(
166  data->bmain, data->scene->master_collection, display_name);
167  id_fake_user_set(&import_collection->id);
168 
169  DEG_id_tag_update(&import_collection->id, ID_RECALC_COPY_ON_WRITE);
171 
173 
174  data->view_layer->active_collection = BKE_layer_collection_first_from_scene_collection(
175  data->view_layer, import_collection);
176  }
177 
179 
180  CacheFile *cache_file = static_cast<CacheFile *>(
181  BKE_cachefile_add(data->bmain, BLI_path_basename(data->filepath)));
182 
183  /* Decrement the ID ref-count because it is going to be incremented for each
184  * modifier and constraint that it will be attached to, so since currently
185  * it is not used by anyone, its use count will off by one. */
186  id_us_min(&cache_file->id);
187 
188  cache_file->is_sequence = data->params.is_sequence;
189  cache_file->scale = data->params.scale;
190  STRNCPY(cache_file->filepath, data->filepath);
191 
192  data->settings.cache_file = cache_file;
193 
194  *data->do_update = true;
195  *data->progress = 0.05f;
196 
197  if (G.is_break) {
198  data->was_canceled = true;
199  return;
200  }
201 
202  *data->do_update = true;
203  *data->progress = 0.1f;
204 
205  pxr::UsdStageRefPtr stage = pxr::UsdStage::Open(data->filepath);
206 
207  if (!stage) {
208  WM_reportf(RPT_ERROR, "USD Import: unable to open stage to read %s", data->filepath);
209  data->import_ok = false;
210  return;
211  }
212 
213  convert_to_z_up(stage, &data->settings);
214 
215  /* Set up the stage for animated data. */
216  if (data->params.set_frame_range) {
217  data->scene->r.sfra = stage->GetStartTimeCode();
218  data->scene->r.efra = stage->GetEndTimeCode();
219  }
220 
221  *data->do_update = true;
222  *data->progress = 0.15f;
223 
224  USDStageReader *archive = new USDStageReader(stage, data->params, data->settings);
225 
226  data->archive = archive;
227 
228  archive->collect_readers(data->bmain);
229 
230  *data->do_update = true;
231  *data->progress = 0.2f;
232 
233  const float size = static_cast<float>(archive->readers().size());
234  size_t i = 0;
235 
236  /* Sort readers by name: when creating a lot of objects in Blender,
237  * it is much faster if the order is sorted by name. */
238  archive->sort_readers();
239  *data->do_update = true;
240  *data->progress = 0.25f;
241 
242  /* Create blender objects. */
243  for (USDPrimReader *reader : archive->readers()) {
244  if (!reader) {
245  continue;
246  }
247  reader->create_object(data->bmain, 0.0);
248  if ((++i & 1023) == 0) {
249  *data->do_update = true;
250  *data->progress = 0.25f + 0.25f * (i / size);
251  }
252  }
253 
254  /* Setup parenthood and read actual object data. */
255  i = 0;
256  for (USDPrimReader *reader : archive->readers()) {
257 
258  if (!reader) {
259  continue;
260  }
261 
262  Object *ob = reader->object();
263 
264  reader->read_object_data(data->bmain, 0.0);
265 
266  USDPrimReader *parent = reader->parent();
267 
268  if (parent == nullptr) {
269  ob->parent = nullptr;
270  }
271  else {
272  ob->parent = parent->object();
273  }
274 
275  *data->progress = 0.5f + 0.5f * (++i / size);
276  *data->do_update = true;
277 
278  if (G.is_break) {
279  data->was_canceled = true;
280  return;
281  }
282  }
283 
284  data->import_ok = !data->was_canceled;
285 
286  *progress = 1.0f;
287  *do_update = true;
288 }
289 
290 static void import_endjob(void *customdata)
291 {
292  ImportJobData *data = static_cast<ImportJobData *>(customdata);
293 
294  /* Delete objects on cancellation. */
295  if (data->was_canceled && data->archive) {
296 
297  for (USDPrimReader *reader : data->archive->readers()) {
298 
299  if (!reader) {
300  continue;
301  }
302 
303  /* It's possible that cancellation occurred between the creation of
304  * the reader and the creation of the Blender object. */
305  if (Object *ob = reader->object()) {
306  BKE_id_free_us(data->bmain, ob);
307  }
308  }
309  }
310  else if (data->archive) {
311  Base *base;
312  LayerCollection *lc;
313  ViewLayer *view_layer = data->view_layer;
314 
316 
317  lc = BKE_layer_collection_get_active(view_layer);
318 
319  /* Add all objects to the collection (don't do sync for each object). */
321  for (USDPrimReader *reader : data->archive->readers()) {
322  if (!reader) {
323  continue;
324  }
325  Object *ob = reader->object();
326  if (!ob) {
327  continue;
328  }
329  BKE_collection_object_add(data->bmain, lc->collection, ob);
330  }
331 
332  /* Sync the collection, and do view layer operations. */
335  for (USDPrimReader *reader : data->archive->readers()) {
336  if (!reader) {
337  continue;
338  }
339  Object *ob = reader->object();
340  if (!ob) {
341  continue;
342  }
343  base = BKE_view_layer_base_find(view_layer, ob);
344  /* TODO: is setting active needed? */
346 
348  DEG_id_tag_update_ex(data->bmain,
349  &ob->id,
352  }
353 
356  }
357 
358  WM_set_locked_interface(data->wm, false);
359 
360  switch (data->error_code) {
361  default:
362  case USD_NO_ERROR:
363  data->import_ok = !data->was_canceled;
364  break;
365  case USD_ARCHIVE_FAIL:
366  WM_report(RPT_ERROR, "Could not open USD archive for reading! See console for detail.");
367  break;
368  }
369 
372 }
373 
374 static void import_freejob(void *user_data)
375 {
376  ImportJobData *data = static_cast<ImportJobData *>(user_data);
377 
378  delete data->archive;
379  delete data;
380 }
381 
382 } // namespace blender::io::usd
383 
384 using namespace blender::io::usd;
385 
386 bool USD_import(struct bContext *C,
387  const char *filepath,
388  const USDImportParams *params,
389  bool as_background_job)
390 {
392 
393  /* Using new here since `MEM_*` functions do not call constructor to properly initialize data. */
394  ImportJobData *job = new ImportJobData();
395  job->bmain = CTX_data_main(C);
396  job->scene = CTX_data_scene(C);
398  job->wm = CTX_wm_manager(C);
399  job->import_ok = false;
400  BLI_strncpy(job->filepath, filepath, 1024);
401 
402  job->settings.scale = params->scale;
403  job->settings.sequence_offset = params->offset;
404  job->settings.is_sequence = params->is_sequence;
405  job->settings.sequence_len = params->sequence_len;
406  job->settings.validate_meshes = params->validate_meshes;
407  job->settings.sequence_len = params->sequence_len;
408  job->error_code = USD_NO_ERROR;
409  job->was_canceled = false;
410  job->archive = nullptr;
411 
412  job->params = *params;
413 
414  G.is_break = false;
415 
416  bool import_ok = false;
417  if (as_background_job) {
418  wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
419  CTX_wm_window(C),
420  job->scene,
421  "USD Import",
424 
425  /* setup job */
427  WM_jobs_timer(wm_job, 0.1, NC_SCENE, NC_SCENE);
428  WM_jobs_callbacks(wm_job, import_startjob, nullptr, nullptr, import_endjob);
429 
430  WM_jobs_start(CTX_wm_manager(C), wm_job);
431  }
432  else {
433  /* Fake a job context, so that we don't need NULL pointer checks while importing. */
434  short stop = 0, do_update = 0;
435  float progress = 0.0f;
436 
437  import_startjob(job, &stop, &do_update, &progress);
438  import_endjob(job);
439  import_ok = job->import_ok;
440 
441  import_freejob(job);
442  }
443 
444  return import_ok;
445 }
446 
447 /* TODO(makowalski): Extend this function with basic validation that the
448  * USD reader is compatible with the type of the given (currently unused) 'ob'
449  * Object parameter, similar to the logic in get_abc_reader() in the
450  * Alembic importer code. */
451 static USDPrimReader *get_usd_reader(CacheReader *reader, Object * /* ob */, const char **err_str)
452 {
453  USDPrimReader *usd_reader = reinterpret_cast<USDPrimReader *>(reader);
454  pxr::UsdPrim iobject = usd_reader->prim();
455 
456  if (!iobject.IsValid()) {
457  *err_str = "Invalid object: verify object path";
458  return nullptr;
459  }
460 
461  return usd_reader;
462 }
463 
464 struct Mesh *USD_read_mesh(struct CacheReader *reader,
465  struct Object *ob,
466  struct Mesh *existing_mesh,
467  const double time,
468  const char **err_str,
469  const int read_flag)
470 {
471  USDGeomReader *usd_reader = dynamic_cast<USDGeomReader *>(get_usd_reader(reader, ob, err_str));
472 
473  if (usd_reader == nullptr) {
474  return nullptr;
475  }
476 
477  return usd_reader->read_mesh(existing_mesh, time, read_flag, err_str);
478 }
479 
481  CacheReader *reader, Object *ob, Mesh *existing_mesh, const double time, const char **err_str)
482 {
483  USDGeomReader *usd_reader = dynamic_cast<USDGeomReader *>(get_usd_reader(reader, ob, err_str));
484 
485  if (usd_reader == nullptr) {
486  return false;
487  }
488 
489  return usd_reader->topology_changed(existing_mesh, time);
490 }
491 
493 {
494  USDPrimReader *usd_reader = reinterpret_cast<USDPrimReader *>(reader);
495  usd_reader->incref();
496 }
497 
499  CacheReader *reader,
500  Object *object,
501  const char *object_path)
502 {
503  if (object_path[0] == '\0') {
504  return reader;
505  }
506 
507  USDStageReader *archive = stage_reader_from_handle(handle);
508 
509  if (!archive || !archive->valid()) {
510  return reader;
511  }
512 
513  pxr::UsdPrim prim = archive->stage()->GetPrimAtPath(pxr::SdfPath(object_path));
514 
515  if (reader) {
516  USD_CacheReader_free(reader);
517  }
518 
519  /* TODO(makowalski): The handle does not have the proper import params or settings. */
520  USDPrimReader *usd_reader = archive->create_reader(prim);
521 
522  if (usd_reader == nullptr) {
523  /* This object is not supported. */
524  return nullptr;
525  }
526  usd_reader->object(object);
527  usd_reader->incref();
528 
529  return reinterpret_cast<CacheReader *>(usd_reader);
530 }
531 
533 {
534  USDPrimReader *usd_reader = reinterpret_cast<USDPrimReader *>(reader);
535  usd_reader->decref();
536 
537  if (usd_reader->refcount() == 0) {
538  delete usd_reader;
539  }
540 }
541 
543  const char *filepath,
544  ListBase *object_paths)
545 {
546  /* Must call this so that USD file format plugins are loaded. */
548 
549  pxr::UsdStageRefPtr stage = pxr::UsdStage::Open(filepath);
550 
551  if (!stage) {
552  return nullptr;
553  }
554 
556 
558  convert_to_z_up(stage, &settings);
559 
560  USDStageReader *stage_reader = new USDStageReader(stage, params, settings);
561 
562  if (object_paths) {
563  gather_objects_paths(stage->GetPseudoRoot(), object_paths);
564  }
565 
566  return handle_from_stage_reader(stage_reader);
567 }
568 
570 {
571  USDStageReader *stage_reader = stage_reader_from_handle(handle);
572  delete stage_reader;
573 }
574 
575 void USD_get_transform(struct CacheReader *reader,
576  float r_mat_world[4][4],
577  float time,
578  float scale)
579 {
580  if (!reader) {
581  return;
582  }
583  USDXformReader *usd_reader = reinterpret_cast<USDXformReader *>(reader);
584 
585  bool is_constant = false;
586 
587  /* Convert from the local matrix we obtain from USD to world coordinates
588  * for Blender. This conversion is done here rather than by Blender due to
589  * work around the non-standard interpretation of CONSTRAINT_SPACE_LOCAL in
590  * BKE_constraint_mat_convertspace(). */
591  Object *object = usd_reader->object();
592  if (object->parent == nullptr) {
593  /* No parent, so local space is the same as world space. */
594  usd_reader->read_matrix(r_mat_world, time, scale, &is_constant);
595  return;
596  }
597 
598  float mat_parent[4][4];
599  BKE_object_get_parent_matrix(object, object->parent, mat_parent);
600 
601  float mat_local[4][4];
602  usd_reader->read_matrix(mat_local, time, scale, &is_constant);
603  mul_m4_m4m4(r_mat_world, mat_parent, object->parentinv);
604  mul_m4_m4m4(r_mat_world, r_mat_world, mat_local);
605 }
void * BKE_cachefile_add(struct Main *bmain, const char *name)
Definition: cachefile.c:324
struct Collection * BKE_collection_add(struct Main *bmain, struct Collection *parent, const char *name)
Definition: collection.c:425
bool BKE_collection_object_add(struct Main *bmain, struct Collection *collection, struct Object *ob)
Definition: collection.c:1125
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:713
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1100
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1074
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:723
struct LayerCollection * BKE_layer_collection_get_active(struct ViewLayer *view_layer)
Definition: layer.c:636
void BKE_main_collection_sync(const struct Main *bmain)
void BKE_layer_collection_resync_allow(void)
Definition: layer.c:766
void BKE_view_layer_base_deselect_all(struct ViewLayer *view_layer)
Definition: layer.c:388
struct Base * BKE_view_layer_base_find(struct ViewLayer *view_layer, struct Object *ob)
Definition: layer.c:379
struct LayerCollection * BKE_layer_collection_first_from_scene_collection(const struct ViewLayer *view_layer, const struct Collection *collection)
void BKE_view_layer_base_select_and_set_active(struct ViewLayer *view_layer, struct Base *selbase)
Definition: layer.c:397
void BKE_layer_collection_resync_forbid(void)
Definition: layer.c:761
void id_us_min(struct ID *id)
Definition: lib_id.c:313
void id_fake_user_set(struct ID *id)
Definition: lib_id.c:343
void BKE_id_free_us(struct Main *bmain, void *idv) ATTR_NONNULL()
const char * BKE_main_blendfile_path_from_global(void)
Definition: main.c:562
General operations, lookup, etc. for blender objects.
void BKE_object_get_parent_matrix(struct Object *ob, struct Object *par, float r_parentmat[4][4])
Definition: object.cc:3342
File and directory operations.
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
#define M_PI_2
Definition: BLI_math_base.h:23
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:259
void unit_m4(float m[4][4])
Definition: rct.c:1090
void copy_m4_m3(float m1[4][4], const float m2[3][3])
Definition: math_matrix.c:102
void axis_angle_normalized_to_mat3(float R[3][3], const float axis[3], float angle)
void BLI_path_to_display_name(char *display_name, int maxlen, const char *name) ATTR_NONNULL()
Definition: path_util.c:859
const char * BLI_path_basename(const char *path) ATTR_NONNULL() ATTR_WARN_UNUSED_RESULT
Definition: path_util.c:1653
bool BLI_path_abs(char *path, const char *basepath) ATTR_NONNULL()
Definition: path_util.c:897
#define STRNCPY(dst, src)
Definition: BLI_string.h:483
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
void DEG_id_tag_update_ex(struct Main *bmain, struct ID *id, int flag)
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
@ ID_RECALC_TRANSFORM
Definition: DNA_ID.h:771
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:834
@ ID_RECALC_ANIMATION
Definition: DNA_ID.h:794
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:791
@ ID_RECALC_BASE_FLAGS
Definition: DNA_ID.h:821
Object groups, one object can be in many groups at once.
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:25
@ WM_JOB_PROGRESS
Definition: WM_api.h:1339
@ WM_JOB_TYPE_ALEMBIC
Definition: WM_api.h:1366
#define NC_SCENE
Definition: WM_types.h:328
#define ND_FRAME
Definition: WM_types.h:382
#define ND_LAYER
Definition: WM_types.h:398
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
virtual Mesh * read_mesh(struct Mesh *existing_mesh, double motionSampleTime, int read_flag, const char **err_str)=0
virtual bool topology_changed(const Mesh *, double)
const pxr::UsdPrim & prim() const
USDPrimReader * parent() const
USDPrimReader * create_reader(const pxr::UsdPrim &prim)
const std::vector< USDPrimReader * > & readers() const
void collect_readers(struct Main *bmain)
void read_matrix(float r_mat[4][4], float time, float scale, bool *r_is_constant)
double time
EvaluationStage stage
Definition: deg_eval.cc:89
void * user_data
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
#define G(x, y, z)
static void import_endjob(void *customdata)
static USDStageReader * stage_reader_from_handle(CacheArchiveHandle *handle)
static void convert_to_z_up(pxr::UsdStageRefPtr stage, ImportSettings *r_settings)
static void import_freejob(void *user_data)
static bool gather_objects_paths(const pxr::UsdPrim &object, ListBase *object_paths)
static void report_job_duration(const ExportJobData *data)
static CacheArchiveHandle * handle_from_stage_reader(USDStageReader *reader)
void ensure_usd_plugin_path_registered()
Definition: usd_common.cc:12
static void import_startjob(void *customdata, short *stop, short *do_update, float *progress)
Clock::time_point TimePoint
Definition: BLI_timeit.hh:14
void print_duration(Nanoseconds duration)
Definition: timeit.cc:10
std::chrono::nanoseconds Nanoseconds
Definition: BLI_timeit.hh:15
char filepath[1024]
struct Collection * collection
Definition: BKE_main.h:121
float parentinv[4][4]
struct Object * parent
Definition: wm_jobs.c:57
static USDPrimReader * get_usd_reader(CacheReader *reader, Object *, const char **err_str)
struct Mesh * USD_read_mesh(struct CacheReader *reader, struct Object *ob, struct Mesh *existing_mesh, const double time, const char **err_str, const int read_flag)
void USD_CacheReader_incref(CacheReader *reader)
CacheArchiveHandle * USD_create_handle(struct Main *, const char *filepath, ListBase *object_paths)
void USD_get_transform(struct CacheReader *reader, float r_mat_world[4][4], float time, float scale)
bool USD_import(struct bContext *C, const char *filepath, const USDImportParams *params, bool as_background_job)
void USD_CacheReader_free(CacheReader *reader)
CacheReader * CacheReader_open_usd_object(CacheArchiveHandle *handle, CacheReader *reader, Object *object, const char *object_path)
void USD_free_handle(CacheArchiveHandle *handle)
bool USD_mesh_topology_changed(CacheReader *reader, Object *ob, Mesh *existing_mesh, const double time, const char **err_str)
void WM_main_add_notifier(unsigned int type, void *reference)
void WM_report(eReportType type, const char *message)
void WM_reportf(eReportType type, const char *format,...)
void WM_set_locked_interface(wmWindowManager *wm, bool lock)
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
Definition: wm_jobs.c:437
void WM_jobs_callbacks(wmJob *wm_job, wm_jobs_start_callback startjob, void(*initjob)(void *), void(*update)(void *), void(*endjob)(void *))
Definition: wm_jobs.c:351
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *))
Definition: wm_jobs.c:323
void WM_jobs_timer(wmJob *wm_job, double timestep, unsigned int note, unsigned int endnote)
Definition: wm_jobs.c:339
wmJob * WM_jobs_get(wmWindowManager *wm, wmWindow *win, const void *owner, const char *name, int flag, int job_type)
Definition: wm_jobs.c:184