* Initial commit for automating code formatting

- Added Yamato config file to run the unity-meta tool
- Added .repoconfig to ignore files we don't want modified

* Apply formatting changes

* Code Formatting CI Updates

- Renamed 'Formatting' to 'Validate Formatting' for clarity
- Added the formatting checks to the Test Trigger

Co-authored-by: noreply@unity3d.com <noreply@unity3d.com>
This commit is contained in:
Vicky Clark 2022-12-09 12:48:24 +00:00 коммит произвёл GitHub
Родитель b8557d9eaf
Коммит 1308f89b2f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
28 изменённых файлов: 211 добавлений и 152 удалений

19
.repoconfig Normal file
Просмотреть файл

@ -0,0 +1,19 @@
[version]
repoconfig=7
minimum-unity-meta=47
[format]
path-ignore=<<EOT
# specially named folders that will be matched anywhere in a path (e.g. all files under any 'src' will be ignored)
(^|/)(
src
)(/|$)
|
(^|/)(
package/com.unity.formats.usd/Dependencies
)(/|$)
|
.*\.meta
|
.md
EOT

30
.yamato/formatting.yml Normal file
Просмотреть файл

@ -0,0 +1,30 @@
formatting:
name: Validate Formatting
agent:
type: Unity::VM
image: package-ci/ubuntu:v1.3.1-719011
flavor: b1.small
commands:
- git clone --depth 1 --branch stable git@github.cds.internal.unity3d.com:unity/unity-meta.git
- mv unity-meta ~/unity-meta
- perl ~/unity-meta/Tools/Format/format.pl --dry-run TestProject package/com.unity.formats.usd
timeout: 1
formatting_apply:
name: Formatting (Apply requested changes)
agent:
type: Unity::VM
image: package-ci/ubuntu:v1.3.1-719011
flavor: b1.small
commands:
- git config --global user.name "noreply@unity3d.com"
- git config --global user.email "noreply@unity3d.com"
- git checkout $GIT_BRANCH
- git pull origin $GIT_BRANCH # In case the job was not run on the latest commit, attempt to get it. There may be situations with merge conflicts, in that case wait for everyone to push their changes and then only run the formatting job on HEAD.
- git clone --depth 1 --branch stable git@github.cds.internal.unity3d.com:unity/unity-meta.git
- mv unity-meta ~/unity-meta
- perl ~/unity-meta/Tools/Format/format.pl TestProject package/com.unity.formats.usd --nobackups
- git add . # Take care not to add commands that might create unexpected changes
- git commit -m "Apply formatting changes"
- git push --set-upstream origin $GIT_BRANCH
timeout: 1

Просмотреть файл

@ -116,6 +116,7 @@ test_trigger:
- .yamato/upm-ci.yml#test_standalone_{{ platform.name }}_{{ backend.editor }}_{{ backend.name }}
{% endfor %}
{% endfor %}
- .yamato/formatting.yml#formatting
nightly_test_trigger:
name: Nightly tests Trigger

Просмотреть файл

