USD Import: mask multiple prim paths. #106974

Merged
Michael Kowalski merged 8 commits from makowalski/blender:usd_import_open_masked into main 2023-04-25 16:32:58 +02:00

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

image

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` ![image](/attachments/addf0ed5-384e-4e6a-b7a0-203a68913e83)
Michael Kowalski added 1 commit 2023-04-15 00:28:48 +02:00
2a1d9dd4e7 USD Import: mask multiple prim paths.
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 spaces, 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.
Michael Kowalski added the
Interest
USD
Interest
Pipeline, Assets & IO
labels 2023-04-15 00:29:21 +02:00
Michael Kowalski requested review from Matt McLin 2023-04-17 16:06:27 +02:00
Michael Kowalski requested review from Bastien Montagne 2023-04-17 16:40:26 +02:00
Michael Kowalski added the
Module
Pipeline, Assets & IO
label 2023-04-17 17:44:45 +02:00
Michael Kowalski added this to the USD project 2023-04-17 18:19:29 +02:00
Matt McLin requested changes 2023-04-17 19:06:46 +02:00
Matt McLin left a comment
Member

Overall looks good to me, just a couple small changes recommended.

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");
Member

Typo here, should be "semicolons"

Typo here, should be "semicolons"
makowalski marked this conversation as resolved
@ -376,6 +390,8 @@ static void import_endjob(void *customdata)
break;
}
MEM_freeN(data->params.prim_path_mask);
Member

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 call MEM_freeN if non-null.

`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 call `MEM_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.

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.
Author
Member

Thanks for pointing this out, @Matt-McLin and @mont29. I've updated the code to use MEM_SAFE_FREE.

Thanks for pointing this out, @Matt-McLin and @mont29. I've updated the code to use `MEM_SAFE_FREE`.
Bastien Montagne reviewed 2023-04-18 09:57:22 +02:00
Bastien Montagne left a comment
Owner

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?

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?
Michael Kowalski added 2 commits 2023-04-18 18:43:25 +02:00
d642a2c5e2 USD import: prim_path_mask option cleanup.
Fixes based on review feedback:

Fixed typo in prim_path_mask option description.

Now calling MEM_SAFE_FREE on allocated prim_path_mask string.
Author
Member

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?

> 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 ;) ).

@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 ;) ).*
Bastien Montagne approved these changes 2023-04-19 20:42:53 +02:00
Author
Member

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.

> *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.
Matt McLin approved these changes 2023-04-20 04:45:50 +02:00
Matt McLin left a comment
Member

LGTM

LGTM
Michael Kowalski added 2 commits 2023-04-24 18:03:50 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
9d7a0a2f18
USD import: don't allow spaces in Path Mask.
No longer allowing spaces as separators in Path Mask option.
Author
Member

@mont29 No longer allowing spaces as separators. I'll aim to commit this tomorrow.

@mont29 No longer allowing spaces as separators. I'll aim to commit this tomorrow.
Author
Member

@blender-bot build

@blender-bot build
Michael Kowalski added 2 commits 2023-04-25 15:59:12 +02:00
Michael Kowalski added 1 commit 2023-04-25 16:18:15 +02:00
Michael Kowalski merged commit 239af1705d into main 2023-04-25 16:32:58 +02:00
Michael Kowalski deleted branch usd_import_open_masked 2023-04-25 16:32:58 +02:00
Howard Trickey referenced this issue from a commit 2023-05-29 02:51:44 +02:00
Bastien Montagne removed this from the USD project 2023-08-25 23:52:45 +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#106974
No description provided.