USD Curve Export: Pinned CatmullRom Curve

In Blender the first and last points of a catmullRom curve are
treated as endpoints. To account for this in USD, we must set
the wrap attribute to 'pinned'. This lets the client know that
the first and last points are to be treated as points on the
curve, and that it needs to generate "phantom" points to account
for the start and end control points of a general catmullRom curve.

Related to #102376

Co-authored-by: DESKTOP-ON14TH5\Sonny Campbell <sonny.campbell@unity3d.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/108183
This commit is contained in:
Sonny Campbell
2023-05-23 19:18:17 +02:00
committed by Michael Kowalski
parent 2262ea079b
commit a127707cb4
2 changed files with 9 additions and 2 deletions

View File

@@ -54,6 +54,13 @@ pxr::UsdGeomCurves USDCurvesWriter::DefineUsdGeomBasisCurves(pxr::VtValue curve_
if (is_cyclic) {
basis_curves.CreateWrapAttr(pxr::VtValue(pxr::UsdGeomTokens->periodic));
}
else if (curve_basis == pxr::VtValue(pxr::UsdGeomTokens->catmullRom)) {
/* In Blender the first and last points are treated as endpoints. The pinned attribute tells
* the client that to evaluate or render the curve, it must effectively add 'phantom
* points' at the beginning and end of every curve in a batch. These phantom points are
* injected to ensure that the interpolated curve begins at P[0] and ends at P[n-1]. */
basis_curves.CreateWrapAttr(pxr::VtValue(pxr::UsdGeomTokens->pinned));
}
else {
basis_curves.CreateWrapAttr(pxr::VtValue(pxr::UsdGeomTokens->nonperiodic));
}

View File

@@ -192,8 +192,8 @@ static void check_catmullRom_curve(const pxr::UsdPrim prim,
<< "Wrap token should be periodic for periodic curve";
}
else {
EXPECT_EQ(wrap_token, pxr::UsdGeomTokens->nonperiodic)
<< "Wrap token should be nonperiodic for nonperiodic curve";
EXPECT_EQ(wrap_token, pxr::UsdGeomTokens->pinned)
<< "Wrap token should be pinned for nonperiodic catmullRom curve";
}
pxr::UsdAttribute vert_count_attr = curve.GetCurveVertexCountsAttr();