@ -27,7 +27,7 @@ namespace DefaultNamespace
public void SetUp()
{
var curve = AnimationCurve.Linear(0, 0, 10, 10);
var clip = new AnimationClip {hideFlags = HideFlags.DontSave};
var clip = new AnimationClip { hideFlags = HideFlags.DontSave };
clip.SetCurve("", typeof(Transform), "localPosition.x", curve);
var timeline = ScriptableObject.CreateInstance<TimelineAsset>();
timeline.hideFlags = HideFlags.DontSave;
@ -59,13 +59,13 @@ namespace DefaultNamespace
[TearDown]
public void TearDown()
{
// For some reason Yamato throws System.UnauthorizedAccessException
/* foreach (var file in deleteFileList)
{
File.Delete(file);
}
// For some reason Yamato throws System.UnauthorizedAccessException
/* foreach (var file in deleteFileList)
{
File.Delete(file);
}
deleteFileList.Clear();*/
deleteFileList.Clear();*/
}
[UnityTest]
@ -73,7 +73,7 @@ namespace DefaultNamespace
{
var sampleT = 3f;
director.Play();
while (Time.time < director.duration )
while (Time.time < director.duration)
{
yield return null;
}

Просмотреть файл

@ -27,7 +27,7 @@ namespace Unity.Formats.USD
[CustomEditor(typeof(UsdAsset))]
public class UsdAssetEditor : Editor
{
private readonly string[] kTabNames = new string[] {"Simple", "Advanced"};
private readonly string[] kTabNames = new string[] { "Simple", "Advanced" };
private int m_tab;
private Texture2D m_usdLogo;
@ -233,7 +233,7 @@ namespace Unity.Formats.USD
else
lastDir = Path.GetDirectoryName(usdAsset.usdFullPath);
string importFilepath =
EditorUtility.OpenFilePanelWithFilters("Usd Asset", lastDir, new string[] {"Usd", "us*"});
EditorUtility.OpenFilePanelWithFilters("Usd Asset", lastDir, new string[] { "Usd", "us*" });
if (string.IsNullOrEmpty(importFilepath)) return;
usdAsset.usdFullPath = importFilepath;
}

Просмотреть файл

@ -80,7 +80,7 @@ namespace Unity.Formats.USD
sample.joints = new string[bones.Length];
if (!string.IsNullOrEmpty(skeletonPath))
{
sample.skeleton.targetPaths = new string[] {skeletonPath};
sample.skeleton.targetPaths = new string[] { skeletonPath };
}
int b = 0;

Просмотреть файл

@ -301,7 +301,7 @@ namespace Unity.Formats.USD
var smr = ImporterBase.GetOrAddComponent<SkinnedMeshRenderer>(go);
if (smr.sharedMesh == null)
{
smr.sharedMesh = new Mesh {name = UniqueMeshName(go.name)};
smr.sharedMesh = new Mesh { name = UniqueMeshName(go.name) };
}
// We only check if a mesh is dynamic when scene.IsPopulatingAccessMask is True. It only happens when a playable is
@ -408,7 +408,7 @@ namespace Unity.Formats.USD
var mr = ImporterBase.GetOrAddComponent<MeshRenderer>(go);
if (mf.sharedMesh == null)
{
mf.sharedMesh = new Mesh {name = UniqueMeshName(go.name)};
mf.sharedMesh = new Mesh { name = UniqueMeshName(go.name) };
}
// We only check if a mesh is dynamic when scene.IsPopulatingAccessMask is True. It only happens when a playable is
@ -448,7 +448,7 @@ namespace Unity.Formats.USD
// Annoyingly, there is a circular dependency between vertices and triangles, which makes
// it impossible to have a fixed update order in this function. As a result, we must clear
// the triangles before setting the points, to break that dependency.
unityMesh.SetTriangles(new int[0] {}, 0);
unityMesh.SetTriangles(new int[0] { }, 0);
}
unityMesh.vertices = usdMesh.points;
@ -696,7 +696,7 @@ namespace Unity.Formats.USD
}
catch (Exception ex)
{
Debug.LogError(new Exception("Error reading UVs at " + usdMeshPath + "> uv-index: " + i, ex));
Debug.LogError(new Exception("Error reading UVs at " + usdMeshPath + "> uv-index: " + i, ex));
}
}
}

Просмотреть файл

