diff --git a/Assets/Scenes/MainScene.unity b/Assets/Scenes/MainScene.unity index 2a740bce..37f0e348 100644 --- a/Assets/Scenes/MainScene.unity +++ b/Assets/Scenes/MainScene.unity @@ -38,7 +38,6 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.17276844, g: 0.2158925, b: 0.29782635, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -567,7 +566,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 245, y: 0} + m_AnchoredPosition: {x: 240, y: 0} m_SizeDelta: {x: 95, y: 25} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &92331978 @@ -1519,7 +1518,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 615, y: 20} + m_AnchoredPosition: {x: 593, y: 20} m_SizeDelta: {x: 175, y: 25} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &227849492 @@ -2584,7 +2583,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 185, y: 0} + m_AnchoredPosition: {x: 180, y: 0} m_SizeDelta: {x: 30, y: 25} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &389794125 @@ -5288,7 +5287,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 345, y: 0} + m_AnchoredPosition: {x: 336, y: 0} m_SizeDelta: {x: 45, y: 25} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &957005822 @@ -5961,7 +5960,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: 'Time: Sim' + m_text: 'Time: Sim' m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2100000, guid: e73a58f6e2794ae7b1b7e50b7fb811b0, type: 2} @@ -7032,7 +7031,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 315, y: 0} + m_AnchoredPosition: {x: 308, y: 0} m_SizeDelta: {x: 30, y: 25} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1426083622 @@ -7249,7 +7248,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 410, y: 20} + m_AnchoredPosition: {x: 395, y: 20} m_SizeDelta: {x: 30, y: 25} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1608531202 @@ -7419,7 +7418,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 115, y: 0} + m_AnchoredPosition: {x: 112, y: 0} m_SizeDelta: {x: 95, y: 25} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1652506032 @@ -8229,7 +8228,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 500, y: 20} + m_AnchoredPosition: {x: 480, y: 20} m_SizeDelta: {x: 50, y: 25} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1829705137 @@ -8832,7 +8831,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 440, y: 20} + m_AnchoredPosition: {x: 423, y: 20} m_SizeDelta: {x: 30, y: 25} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1928431087 diff --git a/Assets/Scripts/Main.cs b/Assets/Scripts/Main.cs index 0fdb2ee7..20f0825e 100644 --- a/Assets/Scripts/Main.cs +++ b/Assets/Scripts/Main.cs @@ -44,7 +44,7 @@ public class Main : MonoBehaviour private static RuntimeGizmos.TransformGizmo transformGizmo = null; private static CameraControl cameraControl = null; private static SegmentationManager _segmentationManager = null; - + private static MeshProcess.VHACD _vhacd = null; private static bool isResetting = false; private static bool resetTriggered = false; @@ -64,6 +64,8 @@ public class Main : MonoBehaviour public static CameraControl CameraControl => cameraControl; + public static MeshProcess.VHACD MeshVHACD => _vhacd; + #region SDF Parser private SDF.Root _sdfRoot = null; private SDF.Import.Loader _sdfLoader = null; @@ -253,7 +255,11 @@ void Awake() SensorDevices.DepthCamera.LoadComputeShader(); gameObject.AddComponent(); + _segmentationManager = gameObject.AddComponent(); + + _vhacd = gameObject.AddComponent(); + _vhacd.m_parameters = VHACD.Params; } void Start() diff --git a/Assets/Scripts/Tools/Mesh/VHACD.cs b/Assets/Scripts/Tools/Mesh/VHACD.cs index 62621e82..c03a5202 100644 --- a/Assets/Scripts/Tools/Mesh/VHACD.cs +++ b/Assets/Scripts/Tools/Mesh/VHACD.cs @@ -5,79 +5,67 @@ */ using UnityEngine; -using MeshVHACD = MeshProcess.VHACD; public partial class VHACD { private static readonly int NumOfLimitConvexMeshTriangles = 255; - private static MeshVHACD.Parameters VHACDParams = new MeshVHACD.Parameters() + public static MeshProcess.VHACD.Parameters Params = new MeshProcess.VHACD.Parameters() { - m_resolution = 18000, - // m_resolution = 800000, // max: 64,000,000 - m_concavity = 0.005, - m_planeDownsampling = 3, - m_convexhullDownsampling = 3, + m_resolution = 250000, + m_concavity = 0.01, + m_planeDownsampling = 4, + m_convexhullDownsampling = 4, m_alpha = 0.1, - m_beta = 0.05, + m_beta = 0.1, m_pca = 0, m_mode = 0, - m_maxNumVerticesPerCH = 128, - m_minVolumePerCH = 0.0005, + m_maxNumVerticesPerCH = 512, + m_minVolumePerCH = 0.001, m_convexhullApproximation = 1, - m_oclAcceleration = 0, - m_maxConvexHulls = 256, + m_oclAcceleration = 1, + m_maxConvexHulls = 1024, m_projectHullVertices = true }; - public static void Apply(in GameObject targetObject) + public static void Apply(MeshFilter[] meshFilters) { - for (var i = 0; i < targetObject.transform.childCount; i++) - { - var targetMeshObject = targetObject.transform.GetChild(i).gameObject; - - var meshFilters = targetMeshObject.GetComponentsInChildren(); - - var decomposer = targetMeshObject.AddComponent(); - decomposer.m_parameters = VHACDParams; + var decomposer = Main.MeshVHACD; - foreach (var meshFilter in meshFilters) + foreach (var meshFilter in meshFilters) + { + // Just skip if the number of vertices in the mesh is less than the limit of convex mesh triangles + if (meshFilter.sharedMesh.vertexCount >= NumOfLimitConvexMeshTriangles) { - // Just skip if the number of vertices in the mesh is less than the limit of convex mesh triangles - if (meshFilter.sharedMesh.vertexCount >= NumOfLimitConvexMeshTriangles) + // #if ENABLE_MERGE_COLLIDER + // Debug.LogFormat("Apply VHACD({0}), EnableMergeCollider will be ignored.", targetObject.name); + // #else + // Debug.LogFormat("Apply VHACD({0})", targetObject.name); + // #endif + var colliderMeshes = decomposer.GenerateConvexMeshes(meshFilter.sharedMesh); + + for (var index = 0; index < colliderMeshes.Count; index++) { - // #if ENABLE_MERGE_COLLIDER - // Debug.LogFormat("Apply VHACD({0}), EnableMergeCollider will be ignored.", targetObject.name); - // #else - // Debug.LogFormat("Apply VHACD({0})", targetObject.name); - // #endif - var colliderMeshes = decomposer.GenerateConvexMeshes(meshFilter.sharedMesh); + var colliderMesh = colliderMeshes[index]; - for (var index = 0; index < colliderMeshes.Count; index++) - { - var collider = colliderMeshes[index]; + var currentMeshCollider = meshFilter.gameObject.AddComponent(); + colliderMesh.name = "VHACD_" + meshFilter.name + "_" + index; - var currentMeshCollider = targetMeshObject.AddComponent(); - collider.name = "VHACD_" + meshFilter.name + "_" + index; - // Debug.Log(collider.name); - currentMeshCollider.sharedMesh = collider; - currentMeshCollider.convex = false; - currentMeshCollider.cookingOptions = SDF.Implement.Collision.CookingOptions; - currentMeshCollider.hideFlags |= HideFlags.NotEditable; - } + // Debug.Log(collider.name); + currentMeshCollider.sharedMesh = colliderMesh; + currentMeshCollider.convex = false; + currentMeshCollider.cookingOptions = SDF.Implement.Collision.CookingOptions; + currentMeshCollider.hideFlags |= HideFlags.NotEditable; } - else - { - var meshCollider = targetMeshObject.AddComponent(); - meshCollider.sharedMesh = meshFilter.sharedMesh; - meshCollider.convex = false; - meshCollider.cookingOptions = SDF.Implement.Collision.CookingOptions; - meshCollider.hideFlags |= HideFlags.NotEditable; - } - GameObject.Destroy(meshFilter.gameObject); } - - Component.Destroy(decomposer); + else + { + var meshCollider = meshFilter.gameObject.AddComponent(); + meshCollider.sharedMesh = meshFilter.sharedMesh; + meshCollider.convex = false; + meshCollider.cookingOptions = SDF.Implement.Collision.CookingOptions; + meshCollider.hideFlags |= HideFlags.NotEditable; + } } } } \ No newline at end of file diff --git a/Assets/Scripts/Tools/SDF/Implement/Implement.Collision.cs b/Assets/Scripts/Tools/SDF/Implement/Implement.Collision.cs index c7a2c9b3..ed92f0b9 100644 --- a/Assets/Scripts/Tools/SDF/Implement/Implement.Collision.cs +++ b/Assets/Scripts/Tools/SDF/Implement/Implement.Collision.cs @@ -70,17 +70,17 @@ public static void Make(UE.GameObject targetObject) var modelHelper = targetObject.GetComponentInParent(); // UE.Debug.Log(modelHelper); + var meshFilters = targetObject.GetComponentsInChildren(); + // Skip for Primitive Mesh or static model if (UseVHACD && targetObject.name != "Primitive Mesh" && modelHelper.isStatic == false) { - VHACD.Apply(targetObject); + VHACD.Apply(meshFilters); } else { - var meshFilters = targetObject.GetComponentsInChildren(); - if (targetObject.GetComponent() == null) { KeepUnmergedMeshes(meshFilters); @@ -89,9 +89,9 @@ public static void Make(UE.GameObject targetObject) MergeCollider(targetObject); #endif } - - RemoveRenderers(meshFilters); } + + RemoveRenderers(meshFilters); } private static void RemoveRenderers(UE.MeshFilter[] meshFilters) diff --git a/Assets/Scripts/Tools/SDF/Implement/Implement.Road.cs b/Assets/Scripts/Tools/SDF/Implement/Implement.Road.cs index 81d89ed5..bda46ba6 100644 --- a/Assets/Scripts/Tools/SDF/Implement/Implement.Road.cs +++ b/Assets/Scripts/Tools/SDF/Implement/Implement.Road.cs @@ -33,10 +33,7 @@ public static UE.GameObject Generate(in SDF.World.Road road) foreach (var point in road.points) { var offset = point - centerPosOfRoad; - var knotPos = SDF2Unity.Position(offset); - var knot = new Splines.BezierKnot(); - knot.Position = knotPos; - splineContainer.Spline.Add(knot, Splines.TangentMode.AutoSmooth); + splineContainer.Spline.Add(SDF2Unity.Position(offset), Splines.TangentMode.AutoSmooth); } splineContainer.Spline.SetTangentMode(0, Splines.TangentMode.Linear); diff --git a/Assets/Scripts/UI/FollowingTargetList.cs b/Assets/Scripts/UI/FollowingTargetList.cs index 871158c3..2cbb1d03 100644 --- a/Assets/Scripts/UI/FollowingTargetList.cs +++ b/Assets/Scripts/UI/FollowingTargetList.cs @@ -36,7 +36,7 @@ void Start() { dropdown.onValueChanged.AddListener(OnDropDownValueChanged); - _emptyOption = new TMP_Dropdown.OptionData("- unfollowing -"); + _emptyOption = new TMP_Dropdown.OptionData("UNFOLLOWING"); dropdown.options.Add(_emptyOption); SelectItem(0); } diff --git a/Assets/Scripts/UI/InfoDisplay.FPS.cs b/Assets/Scripts/UI/InfoDisplay.FPS.cs index 8f4a8090..b8776963 100644 --- a/Assets/Scripts/UI/InfoDisplay.FPS.cs +++ b/Assets/Scripts/UI/InfoDisplay.FPS.cs @@ -8,7 +8,7 @@ public partial class InfoDisplay : MonoBehaviour { - private const float fpsUpdatePeriod = 0.25f; + private const float fpsUpdatePeriod = 1f; private int frameCount = 0; private float dT = 0.0F; private float fps = 0.0F; @@ -16,7 +16,7 @@ public partial class InfoDisplay : MonoBehaviour private void CalculateFPS() { frameCount++; - dT += Time.unscaledDeltaTime; + dT += Time.deltaTime; if (dT > fpsUpdatePeriod) { fps = Mathf.Round(frameCount / dT); @@ -27,8 +27,6 @@ private void CalculateFPS() private void UpdateFPS() { - CalculateFPS(); - if (_inputFieldFPS != null) { _inputFieldFPS.text = fps.ToString(); diff --git a/Assets/Scripts/UI/InfoDisplay.cs b/Assets/Scripts/UI/InfoDisplay.cs index a212179b..755e09cd 100644 --- a/Assets/Scripts/UI/InfoDisplay.cs +++ b/Assets/Scripts/UI/InfoDisplay.cs @@ -51,6 +51,11 @@ void Awake() } } + void Update() + { + CalculateFPS(); + } + void LateUpdate() { UpdateFPS(); diff --git a/Assets/Scripts/UI/SimulationDisplay.Help.cs b/Assets/Scripts/UI/SimulationDisplay.Help.cs index 77e09d2e..43352ba6 100644 --- a/Assets/Scripts/UI/SimulationDisplay.Help.cs +++ b/Assets/Scripts/UI/SimulationDisplay.Help.cs @@ -65,7 +65,7 @@ private void UpdateHelpContents() sb.AppendLine(" - Camera following mode"); sb.AppendLine(string.Empty); sb.AppendLine(" Choose one object from the list on the bottom right corner."); - sb.AppendLine(" if you want cancel the following mode, choose '--unfollowing--' menu from the list."); + sb.AppendLine(" if you want cancel the following mode, choose 'UNFOLLOWING' menu from the list."); sb.AppendLine(" Select object and Left Ctrl + F: Follow the object"); sb.AppendLine(" Left Ctrl + Left Shift + F: Unfollow"); sb.AppendLine(string.Empty); diff --git a/Packages/manifest.json b/Packages/manifest.json index 5dc6b8d4..e4ec5489 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -7,9 +7,9 @@ "com.unity.render-pipelines.universal": "14.0.11", "com.unity.robotics.vhacd": "https://github.com/Unity-Technologies/VHACD.git?path=/com.unity.robotics.vhacd", "com.unity.searcher": "4.9.2", - "com.unity.splines": "2.6.0", + "com.unity.splines": "2.6.1", "com.unity.terrain-tools": "5.0.4", - "com.unity.textmeshpro": "3.0.8", + "com.unity.textmeshpro": "3.0.9", "com.unity.toolchain.linux-x86_64": "2.0.9", "com.unity.ugui": "1.0.0", "com.unity.modules.ai": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index deb156f7..9ea479a3 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -102,7 +102,7 @@ } }, "com.unity.splines": { - "version": "2.6.0", + "version": "2.6.1", "depth": 0, "source": "registry", "dependencies": { @@ -139,7 +139,7 @@ "url": "https://packages.unity.com" }, "com.unity.textmeshpro": { - "version": "3.0.8", + "version": "3.0.9", "depth": 0, "source": "registry", "dependencies": { diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 272337b9..180266fb 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -139,7 +139,7 @@ PlayerSettings: loadStoreDebugModeEnabled: 0 visionOSBundleVersion: 1.0 tvOSBundleVersion: 1.0 - bundleVersion: 4.5.4 + bundleVersion: 4.5.5 preloadedAssets: [] metroInputSource: 0 wsaTransparentSwapchain: 0 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index d971767b..d8a33589 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2022.3.28f1 -m_EditorVersionWithRevision: 2022.3.28f1 (6bae5ce6b222) +m_EditorVersion: 2022.3.30f1 +m_EditorVersionWithRevision: 2022.3.30f1 (70558241b701)