Blender V5.3
blender::io::usd Namespace Reference

Namespaces

namespace  detail
namespace  usdtokens
namespace  utils

Classes

class  AbstractHierarchyIterator
class  AbstractHierarchyWriter
struct  CurveData
struct  ExportJobData
struct  ExtraLinkInfo
struct  HierarchyContext
struct  ImportJobData
struct  ImportSettings
struct  InputSpec
struct  IntermediateNode
class  MaterialImportPollInvoker
struct  NodePlacementContext
class  OnExportInvoker
class  OnImportInvoker
class  OnMaterialExportInvoker
class  OnMaterialImportInvoker
struct  PointerRNAToPython
class  USDAbstractWriter
class  USDArmatureWriter
class  USDBasisCurvesReader
class  USDCameraReader
class  USDCameraWriter
struct  USDCurveData
class  USDCurvesReader
class  USDCurvesWriter
class  USDDomeLightReader
struct  USDExporterContext
struct  USDExportParams
class  UsdExportTest
class  USDGenericMeshWriter
class  USDGeomReader
class  USDHairWriter
class  USDHierarchyIterator
struct  USDHook
class  USDHookInvoker
struct  USDImportDomeLightData
struct  USDImportParams
class  USDInstanceReader
class  USDLightReader
class  USDLightWriter
class  USDMaterialExportContext
class  USDMaterialImportContext
class  USDMaterialReader
struct  USDMeshData
struct  USDMeshReadData
class  USDMeshReader
struct  USDMeshReadParams
class  USDMeshWriter
class  USDMetaballWriter
class  USDNurbsReader
class  USDParticleFieldReader
class  USDPointInstancerReader
class  USDPointInstancerWriter
class  USDPointsReader
class  USDPointsWriter
class  USDPrimReader
class  USDSceneExportContext
class  USDSceneImportContext
class  USDShapeReader
class  USDSkeletonReader
class  USDStageCreationTest
class  USDStageReader
class  USDTextWriter
class  USDTransformWriter
class  USDVolumeReader
class  USDVolumeWriter
struct  UsdWrappedData
struct  UsdWrappedFloat
struct  UsdWrappedQuat
struct  UsdWrappedVec3
class  USDXformReader
struct  WorldToDomeLight

Typedefs

using USDHookList = std::list<std::unique_ptr<USDHook>>
using ImportedPrimMap = Map<pxr::SdfPath, Vector<PointerRNA>>
using PathMap = std::map<pxr::SdfPath, pxr::SdfPath>
using PathSet = Set<pxr::SdfPath>
using ReferencesMap = Map<pxr::SdfPath, Vector<pxr::SdfPath>>
using ShaderToNodeMap = Map<std::string, bNode *>
using ProtoReaderMap = Map<pxr::SdfPath, Vector<USDPrimReader *>>
using UsdPathSet = Set<pxr::SdfPath>
using XformResult = std::tuple<pxr::GfMatrix4f, bool>
using ObjExportMap = Map<const Object *, pxr::SdfPath>
using InputSpecMap = Map<StringRef, InputSpec>
using MaterialFaceGroups = Map<short, pxr::VtArray<int>>

Enumerations

enum  { USD_NO_ERROR = 0 , USD_ARCHIVE_FAIL }
enum class  MtlNameCollisionMode { MakeUnique = 0 , ReferenceExisting = 1 }
enum class  MtlPurpose { All = 0 , Preview = 1 , Full = 2 }
enum class  PropertyImportMode { None = 0 , User = 1 , All = 2 }
enum class  TexImportMode { None = 0 , Pack , Copy }
enum class  TexNameCollisionMode { UseExisting = 0 , Overwrite = 1 }
enum class  SubdivExportMode { Ignore = 0 , Tessellate = 1 , Match = 2 }
enum class  XformOpMode { TRS = 0 , TOS = 1 , MAT = 2 }
enum class  TextureDownscaleSize {
  Custom = -1 , Keep = 0 , Size256 = 256 , Size512 = 512 ,
  Size1024 = 1024 , Size2048 = 2048 , Size4096 = 4096
}
enum class  TexExportMode { Keep = 0 , Preserve , NewPath }
enum class  SceneUnits {
  Custom = -1 , Meters = 0 , Kilometers = 1 , Centimeters = 2 ,
  Millimeters = 3 , Inches = 4 , Feet = 5 , Yards = 6
}

Functions