@ -138,34 +138,34 @@ namespace Unity.Formats.USD
if (options.ShouldBindMaterials)
{
FindPathsJob.queries[0] = (FindPathsJob.IQuery) new FindPathsJob.Query<MaterialSample>();
FindPathsJob.queries[0] = (FindPathsJob.IQuery)new FindPathsJob.Query<MaterialSample>();
}
if (options.importCameras)
{
FindPathsJob.queries[1] = (FindPathsJob.IQuery) new FindPathsJob.Query<CameraSample>();
FindPathsJob.queries[1] = (FindPathsJob.IQuery)new FindPathsJob.Query<CameraSample>();
}
if (options.importMeshes)
{
FindPathsJob.queries[2] = (FindPathsJob.IQuery) new FindPathsJob.Query<MeshSample>();
FindPathsJob.queries[3] = (FindPathsJob.IQuery) new FindPathsJob.Query<CubeSample>();
FindPathsJob.queries[4] = (FindPathsJob.IQuery) new FindPathsJob.Query<SphereSample>();
FindPathsJob.queries[2] = (FindPathsJob.IQuery)new FindPathsJob.Query<MeshSample>();
FindPathsJob.queries[3] = (FindPathsJob.IQuery)new FindPathsJob.Query<CubeSample>();
FindPathsJob.queries[4] = (FindPathsJob.IQuery)new FindPathsJob.Query<SphereSample>();
}
FindPathsJob.queries[5] = (FindPathsJob.IQuery) new FindPathsJob.Query<SkelRootSample>();
FindPathsJob.queries[5] = (FindPathsJob.IQuery)new FindPathsJob.Query<SkelRootSample>();
if (options.importSkinning)
{
FindPathsJob.queries[6] = (FindPathsJob.IQuery) new FindPathsJob.Query<SkeletonSample>();
FindPathsJob.queries[6] = (FindPathsJob.IQuery)new FindPathsJob.Query<SkeletonSample>();
}
if (options.importTransforms)
{
FindPathsJob.queries[7] = (FindPathsJob.IQuery) new FindPathsJob.Query<XformSample>();
FindPathsJob.queries[7] = (FindPathsJob.IQuery)new FindPathsJob.Query<XformSample>();
}
FindPathsJob.queries[8] = (FindPathsJob.IQuery) new FindPathsJob.Query<ScopeSample>();
FindPathsJob.queries[8] = (FindPathsJob.IQuery)new FindPathsJob.Query<ScopeSample>();
var findPathsJob = new FindPathsJob();
var findHandle = findPathsJob.Schedule(FindPathsJob.queries.Length, 1);

Просмотреть файл

@ -107,7 +107,7 @@ namespace Unity.Formats.USD
public void AddInstanceRoot(SdfPath instancePath, GameObject go, SdfPath masterPath)
{
m_instanceRoots[instancePath] = new InstanceRoot {gameObject = go, masterPath = masterPath};
m_instanceRoots[instancePath] = new InstanceRoot { gameObject = go, masterPath = masterPath };
}
public Dictionary<SdfPath, GameObject>.KeyCollection GetMasterRootPaths()

Просмотреть файл

@ -755,7 +755,7 @@ namespace Unity.Formats.USD
context.plans.Add(go, new ExportPlan());
}
var exp = new Exporter {exportFunc = exportFunc, sample = sample, path = path};
var exp = new Exporter { exportFunc = exportFunc, sample = sample, path = path };
if (insertFirst)
{
context.plans[go].exporters.Insert(0, exp);

Просмотреть файл

@ -29,7 +29,8 @@ namespace Unity.Formats.USD
public class SkelBindingSample : SampleBase
{
// Blend Shapes.
[UsdNamespace("skel")][UsdVariability(Variability.Uniform)]
[UsdNamespace("skel")]
[UsdVariability(Variability.Uniform)]
public string[] blendShapes;
[UsdNamespace("skel")] public Relationship blendShapeTargets = new Relationship();
@ -40,16 +41,20 @@ namespace Unity.Formats.USD
[UsdNamespace("skel")] public Relationship skeleton = new Relationship();
// Skeleton Binding Data.
[UsdNamespace("skel")][UsdVariability(Variability.Uniform)]
[UsdNamespace("skel")]
[UsdVariability(Variability.Uniform)]
public string[] joints;
[UsdNamespace("skel")][UsdVariability(Variability.Uniform)]
[UsdNamespace("skel")]
[UsdVariability(Variability.Uniform)]
public Primvar<int[]> jointIndices = new Primvar<int[]>();
[UsdNamespace("skel")][UsdVariability(Variability.Uniform)]
[UsdNamespace("skel")]
[UsdVariability(Variability.Uniform)]
public Primvar<Matrix4x4> geomBindTransform = new Primvar<Matrix4x4>();
[UsdNamespace("skel")][UsdVariability(Variability.Uniform)]
[UsdNamespace("skel")]
[UsdVariability(Variability.Uniform)]
public Primvar<float[]> jointWeights = new Primvar<float[]>();
}

Просмотреть файл

@ -201,7 +201,7 @@ namespace Unity.Formats.USD
{
public class NativeExporter
{
public static void ExportObject(ObjectContext objContext, ExportContext exportContext) {}
public static void ExportObject(ObjectContext objContext, ExportContext exportContext) { }
}
}
#endif

Просмотреть файл

@ -177,7 +177,8 @@ namespace Unity.Formats.USD
static public void ImportObject(Scene scene,
GameObject go,
pxr.UsdPrim usdPrim,
SceneImportOptions options) {}
SceneImportOptions options)
{ }
}
}
#endif

