USD: Adding an option to convert the scene's meters per unit value #122804
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
FBX
Interest
Freestyle
Interest
Geometry Nodes
Interest
glTF
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#122804
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "CharlesWardlaw/blender:feature/usd_convert_to_cm"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This rescales the whole scene by its root transform to match the same visual size while not forcing the user to wait for scale to be applied to each object.
This is requested by studios whose main applications / USD scenes are in CM, because referencing and payloading scenes from disparate scales can cause issues at resolution time.
Thanks for porting this @CharlesWardlaw ! I was thinking that the unit conversion should be made more generic to handle arbitrary unit scaling, not just centimeters. The initial USD branch implementation supported centimeters only, but I always felt that this prototype is too limited in that regard. It shouldn't be hard to extend this to handle other units. What do you think?
I agree that the functionality would be useful (even though we prefer meters ourselves).
However, I think this might be better served as a dropdown enum choice of common units? With a default of Meters, and any other unit sizes as options (could just be meters and centimetres to start). In fact, I'd recommend that the input to the operator itself actually be a float that defaults to 1 (metersPerUnit=1.0) and the dropdown just be a UI set of preset values.
That way it's generalizable and easy to add more unit sizes in the future, since some studios use imperial units. By generalizing it to a scalar , that enum just needs to change the scalar without modifying the rest of the code.
This is generally how I implemented it in other DCCs and our internal pipeline as well.
It's easy enough to add-- I'll send a follow up in a few.
I think this is correct, but I'm going to do a bunch more tests first. 🤣
USD: Adding a Convert to Centimeters optionto USD: Adding an option to convert the scene's meters per unit value@ -159,0 +164,4 @@
{USD_SCENE_UNITS_INCHES, "INCHES", 0, "Inches", "Scene scale of 0.0254"},
{USD_SCENE_UNITS_FEET, "FEET", 0, "Feet", "Scene scale of 0.3048"},
{USD_SCENE_UNITS_YARDS, "YARDS", 0, "Yards", "Scene scale of 0.9144"},
{USD_SCENE_UNITS_CUSTOM, "CUSTOM", 0, "Custom", "Specify a custom scene scale value"},
Minor point: the help for the
Custom
option is "Specify a custom scene scale value". However, the custom value is actually in meters-per-unit. Would it be better to be consistent? I.e., either have the help for all the menu items be in meters-per-unit, or have theCustom
option be a scene scale? The former option (using meters-per-unit for all items) would probably be less work and might fit better with the USD conventions. Again, this might not be an important issue.@ -45,1 +45,3 @@
if (!usd_export_context_.export_params.convert_orientation) {
if ((!usd_export_context_.export_params.convert_orientation ||
usd_export_context_.export_params.convert_scene_units))
{
I think this conditional should be
Note the
!
is outside the innermost parentheses. Without this change, no transform is applied to root prims if theRoot Prim
export param is empty. To reproduce, export the default cube to USDA with an emptyRoot Prim
path withConvert Scene Units
set to something other than meters. Note that the prims don't have the scaling set.@ -135,2 +145,3 @@
bool allow_unicode = false;
eUSDSceneUnits convert_scene_units = eUSDSceneUnits::USD_SCENE_UNITS_METERS;
float meters_per_unit = 1.0f;
Just a question that occurred to me: is
convert_scene_units
redundant in this case? I.e., would it be sufficient to just havemeters_per_unit
set appropriately inio_usd.cc
and use that to compute the scale? I know this would change some of the logic elsewhere to determine whether to apply scaling by checking ifmeters_per_unit
is close to 1.0, so there are tradeoffs with either approach.This whole units thing reminded me of #128337 which also attempts to add units dropdown to another I/O type. Maybe it would be good to unify that across various I/O types and use shared code?
Checkout
From your project repository, check out a new branch and test the changes.