FCurve * create_fcurve (animrig::Channelbag &channelbag, const animrig::FCurveDescriptor &fcurve_descriptor, const int sample_count)
void set_fcurve_sample (FCurve *fcu, int64_t sample_index, const float frame, const float value)
static void visit_bones (const Bone *bone, FunctionRef< void(const Bone *)> visitor)
const ModifierData * get_enabled_modifier (const Object &obj, ModifierType type, const Depsgraph *depsgraph)
static const ArmatureModifierData * get_armature_modifier (const Object &obj, const Depsgraph *depsgraph)
void visit_bones (const Object *ob_arm, FunctionRef< void(const Bone *)> visitor)
void get_armature_bone_names (const Object *ob_arm, const bool use_deform, Vector< StringRef > &r_names)
pxr::TfToken build_usd_joint_path (const Bone *bone, bool allow_unicode)
void create_pose_joints (pxr::UsdSkelAnimation &skel_anim, const Object &obj, const Map< StringRef, const Bone * > *deform_map, bool allow_unicode)
const Object * get_armature_modifier_obj (const Object &obj, const Depsgraph *depsgraph)
bool is_armature_modifier_bone_name (const Object &obj, const StringRefNull name, const Depsgraph *depsgraph)
bool can_export_skinned_mesh (const Object &obj, const Depsgraph *depsgraph)
void init_deform_bones_map (const Object *obj, Map< StringRef, const Bone * > *deform_map)
const pxr::TfToken BlenderBoneLengths ("blender:bone_lengths", pxr::TfToken::Immortal)
static std::pair< std::string, std::string > split_udim_pattern (const std::string &path)
static std::string get_asset_base_name (const std::string &src_path, ReportList *reports)
static std::string copy_asset_to_directory (const std::string &src_path, const char *dest_dir_path, TexNameCollisionMode name_collision_mode, ReportList *reports)
static std::string copy_udim_asset_to_directory (const std::string &src_path, const char *dest_dir_path, TexNameCollisionMode name_collision_mode, ReportList *reports)
bool copy_asset (const std::string &src, const std::string &dst, TexNameCollisionMode name_collision_mode, ReportList *reports)
bool asset_exists (const std::string &path)
std::string import_asset (const std::string &src, const char *import_dir, TexNameCollisionMode name_collision_mode, ReportList *reports)
static bool parent_dir_exists_on_file_system (const std::string &path)
bool is_udim_path (const std::string &path)
std::string get_export_textures_dir (const pxr::UsdStageRefPtr stage)
bool should_import_asset (const std::string &path)
bool paths_equal (const std::string &path1, const std::string &path2)
const char * temp_textures_dir ()
bool write_to_path (const void *data, size_t size, const std::string &path, ReportList *reports)
void ensure_usd_source_path_prop (const std::string &path, ID *id)
std::string get_usd_source_path (ID *id)
std::string get_relative_path (const std::string &path, const std::string &anchor)
void USD_path_abs (char *path, const char *basepath, bool for_import)
std::optional< pxr::SdfValueTypeName > convert_blender_type_to_usd (const bke::AttrType blender_type, bool use_color3f_type)
std::optional< bke::AttrType > convert_usd_type_to_blender (const pxr::SdfValueTypeName usd_type)
void copy_primvar_to_blender_attribute (const pxr::UsdGeomPrimvar &primvar, const pxr::UsdTimeCode time, const bke::AttrType data_type, const bke::AttrDomain domain, const OffsetIndices< int > face_indices, bke::MutableAttributeAccessor attributes)
void copy_blender_attribute_to_primvar (const GVArray &attribute, const bke::AttrType data_type, const pxr::UsdTimeCode time, const pxr::UsdGeomPrimvar &primvar, pxr::UsdUtilsSparseValueWriter &value_writer)
template<typename USDT>
void set_attribute (const pxr::UsdAttribute &attr, const USDT value, pxr::UsdTimeCode time, pxr::UsdUtilsSparseValueWriter &value_writer)
template<typename USDT>
void set_attribute (const pxr::UsdAttribute &attr, pxr::VtArray< USDT > &value, pxr::UsdTimeCode time, pxr::UsdUtilsSparseValueWriter &value_writer)
template<typename BlenderT, typename USDT>
void copy_blender_buffer_to_primvar (const VArray< BlenderT > &buffer, const pxr::UsdTimeCode time, const pxr::UsdGeomPrimvar &primvar, pxr::UsdUtilsSparseValueWriter &value_writer)
template<typename T>
pxr::VtArray< T > get_primvar_array (const pxr::UsdGeomPrimvar &primvar, const pxr::UsdTimeCode time)
void set_single_value (bke::MutableAttributeAccessor attributes, const StringRef attr_name, const bke::AttrDomain domain, const bke::AttrType data_type, const bke::AttributeInit &value)
template<typename USDT, typename BlenderT>
void copy_primvar_to_blender_buffer (const pxr::UsdGeomPrimvar &primvar, const pxr::UsdTimeCode time, const bke::AttrType data_type, const bke::AttrDomain domain, const OffsetIndices< int > faces, bke::MutableAttributeAccessor attributes)
pxr::TfToken TempBlendShapeWeightsPrimvarName ("temp:weights", pxr::TfToken::Immortal)
void ensure_blend_shape_skeleton (pxr::UsdStageRefPtr stage, pxr::UsdPrim &mesh_prim)
const Key * get_mesh_shape_key (const Object *obj)
bool is_mesh_with_shape_keys (const Object *obj)
void create_blend_shapes (pxr::UsdStageRefPtr stage, const Object *obj, const pxr::UsdPrim &mesh_prim, bool allow_unicode)
pxr::VtFloatArray get_blendshape_weights (const Key *key)
void remap_blend_shape_anim (pxr::UsdStageRefPtr stage, const pxr::SdfPath &skel_path, const pxr::SdfPathSet &mesh_paths)
Mesh * get_shape_key_basis_mesh (Object *obj)
static bool prim_path_valid (const std::string &path)
static bool export_params_valid (const USDExportParams &params)
static void ensure_root_prim (pxr::UsdStageRefPtr stage, const USDExportParams &params)
static void write_root_accessibility_information (pxr::UsdStageRefPtr stage, const USDExportParams &params)
static void report_job_duration (const ExportJobData *data)
static void process_usdz_textures (const ExportJobData *data, const char *path)
static bool perform_usdz_conversion (const ExportJobData *data)
std::string image_cache_file_path ()
std::string get_image_cache_file (const std::string &file_name, bool mkdir)
std::string cache_image_color (const float color[4])
static void collect_point_instancer_prototypes_and_set_extent (pxr::UsdGeomPointInstancer instancer, const pxr::UsdStageRefPtr &stage, const pxr::SdfPath &wrapper_path, std::vector< pxr::UsdPrim > &proto_list)
pxr::UsdStageRefPtr export_to_stage (const USDExportParams &params, Depsgraph *depsgraph, const char *filepath)
static void export_startjob (void *customdata, wmJobWorkerStatus *worker_status)
static void export_endjob_usdz_cleanup (const ExportJobData *data)
static void export_endjob (void *customdata)
static void create_temp_path_for_usdz_export (const char *filepath, io::usd::ExportJobData *job)
static void set_job_filepath (io::usd::ExportJobData *job, const char *filepath)
bool USD_export (const bContext *C, const char *filepath, const USDExportParams *params, bool as_background_job, ReportList *reports)
int USD_get_version ()
double get_meters_per_unit (const USDExportParams &params)
static CacheArchiveHandle * handle_from_stage_reader (USDStageReader *reader)
static USDStageReader * stage_reader_from_handle (CacheArchiveHandle *handle)
static bool gather_objects_paths (const pxr::UsdPrim &object, ListBaseT< CacheObjectPath > *object_paths)
static void report_job_duration (const ImportJobData *data)
static void import_startjob (void *customdata, wmJobWorkerStatus *worker_status)
static void import_endjob (void *customdata)
static void import_freejob (void *user_data)
bool USD_import (bContext *C, const char *filepath, const USDImportParams *params, bool as_background_job, ReportList *reports)
static USDPrimReader * get_usd_reader (CacheReader *reader, const Object *, const char **r_err_str)
USDMeshReadParams create_mesh_read_params (const double motion_sample_time, const int read_flags)
void USD_read_geometry (CacheReader *reader, const Object *ob, bke::GeometrySet &geometry_set, const USDMeshReadParams params, const char **r_err_str)
bool USD_mesh_topology_changed (CacheReader *reader, const Object *ob, const Mesh *existing_mesh, const double time, const char **r_err_str)
CacheReader * CacheReader_open_usd_object (CacheArchiveHandle *handle, CacheReader *reader, Object *object, const char *object_path)
void USD_CacheReader_free (CacheReader *reader)
CacheArchiveHandle * USD_create_handle (Main *, const char *filepath, ListBaseT< CacheObjectPath > *object_paths)
void USD_free_handle (CacheArchiveHandle *handle)
void USD_get_transform (CacheReader *reader, float4x4 &r_mat_world, float time, float scale)
pxr::TfToken colorspace_scene_linear_interop_id ()
void colorspace_apply_to_prim (const pxr::UsdPrim &prim)
static const ColorSpace * colorspace_from_attr (const pxr::UsdAttribute &attr)
void colorspace_attr_to_scene_linear (const pxr::UsdAttribute &attr, pxr::GfVec3f &color)
void colorspace_attr_to_scene_linear (const pxr::UsdAttribute &attr, ColorGeometry4f &color)
void colorspace_attr_to_scene_linear (const pxr::UsdAttribute &attr, MutableSpan< ColorGeometry4f > colors)
static pxr::TfToken get_source_color_space (const pxr::UsdShadeShader &usd_shader)
void colorspace_to_image_texture (const pxr::UsdShadeShader &usd_shader, const pxr::UsdShadeInput &file_input, const bool is_data, Image *image)
void colorspace_from_image_texture (const Image *image, pxr::UsdShadeShader &shader)
static USDHookList & hook_list ()
void USD_register_hook (std::unique_ptr< USDHook > hook)
void USD_unregister_hook (const USDHook *hook)
USDHook * USD_find_hook_name (const char idname[])
void register_hook_converters ()
static void handle_python_error (USDHook *hook, ReportList *reports)
void call_export_hooks (Depsgraph *depsgraph, const USDHierarchyIterator *iter, ReportList *reports)
void call_material_export_hooks (pxr::UsdStageRefPtr stage, const Material *material, const pxr::UsdShadeMaterial &usd_material, const USDExportParams &export_params, ReportList *reports)
void call_import_hooks (USDStageReader *archive, ReportList *reports)
bool have_material_import_hook (pxr::UsdStageRefPtr stage, const pxr::UsdShadeMaterial &usd_material, const USDImportParams &import_params, ReportList *reports)
bool call_material_import_hooks (pxr::UsdStageRefPtr stage, Material *material, const pxr::UsdShadeMaterial &usd_material, const USDImportParams &import_params, ReportList *reports)
static void convert_proto_to_instance (pxr::UsdStageRefPtr stage, const pxr::SdfPath &proto_path, const pxr::SdfPath &ref_path)
void process_scene_graph_instances (const USDExportParams &export_params, pxr::UsdStageRefPtr stage)
static Image * load_image (std::string tex_path, Main *bmain, const USDImportParams &params)
static bNode * append_node (bNode *dst_node, int new_node_type, const StringRef out_sock, const StringRef in_sock, bNodeTree *ntree, float offset)
void world_material_to_dome_light (const USDExportParams &params, const Scene *scene, pxr::UsdStageRefPtr stage)
void dome_light_to_world_material (const USDImportParams &params, Scene *scene, Main *bmain, const USDImportDomeLightData &dome_light_data, const pxr::UsdPrim &prim, const pxr::UsdTimeCode time)
static bool node_search (bNode *fromnode, bNode *, void *userdata, bool)
void world_material_to_dome_light (const Scene *scene, WorldToDomeLight &res)
template<typename USDT>
static void read_face_display_color (Mesh *mesh, const pxr::UsdGeomPrimvar &primvar, const pxr::TfToken &pv_name, const pxr::UsdTimeCode time)
static std::optional< bke::AttrDomain > convert_usd_varying_to_blender (const pxr::TfToken usd_domain)
void read_generic_mesh_primvar (Mesh *mesh, const pxr::UsdGeomPrimvar &primvar, const pxr::UsdTimeCode time, const bool is_left_handed)
static float3 to_float3 (pxr::GfVec3f vec3f)
static int bezier_point_count (int usd_count, bool is_cyclic)
static int point_count (int usdCount, CurveType curve_type, bool is_cyclic)
static Array< int > calc_curve_offsets (const pxr::VtIntArray &usdCounts, const CurveType curve_type, bool is_cyclic)
static void add_bezier_control_point (int cp, int offset, MutableSpan< float3 > positions, MutableSpan< float3 > handles_left, MutableSpan< float3 > handles_right, const Span< pxr::GfVec3f > usdPoints)
static bool curves_topology_changed (const bke::CurvesGeometry &curves, const Span< int > usd_offsets)
static CurveType get_curve_type (pxr::TfToken type, pxr::TfToken basis)
static std::optional< bke::AttrDomain > convert_usd_interp_to_blender (const pxr::TfToken usd_domain)
template<typename T>
static bool get_authored_value (const pxr::UsdAttribute &attr, const pxr::UsdTimeCode time, const pxr::UsdPrim &prim, const pxr::TfToken fallback_attr_name, T *r_value)
template<typename T>
static float get_intensity (const T &dome_light, const pxr::UsdTimeCode time)
template<typename T>
static bool get_tex_path (const T &dome_light, const pxr::UsdTimeCode time, pxr::SdfAssetPath *tex_path)
template<typename T>
static bool get_color (const T &dome_light, const pxr::UsdTimeCode time, pxr::GfVec3f *color)
static pxr::TfToken get_pole_axis (const pxr::UsdLuxDomeLight_1 &dome_light, const pxr::UsdTimeCode time)
static IntermediateNode add_normal_map (bNodeTree *ntree, int column, NodePlacementContext &ctx)
static IntermediateNode add_scale_bias (const pxr::UsdShadeShader &usd_shader, bNodeTree *ntree, int column, bool feeds_normal_map, NodePlacementContext &ctx)
static IntermediateNode add_scale_bias_adjust (bNodeTree *ntree, int column, NodePlacementContext &ctx)
static IntermediateNode add_separate_color (const pxr::UsdShadeShader &usd_shader, const pxr::TfToken &usd_source_name, bNodeTree *ntree, int column, NodePlacementContext &ctx)
static IntermediateNode add_lessthan (bNodeTree *ntree, float threshold, int column, NodePlacementContext &ctx)
static IntermediateNode add_oneminus (bNodeTree *ntree, int column, NodePlacementContext &ctx)
static void configure_displacement (const pxr::UsdShadeShader &usd_shader, bNode *displacement_node)
static pxr::UsdShadeShader node_graph_output_source (const pxr::UsdShadeNodeGraph &node_graph, const pxr::TfToken &output_name)
void build_material_map (const Main *bmain, Map< std::string, Material * > &r_mat_map)
Material * find_existing_material (const pxr::SdfPath &usd_mat_path, const USDImportParams &params, const Map< std::string, Material * > &mat_map, const Map< pxr::SdfPath, Material * > &usd_path_to_mat)
static KnotsMode determine_knots_mode (const Span< double > usd_knots, const int order, const bool is_cyclic)
static CurveData calc_curve_offsets (const Span< float3 > usd_points, const Span< int > usd_counts, const Span< int > usd_orders, const Span< double > usd_knots)
static bool curves_topology_changed (const bke::CurvesGeometry &curves, const Span< int > usd_offsets)
static IndexRange get_usd_points_range_de_dup (IndexRange blender_points_range, IndexRange usd_points_range)
static bNode * add_input_named_attrib_node (bNodeTree *ntree, const char *name, int8_t prop_type)
static void decref (USDPrimReader *reader)
static Collection * create_collection (Main *bmain, Collection *parent, const char *name)
static void set_instance_collection (USDInstanceReader *instance_reader, const Map< pxr::SdfPath, Collection * > &proto_collection_map)
static void convert_to_z_up (pxr::UsdStageRefPtr stage, ImportSettings &settings)
static void find_prefix_to_skip (pxr::UsdStageRefPtr stage, ImportSettings &settings)
static void determine_blender_compat (pxr::UsdStageRefPtr stage, ImportSettings &settings)
static void set_string_prop (IDProperty *idgroup, const StringRefNull prop_name, const StringRefNull str_val)
static void set_int_prop (IDProperty *idgroup, const StringRefNull prop_name, const int ival)
static void set_bool_prop (IDProperty *idgroup, const StringRefNull prop_name, const bool bval)
static void set_float_prop (IDProperty *idgroup, const StringRefNull prop_name, const float fval)
static void set_double_prop (IDProperty *idgroup, const StringRefNull prop_name, const double dval)
static void set_accessibility_property (const pxr::UsdAttribute &attr, IDProperty *idgroup, const pxr::UsdTimeCode time_code)
void set_id_props_from_prim (ID *id, const pxr::UsdPrim &prim, const PropertyImportMode property_import_mode, const pxr::UsdTimeCode time_code)
void import_blendshapes (Main *bmain, Object *mesh_obj, const pxr::UsdPrim &prim, ReportList *reports, const bool import_anim)
static void set_rest_pose (Main *bmain, Object *arm_obj, bArmature *arm, const pxr::VtArray< pxr::GfMatrix4d > &bind_xforms, const pxr::VtTokenArray &joint_order, const Map< pxr::TfToken, std::string > &joint_to_bone_map, const pxr::UsdSkelTopology &skel_topology, const pxr::UsdSkelSkeletonQuery &skel_query)
void import_skeleton (Main *bmain, Object *arm_obj, const pxr::UsdSkelSkeleton &skel, ReportList *reports, const bool import_anim)
void import_mesh_skel_bindings (Object *mesh_obj, const pxr::UsdPrim &prim, ReportList *reports)
void skel_export_chaser (pxr::UsdStageRefPtr stage, const ObjExportMap &armature_export_map, const ObjExportMap &skinned_mesh_export_map, const ObjExportMap &shape_key_mesh_export_map, const Depsgraph *depsgraph)
void skinned_mesh_export_chaser (pxr::UsdStageRefPtr stage, const ObjExportMap &armature_export_map, const ObjExportMap &skinned_mesh_export_map, pxr::UsdGeomXformCache &xf_cache, const Depsgraph *depsgraph)
void shape_key_export_chaser (pxr::UsdStageRefPtr stage, const ObjExportMap &shape_key_mesh_export_map)
void export_deform_verts (const Mesh *mesh, const pxr::UsdSkelBindingAPI &skel_api, const Span< StringRef > bone_names)
void create_skel_roots (pxr::UsdStageRefPtr stage, const USDExportParams &params)
static bool is_safe_char (const pxr::TfUtf8CodePoint cp, bool is_first, bool allow_unicode)
static std::string make_safe_identifier (const StringRef name, bool allow_unicode)
std::string make_safe_name (const StringRef name, bool allow_unicode)
std::string make_safe_primvar_name (const StringRef name, bool allow_unicode)
pxr::SdfPath get_unique_path (pxr::UsdStageRefPtr stage, const std::string &path)
static void create_vector_attrib (const pxr::UsdPrim &prim, const IDProperty *prop, const pxr::TfToken &prop_token, const pxr::UsdTimeCode &time)
static void add_anim_sample (pxr::UsdSkelAnimation &skel_anim, const Object *obj, const pxr::UsdTimeCode time, const Map< StringRef, const Bone * > *deform_map, pxr::UsdUtilsSparseValueWriter &value_writer)
static void camera_sensor_size_for_render (const Camera *camera, const RenderData *rd, float *r_sensor, float *r_sensor_x, float *r_sensor_y)
static void populate_curve_widths (const bke::CurvesGeometry &curves, pxr::VtArray< float > &widths)
static pxr::TfToken get_curve_width_interpolation (const pxr::VtArray< float > &widths, const pxr::VtArray< int > &segments, const pxr::VtIntArray &control_point_counts, const bool is_cyclic, ReportList *reports)
static void populate_curve_verts (const bke::CurvesGeometry &curves, const Span< float3 > positions, pxr::VtArray< pxr::GfVec3f > &verts, pxr::VtIntArray &control_point_counts, pxr::VtArray< int > &segments, const bool is_cyclic, const bool is_cubic)
static void populate_curve_props (const bke::CurvesGeometry &curves, pxr::VtArray< pxr::GfVec3f > &verts, pxr::VtIntArray &control_point_counts, pxr::VtArray< float > &widths, pxr::TfToken &interpolation, const bool is_cyclic, const bool is_cubic, ReportList *reports)
static void populate_curve_verts_for_bezier (const bke::CurvesGeometry &curves, const Span< float3 > positions, const Span< float3 > handles_l, const Span< float3 > handles_r, pxr::VtArray< pxr::GfVec3f > &verts, pxr::VtIntArray &control_point_counts, pxr::VtArray< int > &segments, const bool is_cyclic)
static void populate_curve_props_for_bezier (const bke::CurvesGeometry &curves, pxr::VtArray< pxr::GfVec3f > &verts, pxr::VtIntArray &control_point_counts, pxr::VtArray< float > &widths, pxr::TfToken &interpolation, const bool is_cyclic, ReportList *reports)
static void populate_curve_props_for_nurbs (const bke::CurvesGeometry &curves, pxr::VtArray< pxr::GfVec3f > &verts, pxr::VtIntArray &control_point_counts, pxr::VtArray< float > &widths, pxr::VtArray< double > &knots, pxr::VtArray< double > &weights, pxr::VtArray< int > &orders, pxr::TfToken &interpolation, const bool is_cyclic)
static std::optional< pxr::TfToken > convert_blender_domain_to_usd (const bke::AttrDomain blender_domain, bool is_bezier)
static bool is_excluded_attr (StringRefNull name)
static pxr::UsdShadeShader create_usd_preview_shader (const USDExporterContext &usd_export_context, const pxr::UsdShadeMaterial &material, const StringRef name, int type)
static pxr::UsdShadeShader create_usd_preview_shader (const USDExporterContext &usd_export_context, const pxr::UsdShadeMaterial &material, const bNode *node)
static pxr::UsdShadeShader create_primvar_reader_shader (const USDExporterContext &usd_export_context, const pxr::UsdShadeMaterial &material, const pxr::TfToken &primvar_type, const bNode *node)
static void create_uv_input (const USDExporterContext &usd_export_context, const bNodeSocket *input_socket, pxr::UsdShadeMaterial &usd_material, pxr::UsdShadeInput &usd_input, const std::string &active_uvmap_name, ReportList *reports)
static void export_texture (const USDExporterContext &usd_export_context, bNode *node)
static bNode * find_bsdf_node (const Material *material)
static bNode * find_displacement_node (const Material *material)
static void get_absolute_path (const Image *ima, char *r_path)
static std::string get_tex_image_asset_filepath (const USDExporterContext &usd_export_context, const bNode *node)
static const InputSpecMap & preview_surface_input_map ()
static const bNodeLink * traverse_channel (const bNodeSocket *input, short target_type)
void set_transmission_opacity_range (pxr::UsdShadeShader &usd_shader, const InputSpec &input_spec, const pxr::TfToken &source_name)
void set_normal_texture_range (pxr::UsdShadeShader &usd_shader, const InputSpec &input_spec)
template<typename T>
void create_input (pxr::UsdShadeShader &shader, const InputSpec &spec, const T &value, float scale)
static void set_scale_bias (pxr::UsdShadeShader &usd_shader, const pxr::GfVec4f scale, const pxr::GfVec4f bias)
static void process_inputs (const USDExporterContext &usd_export_context, pxr::UsdShadeMaterial &usd_material, pxr::UsdShadeShader &shader, const bNode *node, const std::string &active_uvmap_name, ReportList *reports)
static void create_usd_preview_surface_material (const USDExporterContext &usd_export_context, const Material *material, pxr::UsdShadeMaterial &usd_material, const std::string &active_uvmap_name, ReportList *reports)
void create_usd_viewport_material (const USDExporterContext &usd_export_context, const Material *material, const pxr::UsdShadeMaterial &usd_material)
static void create_uvmap_shader (const USDExporterContext &usd_export_context, const bNodeLink *uvmap_link, const pxr::UsdShadeMaterial &usd_material, const pxr::UsdShadeInput &usd_input, const std::string &active_uvmap_name, ReportList *reports)
static void create_transform2d_shader (const USDExporterContext &usd_export_context, const bNodeLink *mapping_link, pxr::UsdShadeMaterial &usd_material, pxr::UsdShadeInput &usd_input, const std::string &uvmap_name, ReportList *reports)
static bool has_generated_tiles (const Image *ima)
static bool is_in_memory_texture (Image *ima)
static bool is_packed_texture (const Image *ima)
static std::string get_in_memory_texture_filename (Image *ima)
static void export_in_memory_imbuf (ImBuf *imbuf, const std::string &export_dir, const char image_abs_path[FILE_MAX], const char file_name[FILE_MAX], const bool allow_overwrite, ReportList *reports)
static void export_in_memory_texture (Image *ima, const std::string &export_dir, const bool allow_overwrite, ReportList *reports)
static void export_packed_texture (const Image *ima, const std::string &export_dir, const bool allow_overwrite, ReportList *reports)
static pxr::TfToken get_node_tex_image_wrap (const bNode *node)
static std::string get_tex_image_asset_filepath (const Image *ima)
std::string get_tex_image_asset_filepath (Image *ima, const pxr::UsdStageRefPtr stage, const USDExportParams &export_params)
std::string get_tex_image_asset_filepath (const std::string &path, const std::string &stage_path, const USDExportParams &export_params)
std::string get_tex_image_asset_filepath (const bNode *node, const pxr::UsdStageRefPtr stage, const USDExportParams &export_params)
static void copy_tiled_textures (const Image *ima, const std::string &dest_dir, const bool allow_overwrite, ReportList *reports)
static void copy_single_file (const Image *ima, const std::string &dest_dir, const bool allow_overwrite, ReportList *reports)
void export_texture (Image *ima, const pxr::UsdStageRefPtr stage, const bool allow_overwrite, ReportList *reports)
void export_texture (bNode *node, const pxr::UsdStageRefPtr stage, const bool allow_overwrite, ReportList *reports)
pxr::TfToken token_for_input (const StringRef input_name)
pxr::UsdShadeMaterial create_usd_material (const USDExporterContext &usd_export_context, pxr::SdfPath usd_path, const Material *material, const std::string &active_uvmap_name, ReportList *reports)
static const SubsurfModifierData * get_last_subdiv_modifier (eEvaluationMode eval_mode, Object *obj)
static std::optional< pxr::TfToken > convert_blender_domain_to_usd (const bke::AttrDomain blender_domain)
static void get_positions (const Mesh *mesh, USDMeshData &usd_mesh_data)
static void get_loops_polys (const Mesh *mesh, USDMeshData &usd_mesh_data)
static void get_edge_creases (const Mesh *mesh, USDMeshData &usd_mesh_data)
static void get_vert_creases (const Mesh *mesh, USDMeshData &usd_mesh_data)
template<typename T>
static pxr::VtArray< T > DuplicateArray (const pxr::VtArray< T > &original, size_t copies)
template<typename T, typename GetterFunc, typename CreatorFunc>
static void DuplicatePerInstanceAttribute (const GetterFunc &getter, const CreatorFunc &creator, size_t copies, const pxr::UsdTimeCode &time)
template<typename T, typename GetterFunc, typename CreatorFunc>
static void ExpandAttributePerInstance (const GetterFunc &getter, const CreatorFunc &creator, const Span< std::pair< int, int > > instance_object_map, const pxr::UsdTimeCode &time)
static std::optional< pxr::TfToken > convert_blender_domain_to_usd (const bke::AttrDomain blender_domain)
static bool has_varying_modifiers (const Object *ob)
static const bNode * find_node_for_type_in_graph (const bNodeTree *nodetree, const UString type_idname)
 TEST_F (UsdExportTest, usd_export_rain_mesh)
 TEST_F (UsdExportTest, usd_export_material)
 TEST (utilities, make_safe_name)
 TEST (utilities, make_safe_primvar_name)
 TEST_F (USDStageCreationTest, JSONFileLoadingTest)