Просмотреть файл

@ -1,4 +1,4 @@
// Copyright 2018 Jeremy Cowles. All rights reserved.
// Copyright 2018 Jeremy Cowles. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

Просмотреть файл

@ -1,4 +1,4 @@
// Copyright 2018 Jeremy Cowles. All rights reserved.
// Copyright 2018 Jeremy Cowles. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

Просмотреть файл

@ -1,79 +1,79 @@
Shader "Hidden/USD/NormalChannel"
Shader "Hidden/USD/NormalChannel"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
// No culling or depth
Cull Off ZWrite Off ZTest Always
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
// No culling or depth
Cull Off ZWrite Off ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
#include "UnityCG.cginc"
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
sampler2D _MainTex;
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
// from https://forum.unity.com/threads/runtime-generated-bump-maps-are-not-marked-as-normal-maps.413778/#post-4935776
// Unpack normal as DXT5nm (1, y, 1, x) or BC5 (x, y, 0, 1)
// Note neutral texture like "bump" is (0, 0, 1, 1) to work with both plain RGB normal and DXT5nm/BC5
/*
fixed3 UnpackNormalmapRGorAG(fixed4 packednormal)
{
// This do the trick
packednormal.x *= packednormal.w;
fixed3 normal;
normal.xy = packednormal.xy * 2 - 1;
normal.z = sqrt(1 - saturate(dot(normal.xy, normal.xy)));
return normal;
}
*/
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
// from https://forum.unity.com/threads/runtime-generated-bump-maps-are-not-marked-as-normal-maps.413778/#post-5424156
// float4 DTXnm2RGBA(float4 col)
// {
// float4 c = col;
// c.r = c.a * 2 - 1; //red<-alpha (x<-w)
// c.g = c.g * 2 - 1; //green is always the same (y)
// float2 xy = float2(c.r, c.g); //this is the xy vector, can be written also just "c.xy"
// c.b = sqrt(1 - clamp(dot(xy, xy), 0, 1)); //recalculate the blue channel (z)
// return float4(c.r * 0.5f + 0.5f, c.g * 0.5f + 0.5f, c.b * 0.5f + 0.5f, 1); //back to 0-1 range
// }
sampler2D _MainTex;
float4 frag (v2f i) : SV_Target
{
float4 col = tex2D(_MainTex, i.uv);
// If a texture is marked as a normal map
// the values are stored in the A and G channel.
return float4(UnpackNormalmapRGorAG(col) * 0.5f + 0.5f, 1);
}
ENDCG
}
}
// from https://forum.unity.com/threads/runtime-generated-bump-maps-are-not-marked-as-normal-maps.413778/#post-4935776
// Unpack normal as DXT5nm (1, y, 1, x) or BC5 (x, y, 0, 1)
// Note neutral texture like "bump" is (0, 0, 1, 1) to work with both plain RGB normal and DXT5nm/BC5
/*
fixed3 UnpackNormalmapRGorAG(fixed4 packednormal)
{
// This do the trick
packednormal.x *= packednormal.w;
fixed3 normal;
normal.xy = packednormal.xy * 2 - 1;
normal.z = sqrt(1 - saturate(dot(normal.xy, normal.xy)));
return normal;
}
*/
// from https://forum.unity.com/threads/runtime-generated-bump-maps-are-not-marked-as-normal-maps.413778/#post-5424156
// float4 DTXnm2RGBA(float4 col)
// {
// float4 c = col;
// c.r = c.a * 2 - 1; //red<-alpha (x<-w)
// c.g = c.g * 2 - 1; //green is always the same (y)
// float2 xy = float2(c.r, c.g); //this is the xy vector, can be written also just "c.xy"
// c.b = sqrt(1 - clamp(dot(xy, xy), 0, 1)); //recalculate the blue channel (z)
// return float4(c.r * 0.5f + 0.5f, c.g * 0.5f + 0.5f, c.b * 0.5f + 0.5f, 1); //back to 0-1 range
// }
float4 frag (v2f i) : SV_Target
{
float4 col = tex2D(_MainTex, i.uv);
// If a texture is marked as a normal map
// the values are stored in the A and G channel.
return float4(UnpackNormalmapRGorAG(col) * 0.5f + 0.5f, 1);
}
ENDCG
}
}
}

