diff --git a/Assets/Scenes/Worlds/RiverWorld.unity b/Assets/Scenes/Worlds/RiverWorld.unity index 301e7353e05c2c4a3d7397bc8d2dca7f196212aa..db57f12ce3bf68dc3c1a5f96a058a21b5de95693 100644 --- a/Assets/Scenes/Worlds/RiverWorld.unity +++ b/Assets/Scenes/Worlds/RiverWorld.unity @@ -3870,7 +3870,7 @@ Mesh: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh1141600 + m_Name: pb_Mesh272762 serializedVersion: 10 m_SubMeshes: - serializedVersion: 2 diff --git a/Assets/Scripts/GlobalBehaviour.cs b/Assets/Scripts/GlobalBehaviour.cs index 9d76c011d2b109823e5a24cb40ca07d8b88efe37..2c503ce4e25dc72b7b1c3ad85fa18f8f64fccfd8 100644 --- a/Assets/Scripts/GlobalBehaviour.cs +++ b/Assets/Scripts/GlobalBehaviour.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Text.RegularExpressions; +using UnityEditor.PackageManager.Requests; using UnityEngine; using UnityEngine.Networking; @@ -97,6 +98,9 @@ IEnumerator _GetScrollsfromServer() // else // break; //} + //while (request.result == UnityWebRequest.Result.InProgress) + // yield return null; + System.DateTime answerTime = System.DateTime.UtcNow; string jsonString = null; @@ -165,6 +169,9 @@ IEnumerator _GetContextfromServer() else break; } + while(request.result == UnityWebRequest.Result.InProgress) + yield return null; + System.DateTime answerTime = System.DateTime.UtcNow; string jsonString = null; diff --git a/Assets/Scripts/Loading/Stage.cs b/Assets/Scripts/Loading/Stage.cs index 9e00f96679199753eed893a9b0c8865dc1fc6b3a..794595444f41e4452899395690dddaf91590c48e 100644 --- a/Assets/Scripts/Loading/Stage.cs +++ b/Assets/Scripts/Loading/Stage.cs @@ -73,7 +73,7 @@ public PlayerRecord player_record value.CopyExposedSolutionFacts(this); } } - + [JsonProperty] // unused, but could be for resuming private string record_index; /// <summary> diff --git a/Assets/Scripts/StageBehaviour.cs b/Assets/Scripts/StageBehaviour.cs index 4ca3d8c0c3162f10b72c4726ee38e61f0e6e2a7b..18186009f4f5eabc70150c8259dd880196d34296 100644 --- a/Assets/Scripts/StageBehaviour.cs +++ b/Assets/Scripts/StageBehaviour.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Xml.Serialization; @@ -15,36 +16,69 @@ public class StageBehaviour : MonoBehaviour void Start() { StageStatic.LoadInitStage(true /*StageStatic.stage.player_record.solved*/, gameObject); + GenerateMMTCollider(gameObject); } public static List<TriangleFact> GenerateMMTCollider(GameObject obj = null) { bool debug = false; var t0 = System.DateTime.Now; - List<TriangleFact> tris = new(); - foreach (MeshCollider coll in FindObjectsOfType<MeshCollider>()) + + foreach (BoxCollider coll in FindObjectsOfType<BoxCollider>()) { - if (!coll.sharedMesh.isReadable) - continue; + Vector3[] minmax = new Vector3[] + { + coll.center - coll.size/2, + coll.center + coll.size/2, + }; - for (int i = 0; i < coll.sharedMesh.triangles.Length; i += 3) + _QuadAdd(0, 1, 3, 2); + _QuadAdd(1, 5, 7, 3); + _QuadAdd(5, 4, 6, 7); + _QuadAdd(4, 0, 2, 6); + + _QuadAdd(2, 3, 7, 6); + _QuadAdd(0, 4, 5, 1); + + void _QuadAdd(uint i, uint j, uint k, uint l) + { + _TrisAdd(i, k, j); + _TrisAdd(k, i, l); + } + + void _TrisAdd(uint i, uint j, uint k) { tris.Add(new( new[] { - _Transform(coll.sharedMesh.vertices[coll.sharedMesh.triangles[i + 0]], coll.transform.localToWorldMatrix), - _Transform(coll.sharedMesh.vertices[coll.sharedMesh.triangles[i + 1]], coll.transform.localToWorldMatrix), - _Transform(coll.sharedMesh.vertices[coll.sharedMesh.triangles[i + 2]], coll.transform.localToWorldMatrix), - }, - null) - ); + _Transform(new Vector3(minmax[i>>0&1][0], minmax[i>>1&1][1], minmax[i>>2&1][2]), coll.transform.localToWorldMatrix), + _Transform(new Vector3(minmax[j>>0&1][0], minmax[j>>1&1][1], minmax[j>>2&1][2]), coll.transform.localToWorldMatrix), + _Transform(new Vector3(minmax[k>>0&1][0], minmax[k>>1&1][1], minmax[k>>2&1][2]), coll.transform.localToWorldMatrix), + })); } } + //foreach (MeshCollider coll in FindObjectsOfType<MeshCollider>()) + //{ + // if (!coll.sharedMesh.isReadable) + // continue; + + // for (int i = 0; i < coll.sharedMesh.triangles.Length; i += 3) + // { + // tris.Add(new( + // new[] { + // _Transform(coll.sharedMesh.vertices[coll.sharedMesh.triangles[i + 0]], coll.transform.localToWorldMatrix), + // _Transform(coll.sharedMesh.vertices[coll.sharedMesh.triangles[i + 1]], coll.transform.localToWorldMatrix), + // _Transform(coll.sharedMesh.vertices[coll.sharedMesh.triangles[i + 2]], coll.transform.localToWorldMatrix), + // }) + // ); + // } + //} + if (debug && obj != null) { var t1 = System.DateTime.Now - t0; - Debug.Log($"{tris.Count} Tris in {t1.Milliseconds}"); + Debug.Log($"{tris.Count} Tris in {t1.Milliseconds}ms"); Mesh mesh = new() { @@ -52,8 +86,8 @@ public static List<TriangleFact> GenerateMMTCollider(GameObject obj = null) vertices = tris.SelectMany(t => t.Verticies).ToArray(), triangles = Enumerable.Range(0, tris.Count * 3).ToArray(), }; - mesh.Optimize(); mesh.RecalculateNormals(); + mesh.Optimize(); MeshFilter filter = obj.GetComponent<MeshFilter>(); filter.sharedMesh = mesh; diff --git a/Assets/Scripts/StageStatic.cs b/Assets/Scripts/StageStatic.cs index c7e3cead53185e364c03db8c15b0caeee2439349..bd27fad7c35a9b831ce32d6c9c70a55d9c63805a 100644 --- a/Assets/Scripts/StageStatic.cs +++ b/Assets/Scripts/StageStatic.cs @@ -318,6 +318,8 @@ public static void ShallowLoadStages(bool force = false) && !force) return; + //GlobalBehaviour.InitiateContext.FastForward(); //active wait + List<FileInfo>[] crawler = new List<FileInfo>[StageChapters.Count]; _ = new Stage(); // Init static members diff --git a/Assets/Scripts/Utility/Extensions/IEnumeratorExtensions.cs b/Assets/Scripts/Utility/Extensions/IEnumeratorExtensions.cs index 5dd0533f370a81219c129ebada9378e7f231670a..6d8c37ce283010ca9e975dee250ec3515243bfd0 100644 --- a/Assets/Scripts/Utility/Extensions/IEnumeratorExtensions.cs +++ b/Assets/Scripts/Utility/Extensions/IEnumeratorExtensions.cs @@ -11,6 +11,15 @@ public static void FastForward(this IEnumerator that) next.FastForward(); } + public static IEnumerator ProxyHandle(this IEnumerator that) + { + while (that.MoveNext()) + if(that.Current is IEnumerator next) + yield return next.ProxyHandle(); + else + yield return null; + } + public static IEnumerator yield_break => _YieldBreak; private static IEnumerator _YieldBreak = YieldBreak(); public static IEnumerator YieldBreak()