Variables

constexpr char UDIM_PATTERN [] = "<UDIM>"
constexpr char UDIM_PATTERN2 [] = "%3CUDIM%3E"
constexpr int UDIM_START_TILE = 1001
constexpr int UDIM_END_TILE = 1100
pxr::TfToken TempBlendShapeWeightsPrimvarName
static CLG_LogRef LOG = {"io.usd"}
const StringRefNull simple_scene_filename = "usd/usd_simple_scene.blend"
const StringRefNull materials_filename = "usd/usd_materials_export.blend"
const StringRefNull output_filename = "output.usd"

Typedef Documentation

◆ ImportedPrimMap

Definition at line 51 of file usd_hook.cc.

◆ InputSpecMap

◆ MaterialFaceGroups

using blender::io::usd::MaterialFaceGroups = Map<short, pxr::VtArray<int>>

Definition at line 25 of file usd_writer_mesh.hh.

◆ ObjExportMap

using blender::io::usd::ObjExportMap = Map<const Object *, pxr::SdfPath>

Map an object to its USD prim export path.

Definition at line 85 of file usd_skel_convert.hh.

◆ PathMap

using blender::io::usd::PathMap = std::map<pxr::SdfPath, pxr::SdfPath>

Definition at line 30 of file usd_instancing_utils.cc.

◆ PathSet

using blender::io::usd::PathSet = Set<pxr::SdfPath>

Definition at line 31 of file usd_instancing_utils.cc.

◆ ProtoReaderMap

Map a USD prototype prim path to the list of readers that convert the prototype data.

Definition at line 30 of file usd_reader_stage.hh.

◆ ReferencesMap

using blender::io::usd::ReferencesMap = Map<pxr::SdfPath, Vector<pxr::SdfPath>>

Definition at line 34 of file usd_instancing_utils.cc.

◆ ShaderToNodeMap

using blender::io::usd::ShaderToNodeMap = Map<std::string, bNode *>

Definition at line 27 of file usd_reader_material.hh.

◆ USDHookList

using blender::io::usd::USDHookList = std::list<std::unique_ptr<USDHook>>

Definition at line 50 of file usd_hook.cc.

◆ UsdPathSet

using blender::io::usd::UsdPathSet = Set<pxr::SdfPath>

Definition at line 32 of file usd_reader_stage.hh.

◆ XformResult

using blender::io::usd::XformResult = std::tuple<pxr::GfMatrix4f, bool>

A transformation matrix and a boolean indicating whether the matrix is constant over time.

Definition at line 26 of file usd_reader_xform.hh.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
USD_NO_ERROR 
USD_ARCHIVE_FAIL 

Definition at line 91 of file usd_capi_import.cc.

◆ MtlNameCollisionMode

Behavior when the name of an imported material conflicts with an existing material.

Enumerator
MakeUnique 
ReferenceExisting 

Definition at line 29 of file usd.hh.

◆ MtlPurpose

enum class blender::io::usd::MtlPurpose
strong
Enumerator
All 
Preview 
Full 

Definition at line 37 of file usd.hh.

◆ PropertyImportMode

Behavior for importing of custom attributes / properties outside a prim's regular schema.

Enumerator
None 
User 
All 

Definition at line 44 of file usd.hh.

◆ SceneUnits

enum class blender::io::usd::SceneUnits
strong
Enumerator
Custom 
Meters 
Kilometers 
Centimeters 
Millimeters 
Inches 
Feet 
Yards 

Definition at line 106 of file usd.hh.

◆ SubdivExportMode

Enumerator
Ignore 

Subdivision scheme = None, export base mesh without subdivision.

Tessellate 

Subdivision scheme = None, export subdivided mesh.

Match 

Apply the USD subdivision scheme that is the closest match to Blender. Reverts to #SubdivExportMode::Tessellate if the subdivision method is not supported.

Definition at line 69 of file usd.hh.

◆ TexExportMode

Behavior when exporting textures.

Enumerator
Keep 
Preserve 
NewPath 

Definition at line 100 of file usd.hh.

◆ TexImportMode

Behavior when importing textures from a package (e.g., USDZ archive) or from a URI path.

Enumerator
None 
Pack 
Copy 

Definition at line 54 of file usd.hh.

◆ TexNameCollisionMode

Behavior when the name of an imported texture file conflicts with an existing file.

Enumerator
UseExisting 
Overwrite 

Definition at line 64 of file usd.hh.

◆ TextureDownscaleSize

Enumerator
Custom 
Keep 
Size256 
Size512 
Size1024 
Size2048 
Size4096 

Definition at line 87 of file usd.hh.

◆ XformOpMode

enum class blender::io::usd::XformOpMode
strong
Enumerator
TRS 
TOS 
MAT 

Definition at line 81 of file usd.hh.

Function Documentation

◆ add_anim_sample()

void blender::io::usd::add_anim_sample ( pxr::UsdSkelAnimation & skel_anim,
const Object * obj,
const pxr::UsdTimeCode time,
const Map< StringRef, const Bone * > * deform_map,
pxr::UsdUtilsSparseValueWriter & value_writer )
static

◆ add_bezier_control_point()

void blender::io::usd::add_bezier_control_point ( int cp,
int offset,
MutableSpan< float3 > positions,
MutableSpan< float3 > handles_left,
MutableSpan< float3 > handles_right,
const Span< pxr::GfVec3f > usdPoints )
static

◆ add_input_named_attrib_node()

◆ add_lessthan()

◆ add_normal_map()

◆ add_oneminus()

◆ add_scale_bias()

◆ add_scale_bias_adjust()

◆ add_separate_color()

◆ append_node()

bNode * blender::io::usd::append_node ( bNode * dst_node,
int new_node_type,
const StringRef out_sock,
const StringRef in_sock,
bNodeTree * ntree,
float offset )
static

◆ asset_exists()

bool blender::io::usd::asset_exists ( const std::string & path)

Invoke the USD asset resolver to determine if the asset with the given path exists.

Parameters
paththe path to resolve
Returns
true if the asset exists, false otherwise

Definition at line 272 of file usd_asset_utils.cc.

References asset_exists().

Referenced by asset_exists(), copy_udim_asset_to_directory(), export_packed_texture(), and should_import_asset().

◆ bezier_point_count()

int blender::io::usd::bezier_point_count ( int usd_count,
bool is_cyclic )
inlinestatic

◆ BlenderBoneLengths()

◆ build_material_map()

void blender::io::usd::build_material_map ( const Main * bmain,
Map< std::string, Material * > & r_mat_map )

Returns a map containing all the Blender materials which allows a fast lookup of the material by name. Note that the material name key might be modified to be a valid USD identifier, to match material names in the imported USD.

Definition at line 1546 of file usd_reader_material.cc.

References blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add_new(), BLI_assert_msg, build_material_map(), blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::is_empty(), and blender::Main::materials.

Referenced by build_material_map(), and blender::io::usd::USDStageReader::import_all_materials().

◆ build_usd_joint_path()

pxr::TfToken blender::io::usd::build_usd_joint_path ( const Bone * bone,
bool allow_unicode )

Return the USD joint path corresponding to the given bone. For example, for the bone "Hand", this function might return the full path "Shoulder/Elbow/Hand" of the joint in the hierarchy.

Parameters
boneThe bone whose path will be queried.
allow_unicodeWhether to allow unicode bone names to be used
Returns
The path to the joint.

Definition at line 131 of file usd_armature_utils.cc.

References build_usd_joint_path(), make_safe_name(), blender::Bone::name, and blender::Bone::parent.

Referenced by BlenderBoneLengths(), build_usd_joint_path(), create_pose_joints(), and blender::initialize().

◆ cache_image_color()

◆ CacheReader_open_usd_object()

◆ calc_curve_offsets() [1/2]

Array< int > blender::io::usd::calc_curve_offsets ( const pxr::VtIntArray & usdCounts,
const CurveType curve_type,
bool is_cyclic )
static

◆ calc_curve_offsets() [2/2]

◆ call_export_hooks()

void blender::io::usd::call_export_hooks ( Depsgraph * depsgraph,
const USDHierarchyIterator * iter,
ReportList * reports )

Call the 'on_export' chaser function defined in the registered USDHook classes.

Definition at line 594 of file usd_hook.cc.

References blender::io::usd::USDHookInvoker::call(), call_export_hooks(), and hook_list().

Referenced by call_export_hooks(), and export_to_stage().

◆ call_import_hooks()

◆ call_material_export_hooks()

void blender::io::usd::call_material_export_hooks ( pxr::UsdStageRefPtr stage,
const Material * material,
const pxr::UsdShadeMaterial & usd_material,
const USDExportParams & export_params,
ReportList * reports )

Call the 'on_material_export' hook functions defined in the registered USDHook classes.

Definition at line 604 of file usd_hook.cc.

References blender::io::usd::USDHookInvoker::call(), call_material_export_hooks(), and hook_list().

Referenced by call_material_export_hooks(), and create_usd_material().

◆ call_material_import_hooks()

bool blender::io::usd::call_material_import_hooks ( pxr::UsdStageRefPtr stage,
Material * material,
const pxr::UsdShadeMaterial & usd_material,
const USDImportParams & import_params,
ReportList * reports )

Call the 'on_material_import' hook functions defined in the registered USDHook classes. Returns true if any of the hooks were successful, false otherwise.

Definition at line 667 of file usd_hook.cc.

References blender::io::usd::USDHookInvoker::call(), call_material_import_hooks(), hook_list(), and blender::io::usd::OnMaterialImportInvoker::result().

Referenced by call_material_import_hooks(), and blender::io::usd::USDStageReader::call_material_import_hooks().

◆ camera_sensor_size_for_render()

◆ can_export_skinned_mesh()

bool blender::io::usd::can_export_skinned_mesh ( const Object & obj,
const Depsgraph * depsgraph )

Query whether exporting a skinned mesh is supported for the given object. Currently, the object can be exported as a skinned mesh if it has an enabled armature modifier and no other enabled modifiers.

Parameters
objObject to query
depsgraphThe dependency graph where the object was evaluated
Returns
True if skinned mesh export is supported, false otherwise.

Definition at line 194 of file usd_armature_utils.cc.

References can_export_skinned_mesh(), blender::eModifierType_Armature, and get_enabled_modifier().

Referenced by BlenderBoneLengths(), can_export_skinned_mesh(), and blender::io::usd::USDMeshWriter::set_skel_export_flags().

◆ collect_point_instancer_prototypes_and_set_extent()

