openusd is a Rust implementation of Pixar's Universal Scene Description, with no C++ dependencies. Version 0.8 adds a code generator that turns a schema file into typed Rust views, and the standard schemas are now built with it. Stages also open and traverse faster.
openusd is a Rust implementation of Pixar's Universal Scene Description, with no C++ dependencies. Version 0.8 adds a code generator that turns a schema file into typed Rust views, and the standard schemas are now built with it. Stages also open and traverse faster.
Slide text
openusd 0.8 generates typed Rust code from any USD schema
Release v0.8.0 of mxpv/openusd, a Rust implementation of OpenUSD with no C++ dependencies
The new crate, openusd-build, does the job that usdGenSchema does for C++, without C++ or Python. Add it as a build dependency. In the build script, give it a search path and a schema file for each library, then call generate. Each library becomes one Rust file, with tokens, a schemas constant, typed views and token enums.
Slide text
openusdv0.8.0
Schema codegen
Generated views
Schema families
Primvars
Faster traversal
Memory mapping
Also new
Upgrading
Point a build script at schema.usda and get typed Rust views
The include schema macro brings the generated code in under the library name that the schema declares, here usdGeom. Its schemas constant registers the library, and the stage opens with that registry. From there, a mesh is a typed view, and its points read straight into a vector.
Slide text
openusdv0.8.0
Schema codegen
Generated views
Schema families
Primvars
Faster traversal
Memory mapping
Also new
Upgrading
Include the views, register them, read a mesh
use openusd::{gf, usd};
pub mod geom {
openusd::include_schema!("usdGeom");
}
let registry = usd::SchemaRegistry::builder()
.register(geom::SCHEMAS)
.build()?;
let stage = usd::Stage::builder()
.schema_registry(registry)
.open("scene.usda")?;
let mesh = geom::Mesh::get(&stage, "/World/Mesh")?
.expect("a Mesh");
let points = mesh.points_attr()
.get::<Vec<gf::Vec3f>>()?;
The schemas crate is now generated this way, and its views replace the hand-written ones. That covers eleven families, from geometry to volumes. UsdSemantics is new, and labels prims by taxonomy. UsdGeom gains primvars, the visibility and motion APIs, and a transform cache.
Slide text
openusdv0.8.0
Schema codegen
Generated views
Schema families
Primvars
Faster traversal
Memory mapping
Also new
Upgrading
All eleven standard schema families now come out of the generator
The new PrimvarsAPI creates, lists, blocks and removes a prim's primvars. Here, a heat primvar on a mesh stores two values. Four vertices share them through indices. get_at returns the two values as they were authored, and compute_flattened applies the indices, so you get one value for every vertex.
Slide text
openusdv0.8.0
Schema codegen
Generated views
Schema families
Primvars
Faster traversal
Memory mapping
Also new
Upgrading
Read a primvar as authored, or flattened to one value per vertex
Grey is before these changes and blue is after, on a generated scene of about 66 thousand prims. A warm traversal fell from about 510 milliseconds to about 110. The biggest single step came from a prim taking its status from its parent. A cold traversal takes more than 40 percent less time, and opening the scene takes about half the time.
Slide text
openusdv0.8.0
Schema codegen
Generated views
Schema families
Primvars
Faster traversal
Memory mapping
Also new
Upgrading
A warm traversal is almost five times faster
beforeafter the changes in #142
Warm traversal
507 ms
107 ms
Cold traversal
1,026 ms
577 ms
Open the scene
37.8 ms
20.5 ms
Generated scene of 65,556 prims, release build, median of 7 runs. From pull request #142 by @bresilla.
Memory mapping is new, and off by default. With it, peak heap drops by 39 percent on Moana with instance proxies, and by 42 percent on Caldera. Turn on the mmap feature and call map_files on the default resolver. It is marked unsafe because a mapped file must not change while anything read from it is still alive.
Slide text
openusdv0.8.0
Schema codegen
Generated views
Schema families
Primvars
Faster traversal
Memory mapping
Also new
Upgrading
Opt in to memory-mapped files and peak heap drops by up to 42 percent
Scene
Before
Mapped
Change
Moana, default 135k prims
3,399
2,752
−19%
Moana, instance proxies 417k prims
7,452
4,526
−39%
Caldera, default 54k prims
636
371
−42%
Heap peak in MiB
openusd = { version = "0.8", features = ["mmap"] }
let resolver = unsafe { DefaultResolver::new().map_files() };
A new utilities module ports dependency discovery, usdz packaging and asset path rewriting. A usdz package nested inside another package now reads. resolve_info reports which spec a value came from, and flatten writes a composed stage into one layer. And a damaged binary file returns an error instead of aborting.
Slide text
openusdv0.8.0
Schema codegen
Generated views
Schema families
Primvars
Faster traversal
Memory mapping
Also new
Upgrading
Package, flatten and trace where a value came from
If you use the schema views, two lines of the README example changed. Accessors now live on a trait named after the class, so PointBased becomes PointBasedSchema. And the stage opens through the builder with the schema registry, which is what makes a prim a mesh. Bump both crates to 0.8. They are still before 1.0, so the API can keep changing. So openusd 0.8 brings typed Rust code from any USD schema, and a faster stage.
Slide text
openusdv0.8.0
Schema codegen
Generated views
Schema families
Primvars
Faster traversal
Memory mapping
Also new
Upgrading
The README example changes in two places from 0.7 to 0.8
0.7
use openusd_schemas::geom::{self, PointBased};
let stage = usd::Stage::open("scene.usda")?;
0.8
use openusd_schemas::geom::{self, PointBasedSchema};
let stage = usd::Stage::builder()
.schema_registry(openusd_schemas::schema_registry())
.open("scene.usda")?;
toml
openusd = "0.8"
openusd-schemas = { version = "0.8", features = ["geom", "shade"] }