Просмотреть файл

@ -1,4 +1,4 @@
// Copyright 2018 Jeremy Cowles. All rights reserved.
// Copyright 2018 Jeremy Cowles. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.

Просмотреть файл

@ -40,7 +40,7 @@ namespace Unity.Formats.USD.Examples
// Populate Values.
var value = new MyCustomData();
value.aString = "IT'S ALIIIIIIIIIIIIIVE!";
value.anArrayOfInts = new int[] {1, 2, 3, 4};
value.anArrayOfInts = new int[] { 1, 2, 3, 4 };
value.aBoundingBox = new UnityEngine.Bounds();
// Writing the value.

Просмотреть файл

@ -309,7 +309,7 @@ namespace Unity.Formats.USD.Examples
// Various shader keywords are required to enable the standard shader to work as intended,
// while these can be encoded as part of the schema, often they require some logic (e.g. is
// emission color != black?).
material.requiredKeywords = new string[] {"_EMISSION"};
material.requiredKeywords = new string[] { "_EMISSION" };
//
// Setup Shader.

Просмотреть файл

@ -117,7 +117,7 @@ namespace Unity.Formats.USD.Tests
scene = ImportHelpers.InitForOpen(Path.GetFullPath(assetPath));
gameObject = ImportHelpers.ImportSceneAsGameObject(scene, null,
new SceneImportOptions { payloadPolicy = PayloadPolicy.LoadAll});
new SceneImportOptions { payloadPolicy = PayloadPolicy.LoadAll });
}
[TearDown]

Просмотреть файл

@ -35,7 +35,7 @@ namespace Unity.Formats.USD.Standalone.Tests
// Populate Values.
var value = new MyCustomData();
value.aString = "IT'S ALIIIIIIIIIIIIIVE!";
value.anArrayOfInts = new int[] {1, 2, 3, 4};
value.anArrayOfInts = new int[] { 1, 2, 3, 4 };
value.aBoundingBox = new UnityEngine.Bounds();
// Writing the value.

Просмотреть файл

@ -15,7 +15,7 @@ namespace USD.NET.Unity.Tests
var pi = new PointInstancerSample();
var cube = new CubeSample();
pi.prototypes.targetPaths = new[] {"/Instancer/Cube"};
pi.prototypes.targetPaths = new[] { "/Instancer/Cube" };
// Three instances, all prototype index zero.
pi.protoIndices = new int[3];

Просмотреть файл

@ -185,7 +185,7 @@ namespace USD.NET.Unity.Tests
Assert.AreEqual("", UnityTypeConverter.GetPath(c.transform, c.transform));
Assert.AreEqual("", UnityTypeConverter.GetPath(null));
Assert.AreEqual("", UnityTypeConverter.GetPath(null, null));
Assert.Throws<System.Exception>(delegate() { UnityTypeConverter.GetPath(null, a.transform); });
Assert.Throws<System.Exception>(delegate () { UnityTypeConverter.GetPath(null, a.transform); });
}
[Test]