void blender::io::usd::collect_point_instancer_prototypes_and_set_extent ( pxr::UsdGeomPointInstancer instancer,
const pxr::UsdStageRefPtr & stage,
const pxr::SdfPath & wrapper_path,
std::vector< pxr::UsdPrim > & proto_list )
static

◆ colorspace_apply_to_prim()

◆ colorspace_attr_to_scene_linear() [1/3]

void blender::io::usd::colorspace_attr_to_scene_linear ( const pxr::UsdAttribute & attr,
ColorGeometry4f & color )

◆ colorspace_attr_to_scene_linear() [2/3]

void blender::io::usd::colorspace_attr_to_scene_linear ( const pxr::UsdAttribute & attr,
MutableSpan< ColorGeometry4f > colors )

◆ colorspace_attr_to_scene_linear() [3/3]

◆ colorspace_from_attr()

◆ colorspace_from_image_texture()

◆ colorspace_scene_linear_interop_id()

◆ colorspace_to_image_texture()

◆ configure_displacement()

void blender::io::usd::configure_displacement ( const pxr::UsdShadeShader & usd_shader,
bNode * displacement_node )
static

◆ convert_blender_domain_to_usd() [1/3]

std::optional< pxr::TfToken > blender::io::usd::convert_blender_domain_to_usd ( const bke::AttrDomain blender_domain)
static

◆ convert_blender_domain_to_usd() [2/3]

std::optional< pxr::TfToken > blender::io::usd::convert_blender_domain_to_usd ( const bke::AttrDomain blender_domain)
static

Definition at line 64 of file usd_writer_points.cc.

References convert_blender_domain_to_usd(), and blender::bke::Point.

◆ convert_blender_domain_to_usd() [3/3]

std::optional< pxr::TfToken > blender::io::usd::convert_blender_domain_to_usd ( const bke::AttrDomain blender_domain,
bool is_bezier )
static

◆ convert_blender_type_to_usd()

std::optional< pxr::SdfValueTypeName > blender::io::usd::convert_blender_type_to_usd ( const bke::AttrType blender_type,
bool use_color3f_type )

◆ convert_proto_to_instance()

void blender::io::usd::convert_proto_to_instance ( pxr::UsdStageRefPtr stage,
const pxr::SdfPath & proto_path,
const pxr::SdfPath & ref_path )
static

◆ convert_to_z_up()

void blender::io::usd::convert_to_z_up ( pxr::UsdStageRefPtr stage,
ImportSettings & settings )
static

◆ convert_usd_interp_to_blender()

◆ convert_usd_type_to_blender()

◆ convert_usd_varying_to_blender()

◆ copy_asset()

bool blender::io::usd::copy_asset ( const std::string & src,
const std::string & dst,
TexNameCollisionMode name_collision_mode,
ReportList * reports )

Invoke the USD asset resolver to copy an asset.

Parameters
srcsource path of the asset to copy
dstdestination path of the copy
name_collision_modebehavior when dst already exists
reportsthe storage for potential warning or error reports (generated using BKE_report API).
Returns
true if the copy succeeded, false otherwise

Definition at line 156 of file usd_asset_utils.cc.

References blender::BKE_reportf(), copy_asset(), Overwrite, blender::RPT_ERROR, blender::RPT_INFO, and blender::RPT_WARNING.

Referenced by copy_asset(), and copy_asset_to_directory().

◆ copy_asset_to_directory()

std::string blender::io::usd::copy_asset_to_directory ( const std::string & src_path,
const char * dest_dir_path,
TexNameCollisionMode name_collision_mode,
ReportList * reports )
static

◆ copy_blender_attribute_to_primvar()

void blender::io::usd::copy_blender_attribute_to_primvar ( const GVArray & attribute,
const bke::AttrType data_type,
const pxr::UsdTimeCode time,
const pxr::UsdGeomPrimvar & primvar,
pxr::UsdUtilsSparseValueWriter & value_writer )

◆ copy_blender_buffer_to_primvar()

template<typename BlenderT, typename USDT>
void blender::io::usd::copy_blender_buffer_to_primvar ( const VArray< BlenderT > & buffer,
const pxr::UsdTimeCode time,
const pxr::UsdGeomPrimvar & primvar,
pxr::UsdUtilsSparseValueWriter & value_writer )

◆ copy_primvar_to_blender_attribute()

◆ copy_primvar_to_blender_buffer()

◆ copy_single_file()

void blender::io::usd::copy_single_file ( const Image * ima,
const std::string & dest_dir,
const bool allow_overwrite,
ReportList * reports )
static

◆ copy_tiled_textures()

◆ copy_udim_asset_to_directory()

std::string blender::io::usd::copy_udim_asset_to_directory ( const std::string & src_path,
const char * dest_dir_path,
TexNameCollisionMode name_collision_mode,
ReportList * reports )
static

◆ create_blend_shapes()

void blender::io::usd::create_blend_shapes ( pxr::UsdStageRefPtr stage,
const Object * obj,
const pxr::UsdPrim & mesh_prim,
bool allow_unicode )

Convert shape keys on the given object to USD blend shapes. The blend-shapes will be added to the stage as children of the given USD mesh prim. The blend-shape names and targets will also be set as properties on the primitive.

Parameters
stageThe stage
objThe mesh object whose shape keys will be converted to blend shapes
mesh_primThe USD mesh that will be assigned the blend shape targets
allow_unicodeWhether to allow unicode encoded characters in the blend shape name

Definition at line 195 of file usd_blend_shape_utils.cc.

References blender::Key::block, CLOG_WARN, create_blend_shapes(), blender::data, blender::KeyBlock::data, float, get_mesh_shape_key(), blender::LOG, make_safe_name(), blender::KeyBlock::name, blender::sub_v3_v3v3(), and blender::KeyBlock::totelem.

Referenced by create_blend_shapes(), and blender::io::usd::USDMeshWriter::init_blend_shapes().

◆ create_collection()

Collection * blender::io::usd::create_collection ( Main * bmain,
Collection * parent,
const char * name )
static

Create a collection with the given parent and name.

Definition at line 92 of file usd_reader_stage.cc.

References blender::BKE_collection_add(), and create_collection().

Referenced by create_collection(), and blender::io::usd::USDStageReader::create_proto_collections().

◆ create_fcurve()

◆ create_input()

template<typename T>
void blender::io::usd::create_input ( pxr::UsdShadeShader & shader,
const InputSpec & spec,
const T & value,
float scale )

◆ create_mesh_read_params()

◆ create_pose_joints()

void blender::io::usd::create_pose_joints ( pxr::UsdSkelAnimation & skel_anim,
const Object & obj,
const Map< StringRef, const Bone * > * deform_map,
bool allow_unicode )

Sets the USD joint paths as an attribute on the given USD animation, where the paths correspond to the bones of the given armature.

Parameters
skel_animThe animation whose joints attribute will be set
objThe armature object
deform_mapA pointer to a map associating bone names with deform bones and their parents. If the pointer is not null, assume only deform bones are to be exported and bones not found in this map will be skipped
allow_unicodeWhether to allow unicode bone names to be used

Definition at line 144 of file usd_armature_utils.cc.

References blender::BKE_pose_ensure_bone_indices(), blender::BLI_assert(), build_usd_joint_path(), blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::contains(), create_pose_joints(), and blender::bPoseChannel::name.

Referenced by BlenderBoneLengths(), create_pose_joints(), and blender::initialize().

◆ create_primvar_reader_shader()

pxr::UsdShadeShader blender::io::usd::create_primvar_reader_shader ( const USDExporterContext & usd_export_context,
const pxr::UsdShadeMaterial & material,
const pxr::TfToken & primvar_type,
const bNode * node )
static

◆ create_skel_roots()

void blender::io::usd::create_skel_roots ( pxr::UsdStageRefPtr stage,
const USDExportParams & params )

We must structure the scene graph to encapsulate skinned prim under a UsdSkelRoot prim. Per the USD documentation, a SkelRoot is a:

"Boundable prim type used to identify a scope beneath which skeletally-posed primitives are defined. A SkelRoot must be defined at or above a skinned primitive for any skinning behaviors in UsdSkel."

See: https://openusd.org/23.05/api/class_usd_skel_root.html#details

This function attempts to ensure that skinned primitives and skeletons are encapsulated under SkelRoots, converting existing Xform primitives to SkelRoots to achieve this, if possible. In the case where no common ancestor which can be converted to a SkelRoot is found, this function issues a warning. One way to address such a case is by setting a root prim in the export options, so that this root prim can be converted to a SkelRoot for the entire scene.

Parameters
stageThe stage
paramsThe export parameters

Definition at line 55 of file usd_skel_root_utils.cc.

References blender::BKE_reportf(), CLOG_DEBUG, CLOG_WARN, create_skel_roots(), blender::io::usd::USDExportParams::export_armatures, blender::io::usd::USDExportParams::export_shapekeys, blender::get_xform_ancestor(), blender::LOG, blender::wmJobWorkerStatus::reports, blender::RPT_WARNING, and blender::io::usd::USDExportParams::worker_status.

Referenced by create_skel_roots(), and blender::io::usd::USDHierarchyIterator::process_usd_skel().

◆ create_temp_path_for_usdz_export()

void blender::io::usd::create_temp_path_for_usdz_export ( const char * filepath,
io::usd::ExportJobData * job )
static

To create a USDZ file, we must first create a .usd/a/c file and then covert it to .usdz. The temporary files will be created in Blender's temporary session storage. The .usdz file will then be moved to job->usdz_filepath.

Definition at line 786 of file usd_capi_export.cc.

References blender::BKE_tempdir_session(), blender::BLI_path_basename(), blender::BLI_path_extension_check(), blender::BLI_path_extension_replace(), BLI_path_join, create_temp_path_for_usdz_export(), FILE_MAX, blender::STRNCPY(), blender::io::usd::ExportJobData::unarchived_filepath, and blender::io::usd::ExportJobData::usdz_filepath.

Referenced by create_temp_path_for_usdz_export(), and set_job_filepath().

◆ create_transform2d_shader()

◆ create_usd_material()

pxr::UsdShadeMaterial blender::io::usd::create_usd_material ( const USDExporterContext & usd_export_context,
pxr::SdfPath usd_path,
const Material * material,
const std::string & active_uvmap_name,
ReportList * reports )

◆ create_usd_preview_shader() [1/2]

pxr::UsdShadeShader blender::io::usd::create_usd_preview_shader ( const USDExporterContext & usd_export_context,
const pxr::UsdShadeMaterial & material,
const bNode * node )
static

◆ create_usd_preview_shader() [2/2]

◆ create_usd_preview_surface_material()

◆ create_usd_viewport_material()

void blender::io::usd::create_usd_viewport_material ( const USDExporterContext & usd_export_context,
const Material * material,
const pxr::UsdShadeMaterial & usd_material )

◆ create_uv_input()

void blender::io::usd::create_uv_input ( const USDExporterContext & usd_export_context,
const bNodeSocket * input_socket,
pxr::UsdShadeMaterial & usd_material,
pxr::UsdShadeInput & usd_input,
const std::string & active_uvmap_name,
ReportList * reports )
static

◆ create_uvmap_shader()

◆ create_vector_attrib()

void blender::io::usd::create_vector_attrib ( const pxr::UsdPrim & prim,
const IDProperty * prop,
const pxr::TfToken & prop_token,
const pxr::UsdTimeCode & time )
static

◆ curves_topology_changed() [1/2]

bool blender::io::usd::curves_topology_changed ( const bke::CurvesGeometry & curves,
const Span< int > usd_offsets )
static

Returns true if the number of curves or the number of curve points in each curve differ.

Definition at line 86 of file usd_reader_curve.cc.

References curves_topology_changed().

Referenced by curves_topology_changed(), and blender::io::usd::USDBasisCurvesReader::read_curve_sample().

◆ curves_topology_changed() [2/2]

bool blender::io::usd::curves_topology_changed ( const bke::CurvesGeometry & curves,
const Span< int > usd_offsets )
static

Returns true if the number of curves or the number of curve points in each curve differ.

Definition at line 239 of file usd_reader_nurbs.cc.

References curves_topology_changed().

Referenced by blender::io::usd::USDNurbsReader::read_curve_sample().

◆ decref()

void blender::io::usd::decref ( USDPrimReader * reader)
static

◆ determine_blender_compat()

void blender::io::usd::determine_blender_compat ( pxr::UsdStageRefPtr stage,
ImportSettings & settings )
static

Set compatibility flags if the Stage was written by Blender.

Definition at line 188 of file usd_reader_stage.cc.

References blender::io::usd::ImportSettings::blender_stage_version_prior_44, and determine_blender_compat().

Referenced by determine_blender_compat(), and blender::io::usd::USDStageReader::USDStageReader().

◆ determine_knots_mode()

◆ dome_light_to_world_material()

void blender::io::usd::dome_light_to_world_material ( const USDImportParams & params,
Scene * scene,
Main * bmain,
const USDImportDomeLightData & dome_light_data,
const pxr::UsdPrim & prim,
const pxr::UsdTimeCode time )

◆ DuplicateArray()

template<typename T>
pxr::VtArray< T > blender::io::usd::DuplicateArray ( const pxr::VtArray< T > & original,
size_t copies )
static

Definition at line 384 of file usd_writer_pointinstancer.cc.

References DuplicateArray().

Referenced by DuplicateArray(), and DuplicatePerInstanceAttribute().

◆ DuplicatePerInstanceAttribute()

template<typename T, typename GetterFunc, typename CreatorFunc>
void blender::io::usd::DuplicatePerInstanceAttribute ( const GetterFunc & getter,
const CreatorFunc & creator,
size_t copies,
const pxr::UsdTimeCode & time )
static

◆ ensure_blend_shape_skeleton()

void blender::io::usd::ensure_blend_shape_skeleton ( pxr::UsdStageRefPtr stage,
pxr::UsdPrim & mesh_prim )

USD implementations expect that a mesh with blend shape targets be bound to a skeleton with an animation that provides the blend shape weights. If the given mesh is not already bound to a skeleton this function will create a dummy skeleton with a single joint and will bind it to the mesh. This is typically required if the source Blender mesh has shape keys but not an armature deformer.

This function will also create a skel animation prim as a child of the skeleton and will copy the weight time samples from a temporary primvar on the mesh to the animation prim.

Parameters
stageThe stage
mesh_primThe USD mesh to which the skeleton will be bound

Definition at line 83 of file usd_blend_shape_utils.cc.

