USD Import: mask multiple prim paths. #106974
No reviewers
Labels
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
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#106974
Loading…
Reference in New Issue
No description provided.
Delete Branch "makowalski/blender:usd_import_open_masked"
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 patch addresses bug #102594.
These changes enhance the prim_path_mask USD import option to allow masking on multiple paths.
Changed the prim_path_mask import property to a string of arbitrary size.
Multiple paths may be specified in a list delimited by commas or semicolons.
Now using the pxr::UsdStagePopulationMask class to apply the masking when opening the stage, which is more efficient and which preserves the full prim paths.
To test, import a USD with the
prim_path_mask
option set to multiple paths delimited by commas or semicolons. For example, when importing the Pixar Kitchen Set, one may set the mask to/Kitchen_set/Props_grp/DiningTable_grp/TableTop_grp/Spoon_2;/Kitchen_set/Props_grp/DiningTable_grp/TableTop_grp/CerealBowl_grp
Overall looks good to me, just a couple small changes recommended.
@ -623,0 +620,4 @@
0,
"Path Mask",
"Import only the primitive at the given path and its descendents. "
"Multiple paths may be specified in a list delimited by spaces, commas or somicolons");
Typo here, should be "semicolons"
@ -376,6 +390,8 @@ static void import_endjob(void *customdata)
break;
}
MEM_freeN(data->params.prim_path_mask);
MEM_freeN
aborts with an error if we attempt to free a null ptr. I think that can't happen here given current implementation, but given that the freeing of the object is so far separated from the allocation, I think it would be safer to only callMEM_freeN
if non-null.Just use
MEM_SAFE_FREE
macro, it checks for NULL pointers, and in addition assigns null to freed pointer, which makes further potential invalid access to it very easy to identify.Thanks for pointing this out, @Matt-McLin and @mont29. I've updated the code to use
MEM_SAFE_FREE
.Patch LGTM, the only thing I would remove is allowing to use spaces as separator...
Not sure about USD paths (and could not find the answer from a very quick search online), but in general paths can have spaces nowadays, so would rather avoid relying on spaces as separators?
Thanks for raising this issue. I certainly understand your concern. I believe spaces are not valid in USD primitive namespaces. If I try to create a USD prim path with a space, USD generates an error. Also, this USD utility function defines valid identifiers as follows:
An identifier is valid if it follows the C/Python identifier convention; that is, it must be at least one character long, must start with a letter or underscore, and must contain only letters, underscores, and numerals.
https://github.com/PixarAnimationStudios/USD/blob/release/pxr/base/tf/stringUtils.h#L680
IMHO, one reason for allowing spaces as separators might be for a more intuitive UI. I.e., it might be a natural way for users to enter items in a list. Would allowing spaces for this reason be acceptable, in your opinion?
@makowalski OK, then if spaces are forbidden into USD paths, I guess it's fine to keep spaces as separators.
Also personally I would never recommend doing this (just like I would never recommend adding spaces into file names and such ;) ).
Thank you, @mont29. I completely respect your opinion on this point, so I will remove the option to use spaces as separators, as I don't feel strongly about this.
I will be out the next two days, so I will aim to merge this pull request on Monday of next week, after I've made this final change, since I want to be available to handle any possible issues after the commit.
Thanks, again.
LGTM
@mont29 No longer allowing spaces as separators. I'll aim to commit this tomorrow.
@blender-bot build