USD export: option to add a root prim. #107855

Merged
Michael Kowalski merged 12 commits from makowalski/blender:usd-root-prim into main 2023-05-15 16:01:06 +02:00

This update combines work in pull request #104506 by @expenses and an implementation in the 'universal-scene-description' branch.

This pull request adds a root_prim_path USD export string parameter. If this option is set to a well-formed prim path (e.g., '/World'), a transform primitive with the given path will be added to the stage as the parent of all exported primitives. This will allow transforming the scene by this root node in other applications and is also required for loading the exported scene as a reference in other USDs.

As part of this change, the _materials node, which contains all exported materials, is also created under the root prim. This is required so that materials are imported correctly when the USD is referenced in another stage.

Finally, added an export_params_valid() function to verify that the root_prim_path is valid before starting the export job. This function can be extended in the future to perform additional validation of other export parameters.

Contributor: Ashley Ruglys (expenses)

This update combines work in pull request https://projects.blender.org/blender/blender/pulls/104506 by @expenses and an implementation in the 'universal-scene-description' branch. This pull request adds a `root_prim_path` USD export string parameter. If this option is set to a well-formed prim path (e.g., '/World'), a transform primitive with the given path will be added to the stage as the parent of all exported primitives. This will allow transforming the scene by this root node in other applications and is also required for loading the exported scene as a reference in other USDs. As part of this change, the `_materials` node, which contains all exported materials, is also created under the root prim. This is required so that materials are imported correctly when the USD is referenced in another stage. Finally, added an `export_params_valid()` function to verify that the `root_prim_path` is valid before starting the export job. This function can be extended in the future to perform additional validation of other export parameters. Contributor: Ashley Ruglys (expenses)
Michael Kowalski added the
Interest
Pipeline, Assets & IO
Interest
USD
labels 2023-05-11 23:27:47 +02:00
Michael Kowalski added 7 commits 2023-05-11 23:27:56 +02:00
4c65168e3c USD export: option to add a root prim.
Added a root_prim_path USD string option.  If this option is set to
a prim path (e.g., '/World'), a transform primitive with the given
path will be added to the stage as the parent of all exported
primitives. This will allow transforming the scene by this root
node in other applications and is also required for loading the
exported scene as a reference in other USDs.

Also added logic to include the material library node, which contains
all exported materials, under this root prim.

Finally, added an export_params_valid() function to verify that the
root_prim_path is valid before starting the export jog.  This function
can be extended in the future to perform additional validation of
other export parameters.
Michael Kowalski added this to the USD project 2023-05-11 23:29:03 +02:00
Michael Kowalski requested review from Brecht Van Lommel 2023-05-11 23:29:27 +02:00
Michael Kowalski requested review from Matt McLin 2023-05-11 23:29:43 +02:00
Matt McLin approved these changes 2023-05-12 02:32:24 +02:00
Matt McLin left a comment
Member

This looks good to me, thanks! Just a minor consideration about the error reporting and question to @brecht about RNA_string_get.

This looks good to me, thanks! Just a minor consideration about the error reporting and question to @brecht about `RNA_string_get`.
@ -140,1 +155,4 @@
char root_prim_path[FILE_MAX];
RNA_string_get(op->ptr, "root_prim_path", root_prim_path);
process_prim_path(root_prim_path);
Member

I see this is same convention used everywhere else, so not a problem for this PR, but just a question: it seems RNA_string_get doesn't concern itself with potential buffer overflow or null termination (which could impact the strlen operation in process_prim_path, among other things). Is this somehow handled in a clever way that I'm missing?

I see this is same convention used everywhere else, so not a problem for this PR, but just a question: it seems `RNA_string_get` doesn't concern itself with potential buffer overflow or null termination (which could impact the `strlen` operation in `process_prim_path`, among other things). Is this somehow handled in a clever way that I'm missing?

The RNA_def_string for this property sets the maximum length to FILE_MAX, so this is ok.

The `RNA_def_string` for this property sets the maximum length to `FILE_MAX`, so this is ok.
brecht marked this conversation as resolved
@ -67,0 +111,4 @@
bool valid = true;
if (!prim_path_valid(params.root_prim_path)) {
WM_reportf(RPT_ERROR, "USD Export: Root Prim option is invalid");
Member

I wonder if it might be better to remove this WM_reportf? If every failure path in prim_path_valid already reports an error, then this seems superfluous, and also the error reported from prim_path_valid provides more explicit guidance to the user about the problem.

I wonder if it might be better to remove this `WM_reportf`? If every failure path in `prim_path_valid` already reports an error, then this seems superfluous, and also the error reported from `prim_path_valid` provides more explicit guidance to the user about the problem.
Author
Member

I agree and will remove the report statement. Thanks very much for the review!

I agree and will remove the report statement. Thanks very much for the review!
brecht marked this conversation as resolved
Michael Kowalski added 3 commits 2023-05-12 19:19:15 +02:00
e9412a03b8 USD export: remove unneeded output in validation.
Per review comments, removed redundant report statement
in the export parameter validation function.
buildbot/vexp-code-patch-coordinator Build done. Details
3b65cdc65b
USD export: consistent report messages.
Updated prim_path_valid() report messages to be
consistent in wording and capitalization.
Author
Member

@blender-bot build

@blender-bot build
Michael Kowalski added 2 commits 2023-05-12 20:20:49 +02:00
Author
Member

@blender-bot build

@blender-bot build
Brecht Van Lommel approved these changes 2023-05-12 20:31:26 +02:00
Author
Member

Thanks for the review, @brecht.

Thanks for the review, @brecht.
Michael Kowalski merged commit 42342124f8 into main 2023-05-15 16:01:06 +02:00
Michael Kowalski deleted branch usd-root-prim 2023-05-15 16:01:07 +02:00
Howard Trickey referenced this issue from a commit 2023-05-29 02:51:39 +02:00
Bastien Montagne removed this from the USD project 2023-08-25 23:55:13 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
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, Assets & 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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#107855
No description provided.