Class CurvesImportUtils
Helper class used by nodes importing UsdGeomCurves
Inherited Members
Namespace: Unity.Importer.USD
Assembly: Unity.Importer.USD.dll
Syntax
public class CurvesImportUtils
Methods
GetLastIndexOfSlice<T>(int, NativeArray<int>, NativeArray<T>)
Simple helper function to return the last point index of a curve at index "index" - force it to be inlined.
Declaration
public static int GetLastIndexOfSlice<T>(int index, NativeArray<int> bufferHead, NativeArray<T> buffer) where T : struct
Parameters
Type | Name | Description |
---|---|---|
int | index | Current curve index. |
Native |
bufferHead | A buffer of curves head (eg. bufferHead[i] => index in buffer where the ith curve points starts). |
Native |
buffer | A buffer containing the points of all the curves, written consecutively. |
Returns
Type | Description |
---|---|
int | The last point index in buffer for the index th curve. |
Type Parameters
Name | Description |
---|---|
T | Type used by the buffer. |
GetLengthOfSlice<T>(int, NativeArray<int>, NativeArray<T>)
Simple helper function to return the buffer length of a curve at index "index" - force it to be inlined.
Declaration
public static int GetLengthOfSlice<T>(int index, NativeArray<int> bufferHead, NativeArray<T> buffer) where T : struct
Parameters
Type | Name | Description |
---|---|---|
int | index | Current curve index. |
Native |
bufferHead | A buffer of curves head (eg. bufferHead[i] => index in buffer where the ith curve points starts). |
Native |
buffer | A buffer containing the points of all the curves, written consecutively. |
Returns
Type | Description |
---|---|
int | The length of the point array that comprised the index th curve. |
Type Parameters
Name | Description |
---|---|
T | Type used by the buffer. |
GetVertexCounts(UsdGeomCurves, int)
Extract the vertexCount usd property from given curves. If the property is missing, will return a single vertexCount entry equals to the count of points. (ide. we consider that the points represent a single curve)
Declaration
public static int[] GetVertexCounts(UsdGeomCurves curves, int totalPointCount)
Parameters
Type | Name | Description |
---|---|---|
Usd |
curves | The curve data to be parsed. |
int | totalPointCount | The count of points present in this prim. |
Returns
Type | Description |
---|---|
int[] | A vertex count array describing how much point comprised each consecutive curves in this prim (derived from the vertexCount usd property) |
TryGetCurveBuffer(UsdGeomCurves, Func<int, bool>, out NativeArray<int>, out NativeArray<float3>, UsdStageMetadata, GraphLogger)
This extracts curve data from a prim and allocates several buffer used for curve sampling :
- curveBuffer, an end-to-end buffer for all curves vertices within this USD Prim
- curveBufferHead, an array which point at the start location of each curve
- vertexCounts, an array describing the length of each curves
Declaration
public static bool TryGetCurveBuffer(UsdGeomCurves curves, Func<int, bool> vertexCountValidation, out NativeArray<int> curveBufferHead, out NativeArray<float3> curveBuffer, UsdStageMetadata usdMetadata, GraphLogger GraphLogger = null)
Parameters
Type | Name | Description |
---|---|---|
Usd |
curves | The UsdGeomCurves to be parsed. |
Func<int, bool> | vertexCountValidation | A function used to validate each curves in function of their vertex count. |
Native |
curveBufferHead | A returned buffer of curves head (eg. bufferHead[i] => index in buffer where the ith curve points starts). |
Native |
curveBuffer | A returned buffer containing the points of all the curves, written consecutively. |
Usd |
usdMetadata | The imported usd metadata. |
Graph |
GraphLogger | Optional graph logger. |
Returns
Type | Description |
---|---|
bool | The result of the data extraction process. |
Remarks
Usd metadata, like scale and axis conversion, are directly applied to the point for more efficiency.
E.g. Considering two curves curve #1 = [(0,0,0), (1,0,0), (1,0,0)] & curve #2 = [(0,0,0), (1,1,1), (2,2,2)] in a prim This yields :
- curveBufferHead = [0, 3]
- curveBuffer = [(0,0,0), (1,0,0), (1,0,0), (0,0,0), (1,1,1), (2,2,2)]
- vertexCounts = [3, 3]
ValidateCurvesVertices(VtVec3fArray, int[], string, GraphLogger)
Validate a set of curve based on its VertexCount and the provided vertices.
Declaration
public static bool ValidateCurvesVertices(VtVec3fArray curvesVertices, int[] vertexCounts, string primPath, GraphLogger GraphLogger = null)
Parameters
Type | Name | Description |
---|---|---|
Vt |
curvesVertices | The curves vertices, written consecutively. |
int[] | vertexCounts | The vertexCount array for this prim. |
string | primPath | The prim path those curves belong to. |
Graph |
GraphLogger | Optional graph logger. |
Returns
Type | Description |
---|---|
bool | The result of this validation. |