Fix T103354: Author extents on UsdGeomMesh #104676

Merged
Sybren A. Stüvel merged 6 commits from wave/blender_wave_Apple:contribs/T103354_author_extents into main 2023-02-14 12:12:05 +01:00

A properly authored USD file will have the extent attribute authored on all prims conforming to UsdGeomBoundable.
This cached extent information is useful because it allows the 3D range of prims to be quickly understood without reading potentially large arrays of data. Note that because the shape of prims may change over time, extent attributes are always evaluated for a given timecode.

This patch introduces support for authoring extents on meshes and volumes during export to USD.

Because extents are common to multiple kinds of geometries, the main support for authoring extents has been placed in USDAbstractWriter, whose new author_extent method can operate on any prim conforming to pxr::UsdGeomBoundable. The USD library already provides us the code necessary to compute the bounds for a given prim, in pxr::UsdGeomBBoxCache::ComputeLocalBound.
Note that not all prims that are imageable are boundable, such as transforms and cameras.

For more details on extents, see https://graphics.pixar.com/usd/release/api/class_usd_geom_boundable.html#details.

Note that when new types of geometries are introduced, such as curves in https://developer.blender.org/D16545, we will need to update the USD writer for that geometry such that it calls this->author_extent.

Update on Feb 2: This patch has been updated to include a unit test to ensure authored extents are valid. This test requires new test assets that will need to be submitted via svn. The test assets are attached in the d16837_usd_test_assets.zip file. To use, unzip and merge the contents of this zip into the lib/tests/usd folder.

This unit test also addresses #104269 by validating compliance of exported USD via UsdUtils.ComplianceChecker.

A properly authored USD file will have the extent attribute authored on all prims conforming to UsdGeomBoundable. This cached extent information is useful because it allows the 3D range of prims to be quickly understood without reading potentially large arrays of data. Note that because the shape of prims may change over time, extent attributes are always evaluated for a given timecode. This patch introduces support for authoring extents on meshes and volumes during export to USD. Because extents are common to multiple kinds of geometries, the main support for authoring extents has been placed in USDAbstractWriter, whose new author_extent method can operate on any prim conforming to pxr::UsdGeomBoundable. The USD library already provides us the code necessary to compute the bounds for a given prim, in pxr::UsdGeomBBoxCache::ComputeLocalBound. Note that not all prims that are imageable are boundable, such as transforms and cameras. For more details on extents, see https://graphics.pixar.com/usd/release/api/class_usd_geom_boundable.html#details. Note that when new types of geometries are introduced, such as curves in https://developer.blender.org/D16545, we will need to update the USD writer for that geometry such that it calls this->author_extent. Update on Feb 2: This patch has been updated to include a unit test to ensure authored extents are valid. This test requires new test assets that will need to be submitted via svn. The test assets are attached in the d16837_usd_test_assets.zip file. To use, unzip and merge the contents of this zip into the lib/tests/usd folder. This unit test also addresses #104269 by validating compliance of exported USD via UsdUtils.ComplianceChecker.
Michael B Johnson added 4 commits 2023-02-13 02:34:03 +01:00
67136bfcfe Fix T103354: Author extents on UsdGeomMesh
* Author extent attribute on all meshes
* Move extent authoring to USDAbstractWriter, add support for hair and volumes

Code review changes: use Blender's own bounds cache for meshes
a60f0ec2c8 Add USD Export Python Test
Initial test uses USD Compliance Checker to validate an exported USD file. Test includes the ability to skip certain tests if so desired.

Requires https://developer.blender.org/D17041 to be merged before it will succeed.

The test asset used does not cover https://developer.blender.org/D17072 as we'll need to craft a test asset for that, and we need to work through that process first. I don't think that should hold up this CI test being integrated, since it wouldn't change the test itself.
5089928eb0 Add unit test for authoring extent. Also apply additional formatting changes suggested during review.
Requires the following new files:
lib/tests/usd/usd_extent_test.blend
lib/tests/usd/textures/small_cloud.vdb
Michael B Johnson changed title from WIP contribs/T103354_author_extents to Fix T103354: Author extents on UsdGeomMesh 2023-02-13 02:35:43 +01:00
Michael B Johnson requested review from Sybren A. Stüvel 2023-02-13 02:38:54 +01:00
Michael B Johnson requested review from Michael Kowalski 2023-02-13 02:39:00 +01:00
Michael B Johnson requested review from Bastien Montagne 2023-02-13 02:40:49 +01:00
Brecht Van Lommel added this to the USD project 2023-02-13 09:06:47 +01:00
Sybren A. Stüvel added the
Interest
USD
label 2023-02-13 12:52:12 +01:00
Sybren A. Stüvel requested changes 2023-02-13 13:04:31 +01:00
Sybren A. Stüvel left a comment
Member

Just a few minor remarks.

Just a few minor remarks.
@ -152,0 +162,4 @@
pxr::GfBBox3d bounds = bboxCache.ComputeLocalBound(prim.GetPrim());
if (pxr::GfBBox3d() == bounds) {
/* This will occur, for example, if a mesh does not have any vertices. */
WM_reportf(RPT_ERROR,

Since this situation doesn't seem to abort the export itself, I think RPT_WARNING would be more suitable here.

Since this situation doesn't seem to abort the export itself, I think `RPT_WARNING` would be more suitable here.
wave marked this conversation as resolved
@ -0,0 +15,4 @@
args = None
class Result(str, enum.Enum):

I don't think this class is necessary. Comparison with {'FINISHED'} etc. is common enough in Blender unit tests that trying to abstract away from it will make it harder for people who know the Blender API to figure out what's going on.

I don't think this `class` is necessary. Comparison with `{'FINISHED'}` etc. is common enough in Blender unit tests that trying to abstract away from it will make it harder for people who know the Blender API to figure out what's going on.
wave marked this conversation as resolved
@ -0,0 +61,4 @@
)
checker.CheckCompliance(str(export_path))
collection = {}

collection is not the most descriptive name. failed_checks would be better.

`collection` is not the most descriptive name. `failed_checks` would be better.
wave marked this conversation as resolved
@ -0,0 +63,4 @@
collection = {}
to_skip = ("MissingReferenceChecker",)

Why is this rule skipped? Might be worth a comment.

Why is this rule skipped? Might be worth a comment.
wave marked this conversation as resolved
Michael B Johnson added 1 commit 2023-02-13 22:51:47 +01:00
Author
Member

We believe we've addressed all the issues @dr.sybren

We believe we've addressed all the issues @dr.sybren
Michael B Johnson requested review from Sybren A. Stüvel 2023-02-13 22:55:40 +01:00
Sybren A. Stüvel added 1 commit 2023-02-14 11:56:02 +01:00
Sybren A. Stüvel merged commit 5040c39d1a into main 2023-02-14 12:12:05 +01:00
Sybren A. Stüvel deleted branch contribs/T103354_author_extents 2023-02-14 12:12:05 +01:00
Bastien Montagne removed this from the USD project 2023-02-27 18:23:48 +01: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
2 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#104676
No description provided.