From 29dee33163a5cf47f782da1d1e7e5c497b6d568e Mon Sep 17 00:00:00 2001
From: PETS automation <299490404+pets-svc[bot]@users.noreply.github.com>
Date: Thu, 11 Jun 2026 11:51:57 -0400
Subject: [PATCH] trunk shadow changes: com.unity.probuilder [skip ci]
---
Content/Shader/EdgePicker.shader | 2 +-
Content/Shader/FaceHighlight.shader | 2 +-
Content/Shader/FacePicker.shader | 2 +-
Content/Shader/HideVertices.shader | 2 +-
Content/Shader/LineBillboard.shader | 2 +-
Content/Shader/LineBillboardMetal.shader | 2 +-
Content/Shader/NormalPreview.shader | 2 +-
Content/Shader/PointBillboard.shader | 2 +-
Content/Shader/ReferenceUnlit.shader | 2 +-
Content/Shader/ScrollHighlight.shader | 2 +-
Content/Shader/SmoothingPreview.shader | 2 +-
Content/Shader/TransparentOverlay.shader | 2 +-
Content/Shader/UnlitSolidColor.shader | 2 +-
Content/Shader/UnlitVertexColor.shader | 2 +-
Content/Shader/VertexPicker.shader | 2 +-
Content/Shader/VertexShader.shader | 2 +-
Runtime/Core/IntVec2.cs | 2 +-
Runtime/Core/IntVec3.cs | 2 +-
Runtime/Core/IntVec4.cs | 2 +-
Runtime/Core/VectorHash.cs | 42 ++++++++++-----
Tests/Editor/Import/MeshImporterTests.cs | 5 +-
Tests/Framework/TestUtility.cs | 38 ++++++-------
Tests/Runtime/MeshOps/BridgeEdgesTests.cs | 1 +
.../Runtime/MeshOps/CollapseVerticesTests.cs | 1 +
Tests/Runtime/MeshOps/DeleteElementsTests.cs | 1 +
Tests/Runtime/MeshOps/TextureUnwrapTests.cs | 1 +
Tests/Runtime/MeshOps/VertexColorTests.cs | 1 +
Tests/Runtime/Shape/ShapeGeneratorTests.cs | 1 +
Tests/Runtime/Type/VertexTests.cs | 49 ++++++++++-------
Tests/Runtime/Utilities/RuntimeUtility.cs | 19 +++----
package.json | 54 +++++--------------
31 files changed, 125 insertions(+), 126 deletions(-)
diff --git a/Content/Shader/EdgePicker.shader b/Content/Shader/EdgePicker.shader
index a12c811ed..cc74aa800 100644
--- a/Content/Shader/EdgePicker.shader
+++ b/Content/Shader/EdgePicker.shader
@@ -49,7 +49,7 @@ CGPROGRAM
return o;
}
- float4 frag (v2f i) : COLOR
+ float4 frag (v2f i) : SV_Target
{
return i.color;
}
diff --git a/Content/Shader/FaceHighlight.shader b/Content/Shader/FaceHighlight.shader
index 745bad138..ea8f6582c 100644
--- a/Content/Shader/FaceHighlight.shader
+++ b/Content/Shader/FaceHighlight.shader
@@ -45,7 +45,7 @@ Shader "Hidden/ProBuilder/FaceHighlight"
return o;
}
- half4 frag (v2f i) : COLOR
+ half4 frag (v2f i) : SV_Target
{
i.pos.xy = floor(i.pos.xy * 1) * .5;
float checker = -frac(i.pos.x + i.pos.y);
diff --git a/Content/Shader/FacePicker.shader b/Content/Shader/FacePicker.shader
index 78d729789..90ada9cc5 100644
--- a/Content/Shader/FacePicker.shader
+++ b/Content/Shader/FacePicker.shader
@@ -41,7 +41,7 @@ Shader "Hidden/ProBuilder/FacePicker"
return o;
}
- float4 frag (v2f i) : COLOR
+ float4 frag (v2f i) : SV_Target
{
return i.color;
}
diff --git a/Content/Shader/HideVertices.shader b/Content/Shader/HideVertices.shader
index fa83ce030..14148ae68 100644
--- a/Content/Shader/HideVertices.shader
+++ b/Content/Shader/HideVertices.shader
@@ -33,7 +33,7 @@ Shader "Hidden/ProBuilder/HideVertices"
return o;
}
- half4 frag (v2f i) : COLOR
+ half4 frag (v2f i) : SV_Target
{
return fixed4(0,0,0,0);
}
diff --git a/Content/Shader/LineBillboard.shader b/Content/Shader/LineBillboard.shader
index b2284b3a2..3e8a58616 100644
--- a/Content/Shader/LineBillboard.shader
+++ b/Content/Shader/LineBillboard.shader
@@ -94,7 +94,7 @@ Shader "Hidden/ProBuilder/LineBillboard"
triStream.Append(geo_out);
}
- fixed4 frag (v2f i) : COLOR
+ fixed4 frag (v2f i) : SV_Target
{
return i.color * _Color;
}
diff --git a/Content/Shader/LineBillboardMetal.shader b/Content/Shader/LineBillboardMetal.shader
index e433a7e98..fa03ee02f 100644
--- a/Content/Shader/LineBillboardMetal.shader
+++ b/Content/Shader/LineBillboardMetal.shader
@@ -67,7 +67,7 @@ Shader "Hidden/ProBuilder/LineBillboardMetal"
return o;
}
- half4 frag (v2f i) : COLOR
+ half4 frag (v2f i) : SV_Target
{
return _Color;
}
diff --git a/Content/Shader/NormalPreview.shader b/Content/Shader/NormalPreview.shader
index 992e28117..21d21a6da 100644
--- a/Content/Shader/NormalPreview.shader
+++ b/Content/Shader/NormalPreview.shader
@@ -44,7 +44,7 @@ Shader "Hidden/ProBuilder/NormalPreview"
return o;
}
- half4 frag (v2f i) : COLOR
+ half4 frag (v2f i) : SV_Target
{
return i.color;
}
diff --git a/Content/Shader/PointBillboard.shader b/Content/Shader/PointBillboard.shader
index 1c57b0d6c..42d8ed926 100644
--- a/Content/Shader/PointBillboard.shader
+++ b/Content/Shader/PointBillboard.shader
@@ -118,7 +118,7 @@ Shader "Hidden/ProBuilder/PointBillboard"
triStream.Append(geo_out);
}
- float4 frag(FS_INPUT input) : COLOR
+ float4 frag(FS_INPUT input) : SV_Target
{
return _Color * input.color;
}
diff --git a/Content/Shader/ReferenceUnlit.shader b/Content/Shader/ReferenceUnlit.shader
index 9f9582f0f..c01ded0af 100644
--- a/Content/Shader/ReferenceUnlit.shader
+++ b/Content/Shader/ReferenceUnlit.shader
@@ -56,7 +56,7 @@ Shader "ProBuilder/Reference Unlit"
return o;
}
- half4 frag (v2f i) : COLOR
+ half4 frag (v2f i) : SV_Target
{
return tex2D(_MainTex, i.uv);
}
diff --git a/Content/Shader/ScrollHighlight.shader b/Content/Shader/ScrollHighlight.shader
index e71c7b6ce..66d292064 100644
--- a/Content/Shader/ScrollHighlight.shader
+++ b/Content/Shader/ScrollHighlight.shader
@@ -54,7 +54,7 @@ Shader "Hidden/ProBuilder/ScrollHighlight" {
o.pos = UnityObjectToClipPos(v.vertex );
return o;
}
- float4 frag(VertexOutput i, float facing : VFACE) : COLOR {
+ float4 frag(VertexOutput i, float facing : VFACE) : SV_Target {
float isFrontFace = ( facing >= 0 ? 1 : 0 );
float faceSign = ( facing >= 0 ? 1 : -1 );
////// Lighting:
diff --git a/Content/Shader/SmoothingPreview.shader b/Content/Shader/SmoothingPreview.shader
index fc2b44e43..af9846522 100644
--- a/Content/Shader/SmoothingPreview.shader
+++ b/Content/Shader/SmoothingPreview.shader
@@ -47,7 +47,7 @@ Shader "Hidden/ProBuilder/SmoothingPreview"
return o;
}
- half4 frag (v2f i) : COLOR
+ half4 frag (v2f i) : SV_Target
{
i.pos.xy = floor(i.pos.xy * 1) * .5;
float checker = -frac(i.pos.x + i.pos.y);
diff --git a/Content/Shader/TransparentOverlay.shader b/Content/Shader/TransparentOverlay.shader
index 350a2dae8..7acd6fc6e 100644
--- a/Content/Shader/TransparentOverlay.shader
+++ b/Content/Shader/TransparentOverlay.shader
@@ -50,7 +50,7 @@ Shader "Hidden/ProBuilder/TransparentOverlay"
return o;
}
- half4 frag (v2f i) : COLOR
+ half4 frag (v2f i) : SV_Target
{
return tex2D(_MainTex, i.uv) * i.color;
}
diff --git a/Content/Shader/UnlitSolidColor.shader b/Content/Shader/UnlitSolidColor.shader
index 24d61a3c2..52cebe5a8 100644
--- a/Content/Shader/UnlitSolidColor.shader
+++ b/Content/Shader/UnlitSolidColor.shader
@@ -44,7 +44,7 @@ Shader "ProBuilder/Unlit Solid Color"
return o;
}
- half4 frag (v2f i) : COLOR
+ half4 frag (v2f i) : SV_Target
{
return _Color;
}
diff --git a/Content/Shader/UnlitVertexColor.shader b/Content/Shader/UnlitVertexColor.shader
index 46be8269b..f1e3b117d 100644
--- a/Content/Shader/UnlitVertexColor.shader
+++ b/Content/Shader/UnlitVertexColor.shader
@@ -40,7 +40,7 @@ Shader "ProBuilder/UnlitVertexColor"
return o;
}
- half4 frag (v2f i) : COLOR
+ half4 frag (v2f i) : SV_Target
{
return i.color;
}
diff --git a/Content/Shader/VertexPicker.shader b/Content/Shader/VertexPicker.shader
index 3c8995c24..d4b153872 100644
--- a/Content/Shader/VertexPicker.shader
+++ b/Content/Shader/VertexPicker.shader
@@ -65,7 +65,7 @@ CGPROGRAM
return o;
}
- float4 frag (v2f i) : COLOR
+ float4 frag (v2f i) : SV_Target
{
return i.color;
}
diff --git a/Content/Shader/VertexShader.shader b/Content/Shader/VertexShader.shader
index 8bfb542d4..b29cce7be 100644
--- a/Content/Shader/VertexShader.shader
+++ b/Content/Shader/VertexShader.shader
@@ -71,7 +71,7 @@ Shader "Hidden/ProBuilder/VertexShader"
return o;
}
- half4 frag (v2f i) : COLOR
+ half4 frag (v2f i) : SV_Target
{
return _Color;
}
diff --git a/Runtime/Core/IntVec2.cs b/Runtime/Core/IntVec2.cs
index 4d93b224b..3e8a6e766 100644
--- a/Runtime/Core/IntVec2.cs
+++ b/Runtime/Core/IntVec2.cs
@@ -57,7 +57,7 @@ public override int GetHashCode()
private static int round(float v)
{
- return System.Convert.ToInt32(v * VectorHash.FltCompareResolution);
+ return VectorHash.RoundToInt(v);
}
public static implicit operator Vector2(IntVec2 p)
diff --git a/Runtime/Core/IntVec3.cs b/Runtime/Core/IntVec3.cs
index 49fb12be8..324beb72e 100644
--- a/Runtime/Core/IntVec3.cs
+++ b/Runtime/Core/IntVec3.cs
@@ -60,7 +60,7 @@ public override int GetHashCode()
private static int round(float v)
{
- return System.Convert.ToInt32(v * VectorHash.FltCompareResolution);
+ return VectorHash.RoundToInt(v);
}
public static implicit operator Vector3(IntVec3 p)
diff --git a/Runtime/Core/IntVec4.cs b/Runtime/Core/IntVec4.cs
index 69ec38960..e2152da77 100644
--- a/Runtime/Core/IntVec4.cs
+++ b/Runtime/Core/IntVec4.cs
@@ -63,7 +63,7 @@ public override int GetHashCode()
private static int round(float v)
{
- return System.Convert.ToInt32(v * VectorHash.FltCompareResolution);
+ return VectorHash.RoundToInt(v);
}
public static implicit operator Vector4(IntVec4 p)
diff --git a/Runtime/Core/VectorHash.cs b/Runtime/Core/VectorHash.cs
index 03246d360..40f9e486d 100644
--- a/Runtime/Core/VectorHash.cs
+++ b/Runtime/Core/VectorHash.cs
@@ -11,10 +11,28 @@ static class VectorHash
{
public const float FltCompareResolution = 1000f;
- static int HashFloat(float f)
+ ///
+ /// Quantize a float to FltCompareResolution. Shared by IntVec2/IntVec3/IntVec4 equality and
+ /// by the hash functions below, so that values which compare equal always hash equally.
+ ///
+ internal static int RoundToInt(float f)
{
- ulong u = (ulong)(f * FltCompareResolution);
- return (int)(u % int.MaxValue);
+ if (float.IsNaN(f))
+ return 0;
+
+ float scaled = f * FltCompareResolution;
+
+ // Casting an out-of-range float to an integer type is unspecified in ECMA-335 - Mono on
+ // x64 wraps around while CoreCLR and Mono on Arm64 saturate, which also collapses every
+ // negative component to 0 - so clamp explicitly (UUM-148935, UUM-111993).
+ if (scaled <= int.MinValue)
+ return int.MinValue;
+
+ if (scaled >= int.MaxValue)
+ return int.MaxValue;
+
+ // System.Math, not UnityEngine.ProBuilder.Math
+ return (int)System.Math.Round(scaled, MidpointRounding.ToEven);
}
///
@@ -29,8 +47,8 @@ public static int GetHashCode(Vector2 v)
unchecked
{
- hash = hash * 29 + HashFloat(v.x);
- hash = hash * 29 + HashFloat(v.y);
+ hash = hash * 29 + RoundToInt(v.x);
+ hash = hash * 29 + RoundToInt(v.y);
}
return hash;
@@ -48,9 +66,9 @@ public static int GetHashCode(Vector3 v)
unchecked
{
- hash = hash * 29 + HashFloat(v.x);
- hash = hash * 29 + HashFloat(v.y);
- hash = hash * 29 + HashFloat(v.z);
+ hash = hash * 29 + RoundToInt(v.x);
+ hash = hash * 29 + RoundToInt(v.y);
+ hash = hash * 29 + RoundToInt(v.z);
}
return hash;
@@ -68,10 +86,10 @@ public static int GetHashCode(Vector4 v)
unchecked
{
- hash = hash * 29 + HashFloat(v.x);
- hash = hash * 29 + HashFloat(v.y);
- hash = hash * 29 + HashFloat(v.z);
- hash = hash * 29 + HashFloat(v.w);
+ hash = hash * 29 + RoundToInt(v.x);
+ hash = hash * 29 + RoundToInt(v.y);
+ hash = hash * 29 + RoundToInt(v.z);
+ hash = hash * 29 + RoundToInt(v.w);
}
return hash;
diff --git a/Tests/Editor/Import/MeshImporterTests.cs b/Tests/Editor/Import/MeshImporterTests.cs
index ba1c86934..2b9cf418a 100644
--- a/Tests/Editor/Import/MeshImporterTests.cs
+++ b/Tests/Editor/Import/MeshImporterTests.cs
@@ -37,9 +37,8 @@ public static void ImportQuads_MatchesWindingOrder()
{
var srcPath = TestUtility.temporarySavedAssetsDirectory + "maya-cube-quads.fbx";
- // do this song and dance because AssetDatabase.LoadAssetAtPath doesn't seem to work with models in the
- // Package directories
- File.Copy(TestUtility.templatesDirectory + "MeshImporter/maya-cube-quads.fbx", srcPath);
+ // overwrite: UTR retries in-fixture, and a leftover copy would fail every later attempt.
+ File.Copy(TestUtility.templatesDirectory + "MeshImporter/maya-cube-quads.fbx", srcPath, true);
AssetDatabase.Refresh();
var source = AssetDatabase.LoadMainAssetAtPath(srcPath);
var meshImporter = (ModelImporter)AssetImporter.GetAtPath(srcPath);
diff --git a/Tests/Framework/TestUtility.cs b/Tests/Framework/TestUtility.cs
index 1699c4beb..55320dbd5 100644
--- a/Tests/Framework/TestUtility.cs
+++ b/Tests/Framework/TestUtility.cs
@@ -1,9 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
-using System.Diagnostics;
using System.IO;
using System.Reflection;
+using System.Runtime.CompilerServices;
using NUnit.Framework;
using UnityEditor;
using UnityEditor.SceneManagement;
@@ -333,14 +333,11 @@ public static bool MeshesAreEqual(Mesh expected, Mesh result)
return true;
}
- public static string GetTemplatePath(string assetName, int methodOffset = 0)
+ public static string GetTemplatePath(string assetName,
+ [CallerFilePath] string callingFilePath = null,
+ [CallerMemberName] string callingMemberName = null)
{
- StackTrace trace = new StackTrace(1 + methodOffset, true);
- StackFrame calling = trace.GetFrame(0);
-
- string filePath = calling.GetFileName();
-
- if (string.IsNullOrEmpty(filePath))
+ if (string.IsNullOrEmpty(callingFilePath))
{
UnityEngine.Debug.LogError(
"Cannot generate mesh templates directory path from calling method. Please use the explicit SaveMeshTemplate overload.");
@@ -348,18 +345,16 @@ public static string GetTemplatePath(string assetName, int methodOffset = 0)
}
// Get the calling file path relative to the `Tests/` directory
- string fullFilePath = Path.GetFullPath(filePath).Replace("\\", "/");
+ string fullFilePath = Path.GetFullPath(callingFilePath).Replace("\\", "/");
string fullTestRootPath = Path.GetFullPath(testsRootDirectory).Replace("\\", "/");
string relativeTemplatePath = fullFilePath.Replace(fullTestRootPath, "");
string relativeTemplateDir = Path.GetDirectoryName(relativeTemplatePath).Replace("\\", "/").TrimStart('/');
- string methodName = calling.GetMethod().Name;
-
return string.Format("{0}/{1}/{2}/{3}/{4}.asset",
typeof(T).ToString(),
relativeTemplateDir,
- Path.GetFileNameWithoutExtension(filePath),
- methodName,
+ Path.GetFileNameWithoutExtension(callingFilePath),
+ callingMemberName,
assetName);
}
@@ -367,11 +362,15 @@ public static string GetTemplatePath(string assetName, int methodOffset = 0)
/// Get a mesh saved from the same path with name. Use SaveAssetTemplate to automatically generate this path.
///
///
+ ///
+ ///
///
///
- public static T GetAssetTemplate(string name) where T : UObject
+ public static T GetAssetTemplate(string name,
+ [CallerFilePath] string callingFilePath = null,
+ [CallerMemberName] string callingMemberName = null) where T : UObject
{
- string assetPath = templatesDirectory + GetTemplatePath(name, 1);
+ string assetPath = templatesDirectory + GetTemplatePath(name, callingFilePath, callingMemberName);
T asset = AssetDatabase.LoadAssetAtPath(assetPath);
Assert.IsFalse(asset == null, "Failed loading asset template " + name + " at path " + assetPath);
return asset;
@@ -393,11 +392,14 @@ public static T GetAssetTemplateWithPath(string pathRelativeToTemplatesDirect
///
///
///
- ///
+ ///
+ ///
///
- public static void SaveAssetTemplate(T asset, string name = null, int methodOffset = 0) where T : UObject
+ public static void SaveAssetTemplate(T asset, string name = null,
+ [CallerFilePath] string callingFilePath = null,
+ [CallerMemberName] string callingMemberName = null) where T : UObject
{
- string templatePath = GetTemplatePath(string.IsNullOrEmpty(name) ? asset.name : name, methodOffset + 1);
+ string templatePath = GetTemplatePath(string.IsNullOrEmpty(name) ? asset.name : name, callingFilePath, callingMemberName);
SaveAssetTemplateAtPath(asset, templatePath);
}
diff --git a/Tests/Runtime/MeshOps/BridgeEdgesTests.cs b/Tests/Runtime/MeshOps/BridgeEdgesTests.cs
index f7ad39fcc..48e41a78e 100644
--- a/Tests/Runtime/MeshOps/BridgeEdgesTests.cs
+++ b/Tests/Runtime/MeshOps/BridgeEdgesTests.cs
@@ -6,6 +6,7 @@
using UnityEngine.ProBuilder.Shapes;
using UnityEngine.ProBuilder.Tests;
using UnityEngine.ProBuilder.Tests.Framework;
+using UnityEngine.TestTools;
static class BridgeEdgesTests
{
diff --git a/Tests/Runtime/MeshOps/CollapseVerticesTests.cs b/Tests/Runtime/MeshOps/CollapseVerticesTests.cs
index 6926a1335..461306797 100644
--- a/Tests/Runtime/MeshOps/CollapseVerticesTests.cs
+++ b/Tests/Runtime/MeshOps/CollapseVerticesTests.cs
@@ -5,6 +5,7 @@
using UnityEngine.ProBuilder.Shapes;
using UnityEngine.ProBuilder.Tests;
using UnityEngine.ProBuilder.Tests.Framework;
+using UnityEngine.TestTools;
static class CollapseVerticesTests
{
diff --git a/Tests/Runtime/MeshOps/DeleteElementsTests.cs b/Tests/Runtime/MeshOps/DeleteElementsTests.cs
index a25b988ae..54939e39e 100644
--- a/Tests/Runtime/MeshOps/DeleteElementsTests.cs
+++ b/Tests/Runtime/MeshOps/DeleteElementsTests.cs
@@ -8,6 +8,7 @@
using UnityEngine.ProBuilder.Shapes;
using UnityEngine.ProBuilder.Tests;
using UnityEngine.ProBuilder.Tests.Framework;
+using UnityEngine.TestTools;
static class DeleteElementsTests
{
diff --git a/Tests/Runtime/MeshOps/TextureUnwrapTests.cs b/Tests/Runtime/MeshOps/TextureUnwrapTests.cs
index 39fc38964..179c45b08 100644
--- a/Tests/Runtime/MeshOps/TextureUnwrapTests.cs
+++ b/Tests/Runtime/MeshOps/TextureUnwrapTests.cs
@@ -6,6 +6,7 @@
using UnityEngine.ProBuilder.Shapes;
using UnityEngine.ProBuilder.Tests;
using UnityEngine.ProBuilder.Tests.Framework;
+using UnityEngine.TestTools;
static class TextureUnwrapTests
{
diff --git a/Tests/Runtime/MeshOps/VertexColorTests.cs b/Tests/Runtime/MeshOps/VertexColorTests.cs
index ea67656cb..847d09156 100644
--- a/Tests/Runtime/MeshOps/VertexColorTests.cs
+++ b/Tests/Runtime/MeshOps/VertexColorTests.cs
@@ -5,6 +5,7 @@
using UnityEngine.ProBuilder.Shapes;
using UnityEngine.ProBuilder.Tests;
using UnityEngine.ProBuilder.Tests.Framework;
+using UnityEngine.TestTools;
static class VertexColorTests
{
diff --git a/Tests/Runtime/Shape/ShapeGeneratorTests.cs b/Tests/Runtime/Shape/ShapeGeneratorTests.cs
index 0472224d8..5a12e92a1 100644
--- a/Tests/Runtime/Shape/ShapeGeneratorTests.cs
+++ b/Tests/Runtime/Shape/ShapeGeneratorTests.cs
@@ -6,6 +6,7 @@
using System;
using UnityEngine.ProBuilder.Shapes;
using UnityEngine.ProBuilder.Tests.Framework;
+using UnityEngine.TestTools;
class ShapeGeneratorTests
{
diff --git a/Tests/Runtime/Type/VertexTests.cs b/Tests/Runtime/Type/VertexTests.cs
index 8b04df701..ff0be7ace 100644
--- a/Tests/Runtime/Type/VertexTests.cs
+++ b/Tests/Runtime/Type/VertexTests.cs
@@ -4,6 +4,7 @@
using System.Linq;
using System;
using UnityEngine.ProBuilder;
+using UnityEngine.TestTools;
static class TestHashUtility
{
@@ -41,6 +42,11 @@ static float RandFlt()
return UnityEngine.Random.Range(0f, 100f) * .001f;
}
+ static float RandJitter()
+ {
+ return UnityEngine.Random.Range(-.001f, .001f);
+ }
+
static Vertex RandVertex()
{
Vertex v = new Vertex();
@@ -58,11 +64,6 @@ static Vertex RandVertex()
[Test]
public static void TestHashCollisions_IVEC3()
{
-#if UNITY_EDITOR_OSX
- if (System.Runtime.InteropServices.RuntimeInformation.OSArchitecture == System.Runtime.InteropServices.Architecture.Arm64)
- Assert.Ignore("Fails on macOS13 Arm64 https://jira.unity3d.com/browse/UUM-111993");
-#endif
-
IntVec3[] ivec3 = ArrayUtility.Fill(TestIterationCount, (i) => { return (IntVec3)RandVec3(); });
Assert.IsTrue(TestHashUtility.GetCollisionsCount(ivec3) < TestIterationCount * .05f);
}
@@ -70,31 +71,24 @@ public static void TestHashCollisions_IVEC3()
[Test]
public static void TestVectorHashOverflow()
{
-#if UNITY_EDITOR_OSX
- if (System.Runtime.InteropServices.RuntimeInformation.OSArchitecture == System.Runtime.InteropServices.Architecture.Arm64)
- Assert.Ignore("Fails on macOS13 Arm64 https://jira.unity3d.com/browse/UUM-111993");
-#endif
-
Vector3 over = new Vector3(((float)int.MaxValue) + 10f, 0f, 0f);
Vector3 under = new Vector3(((float)-int.MaxValue) - 10f, 0f, 0f);
Vector3 inf = new Vector3(Mathf.Infinity, 0f, 0f);
+ Vector3 negInf = new Vector3(Mathf.NegativeInfinity, 0f, 0f);
Vector3 nan = new Vector3(float.NaN, 0f, 0f);
- // mostly checking that GetHashCode doesn't throw an error when converting bad float values
- Assert.AreEqual(VectorHash.GetHashCode(over), 1499503, "Over");
- Assert.AreEqual(VectorHash.GetHashCode(under), 2147303674, "Under");
- Assert.AreNotEqual(VectorHash.GetHashCode(inf), 0, "Inf");
- Assert.AreNotEqual(VectorHash.GetHashCode(nan), 0, "NaN");
+ // Out-of-range components saturate and NaN quantizes to zero, so these hash codes are
+ // identical on every runtime and architecture. See UUM-148935.
+ Assert.AreEqual(-2146825986, VectorHash.GetHashCode(over), "Over");
+ Assert.AreEqual(-2146825145, VectorHash.GetHashCode(under), "Under");
+ Assert.AreEqual(-2146825986, VectorHash.GetHashCode(inf), "Inf");
+ Assert.AreEqual(-2146825145, VectorHash.GetHashCode(negInf), "NegInf");
+ Assert.AreEqual(VectorHash.GetHashCode(Vector3.zero), VectorHash.GetHashCode(nan), "NaN");
}
[Test]
public static void TestComparison_IVEC3()
{
-#if UNITY_EDITOR_OSX
- if (System.Runtime.InteropServices.RuntimeInformation.OSArchitecture == System.Runtime.InteropServices.Architecture.Arm64)
- Assert.Ignore("Fails on macOS13 Arm64 https://jira.unity3d.com/browse/UUM-111993");
-#endif
-
IntVec3 a = (IntVec3)RandVec3();
IntVec3 b = (IntVec3)(a.value * 2.3f);
IntVec3 c = (IntVec3) new Vector3(a.x, a.y + .001f, a.z);
@@ -111,6 +105,21 @@ public static void TestComparison_IVEC3()
Assert.AreEqual(13, arr.Distinct().Count());
}
+ [Test]
+ public static void TestEqualIntVec3SharesHashCode()
+ {
+ // IntVec3.Equals and VectorHash must quantize identically, otherwise positions that
+ // ProBuilder considers coincident land in different dictionary buckets and never weld.
+ for (int i = 0; i < TestIterationCount; ++i)
+ {
+ IntVec3 a = (IntVec3)RandVec3();
+ IntVec3 b = (IntVec3)(a.value + new Vector3(RandJitter(), RandJitter(), RandJitter()));
+
+ if (a == b)
+ Assert.AreEqual(a.GetHashCode(), b.GetHashCode(), a + " == " + b);
+ }
+ }
+
[Test]
public static void TestComparison_VERTEX()
{
diff --git a/Tests/Runtime/Utilities/RuntimeUtility.cs b/Tests/Runtime/Utilities/RuntimeUtility.cs
index 209f5a2db..a7755b534 100644
--- a/Tests/Runtime/Utilities/RuntimeUtility.cs
+++ b/Tests/Runtime/Utilities/RuntimeUtility.cs
@@ -1,8 +1,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
-using System.Diagnostics;
using System.IO;
+using System.Runtime.CompilerServices;
using NUnit.Framework;
using UnityEngine.ProBuilder.MeshOperations;
using UnityEngine.ProBuilder.Shapes;
@@ -206,26 +206,21 @@ public static bool AssertAreEqual(Mesh expected, Mesh result, MeshArrays compare
return true;
}
- public static string GetResourcesPath(string assetName, int methodOffset = 0)
+ public static string GetResourcesPath(string assetName,
+ [CallerFilePath] string callingFilePath = null,
+ [CallerMemberName] string callingMemberName = null)
{
- StackTrace trace = new StackTrace(1 + methodOffset, true);
- StackFrame calling = trace.GetFrame(0);
-
- string filePath = calling.GetFileName();
-
- if (string.IsNullOrEmpty(filePath))
+ if (string.IsNullOrEmpty(callingFilePath))
{
UnityEngine.Debug.LogError(
"Cannot generate mesh templates directory path from calling method. Please use the explicit SaveMeshTemplate overload.");
return null;
}
- string methodName = calling.GetMethod().Name;
-
return string.Format("{0}/{1}/{2}/{3}",
typeof(T).ToString(),
- Path.GetFileNameWithoutExtension(filePath),
- methodName,
+ Path.GetFileNameWithoutExtension(callingFilePath),
+ callingMemberName,
assetName);
}
diff --git a/package.json b/package.json
index 6525bf23f..ae5a978e4 100644
--- a/package.json
+++ b/package.json
@@ -1,47 +1,17 @@
{
- "name": "com.unity.probuilder",
- "displayName": "ProBuilder",
+ "name": "com.unity.probuilder.tests",
+ "displayName": "ProBuilder Tests",
+ "type": "tests",
"version": "6.1.2",
- "unity": "6000.0",
- "description": "Build, edit, and texture custom geometry in Unity. Use ProBuilder for in-scene level design, prototyping, collision meshes, all with on-the-fly play-testing.\n\nAdvanced features include UV editing, vertex colors, parametric shapes, and texture blending. With ProBuilder's model export feature it's easy to tweak your levels in any external 3D modelling suite.",
- "keywords": [
- "3d",
- "model",
- "mesh",
- "modeling",
- "geometry",
- "shape",
- "cube",
- "blender",
- "max",
- "maya",
- "fbx",
- "obj",
- "level",
- "design",
- "block",
- "greybox",
- "graybox",
- "whitebox",
- "prototype",
- "probuilder"
- ],
- "samples": [
- {
- "displayName": "Editor Examples",
- "description": "Scripts demonstrating how to integrate new functionality into the ProBuilder editor window.",
- "path": "Samples~/Editor"
- },
- {
- "displayName": "Runtime Examples",
- "description": "Scripts showing how to create and modify meshes at runtime.",
- "path": "Samples~/Runtime"
- }
- ],
"dependencies": {
- "com.unity.shadergraph": "17.0.3",
- "com.unity.settings-manager": "1.0.3",
- "com.unity.modules.physics": "1.0.0",
- "com.unity.modules.imgui": "1.0.0"
+ "com.unity.test-framework.performance": "3.2.0"
+ },
+ "upmCi": {
+ "footprint": "4c738568f3a3d315f60bafbe6f315b0a6f8c46c7"
+ },
+ "repository": {
+ "url": "https://github.com/Unity-Technologies/com.unity.probuilder.git",
+ "type": "git",
+ "revision": "f070d01a1ecb9e899ee09cbeb17f006b9dfcc8d4"
}
}