Просмотреть файл

@ -28,20 +28,20 @@ namespace USD.NET.Unity.Tests
var texturePath = "/Model/Materials/SimpleMat/TextureReader";
var primvarReaderPath = "/Model/Materials/SimpleMat/UvReader";
var cube = new CubeSample {size = 1};
var cube = new CubeSample { size = 1 };
var material = new MaterialSample();
material.surface.SetConnectedPath(shaderPath, "outputs:result");
var shader = new PreviewSurfaceSample {diffuseColor = {defaultValue = Vector3.one}};
var shader = new PreviewSurfaceSample { diffuseColor = { defaultValue = Vector3.one } };
shader.diffuseColor.SetConnectedPath(texturePath, "outputs:rgb");
var texture = new TextureReaderSample
{
file = {defaultValue = new SdfAssetPath(@"C:\A\Bogus\Texture\Path.png")}
file = { defaultValue = new SdfAssetPath(@"C:\A\Bogus\Texture\Path.png") }
};
var primvarReader = new PrimvarReaderSample<Vector2> {varname = {defaultValue = new TfToken("st")}};
var primvarReader = new PrimvarReaderSample<Vector2> { varname = { defaultValue = new TfToken("st") } };
scene.Write("/Model", new XformSample());
scene.Write("/Model/Geom", new XformSample());

Просмотреть файл

@ -53,18 +53,19 @@ namespace USD.NET.Unity.Tests
var shaderPath = "/Model/Materials/SimpleMat/StandardShader";
var texturePath = "/Model/Materials/SimpleMat/AlbedoTexture";
var cube = new CubeSample {size = 1};
var cube = new CubeSample { size = 1 };
var material = new MaterialSample();
material.surface.SetConnectedPath(shaderPath, "outputs:out");
var shader = new StandardShaderSample {albedo = {defaultValue = Color.white}};
var shader = new StandardShaderSample { albedo = { defaultValue = Color.white } };
shader.albedo.SetConnectedPath(texturePath, "outputs:out");
Assert.AreEqual(shader.albedo.connectedPath, texturePath + ".outputs:out");
var texture = new Texture2DSample
{
sourceFile = {defaultValue = @"C:\A\Bogus\Texture\Path.png"}, sRgb = true
sourceFile = { defaultValue = @"C:\A\Bogus\Texture\Path.png" },
sRgb = true
};
scene.Write("/Model", new XformSample());

Просмотреть файл

