Skip to content

Commit

Permalink
Merge from 'develop' into 'main' for CLOiSim-4.5.5 (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunseok-yang authored May 28, 2024
2 parents 885f972 + 58d88ce commit 742e3ba
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 86 deletions.
21 changes: 10 additions & 11 deletions Assets/Scenes/MainScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion Assets/Scripts/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -253,7 +255,11 @@ void Awake()
SensorDevices.DepthCamera.LoadComputeShader();

gameObject.AddComponent<ObjectSpawning>();

_segmentationManager = gameObject.AddComponent<SegmentationManager>();

_vhacd = gameObject.AddComponent<MeshProcess.VHACD>();
_vhacd.m_parameters = VHACD.Params;
}

void Start()
Expand Down
92 changes: 40 additions & 52 deletions Assets/Scripts/Tools/Mesh/VHACD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MeshFilter>();

var decomposer = targetMeshObject.AddComponent<MeshVHACD>();
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<MeshCollider>();
colliderMesh.name = "VHACD_" + meshFilter.name + "_" + index;

var currentMeshCollider = targetMeshObject.AddComponent<MeshCollider>();
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>();
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>();
meshCollider.sharedMesh = meshFilter.sharedMesh;
meshCollider.convex = false;
meshCollider.cookingOptions = SDF.Implement.Collision.CookingOptions;
meshCollider.hideFlags |= HideFlags.NotEditable;
}
}
}
}
10 changes: 5 additions & 5 deletions Assets/Scripts/Tools/SDF/Implement/Implement.Collision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@ public static void Make(UE.GameObject targetObject)
var modelHelper = targetObject.GetComponentInParent<SDF.Helper.Model>();
// UE.Debug.Log(modelHelper);

var meshFilters = targetObject.GetComponentsInChildren<UE.MeshFilter>();

// 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<UE.MeshFilter>();

if (targetObject.GetComponent<UE.Collider>() == null)
{
KeepUnmergedMeshes(meshFilters);
Expand All @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions Assets/Scripts/Tools/SDF/Implement/Implement.Road.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/UI/FollowingTargetList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 2 additions & 4 deletions Assets/Scripts/UI/InfoDisplay.FPS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

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;

private void CalculateFPS()
{
frameCount++;
dT += Time.unscaledDeltaTime;
dT += Time.deltaTime;
if (dT > fpsUpdatePeriod)
{
fps = Mathf.Round(frameCount / dT);
Expand All @@ -27,8 +27,6 @@ private void CalculateFPS()

private void UpdateFPS()
{
CalculateFPS();

if (_inputFieldFPS != null)
{
_inputFieldFPS.text = fps.ToString();
Expand Down
5 changes: 5 additions & 0 deletions Assets/Scripts/UI/InfoDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ void Awake()
}
}

void Update()
{
CalculateFPS();
}

void LateUpdate()
{
UpdateFPS();
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/UI/SimulationDisplay.Help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private void UpdateHelpContents()
sb.AppendLine(" - Camera following mode");
sb.AppendLine(string.Empty);
sb.AppendLine(" <b>Choose one object from the list</b> 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 <b>Left Ctrl + F</b>: Follow the object");
sb.AppendLine(" <b>Left Ctrl + Left Shift + F</b>: Unfollow");
sb.AppendLine(string.Empty);
Expand Down
4 changes: 2 additions & 2 deletions Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
}
},
"com.unity.splines": {
"version": "2.6.0",
"version": "2.6.1",
"depth": 0,
"source": "registry",
"dependencies": {
Expand Down Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 742e3ba

Please sign in to comment.