Refactor: in USD importer extract read_mesh params into a struct #104459

Closed
Sonny Campbell wants to merge 11 commits from SonnyCampbell_Unity/blender:unity/T91369-parameter-refactor into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

This is a small initial refactor to extract the USDGeomReader.read_mesh parameters into a separate struct. This will allow for adding extra paramters to handle importing velocities for
#104462
https://archive.blender.org/developer/D15430

Original patch was being reviewed here:
https://archive.blender.org/developer/D15435

This is a small initial refactor to extract the USDGeomReader.read_mesh parameters into a separate struct. This will allow for adding extra paramters to handle importing velocities for https://projects.blender.org/blender/blender/pulls/104462 https://archive.blender.org/developer/D15430 Original patch was being reviewed here: https://archive.blender.org/developer/D15435
Sonny Campbell added 2 commits 2023-02-08 10:56:24 +01:00
3de9df6b6d USD Importer refactor: Extracting read_mesh params into a struct
This is a small initial refactor to extract the `USDGeomReader.read_mesh` parameters into a separate struct. This will allow for adding extra paramters to handle importing velocities for T91369
Sonny Campbell changed title from unity/T91369-parameter-refactor to USD Importer refactor: Extracting read_mesh params into a struct 2023-02-08 10:56:35 +01:00
Sonny Campbell requested review from Sybren A. Stüvel 2023-02-08 10:57:02 +01:00
Brecht Van Lommel changed title from USD Importer refactor: Extracting read_mesh params into a struct to Refactor: in USD importer extract read_mesh params into a struct 2023-02-09 12:43:21 +01:00
Sybren A. Stüvel reviewed 2023-02-10 12:27:29 +01:00
@ -38,3 +38,2 @@
Mesh *read_mesh(struct Mesh *existing_mesh,
double motionSampleTime,
int read_flag,
const USDMeshReadParams params,

Remove const, it has no meaning in function declarations for pass-by-value types.
Same in other declarations with a const USDMeshReadParams params parameter.

Remove `const`, it has no meaning in function declarations for pass-by-value types. Same in other declarations with a `const USDMeshReadParams params` parameter.
Author
Member

Done

Done
SonnyCampbell_Unity marked this conversation as resolved
Sybren A. Stüvel requested changes 2023-02-10 12:33:23 +01:00
Sybren A. Stüvel left a comment
Member

The patch compiles now :)

Just a few minor remarks.

The patch compiles now :) Just a few minor remarks.
@ -69,0 +70,4 @@
* usd file for the mesh sequence cache.
*/
typedef struct USDMeshReadParams {
double motion_sample_time; /* Read USD TimeCode in frames. */

"Read" is ambiguous here. Is it past or future tense?

"Read" is ambiguous here. Is it past or future tense?
Author
Member

It's neither. It's read as opposed to write. It's usage is everywhere as a parameter in a read_mesh function, so it's very clear what it means from the context.

It's neither. It's read as opposed to write. It's usage is everywhere as a parameter in a `read_mesh` function, so it's very clear what it means from the context.
Author
Member

It's also consistent with ABCReadParams for ABC_read_mesh in the alembic import code

It's also consistent with `ABCReadParams` for `ABC_read_mesh` in the alembic import code

In that case I would just change the comment to "USD TimeCode in frames", as it then limits itself to just describing the units of measurement, and not the operation that it's involved with. The fact that it's used for reading is clear from the name of the struct.

In that case I would just change the comment to "USD TimeCode in frames", as it then limits itself to just describing the units of measurement, and not the operation that it's involved with. The fact that it's used for reading is clear from the name of the struct.
Author
Member

Done

Done
SonnyCampbell_Unity marked this conversation as resolved
@ -249,3 +249,2 @@
# ifdef WITH_USD
result = USD_read_mesh(
mcmd->reader, ctx->object, mesh, time * FPS, &err_str, mcmd->read_flag);
USDMeshReadParams params = {};

Since there are multiple places where a USDMeshReadParams is created, it'll be better to have a function that takes the fields as arguments, and returns a USDMeshReadParams struct.

That will cause compiler errors if ever a field was added but not handled in that particular bit of code. It also aids in constness as it allows for const USDMeshReadParams params = newUSDMeshReadParams(bla, bla); here.

Since there are multiple places where a `USDMeshReadParams` is created, it'll be better to have a function that takes the fields as arguments, and returns a `USDMeshReadParams` struct. That will cause compiler errors if ever a field was added but not handled in that particular bit of code. It also aids in `const`ness as it allows for `const USDMeshReadParams params = newUSDMeshReadParams(bla, bla);` here.
Author
Member

Done

Done
SonnyCampbell_Unity marked this conversation as resolved
Sonny Campbell added 1 commit 2023-02-10 13:44:32 +01:00
Sonny Campbell requested review from Sybren A. Stüvel 2023-02-10 13:45:46 +01:00
Brecht Van Lommel added this to the USD project 2023-02-13 09:23:02 +01:00
Sybren A. Stüvel reviewed 2023-02-13 11:52:53 +01:00
@ -465,12 +465,19 @@ static USDPrimReader *get_usd_reader(CacheReader *reader,
return usd_reader;
}
USDMeshReadParams create_mesh_read_params(double motion_sample_time, int read_flags)

const for both parameters.

`const` for both parameters.
SonnyCampbell_Unity marked this conversation as resolved
Sybren A. Stüvel reviewed 2023-02-13 11:53:14 +01:00
@ -471,3 +479,1 @@
const double time,
const char **err_str,
const int read_flag)
USDMeshReadParams params,

const

`const`
SonnyCampbell_Unity marked this conversation as resolved
Sonny Campbell added 1 commit 2023-02-13 12:45:47 +01:00
Sybren A. Stüvel approved these changes 2023-02-13 16:48:48 +01:00
Sybren A. Stüvel left a comment
Member

Nice, thanks!

Nice, thanks!
Bastien Montagne approved these changes 2023-02-16 11:22:10 +01:00
Bastien Montagne left a comment
Owner

LGTM too.

@makowalski want to do the commit?

LGTM too. @makowalski want to do the commit?
Bastien Montagne force-pushed unity/T91369-parameter-refactor from 409ee2669b to 035fa023cd 2023-02-16 11:23:54 +01:00 Compare

@blender-bot build

@blender-bot build
Sonny Campbell added 6 commits 2023-02-17 17:48:44 +01:00
Author
Member

@blender-bot build

@blender-bot build
Member

Only blender organization members with write access can start builds. See documentation for details.

Only blender organization members with write access can start builds. See [documentation](https://projects.blender.org/infrastructure/blender-bot) for details.

@blender-bot build

@blender-bot build

LGTM too.

@makowalski want to do the commit?

My apologies. The pull request emails were getting filtered into my junk folder, so I didn't get this message till now. I'll do the commit on Monday, since it's right before the weekend. Thanks.

> LGTM too. > > @makowalski want to do the commit? My apologies. The pull request emails were getting filtered into my junk folder, so I didn't get this message till now. I'll do the commit on Monday, since it's right before the weekend. Thanks.
Sonny Campbell added 1 commit 2023-02-22 11:13:00 +01:00

Committed on the command line to

1b7076bd4f

Committed on the command line to https://projects.blender.org/blender/blender/commit/1b7076bd4f6e453e9fd5b6355ffa5d0c8a31ddbd
Michael Kowalski closed this pull request 2023-02-22 17:26:46 +01:00
Bastien Montagne removed this from the USD project 2023-02-27 18:24:05 +01:00

Pull request closed

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
5 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#104459
No description provided.