References blender::usdtokens::Anim(), CLOG_WARN, ensure_blend_shape_skeleton(), blender::usdtokens::joint1(), blender::LOG, blender::usdtokens::Skel(), and TempBlendShapeWeightsPrimvarName.

Referenced by ensure_blend_shape_skeleton(), and shape_key_export_chaser().

◆ ensure_root_prim()

◆ ensure_usd_source_path_prop()

void blender::io::usd::ensure_usd_source_path_prop ( const std::string & path,
ID * id )

Add the given path as a custom property "usd_source_path" on the given id. If the path is a package-relative path (i.e., is relative to a USDZ archive) it will not be added a a property. If custom property "usd_source_path" already exists, this function does nothing.

Parameters
pathpath to record as a custom property
idid for which to create the custom property

Definition at line 483 of file usd_asset_utils.cc.

References ensure_usd_source_path_prop(), blender::IDP_AddToGroup(), blender::IDP_EnsureProperties(), blender::IDP_GetPropertyFromGroup(), blender::IDP_New(), blender::IDP_STRING, blender::IDP_STRING_SUB_UTF8, and blender::IDPropertyTemplate::string.

Referenced by ensure_usd_source_path_prop(), load_image(), and blender::io::usd::USDMaterialReader::load_tex_image().

◆ ExpandAttributePerInstance()

template<typename T, typename GetterFunc, typename CreatorFunc>
void blender::io::usd::ExpandAttributePerInstance ( const GetterFunc & getter,
const CreatorFunc & creator,
const Span< std::pair< int, int > > instance_object_map,
const pxr::UsdTimeCode & time )
static

◆ export_deform_verts()

void blender::io::usd::export_deform_verts ( const Mesh * mesh,
const pxr::UsdSkelBindingAPI & skel_api,
Span< StringRef > bone_names )

Convert deform groups on the given mesh to USD joint index and weight attributes.

Parameters
meshThe source mesh with deform groups to export
skel_apiAPI for setting the attributes on the USD prim
bone_namesList of armature bone names corresponding to the deform groups

Definition at line 1330 of file usd_skel_convert.cc.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::BLI_assert(), BLI_assert_unreachable, export_deform_verts(), blender::Span< T >::index_range(), blender::Vector< T, InlineBufferCapacity, Allocator >::is_empty(), blender::bDeformGroup::name, blender::Span< T >::size(), and blender::Vector< T, InlineBufferCapacity, Allocator >::size().

Referenced by export_deform_verts(), and blender::io::usd::USDMeshWriter::init_skinned_mesh().

◆ export_endjob()

◆ export_endjob_usdz_cleanup()

◆ export_in_memory_imbuf()

void blender::io::usd::export_in_memory_imbuf ( ImBuf * imbuf,
const std::string & export_dir,
const char image_abs_path[FILE_MAX],
const char file_name[FILE_MAX],
const bool allow_overwrite,
ReportList * reports )
static

◆ export_in_memory_texture()

◆ export_packed_texture()

◆ export_params_valid()

bool blender::io::usd::export_params_valid ( const USDExportParams & params)
static

Perform validation of export parameter settings.

Returns
true if the parameters are valid; returns false otherwise.
Warning
Do not call from worker thread, only from main thread (i.e. before starting the wmJob).

Definition at line 146 of file usd_capi_export.cc.

References export_params_valid(), prim_path_valid(), and blender::io::usd::USDExportParams::root_prim_path.

Referenced by export_params_valid(), and USD_export().

◆ export_startjob()

◆ export_texture() [1/3]

void blender::io::usd::export_texture ( bNode * node,
const pxr::UsdStageRefPtr stage,
const bool allow_overwrite,
ReportList * reports )

◆ export_texture() [2/3]

◆ export_texture() [3/3]

◆ export_to_stage()

pxr::UsdStageRefPtr blender::io::usd::export_to_stage ( const USDExportParams & params,
Depsgraph * depsgraph,
const char * filepath )

Definition at line 509 of file usd_capi_export.cc.

References blender::BKE_blender_version_string(), blender::BKE_scene_graph_update_for_newframe(), blender::BKE_scene_graph_update_tagged(), call_export_hooks(), blender::RenderData::cfra, blender::io::usd::USDExportParams::convert_orientation, blender::io::usd::USDExportParams::convert_world_material, blender::DEG_get_bmain(), blender::DEG_get_input_scene(), blender::io::SubdivModifierDisabler::disable_modifiers(), blender::wmJobWorkerStatus::do_update, blender::RenderData::efra, ELEM, ensure_root_prim(), blender::io::usd::USDExportParams::export_animation, blender::io::usd::USDExportParams::export_armatures, blender::io::usd::USDExportParams::export_shapekeys, blender::io::usd::USDExportParams::export_subdiv, export_to_stage(), blender::G, get_meters_per_unit(), Ignore, blender::io::usd::USDExportParams::incremental_frames, blender::IO_AXIS_X, blender::IO_AXIS_Y, blender::io::AbstractHierarchyIterator::iterate_and_write(), Match, process_scene_graph_instances(), blender::io::usd::USDHierarchyIterator::process_usd_skel(), blender::wmJobWorkerStatus::progress, blender::Scene::r, register_hook_converters(), blender::io::AbstractHierarchyIterator::release_writers(), blender::wmJobWorkerStatus::reports, blender::UnitSettings::scale_length, blender::io::usd::USDHierarchyIterator::set_export_frame(), blender::RenderData::sfra, blender::wmJobWorkerStatus::stop, blender::RenderData::subframe, blender::Scene::unit, blender::io::usd::USDExportParams::up_axis, blender::io::usd::USDExportParams::use_instancing, blender::io::usd::USDExportParams::worker_status, world_material_to_dome_light(), write_root_accessibility_information(), blender::x, y, and z().

Referenced by export_startjob(), export_to_stage(), and blender::io::hydra::USDSceneIndex::populate().

◆ find_bsdf_node()

bNode * blender::io::usd::find_bsdf_node ( const Material * material)
static

◆ find_displacement_node()

bNode * blender::io::usd::find_displacement_node ( const Material * material)
static

Returns the first occurrence of a scalar Displacement node found in the given material's node tree. Vector Displacement is not supported in the #UsdPreviewSurface. Returns null if no instance of either type was found.

Definition at line 1112 of file usd_writer_material.cc.

References find_displacement_node(), node, and SH_NODE_DISPLACEMENT.

Referenced by create_usd_preview_surface_material(), and find_displacement_node().

◆ find_existing_material()

Material * blender::io::usd::find_existing_material ( const pxr::SdfPath & usd_mat_path,
const USDImportParams & params,
const Map< std::string, Material * > & mat_map,
const Map< pxr::SdfPath, Material * > & usd_path_to_mat )

Returns an existing Blender material that corresponds to the USD material with the given path. Returns null if no such material exists.

Parameters
mat_mapMap a material name to a Blender material. Note that the name key might be the Blender material name modified to be a valid USD identifier, to match the material names in the imported USD.
usd_path_to_matMap a USD material path to the imported Blender material.

The usd_path_to_mat is needed to determine the name of the Blender material imported from a USD path in the case when a unique name was generated for the material due to a name collision.

Definition at line 1555 of file usd_reader_material.cc.

References find_existing_material(), blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup_default(), MakeUnique, and blender::io::usd::USDImportParams::mtl_name_collision_mode.

Referenced by blender::io::usd::utils::assign_materials(), find_existing_material(), and blender::io::usd::USDStageReader::import_all_materials().

◆ find_node_for_type_in_graph()

const bNode * blender::io::usd::find_node_for_type_in_graph ( const bNodeTree * nodetree,
const UString type_idname )
static

Definition at line 255 of file usd_export_test.cc.

References find_node_for_type_in_graph().

Referenced by find_node_for_type_in_graph(), and TEST_F().

◆ find_prefix_to_skip()

void blender::io::usd::find_prefix_to_skip ( pxr::UsdStageRefPtr stage,
ImportSettings & settings )
static

Find the lowest level of Blender generated roots so that round tripping an export can be more invisible

Definition at line 144 of file usd_reader_stage.cc.

References find_prefix_to_skip(), and blender::io::usd::ImportSettings::skip_prefix.

Referenced by find_prefix_to_skip(), and blender::io::usd::USDStageReader::USDStageReader().

◆ gather_objects_paths()

bool blender::io::usd::gather_objects_paths ( const pxr::UsdPrim & object,
ListBaseT< CacheObjectPath > * object_paths )
static

◆ get_absolute_path()

◆ get_armature_bone_names()

void blender::io::usd::get_armature_bone_names ( const Object * ob_arm,
bool use_deform,
Vector< StringRef > & r_names )

Return in 'r_names' the names of the given armature object's bones.

Parameters
ob_armThe armature object
use_deformIf true, use only deform bone names, including their parents, to match armature export joint indices
r_namesThe returned list of bone names

Definition at line 110 of file usd_armature_utils.cc.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::contains(), get_armature_bone_names(), init_deform_bones_map(), blender::Bone::name, and visit_bones().

Referenced by BlenderBoneLengths(), get_armature_bone_names(), and blender::io::usd::USDMeshWriter::init_skinned_mesh().

◆ get_armature_modifier()

const ArmatureModifierData * blender::io::usd::get_armature_modifier ( const Object & obj,
const Depsgraph * depsgraph )
static

◆ get_armature_modifier_obj()

const Object * blender::io::usd::get_armature_modifier_obj ( const Object & obj,
const Depsgraph * depsgraph )

If the given object has an enabled armature modifier, return the armature object bound to the modifier.

Parameters
Object to check for the modifier
depsgraphThe dependency graph where the object was evaluated
Returns
The armature object.

Definition at line 173 of file usd_armature_utils.cc.

References get_armature_modifier(), get_armature_modifier_obj(), and mod.

Referenced by BlenderBoneLengths(), get_armature_modifier_obj(), blender::io::usd::USDMeshWriter::init_skinned_mesh(), and skinned_mesh_export_chaser().

◆ get_asset_base_name()

std::string blender::io::usd::get_asset_base_name ( const std::string & src_path,
ReportList * reports )
static

◆ get_authored_value()

template<typename T>
bool blender::io::usd::get_authored_value ( const pxr::UsdAttribute & attr,
const pxr::UsdTimeCode time,
const pxr::UsdPrim & prim,
const pxr::TfToken fallback_attr_name,
T * r_value )
static

If the given attribute has an authored value, return its value in the r_value out parameter.

We wish to support older UsdLux APIs in older versions of USD. For example, in previous versions of the API, shader input attributes did not have the "inputs:" prefix. One can provide the older input attribute name in the 'fallback_attr_name' argument, and that attribute will be queried if 'attr' doesn't exist or doesn't have an authored value.

Definition at line 36 of file usd_reader_domelight.cc.

References get_authored_value(), and T.

Referenced by get_authored_value(), get_color(), get_intensity(), get_pole_axis(), and get_tex_path().

◆ get_blendshape_weights()

pxr::VtFloatArray blender::io::usd::get_blendshape_weights ( const Key * key)

Return the current weight values of the given key.

Parameters
keyThe key whose values will be queried
Returns
The array of key values.

Definition at line 285 of file usd_blend_shape_utils.cc.

References blender::BLI_assert(), blender::Key::block, blender::KeyBlock::curval, and get_blendshape_weights().

Referenced by blender::io::usd::USDMeshWriter::add_shape_key_weights_sample(), and get_blendshape_weights().

◆ get_color()

template<typename T>
bool blender::io::usd::get_color ( const T & dome_light,
const pxr::UsdTimeCode time,
pxr::GfVec3f * color )
static

◆ get_curve_type()

CurveType blender::io::usd::get_curve_type ( pxr::TfToken type,
pxr::TfToken basis )
static

◆ get_curve_width_interpolation()

pxr::TfToken blender::io::usd::get_curve_width_interpolation ( const pxr::VtArray< float > & widths,
const pxr::VtArray< int > & segments,
const pxr::VtIntArray & control_point_counts,
const bool is_cyclic,
ReportList * reports )
static

◆ get_edge_creases()

◆ get_enabled_modifier()

const ModifierData * blender::io::usd::get_enabled_modifier ( const Object & obj,
ModifierType type,
const Depsgraph * depsgraph )

Return the modifier of the given type enabled for the given dependency graph's evaluation mode (viewport or render).

Parameters
objObject to query for the modifier
depsgraphThe dependency graph where the object was evaluated
Returns
The modifier.

Definition at line 65 of file usd_armature_utils.cc.

References blender::BKE_modifier_is_enabled(), blender::BLI_assert(), blender::DEG_get_input_scene(), blender::DEG_get_mode(), get_enabled_modifier(), and blender::ModifierData::type.

Referenced by BlenderBoneLengths(), can_export_skinned_mesh(), get_armature_modifier(), and get_enabled_modifier().

◆ get_export_textures_dir()

std::string blender::io::usd::get_export_textures_dir ( const pxr::UsdStageRefPtr stage)

Invoke the USD asset resolver to return an identifier for a 'textures' directory which is a sibling of the given stage. The resulting path is created by resolving the './textures' relative path with the stage's root layer path as the anchor. If the parent of the stage root layer path resolves to a file system path, the textures directory will be created, if it doesn't exist.

Parameters
stageThe stage whose root layer is a sibling of the 'textures' directory
Returns
the path to the 'textures' directory

Definition at line 352 of file usd_asset_utils.cc.

References blender::BLI_dir_create_recursive(), get_export_textures_dir(), layer, parent_dir_exists_on_file_system(), blender::RPT_WARNING, and blender::WM_global_reportf().

Referenced by export_texture(), and get_export_textures_dir().

◆ get_image_cache_file()

std::string blender::io::usd::get_image_cache_file ( const std::string & file_name,
bool mkdir )

◆ get_in_memory_texture_filename()

◆ get_intensity()

template<typename T>
float blender::io::usd::get_intensity ( const T & dome_light,
const pxr::UsdTimeCode time )
static

◆ get_last_subdiv_modifier()

◆ get_loops_polys()

◆ get_mesh_shape_key()

const Key * blender::io::usd::get_mesh_shape_key ( const Object * obj)

Return the shape key on the given mesh object.

Parameters
objThe mesh object
Returns
The shape key on the given object's mesh data, or null if the object isn't a mesh.

Definition at line 176 of file usd_blend_shape_utils.cc.

References blender::BLI_assert(), get_mesh_shape_key(), and blender::OB_MESH.