@ -102,7 +102,8 @@ namespace USD.NET.Tests
{
// Because an outer namespace was declared, this results in the namespace
// "primvars:nested:foo:bar:baz"
[USD.NET.UsdNamespace("foo:bar")][USD.NET.VertexData(4)]
[USD.NET.UsdNamespace("foo:bar")]
[USD.NET.VertexData(4)]
public int[] baz;
// Not a primvar, so the resulting namespace is:
@ -123,7 +124,8 @@ namespace USD.NET.Tests
[USD.NET.VertexData(2)] public int[] somePrimvar2;
[USD.NET.UsdNamespace("skel")][USD.NET.VertexData(3)]
[USD.NET.UsdNamespace("skel")]
[USD.NET.VertexData(3)]
public int[] jointIndices;
public Primvar<Color[]> colors;
@ -133,24 +135,24 @@ namespace USD.NET.Tests
public static PrimvarSample GetTestSample()
{
var sample = new PrimvarSample();
sample.somePrimvar = new int[] {1, 2, 3, 4};
sample.somePrimvar1 = new int[] {2, 4, 6, 8};
sample.somePrimvar2 = new int[] {9, 8, 7, 6};
sample.jointIndices = new int[] {9, 8, 7, 6, 5, 3};
sample.somePrimvar = new int[] { 1, 2, 3, 4 };
sample.somePrimvar1 = new int[] { 2, 4, 6, 8 };
sample.somePrimvar2 = new int[] { 9, 8, 7, 6 };
sample.jointIndices = new int[] { 9, 8, 7, 6, 5, 3 };
sample.nestedSample = new NestedSample();
sample.nestedSample.baz = new int[] {9, 8, 7, 1};
sample.nestedSample.garply = new int[] {99, 88, 77};
sample.nestedSample.baz = new int[] { 9, 8, 7, 1 };
sample.nestedSample.garply = new int[] { 99, 88, 77 };
var pv = new USD.NET.Primvar<float[]>();
pv.value = new float[] {123f};
pv.value = new float[] { 123f };
sample.nestedSample.namespacedDict["Foo"] = pv;
pv = new USD.NET.Primvar<float[]>();
pv.value = new float[] {3245f};
pv.value = new float[] { 3245f };
sample.nestedSample.vanillaDict["Bar"] = pv;
sample.colors = new Primvar<Color[]>();
sample.colors.SetValue(new Color[1] {Color.red});
sample.colors.SetValue(new Color[1] { Color.red });
return sample;
}
@ -170,16 +172,16 @@ namespace USD.NET.Tests
public static ColorPrimvarSample GetTestSample()
{
var sample = new ColorPrimvarSample();
sample.colorVD = new[] {Color.green};
sample.colorVD = new[] { Color.green };
sample.colorPV = new Primvar<Color[]>();
sample.colorPV.SetValue(new Color[1] {Color.red});
sample.colorPV.SetValue(new Color[1] { Color.red });
sample.colorObjPV = new Primvar<object>();
sample.colorPV.SetValue(new Color[1] {Color.blue});
sample.colorPV.SetValue(new Color[1] { Color.blue });
sample.intPV = new Primvar<int[]>();
sample.intPV.SetValue(new int[3] {1, 2, 3});
sample.intPV.SetValue(new int[3] { 1, 2, 3 });
return sample;
}
@ -219,39 +221,39 @@ namespace USD.NET.Tests
void InitIntrinsicSample(ref IntrinsicsSample sample)
{
sample.boolArray_ = new bool[] {false, true};
sample.boolArray_ = new bool[] { false, true };
sample.boolList_ = sample.boolArray_.ToList();
sample.bool_ = true;
sample.byteArray_ = new byte[] {1, 2, 3};
sample.byteArray_ = new byte[] { 1, 2, 3 };
sample.byteList_ = sample.byteArray_.ToList();
sample.byte_ = 42;
sample.doubleArray_ = new double[] {-1.1, 2.2, double.MaxValue, double.MinValue};
sample.doubleArray_ = new double[] { -1.1, 2.2, double.MaxValue, double.MinValue };
sample.doubleList_ = sample.doubleArray_.ToList();
sample.double_ = double.MaxValue;
sample.floatArray_ = new float[] {-1.1f, 2.2f, float.MaxValue, float.MinValue};
sample.floatArray_ = new float[] { -1.1f, 2.2f, float.MaxValue, float.MinValue };
sample.floatList_ = sample.floatArray_.ToList();
sample.float_ = float.MaxValue;
sample.intArray_ = new int[] {-1, 0, 1, 2, int.MaxValue, int.MinValue};
sample.intArray_ = new int[] { -1, 0, 1, 2, int.MaxValue, int.MinValue };
sample.intList_ = sample.intArray_.ToList();
sample.int_ = int.MaxValue;
sample.longArray_ = new long[] {-1, 0, 2, long.MaxValue, long.MinValue};
sample.longArray_ = new long[] { -1, 0, 2, long.MaxValue, long.MinValue };
sample.longList_ = sample.longArray_.ToList();
sample.long_ = long.MinValue;
sample.stringArray_ = new string[] {"hello", "world"};
sample.stringArray_ = new string[] { "hello", "world" };
sample.stringList_ = sample.stringArray_.ToList();
sample.string_ = "foobar";
sample.uintArray_ = new uint[] {0, 1, 2, uint.MaxValue, uint.MinValue};
sample.uintArray_ = new uint[] { 0, 1, 2, uint.MaxValue, uint.MinValue };
sample.uintList_ = sample.uintArray_.ToList();
sample.uint_ = uint.MaxValue;
sample.ulongArray_ = new ulong[] {0, 2, ulong.MaxValue, ulong.MinValue};
sample.ulongArray_ = new ulong[] { 0, 2, ulong.MaxValue, ulong.MinValue };
sample.ulongList_ = sample.ulongArray_.ToList();
sample.ulong_ = ulong.MaxValue;
@ -262,11 +264,11 @@ namespace USD.NET.Tests
sample.dictTyped["Bar"] = "baz";
sample.dictVertexData = new Dictionary<string, float[]>();
sample.dictVertexData["VertexData"] = new float[] {42.3f};
sample.dictVertexData["VertexData"] = new float[] { 42.3f };
sample.dictPrimvar = new Dictionary<string, USD.NET.Primvar<float[]>>();
var pv = new USD.NET.Primvar<float[]>();
pv.value = new float[] {423.2f};
pv.value = new float[] { 423.2f };
pv.interpolation = USD.NET.PrimvarInterpolation.FaceVarying;
sample.dictPrimvar["PrimvarValue"] = pv;
}
@ -517,7 +519,7 @@ namespace USD.NET.Tests
var sampleToRead = new PrimvarSample();
sampleToRead.nestedSample = new PrimvarSample.NestedSample();
var sampleToWrite2 = PrimvarSample.GetTestSample();
sampleToWrite2.somePrimvar = new int[] {3, 4, 5, 6};
sampleToWrite2.somePrimvar = new int[] { 3, 4, 5, 6 };
var scene = USD.NET.Scene.Create();
scene.Write("/Foo", sampleToWrite);
@ -598,7 +600,7 @@ namespace USD.NET.Tests
{
var sampleToWrite = PrimvarSample.GetTestSample();
var sampleToWrite2 = PrimvarSample.GetTestSample();
sampleToWrite2.somePrimvar = new int[] {3, 4, 5, 6};
sampleToWrite2.somePrimvar = new int[] { 3, 4, 5, 6 };
//Check animated data
TestDefaultTime_NotVarying(sampleToWrite);

Просмотреть файл

@ -152,7 +152,7 @@ namespace USD.NET.Tests
{
var s = CreateStageHierarchy();
var prePostRange = new USD.NET.RangeIterator(UsdPrimRange.PreAndPostVisit(s.GetPseudoRoot()));
bool[] expected = {false, false, true, false, true, true};
bool[] expected = { false, false, true, false, true, true };
bool[] actual = new bool[6];
var i = 0;
foreach (UsdPrim curPrim in prePostRange)
@ -251,7 +251,7 @@ namespace USD.NET.Tests
var material = new MaterialSampleTest();
material.surface = shaderPath;
material.surfaces = new string[] {"/Foo", "/Bar/Baz"};
material.surfaces = new string[] { "/Foo", "/Bar/Baz" };
var mat2 = new MaterialSampleTest();
WriteAndRead(ref material, ref mat2);

Просмотреть файл

@ -32,9 +32,9 @@ namespace USD.NET.Tests
var scene = Scene.Create();
var s1 = new KeyFramesTestSample();
var baseline = new Dictionary<string, double[]>();
baseline["/Foo"] = new double[] {1.0, 2.0, 3.0};
baseline["/Foo/Bar"] = new double[] {5.0, 6.0, 7.0};
baseline["/Baz"] = new double[] {1.0, 2.0, 3.0};
baseline["/Foo"] = new double[] { 1.0, 2.0, 3.0 };
baseline["/Foo/Bar"] = new double[] { 5.0, 6.0, 7.0 };
baseline["/Baz"] = new double[] { 1.0, 2.0, 3.0 };
foreach (var kvp in baseline)
{