USD Export: New Curves/Hair Support #105375
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#105375
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "SonnyCampbell_Unity/blender:unity/T102376-USD-Curves-Export"
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?
Previous patch location: https://archive.blender.org/developer/D16545
This patch addresses #102376
A new writer is added, the usd_writer_curves.cc to handle transforming the new curves system into USD.
The goal was to enable export of the new curves type, but @HooglyBoogly mentioned there is a
curve_legacy_to_curves
utility function that could also handle converting legacy curves to the new Curves type. This very trivially enables the legacy curves for export too so I have included that change in this patch.Result in usdview:
@ -0,0 +1,492 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2022 Blender Foundation. All rights reserved. */
Should be this year.
WIP: USD Export - New Curves/Hair Supportto USD Export - New Curves/Hair SupportUSD Export - New Curves/Hair Supportto USD Export: New Curves/Hair SupportLooking good! Will be really nice to have this supported so IO with the new curve system is more possible.
Did you think about support for generic attributes here? That's an important part of the new workflow so it might be nice to support it here. Probably adds a bunch more code though, so it could make sense to do it in a separate PR.
@ -0,0 +126,4 @@
control_point_counts[i_curve] = tot_points;
/* For periodic linear curve, segment count = curveVertexCount.
For periodic cubic curve, segment count = curveVertexCount / vstep.
Comment formatting: https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Comments
@ -0,0 +175,4 @@
const int bezier_vstep = 3;
const OffsetIndices points_by_curve = geometry.points_by_curve();
for (int i_curve = 0; i_curve < geometry.curve_num; i_curve++) {
for (const int i_curve : geometry.curves_range())
is a slightly nicer way to write this, and it allows the iterator variable to be const@ -0,0 +177,4 @@
for (int i_curve = 0; i_curve < geometry.curve_num; i_curve++) {
const IndexRange curve_points = points_by_curve[i_curve];
The "canonical" variable name used elsewhere for this is
points
instead ofcurve_points
@ -0,0 +183,4 @@
const int start_verts_count = verts.size();
for (int i_point = start_point_index; i_point < last_point_index; i_point++) {
IndexRange
can be iterated directly here:for (const int i : points) {
If you want to skip the last point, you can use
for (const int i : points.drop_back(1)) {
Is this a necessary change? Personally I find "i_point < last_point_index" more readable than points.drop_back(1).
@ -0,0 +294,4 @@
knots.resize(knots_num);
for (int i_knot = 0; i_knot < knots_num; i_knot++) {
knots[i_knot] = double(temp_knots[i_knot]);
Maybe I'm missing something, but doesn't this replace the knots completely with every new curve?
Yeah you are right, thanks for catching this! I need to rethink what I was trying to do here.
I have resolved this issue with the knots now. According to the USD spec
knots should be the concatentation of all batched curves
so I've updated the logic there and added a test with a curve containing two NURBS curves.https://openusd.org/dev/api/class_usd_geom_nurbs_curves.html#details
@ -0,0 +382,4 @@
});
if (number_of_curve_types > 1) {
WM_report(RPT_WARNING, "Cannot export mixed curve types in the same Curve object.");
Small thing, but
Curve
should beCurves
here, same with below.@ -0,0 +419,4 @@
}
else if (first_frame_curve_type != curve_type) {
WM_reportf(RPT_WARNING,
"USD does not support animating curve types. The curve type changes from %i to "
If you want this to be extra pretty, you could use
rna_enum_curves_types
andIFACE_(RNA_enum_name_from_value(..)
to print the UI name instead of the integer value.@ -0,0 +52,4 @@
void check_bezier_curve(const pxr::UsdPrim bezier_prim,
const bool is_periodic,
const int vertex_count);
void check_nurbs_curve(const pxr::UsdPrim nurbs_prim,
The above three functions (
check_catmullRom_curve
,check_bezier_curve
,check_nurbs_curve
) need to be marked as static to match their definition below, otherwise this code does not compile with clang on macOS.Looks good to me, with just small fix needed for compiling on Mac.
I forget exactly where this left off, but the change looks nice now, and makes sense for a first step.Just a few small inline comments this time.
@ -0,0 +86,4 @@
return pxr::TfToken();
}
const size_t accumulatedControlPointCount = std::accumulate(
Use
snake_case
for variable names (https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Naming)@ -0,0 +387,4 @@
});
if (number_of_curve_types > 1) {
WM_report(RPT_WARNING, "Cannot export mixed curve types in the same Curves object.");
It's weird, but the period is added automatically to these report strings AFAIK, so no need to add it here. Same below.
Thanks @HooglyBoogly - yeah sorry it's been awhile since I got a chance to come back to this.
For some reason gitea won't let me resolve conversations, but from the previous comments I just need to take a look at the knots issue, and will address those two you have just added.
I'm standing down as reviewer, to not be a delaying factor here.
LGTM, and confirmed builds & appears to work ok on Mac (after merging latest from main into this branch).
@ -0,0 +427,4 @@
else if (first_frame_curve_type != curve_type) {
const char *first_frame_curve_type_name = nullptr;
RNA_enum_name_from_value(
rna_enum_curves_types, (int)first_frame_curve_type, &first_frame_curve_type_name);
(int)first_frame_curve_type
->int(first_frame_curve_type)
Functional style casts here (and below) (https://wiki.blender.org/wiki/Style_Guide/C_Cpp#C.2B.2B_Type_Cast)
@blender-bot build
I re-tested with the latest changes, and confirmed curves export is working well! I'll commit the PR shortly, as soon as conflict-checking is complete.
I also just committed the test file to svn.
@blender-bot build