Referenced by blender::io::usd::USDMeshWriter::add_shape_key_weights_sample(), create_blend_shapes(), get_mesh_shape_key(), and is_mesh_with_shape_keys().

◆ get_meters_per_unit()

◆ get_node_tex_image_wrap()

◆ get_pole_axis()

pxr::TfToken blender::io::usd::get_pole_axis ( const pxr::UsdLuxDomeLight_1 & dome_light,
const pxr::UsdTimeCode time )
static

◆ get_positions()

void blender::io::usd::get_positions ( const Mesh * mesh,
USDMeshData & usd_mesh_data )
static

◆ get_primvar_array()

template<typename T>
pxr::VtArray< T > blender::io::usd::get_primvar_array ( const pxr::UsdGeomPrimvar & primvar,
const pxr::UsdTimeCode time )

◆ get_relative_path()

std::string blender::io::usd::get_relative_path ( const std::string & path,
const std::string & anchor )

Return the given path as a relative path with respect to the given anchor path.

Parameters
pathpath to make relative with respect to the anchor path
anchorthe anchor path
Returns
the relative path string; return the input path unchanged if it can't be made relative, is already a relative path or is a package-relative path

Definition at line 538 of file usd_asset_utils.cc.

References blender::BLI_is_file(), blender::BLI_path_is_rel(), blender::BLI_path_relative_to(), blender::BLI_path_slash_forward_from_native(), blender::BLI_path_split_dir_part(), FILE_MAX, and get_relative_path().

Referenced by get_relative_path(), and get_tex_image_asset_filepath().

◆ get_shape_key_basis_mesh()

Mesh * blender::io::usd::get_shape_key_basis_mesh ( Object * obj)

If the given object is a mesh with shape keys, return a copy of the object's pre-modified mesh with its verts in the shape key basis positions. The returned mesh must be freed by the caller.

Parameters
objThe mesh object with shape keys
Returns
A new mesh corresponding to the shape key basis shape, or null if the object isn't a mesh or has no shape keys.

Definition at line 436 of file usd_blend_shape_utils.cc.

References blender::BKE_keyblock_convert_to_mesh(), blender::BKE_mesh_copy_for_eval(), blender::BKE_object_get_pre_modified_mesh(), CLOG_WARN, get_shape_key_basis_mesh(), blender::LOG, blender::OB_MESH, and blender::KeyBlock::totelem.

Referenced by blender::io::usd::USDMeshWriter::get_export_mesh(), and get_shape_key_basis_mesh().

◆ get_source_color_space()

pxr::TfToken blender::io::usd::get_source_color_space ( const pxr::UsdShadeShader & usd_shader)
static

◆ get_tex_image_asset_filepath() [1/5]

std::string blender::io::usd::get_tex_image_asset_filepath ( const bNode * node,
const pxr::UsdStageRefPtr stage,
const USDExportParams & export_params )

Gets an asset path for the given texture image / node. The resulting path may be absolute, relative to the USD file, or in a 'textures' directory in the same directory as the USD file, depending on the export parameters. The filename is typically the image filepath but might also be automatically generated based on the image name for in-memory textures when exporting textures. This function may return an empty string if the image does not have a filepath assigned and no asset path could be determined.

Definition at line 1314 of file usd_writer_material.cc.

References get_tex_image_asset_filepath(), and node.

◆ get_tex_image_asset_filepath() [2/5]

std::string blender::io::usd::get_tex_image_asset_filepath ( const Image * ima)
static

◆ get_tex_image_asset_filepath() [3/5]

std::string blender::io::usd::get_tex_image_asset_filepath ( const std::string & asset_path,
const std::string & stage_path,
const USDExportParams & export_params )

Return a USD asset path referencing the given texture file. The resulting path may be absolute, relative to the USD file, or in a 'textures' directory in the same directory as the USD file, depending on the export parameters.

Definition at line 1265 of file usd_writer_material.cc.

References BLI_path_join, blender::BLI_path_split_dir_part(), blender::BLI_path_split_file_part(), blender::BLI_string_replace_char(), blender::io::usd::USDExportParams::export_textures, FILE_MAX, get_relative_path(), get_tex_image_asset_filepath(), and blender::io::usd::USDExportParams::relative_paths.

◆ get_tex_image_asset_filepath() [4/5]

std::string blender::io::usd::get_tex_image_asset_filepath ( const USDExporterContext & usd_export_context,
const bNode * node )
static

◆ get_tex_image_asset_filepath() [5/5]

◆ get_tex_path()

template<typename T>
bool blender::io::usd::get_tex_path ( const T & dome_light,
const pxr::UsdTimeCode time,
pxr::SdfAssetPath * tex_path )
static

◆ get_unique_path()

pxr::SdfPath blender::io::usd::get_unique_path ( pxr::UsdStageRefPtr stage,
const std::string & path )

Return a unique USD SdfPath. If the given path already exists on the given stage, return the path with a numerical suffix appended to the name that ensures the path is unique. If the path does not exist on the stage, it will be returned unchanged.

Parameters
stageThe stage
pathThe original path
Returns
A valid, and unique, USD SdfPath

Definition at line 109 of file usd_utils.cc.

References get_unique_path().

Referenced by get_unique_path(), process_scene_graph_instances(), and world_material_to_dome_light().

◆ get_usd_points_range_de_dup()

IndexRange blender::io::usd::get_usd_points_range_de_dup ( IndexRange blender_points_range,
IndexRange usd_points_range )
static

◆ get_usd_reader()

USDPrimReader * blender::io::usd::get_usd_reader ( CacheReader * reader,
const Object * ,
const char ** r_err_str )
static

◆ get_usd_source_path()

std::string blender::io::usd::get_usd_source_path ( ID * id)

Return the value of the "usd_source_path" custom property on the given id. Return an empty string if the property does not exist.

Definition at line 518 of file usd_asset_utils.cc.

References blender::IDProperty::data, get_usd_source_path(), blender::IDP_EnsureProperties(), blender::IDP_GetPropertyFromGroup(), and blender::IDPropertyData::pointer.

Referenced by get_tex_image_asset_filepath(), and get_usd_source_path().

◆ get_vert_creases()

◆ handle_from_stage_reader()

CacheArchiveHandle * blender::io::usd::handle_from_stage_reader ( USDStageReader * reader)
static

Definition at line 62 of file usd_capi_import.cc.

References handle_from_stage_reader().

Referenced by handle_from_stage_reader(), and USD_create_handle().

◆ handle_python_error()

void blender::io::usd::handle_python_error ( USDHook * hook,
ReportList * reports )
static

◆ has_generated_tiles()

bool blender::io::usd::has_generated_tiles ( const Image * ima)
static

◆ has_varying_modifiers()

◆ have_material_import_hook()

bool blender::io::usd::have_material_import_hook ( pxr::UsdStageRefPtr stage,
const pxr::UsdShadeMaterial & usd_material,
const USDImportParams & import_params,
ReportList * reports )

◆ hook_list()

◆ image_cache_file_path()

◆ import_asset()

std::string blender::io::usd::import_asset ( const std::string & src,
const char * import_dir,
TexNameCollisionMode name_collision_mode,
ReportList * reports )

Invoke the USD asset resolver to copy an asset to a destination directory and return the path to the copied file. This function may be used to copy textures from a USDZ archive to a directory on disk. The destination directory will be created if it doesn't already exist. If the copy was unsuccessful, this function will log an error and return the original source file path unmodified.

Parameters
srcsource path of the asset to import
import_dirpath to the destination directory
name_collision_modebehavior when a file of the same name already exists
reportsthe storage for potential warning or error reports (generated using BKE_report API).
Returns
path to copied file or the original src path if there was an error

Definition at line 277 of file usd_asset_utils.cc.

References blender::BKE_main_blendfile_path_from_global(), blender::BKE_reportf(), blender::BLI_dir_create_recursive(), blender::BLI_path_abs(), blender::BLI_path_is_rel(), blender::BLI_path_normalize(), copy_asset_to_directory(), copy_udim_asset_to_directory(), FILE_MAX, FILE_MAXDIR, import_asset(), is_udim_path(), blender::RPT_ERROR, and blender::STRNCPY().

Referenced by import_asset(), blender::io::usd::USDMaterialImportContext::import_texture(), load_image(), and blender::io::usd::USDMaterialReader::load_tex_image().

◆ import_blendshapes()

void blender::io::usd::import_blendshapes ( Main * bmain,
Object * mesh_obj,
const pxr::UsdPrim & prim,
ReportList * reports,
bool import_anim = true )

This file contains utilities for converting between UsdSkel data and Blender armatures and shape keys. The following is a reference on the UsdSkel API:

https://openusd.org/23.05/api/usd_skel_page_front.html Import USD blend shapes from a USD primitive as shape keys on a mesh object. Optionally, if the blend shapes have animating weights, the time-sampled weights will be imported as shape key animation curves. If the USD primitive does not have blend shape targets defined, this function is a no-op.

Parameters
bmainMain pointer
mesh_objMesh object to which imported shape keys will be added
primThe USD primitive from which blend-shapes will be imported
reportsthe storage for potential warning or error reports (generated using BKE_report API).
import_animWhether to import time-sampled weights as shape key animation curves

Definition at line 361 of file usd_skel_convert.cc.

References blender::animrig::action_channelbag_ensure(), blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), blender::add_v3_v3(), blender::BKE_fcurve_handles_recalc(), blender::BKE_key_add(), blender::BKE_keyblock_add(), blender::BKE_keyblock_convert_from_mesh(), blender::BKE_reportf(), blender::BLI_str_escape(), CLOG_WARN, blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::contains(), create_fcurve(), blender::data, blender::KeyBlock::data, blender::Object::data, blender::Key::id, blender::animrig::id_action_ensure(), import_blendshapes(), blender::KEY_RELATIVE, blender::LOG, blender::OB_MESH, blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::reserve(), blender::RPT_WARNING, set_fcurve_sample(), blender::Span< T >::size(), blender::Span< T >::Span(), blender::KeyBlock::totelem, blender::Key::type, and blender::Object::type.

Referenced by import_blendshapes(), and blender::io::usd::USDMeshReader::read_object_data().

◆ import_endjob()

◆ import_freejob()

void blender::io::usd::import_freejob ( void * user_data)
static

Definition at line 440 of file usd_capi_import.cc.

References blender::data, and import_freejob().

Referenced by import_freejob(), and USD_import().

◆ import_mesh_skel_bindings()

void blender::io::usd::import_mesh_skel_bindings ( Object * mesh_obj,
const pxr::UsdPrim & prim,
ReportList * reports )

◆ import_skeleton()

void blender::io::usd::import_skeleton ( Main * bmain,
Object * arm_obj,
const pxr::UsdSkelSkeleton & skel,
ReportList * reports,
bool import_anim = true )

Import the given USD skeleton as an armature object. Optionally, if the skeleton has an animation defined, the time sampled joint transforms will be imported as bone animation curves.

Parameters
bmainMain pointer
arm_objArmature object to which the bone hierarchy will be added
skelThe USD skeleton from which bones and animation will be imported
reportsthe storage for potential warning or error reports (generated using BKE_report API).
import_animWhether to import time-sampled joint transforms as bone animation curves

Definition at line 730 of file usd_skel_convert.cc.

References blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::BKE_reportf(), BlenderBoneLengths(), CLOG_WARN, blender::copy_v3_v3(), blender::Object::data, blender::ED_armature_ebone_add(), blender::ED_armature_ebone_from_mat4(), blender::ED_armature_edit_free(), blender::ED_armature_from_edit(), blender::ED_armature_to_edit(), blender::EditBone::head, import_skeleton(), blender::LOG, blender::EditBone::name, blender::OB_ARMATURE, blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::reserve(), blender::RPT_WARNING, set_rest_pose(), blender::Vector< T, InlineBufferCapacity, Allocator >::size(), blender::Span< T >::Span(), blender::EditBone::tail, and blender::Object::type.

Referenced by import_skeleton(), and blender::io::usd::USDSkeletonReader::read_object_data().

◆ import_startjob()

◆ init_deform_bones_map()

void blender::io::usd::init_deform_bones_map ( const Object * obj,
Map< StringRef, const Bone * > * deform_map )

Initialize the deform bones map:

  • First: grab all bones marked for deforming and store them.
  • Second: loop the deform bones you found and recursively walk up their parent hierarchies, marking those bones as deform as well.
    Parameters
    objObject to query
    deform_mapA pointer to the deform_map to fill with deform bones and their parents found on the object

Definition at line 199 of file usd_armature_utils.cc.

References blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), blender::BLI_assert(), blender::BONE_NO_DEFORM, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::clear(), blender::Bone::flag, init_deform_bones_map(), blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::items(), blender::Bone::name, blender::Bone::parent, and visit_bones().

Referenced by BlenderBoneLengths(), blender::io::usd::USDArmatureWriter::do_write(), get_armature_bone_names(), and init_deform_bones_map().

◆ is_armature_modifier_bone_name()

bool blender::io::usd::is_armature_modifier_bone_name ( const Object & obj,
StringRefNull name,
const Depsgraph * depsgraph )

If the given object has an armature modifier, query whether the given name matches the name of a bone on the armature referenced by the modifier.

Parameters
objObject to query for the modifier
nameName to check
depsgraphThe dependency graph where the object was evaluated
Returns
True if the name matches a bone name. Return false if no matching bone name is found or if the object does not have an armature modifier

Definition at line 179 of file usd_armature_utils.cc.

References blender::BKE_armature_find_bone_name(), blender::StringRefNull::c_str(), blender::Object::data, get_armature_modifier(), is_armature_modifier_bone_name(), and blender::ArmatureModifierData::object.

Referenced by BlenderBoneLengths(), and is_armature_modifier_bone_name().

◆ is_excluded_attr()

◆ is_in_memory_texture()

bool blender::io::usd::is_in_memory_texture ( Image * ima)
static

◆ is_mesh_with_shape_keys()

bool blender::io::usd::is_mesh_with_shape_keys ( const Object * obj)

Query whether the given object is a mesh with relative shape keys.

Parameters
objThe mesh object
Returns
True if the object is a mesh with shape keys, false otherwise

Definition at line 189 of file usd_blend_shape_utils.cc.

References get_mesh_shape_key(), is_mesh_with_shape_keys(), blender::KEY_RELATIVE, blender::Key::totkey, and blender::Key::type.

Referenced by is_mesh_with_shape_keys(), and blender::io::usd::USDMeshWriter::set_skel_export_flags().

◆ is_packed_texture()

bool blender::io::usd::is_packed_texture ( const Image * ima)
static

◆ is_safe_char()

bool blender::io::usd::is_safe_char ( const pxr::TfUtf8CodePoint cp,
bool is_first,
bool allow_unicode )
static

Definition at line 18 of file usd_utils.cc.

References is_safe_char().

Referenced by is_safe_char(), and make_safe_identifier().

◆ is_udim_path()

bool blender::io::usd::is_udim_path ( const std::string & path)

Check if the given path contains a UDIM token.

Parameters
paththe path to check
Returns
true if the path contains a UDIM token, false otherwise

Definition at line 346 of file usd_asset_utils.cc.

References is_udim_path(), UDIM_PATTERN, and UDIM_PATTERN2.

Referenced by import_asset(), is_udim_path(), blender::io::usd::USDMaterialReader::load_tex_image(), and should_import_asset().

◆ load_image()

◆ make_safe_identifier()

◆ make_safe_name()

std::string blender::io::usd::make_safe_name ( StringRef name,
bool allow_unicode )

◆ make_safe_primvar_name()

std::string blender::io::usd::make_safe_primvar_name ( StringRef name,
bool allow_unicode )

Return a valid USD primvar name based on the passed in string. The name is permitted to contain namespaces separated by colons. E.g. "ns1:ns2:primvar_name".

Parameters
nameIncoming name to sanitize
allow_unicodeWhether to allow unicode encoded characters in the USD primvar name
Returns
A valid USD primvar name

Definition at line 88 of file usd_utils.cc.

References make_safe_identifier(), and make_safe_primvar_name().

Referenced by create_uvmap_shader(), make_safe_primvar_name(), process_inputs(), and TEST().

◆ node_graph_output_source()

pxr::UsdShadeShader blender::io::usd::node_graph_output_source ( const pxr::UsdShadeNodeGraph & node_graph,
const pxr::TfToken & output_name )
static

◆ node_search()

◆ parent_dir_exists_on_file_system()

bool blender::io::usd::parent_dir_exists_on_file_system ( const std::string & path)
static

Returns true if the parent directory of the given path exists on the file system.

Parameters
pathinput file path
Returns
true if the parent directory exists

Definition at line 339 of file usd_asset_utils.cc.

References blender::BLI_is_dir(), blender::BLI_path_split_dir_part(), FILE_MAX, and parent_dir_exists_on_file_system().

Referenced by get_export_textures_dir(), parent_dir_exists_on_file_system(), and should_import_asset().

◆ paths_equal()

bool blender::io::usd::paths_equal ( const std::string & path1,
const std::string & path2 )

Invokes the USD asset resolver to resolve the given paths and returns true if the resolved paths are equal.

Parameters
path1first path to compare
path2second path to compare
Returns
true if the resolved input paths are equal, returns false otherwise.

Definition at line 405 of file usd_asset_utils.cc.

References BLI_assert_msg, blender::BLI_path_is_rel(), and paths_equal().

Referenced by export_packed_texture(), and paths_equal().

◆ perform_usdz_conversion()

bool blender::io::usd::perform_usdz_conversion ( const ExportJobData * data)
static

For usdz export, we must first create a usd/a/c file and then covert it to usdz. In Blender's case, we first create a usdc file in Blender's temporary working directory, and store the path to the usdc file in unarchived_filepath. This function then does the conversion of that usdc file into usdz.

Returns
true when the conversion from usdc to usdz is successful.

Definition at line 325 of file usd_capi_export.cc.

References blender::BKE_reportf(), blender::BLI_assert(), blender::BLI_change_working_dir(), blender::BLI_current_working_dir(), blender::BLI_delete(), blender::BLI_exists(), BLI_path_join, blender::BLI_path_move(), blender::BLI_path_split_dir_file(), blender::BLI_path_split_file_part(), blender::data, FILE_MAX, perform_usdz_conversion(), process_usdz_textures(), blender::result, and blender::RPT_ERROR.

Referenced by export_endjob(), and perform_usdz_conversion().

◆ point_count()

int blender::io::usd::point_count ( int usdCount,
CurveType curve_type,
bool is_cyclic )
static

◆ populate_curve_props()

void blender::io::usd::populate_curve_props ( const bke::CurvesGeometry & curves,
pxr::VtArray< pxr::GfVec3f > & verts,
pxr::VtIntArray & control_point_counts,
pxr::VtArray< float > & widths,
pxr::TfToken & interpolation,
const bool is_cyclic,
const bool is_cubic,
ReportList * reports )
static

◆ populate_curve_props_for_bezier()

void blender::io::usd::populate_curve_props_for_bezier ( const bke::CurvesGeometry & curves,
pxr::VtArray< pxr::GfVec3f > & verts,
pxr::VtIntArray & control_point_counts,
pxr::VtArray< float > & widths,
pxr::TfToken & interpolation,
const bool is_cyclic,
ReportList * reports )
static

◆ populate_curve_props_for_nurbs()

void blender::io::usd::populate_curve_props_for_nurbs ( const bke::CurvesGeometry & curves,
pxr::VtArray< pxr::GfVec3f > & verts,
pxr::VtIntArray & control_point_counts,
pxr::VtArray< float > & widths,
pxr::VtArray< double > & knots,
pxr::VtArray< double > & weights,
pxr::VtArray< int > & orders,
pxr::TfToken & interpolation,
const bool is_cyclic )
static

◆ populate_curve_verts()

void blender::io::usd::populate_curve_verts ( const bke::CurvesGeometry & curves,
const Span< float3 > positions,
pxr::VtArray< pxr::GfVec3f > & verts,
pxr::VtIntArray & control_point_counts,
pxr::VtArray< int > & segments,
const bool is_cyclic,
const bool is_cubic )
static

◆ populate_curve_verts_for_bezier()

void blender::io::usd::populate_curve_verts_for_bezier ( const bke::CurvesGeometry & curves,
const Span< float3 > positions,
const Span< float3 > handles_l,
const Span< float3 > handles_r,
pxr::VtArray< pxr::GfVec3f > & verts,
pxr::VtIntArray & control_point_counts,
pxr::VtArray< int > & segments,
const bool is_cyclic )
static

◆ populate_curve_widths()

void blender::io::usd::populate_curve_widths ( const bke::CurvesGeometry & curves,
pxr::VtArray< float > & widths )
static

◆ preview_surface_input_map()

◆ prim_path_valid()

bool blender::io::usd::prim_path_valid ( const std::string & path)
static

◆ process_inputs()

void blender::io::usd::process_inputs ( const USDExporterContext & usd_export_context,
pxr::UsdShadeMaterial & usd_material,
pxr::UsdShadeShader & shader,
const bNode * node,
const std::string & active_uvmap_name,
ReportList * reports )
static

Definition at line 181 of file usd_writer_material.cc.

References blender::usdtokens::a(), blender::io::usd::USDExportParams::allow_unicode, blender::usdtokens::b(), create_input(), create_primvar_reader_shader(), create_usd_preview_shader(), create_uv_input(), blender::bNode::custom1, blender::usdtokens::displacement(), blender::usdtokens::emissive_color(), blender::io::usd::USDExporterContext::export_params, export_texture(), blender::io::usd::USDExportParams::export_textures, Float, blender::bke::Float3, blender::bNodeLink::fromnode, blender::bNodeLink::fromsock, blender::usdtokens::g(), blender::bNodeSocket::identifier, blender::io::usd::InputSpec::input_name, blender::io::usd::InputSpec::input_type, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup_ptr(), make_safe_primvar_name(), blender::bNodeSocket::name, node, blender::bke::node_find_socket(), blender::NODE_MATH_LESS_THAN, blender::NODE_MATH_ROUND, blender::NODE_MATH_SUBTRACT, blender::NODE_VECTOR_MATH_MULTIPLY_ADD, blender::usdtokens::opacity(), blender::usdtokens::opacityThreshold(), preview_surface_input_map(), blender::usdtokens::primvar_float(), blender::usdtokens::primvar_float3(), blender::usdtokens::primvar_vector(), process_inputs(), blender::usdtokens::r(), blender::usdtokens::result(), blender::usdtokens::rgb(), scale(), blender::io::usd::InputSpec::set_default_value, set_normal_texture_range(), set_scale_bias(), set_transmission_opacity_range(), SH_NODE_ATTRIBUTE, SH_NODE_MATH, SH_NODE_SEPARATE_COLOR, SH_NODE_TEX_IMAGE, SH_NODE_VECTOR_MATH, blender::SHD_ATTRIBUTE_GEOMETRY, blender::SOCK_FLOAT, blender::SOCK_IN, blender::SOCK_RGBA, blender::SOCK_VECTOR, blender::usdtokens::st(), blender::bNode::storage, storage, STREQ, lexit::String, traverse_channel(), blender::bNodeSocket::type, blender::bNodeSocketValueFloat::value, and blender::usdtokens::varname().

Referenced by create_usd_preview_surface_material(), and process_inputs().

◆ process_scene_graph_instances()

void blender::io::usd::process_scene_graph_instances ( const USDExportParams & export_params,
pxr::UsdStageRefPtr stage )

This function processes the USD stage generated by the USD hierarchy iterator to change scene graph instancing prototypes from defined USD prims to abstract prims.

In the following example, instance /root/proto/Plane_0 references prototype prim /root/proto_001/Plane_0:

def Xform "root" { def Xform "proto_001" { def Xform "Plane_0" { def Mesh "Plane" { } } }

def Xform "proto" { def Xform "Plane_0" ( instanceable = true prepend references = </root/proto_001/Plane_0> ) { } } }

The function will copy prototype /root/proto_001/Plane_0 under a new class prim named /root/prototypes and convert prim /root/proto_001/Plane_0 to be an instance referencing the copied abstract prim /root/prototypes/Plane_0.

def Xform "root" { def Xform "proto" { def Xform "Plane_0" ( instanceable = true prepend references = </root/prototypes/Plane_0> ) { } }

def Xform "proto_001" { def Xform "Plane_0" ( instanceable = true references = </root/prototypes/Plane_0> ) { } }

class "prototypes" { def Xform "Plane_0" { def Mesh "Plane" { } } } }

Parameters
export_paramsThe export parameters
stagePointer to the stage to process

Definition at line 66 of file usd_instancing_utils.cc.

References blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), blender::Vector< T, InlineBufferCapacity, Allocator >::append(), CLOG_ERROR, CLOG_WARN, convert_proto_to_instance(), get_unique_path(), blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::is_empty(), blender::Vector< T, InlineBufferCapacity, Allocator >::is_empty(), blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::items(), blender::LOG, process_scene_graph_instances(), and blender::io::usd::USDExportParams::root_prim_path.

Referenced by export_to_stage(), and process_scene_graph_instances().

◆ process_usdz_textures()

◆ read_face_display_color()

◆ read_generic_mesh_primvar()

void blender::io::usd::read_generic_mesh_primvar ( Mesh * mesh,
const pxr::UsdGeomPrimvar & primvar,
const pxr::UsdTimeCode time,
const bool is_left_handed )

◆ register_hook_converters()

◆ remap_blend_shape_anim()

void blender::io::usd::remap_blend_shape_anim ( pxr::UsdStageRefPtr stage,
const pxr::SdfPath & skel_path,
const pxr::SdfPathSet & mesh_paths )

When multiple meshes with blend shape animations are bound to one skeleton, USD implementations typically expect these animations to be combined in a single animation on the skeleton. This function creates an animation prim as a child of the skeleton and merges the blend shape time samples from multiple meshes in a single attribute on the animation. Merging the weight samples requires handling blend shape name collisions by generating unique names for the combined result.

Parameters
stageThe stage
skel_pathPath to the skeleton
mesh_pathsPaths to one or more mesh primitives bound to the skeleton

Definition at line 302 of file usd_blend_shape_utils.cc.

References blender::usdtokens::Anim(), blender::Vector< T, InlineBufferCapacity, Allocator >::append(), CLOG_WARN, blender::Vector< T, InlineBufferCapacity, Allocator >::first(), blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::is_empty(), blender::Vector< T, InlineBufferCapacity, Allocator >::last(), blender::LOG, remap_blend_shape_anim(), blender::Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::Set(), and TempBlendShapeWeightsPrimvarName.

Referenced by remap_blend_shape_anim(), and shape_key_export_chaser().

◆ report_job_duration() [1/2]

void blender::io::usd::report_job_duration ( const ExportJobData * data)
static

◆ report_job_duration() [2/2]

void blender::io::usd::report_job_duration ( const ImportJobData * data)
static

◆ set_accessibility_property()

void blender::io::usd::set_accessibility_property ( const pxr::UsdAttribute & attr,
IDProperty * idgroup,
const pxr::UsdTimeCode time_code )
static

◆ set_attribute() [1/2]

template<typename USDT>
void blender::io::usd::set_attribute ( const pxr::UsdAttribute & attr,
const USDT value,
pxr::UsdTimeCode time,
pxr::UsdUtilsSparseValueWriter & value_writer )

◆ set_attribute() [2/2]

template<typename USDT>
void blender::io::usd::set_attribute ( const pxr::UsdAttribute & attr,
pxr::VtArray< USDT > & value,
pxr::UsdTimeCode time,
pxr::UsdUtilsSparseValueWriter & value_writer )

Set the USD attribute to the provided array value at the given time. The value will be written sparsely. For efficiency, this function swaps out the given value, leaving it empty, so it can leverage the USD API where no additional copy of the data is required.

Definition at line 185 of file usd_attribute_utils.hh.

References set_attribute().

◆ set_bool_prop()

void blender::io::usd::set_bool_prop ( IDProperty * idgroup,
const StringRefNull prop_name,
const bool bval )
static

◆ set_double_prop()

void blender::io::usd::set_double_prop ( IDProperty * idgroup,
const StringRefNull prop_name,
const double dval )
static

◆ set_fcurve_sample()

◆ set_float_prop()

void blender::io::usd::set_float_prop ( IDProperty * idgroup,
const StringRefNull prop_name,
const float fval )
static

◆ set_id_props_from_prim()

◆ set_instance_collection()

void blender::io::usd::set_instance_collection ( USDInstanceReader * instance_reader,
const Map< pxr::SdfPath, Collection * > & proto_collection_map )
static

◆ set_int_prop()

void blender::io::usd::set_int_prop ( IDProperty * idgroup,
const StringRefNull prop_name,
const int ival )
static

◆ set_job_filepath()

◆ set_normal_texture_range()

◆ set_rest_pose()

void blender::io::usd::set_rest_pose ( Main * bmain,
Object * arm_obj,
bArmature * arm,
const pxr::VtArray< pxr::GfMatrix4d > & bind_xforms,
const pxr::VtTokenArray & joint_order,
const Map< pxr::TfToken, std::string > & joint_to_bone_map,
const pxr::UsdSkelTopology & skel_topology,
const pxr::UsdSkelSkeletonQuery & skel_query )
static

◆ set_scale_bias()

void blender::io::usd::set_scale_bias ( pxr::UsdShadeShader & usd_shader,
const pxr::GfVec4f scale,
const pxr::GfVec4f bias )
static

◆ set_single_value()

◆ set_string_prop()

◆ set_transmission_opacity_range()

◆ shape_key_export_chaser()

◆ should_import_asset()

bool blender::io::usd::should_import_asset ( const std::string & path)

Return true if the asset at the given path is a candidate for importing with the USD asset resolver. The following heuristics are currently applied for this test:

  • Returns false if it's a Blender relative path.
  • Returns true if the path is package-relative.
  • Returns true is the path doesn't exist on the file system but can nonetheless be resolved by the USD asset resolver.
  • Returns false otherwise.

TODO(makowalski): the test currently requires a file-system stat. Consider possible ways around this, e.g., by determining if the path is a supported URI.

Parameters
pathinput file path
Returns
true if the path should be imported, false otherwise

Definition at line 384 of file usd_asset_utils.cc.

References asset_exists(), blender::BLI_is_file(), blender::BLI_path_is_rel(), is_udim_path(), parent_dir_exists_on_file_system(), and should_import_asset().

Referenced by blender::io::usd::USDMaterialImportContext::import_texture(), load_image(), and should_import_asset().

◆ skel_export_chaser()

void blender::io::usd::skel_export_chaser ( pxr::UsdStageRefPtr stage,
const ObjExportMap & armature_export_map,
const ObjExportMap & skinned_mesh_export_map,
const ObjExportMap & shape_key_mesh_export_map,
const Depsgraph * depsgraph )

This function is called after the USD writers are invoked, to complete the UsdSkel export process, for example, to bind skinned meshes to skeletons or to set blend shape animation data.

Parameters
stageThe stage
armature_export_mapMap armature objects to USD skeletons
skinned_mesh_export_mapMap mesh objects to USD skinned meshes
shape_key_mesh_export_mapMap mesh objects with shape-key to USD meshes with blend shape targets
depsgraphThe dependency graph in which objects were evaluated

Definition at line 1202 of file usd_skel_convert.cc.

References shape_key_export_chaser(), skel_export_chaser(), and skinned_mesh_export_chaser().

Referenced by blender::io::usd::USDHierarchyIterator::process_usd_skel(), and skel_export_chaser().

◆ skinned_mesh_export_chaser()

void blender::io::usd::skinned_mesh_export_chaser ( pxr::UsdStageRefPtr stage,
const ObjExportMap & armature_export_map,
const ObjExportMap & skinned_mesh_export_map,
pxr::UsdGeomXformCache & xf_cache,
const Depsgraph * depsgraph )

Complete the export process for skinned meshes.

Parameters
stageThe stage
armature_export_mapMap armature objects to USD skeleton paths
skinned_mesh_export_mapMap mesh objects to USD skinned meshes
xf_cacheCache to speed up USD prim transform computations
depsgraphThe dependency graph in which objects were evaluated

Definition at line 1217 of file usd_skel_convert.cc.

References CLOG_WARN, get_armature_modifier_obj(), blender::Object::id, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::items(), blender::LOG, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup_ptr(), blender::ID::name, and skinned_mesh_export_chaser().

Referenced by skel_export_chaser(), and skinned_mesh_export_chaser().

◆ split_udim_pattern()

std::pair< std::string, std::string > blender::io::usd::split_udim_pattern ( const std::string & path)
static

The following is copied from _SplitUdimPattern() in USD library source file materialParamsUtils.cpp. Split a UDIM file path such as /someDir/myFile.<UDIM>.exr into a prefix /someDir/myFile. and suffix .exr.

Definition at line 46 of file usd_asset_utils.cc.

References split_udim_pattern(), UDIM_PATTERN, and UDIM_PATTERN2.

Referenced by copy_udim_asset_to_directory(), and split_udim_pattern().

◆ stage_reader_from_handle()

USDStageReader * blender::io::usd::stage_reader_from_handle ( CacheArchiveHandle * handle)
static

◆ temp_textures_dir()

const char * blender::io::usd::temp_textures_dir ( )

Returns path to temporary folder for saving imported textures prior to packing. CAUTION: this directory is recursively deleted after material import.

Definition at line 414 of file usd_asset_utils.cc.

References blender::BKE_tempdir_session(), BLI_path_join, FILE_MAXDIR, SEP_STR, and temp_textures_dir().

Referenced by blender::io::usd::USDMaterialImportContext::import_texture(), load_image(), blender::io::usd::USDMaterialReader::load_tex_image(), and temp_textures_dir().

◆ TempBlendShapeWeightsPrimvarName()

pxr::TfToken blender::io::usd::TempBlendShapeWeightsPrimvarName ( "temp:weights" ,
pxr::TfToken::Immortal  )

◆ TEST() [1/2]

blender::io::usd::TEST ( utilities ,
make_safe_name  )

Definition at line 331 of file usd_export_test.cc.

References make_safe_name(), and TEST().

Referenced by TEST(), and TEST().

◆ TEST() [2/2]

blender::io::usd::TEST ( utilities ,
make_safe_primvar_name  )

Definition at line 368 of file usd_export_test.cc.

References make_safe_primvar_name(), and TEST().

◆ TEST_F() [1/3]

◆ TEST_F() [2/3]

◆ TEST_F() [3/3]

blender::io::usd::TEST_F ( USDStageCreationTest ,
JSONFileLoadingTest  )

◆ to_float3()

float3 blender::io::usd::to_float3 ( pxr::GfVec3f vec3f)
inlinestatic

Definition at line 29 of file usd_reader_curve.cc.

References to_float3().

Referenced by add_bezier_control_point(), and to_float3().

◆ token_for_input()

pxr::TfToken blender::io::usd::token_for_input ( const StringRef input_name)

Returns a USDPreviewSurface token name for a given Blender shader Socket name, or an empty TfToken if the input name is not found in the map.

Definition at line 1475 of file usd_writer_material.cc.

References blender::io::usd::InputSpec::input_name, blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup_ptr(), preview_surface_input_map(), and token_for_input().

Referenced by blender::io::usd::UsdExportTest::compare_blender_node_to_usd_prim(), and token_for_input().

◆ traverse_channel()

const bNodeLink * blender::io::usd::traverse_channel ( const bNodeSocket * input,
short target_type )
static

◆ USD_CacheReader_free()

◆ USD_create_handle()

CacheArchiveHandle * blender::io::usd::USD_create_handle ( Main * ,
const char * filepath,
ListBaseT< CacheObjectPath > * object_paths )

◆ USD_export()

bool blender::io::usd::USD_export ( const bContext * C,
const char * filepath,
const USDExportParams * params,
bool as_background_job,
ReportList * reports )

The USD_export takes a as_background_job parameter, and returns a boolean.

When as_background_job=true, returns false immediately after scheduling a background job.

When as_background_job=false, performs the export synchronously, and returns true when the export was ok, and false if there were any errors.

Definition at line 813 of file usd_capi_export.cc.

References blender::BKE_libblock_find_name(), blender::BKE_reportf(), blender::io::usd::ExportJobData::bmain, C, blender::io::usd::USDExportParams::collection, blender::CTX_data_main(), blender::CTX_data_scene(), blender::CTX_data_view_layer(), blender::CTX_wm_manager(), blender::CTX_wm_window(), blender::DEG_graph_build_from_collection(), blender::DEG_graph_build_from_view_layer(), blender::DEG_graph_new(), blender::io::usd::ExportJobData::depsgraph, blender::ED_editors_flush_edits(), blender::io::usd::USDExportParams::evaluation_mode, export_endjob(), blender::io::usd::ExportJobData::export_ok, export_params_valid(), export_startjob(), blender::ID_GR, NC_SCENE, ND_FRAME, blender::io::usd::ExportJobData::params, blender::wmJobWorkerStatus::reports, blender::RPT_ERROR, blender::io::usd::ExportJobData::scene, set_job_filepath(), USD_export(), blender::io::usd::ExportJobData::wm, blender::WM_JOB_PROGRESS, blender::WM_JOB_TYPE_USD_EXPORT, blender::WM_jobs_callbacks(), blender::WM_jobs_customdata_set(), blender::WM_jobs_get(), blender::WM_jobs_start(), and blender::WM_jobs_timer().

Referenced by TEST_F(), TEST_F(), and USD_export().

◆ USD_find_hook_name()

USDHook * blender::io::usd::USD_find_hook_name ( const char idname[])

◆ USD_free_handle()

void blender::io::usd::USD_free_handle ( CacheArchiveHandle * handle)

◆ USD_get_transform()

◆ USD_get_version()

int blender::io::usd::USD_get_version ( )

Definition at line 892 of file usd_capi_export.cc.

References USD_get_version().

Referenced by blender::make_usd_info(), and USD_get_version().

◆ USD_import()

◆ USD_mesh_topology_changed()

bool blender::io::usd::USD_mesh_topology_changed ( CacheReader * reader,
const Object * ob,
const Mesh * existing_mesh,
const double time,
const char ** r_err_str )

◆ USD_path_abs()

void blender::io::usd::USD_path_abs ( char * path,
const char * basepath,
bool for_import )

◆ USD_read_geometry()

void blender::io::usd::USD_read_geometry ( CacheReader * reader,
const Object * ob,
bke::GeometrySet & geometry_set,
USDMeshReadParams params,
const char ** r_err_str )

Either modifies current_mesh in-place or constructs a new mesh.

Definition at line 530 of file usd_capi_import.cc.

References get_usd_reader(), blender::io::usd::USDGeomReader::read_geometry(), and USD_read_geometry().

Referenced by blender::modify_geometry_set(), and USD_read_geometry().

◆ USD_register_hook()

void blender::io::usd::USD_register_hook ( std::unique_ptr< USDHook > hook)

Definition at line 60 of file usd_hook.cc.

References hook_list(), USD_find_hook_name(), and USD_register_hook().

Referenced by USD_register_hook().

◆ USD_unregister_hook()

void blender::io::usd::USD_unregister_hook ( const USDHook * hook)

Remove the given entry from the list of registered hooks and free the allocated memory for the hook instance.

Definition at line 71 of file usd_hook.cc.

References hook_list(), and USD_unregister_hook().

Referenced by USD_unregister_hook().

◆ visit_bones() [1/2]

void blender::io::usd::visit_bones ( const Bone * bone,
FunctionRef< void(const Bone *)> visitor )
static

◆ visit_bones() [2/2]

void blender::io::usd::visit_bones ( const Object * ob_arm,
FunctionRef< void(const Bone *)> visitor )

Recursively invoke the given function on the given armature object's bones. This function is a no-op if the object isn't an armature.

Parameters
ob_armThe armature object
visitorThe function to invoke on each bone

Definition at line 98 of file usd_armature_utils.cc.

References blender::bArmature::bonebase, blender::Object::data, blender::OB_ARMATURE, blender::Object::type, and visit_bones().

Referenced by blender::initialize().

◆ world_material_to_dome_light() [1/2]

void blender::io::usd::world_material_to_dome_light ( const Scene * scene,
WorldToDomeLight & res )

◆ world_material_to_dome_light() [2/2]

◆ write_root_accessibility_information()

void blender::io::usd::write_root_accessibility_information ( pxr::UsdStageRefPtr stage,
const USDExportParams & params )
static

If the user has provided an accessibility label and description for the export, write that information to the exported stage's default prim. This information will be written with the UsdUIAccessibilityAPI under the default namespace. Note: The information will only be added if the label is non-empty.

Definition at line 212 of file usd_capi_export.cc.

References blender::io::usd::USDExportParams::accessibility_description, blender::io::usd::USDExportParams::accessibility_label, and write_root_accessibility_information().

Referenced by export_to_stage(), and write_root_accessibility_information().

◆ write_to_path()

bool blender::io::usd::write_to_path ( const void * data,
size_t size,
const std::string & path,
ReportList * reports )

Invokes the USD asset resolver to write data to the given path.

Parameters
datapointer to data to write
sizenumber of bytes to write
pathpath of asset to be written
reportsthe storage for potential warning or error reports (generated using BKE_report API).
Returns
true if the data was written, returns false otherwise.

Definition at line 428 of file usd_asset_utils.cc.

References blender::BKE_reportf(), blender::BLI_assert(), blender::data, blender::RPT_ERROR, and write_to_path().

Referenced by export_packed_texture(), and write_to_path().

Variable Documentation

◆ LOG

CLG_LogRef blender::io::usd::LOG = {"io.usd"}
static

◆ materials_filename

const StringRefNull blender::io::usd::materials_filename = "usd/usd_materials_export.blend"

Definition at line 45 of file usd_export_test.cc.

Referenced by TEST_F().

◆ output_filename

const StringRefNull blender::io::usd::output_filename = "output.usd"

◆ simple_scene_filename

const StringRefNull blender::io::usd::simple_scene_filename = "usd/usd_simple_scene.blend"

Definition at line 44 of file usd_export_test.cc.

Referenced by TEST_F().

◆ TempBlendShapeWeightsPrimvarName

◆ UDIM_END_TILE

int blender::io::usd::UDIM_END_TILE = 1100
constexpr

Definition at line 38 of file usd_asset_utils.cc.

Referenced by copy_udim_asset_to_directory().

◆ UDIM_PATTERN

char blender::io::usd::UDIM_PATTERN[] = "<UDIM>"
constexpr

◆ UDIM_PATTERN2

char blender::io::usd::UDIM_PATTERN2[] = "%3CUDIM%3E"
constexpr

Definition at line 31 of file usd_asset_utils.cc.

Referenced by is_udim_path(), and split_udim_pattern().

◆ UDIM_START_TILE

int blender::io::usd::UDIM_START_TILE = 1001
constexpr

Definition at line 37 of file usd_asset_utils.cc.

Referenced by copy_udim_asset_to_directory().