From 41b6fc3f2cdedd4250d4f730806ad9ecb82d5728 Mon Sep 17 00:00:00 2001 From: Brandon Dang <8165314+parseccentric@users.noreply.github.com> Date: Mon, 7 Feb 2022 14:59:14 -0600 Subject: [PATCH 01/15] Re-enabled grabbable drawing feature --- .../Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs index 91825a7..6f84ed0 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs @@ -60,7 +60,7 @@ public void CreateUserStrokeInstance(int strokeID, LineRenderer lineRenderer, bo var nAGO = NetworkedObjectsManager.Instance.CreateNetworkedGameObject(pivot, strokeID, strokeID); //tag it as a drawing for ECS - pivot.tag = TagList.drawing; + pivot.tag = TagList.interactable; entityManager.AddComponentData(nAGO.Entity, new DrawingTag { }); var bColl = pivot.GetComponent(); @@ -116,7 +116,7 @@ public void CreateExternalClientStrokeInstance(int strokeID, LineRenderer curren NetworkedGameObject nAGO = NetworkedObjectsManager.Instance.CreateNetworkedGameObject(pivot, strokeID, strokeID, true); //overide interactable tag when creatingNetworkGameObject since we are not moving drawings only deleting them - pivot.tag = TagList.drawing; + pivot.tag = TagList.interactable; //tag created drawing object will be useful in the future for having items with multiple tags entityManager.AddComponentData(nAGO.Entity, new DrawingTag { }); From 6c47315df45228e357b281125c8728443f6b9af1 Mon Sep 17 00:00:00 2001 From: Brandon Dang <8165314+parseccentric@users.noreply.github.com> Date: Mon, 7 Feb 2022 17:34:09 -0600 Subject: [PATCH 02/15] added comments for where to find relay vars --- .../KomodoWebXRFullView2020/relay.js | 47 ++++++++++++------ .../KomodoWebXRFullView2020/relay.js | 48 +++++++++++++------ Komodo/ProjectSettings/ProjectSettings.asset | 7 +-- 3 files changed, 69 insertions(+), 33 deletions(-) diff --git a/Komodo/Assets/Packages/KomodoCore/Hidden~/WebGLTemplates/KomodoWebXRFullView2020/relay.js b/Komodo/Assets/Packages/KomodoCore/Hidden~/WebGLTemplates/KomodoWebXRFullView2020/relay.js index 9bd43b5..6010095 100644 --- a/Komodo/Assets/Packages/KomodoCore/Hidden~/WebGLTemplates/KomodoWebXRFullView2020/relay.js +++ b/Komodo/Assets/Packages/KomodoCore/Hidden~/WebGLTemplates/KomodoWebXRFullView2020/relay.js @@ -1,8 +1,14 @@ // 'esversion: 6' -// Remember: also change Assets\WebGLTemplates\KomodoWebXRFullView2020\relay.js (or re-copy the WebGLTemplates to the Assets folder) if you intend for the changes to be reflected in the build. If you are reading this from inside a build folder, you can change this file as you please. +// Remember: also change Assets\WebGLTemplates\KomodoWebXRFullView2020\relay.js (or +// re-copy the WebGLTemplates to the Assets folder) if you intend for the changes to +// be reflected in the build. If you are reading this from inside a build folder, +// you can change this file as you please. -// Tip: if you need to change this on-the-fly, you can edit this file without rebuilding. It's also possible to use the inspector to inspect the VR frame and call `window.RELAY_API_BASE_URL=""`, if for some reason you need to do that in real time. +// Tip: if you need to change this on-the-fly, you can edit this file without +// rebuilding. It's also possible to use the inspector to inspect the VR frame and +// call `window.RELAY_API_BASE_URL=""`, if for some reason you +// need to do that in real time. /* * --------------------------------------------------------------------------------- @@ -11,14 +17,22 @@ */ // Replace these with your own server's URLs. - -var RELAY_BASE_URL = "http://localhost:3000"; -var API_BASE_URL = "http://localhost:4040"; -var VR_BASE_URL = "http://localhost:8123"; //TODO -- change this to a better default - -// init globals which Unity will assign when setup is done. -var sync = null; -var chat = null; +// +// If running each of these without Docker: +// - RELAY_BASE_URL: Look in komodo-relay > serve.js or config.js for the port number +// - API_BASE_URL: Look in komodo-portal > config.js > web.port for the port number +// - VR_BASE_URL: This will be unused for local builds +// +// If running each of these with Docker: +// - RELAY_BASE_URL: Look in komodo-relay > docker-compose.yml > +// services.komodo-relay.labels > traefik.frontend.rule +// - API_BASE_URL: Look in komodo-portal > docker-compose.yml > +// services.backend.labels > traefik.frontend.rule +// - VR_BASE_URL: Look in komodo-portal > .env.* > VUE_APP_VR_CLIENT_BASE_URL + +var RELAY_BASE_URL = "http://localhost:3000"; +var API_BASE_URL = "http://localhost:4040"; +var VR_BASE_URL = "http://localhost:8123"; /* * --------------------------------------------------------------------------------- @@ -26,6 +40,10 @@ var chat = null; * --------------------------------------------------------------------------------- */ +// init globals which Unity will assign when setup is done. +var sync = null; +var chat = null; + /** * Get the URL parameters * source: https://css-tricks.com/snippets/javascript/get-url-variables/ @@ -92,8 +110,6 @@ var splitAppAndBuild = function (appAndBuild) { var runtimeAppAndBuild = removeVRBaseUrl(removeQuery(window.location.href)); -//console.log(runtimeAppAndBuild); - // TODO(Brandon): in the future, pass app and build as separate details like this: // var result = splitAppAndBuild(runtimeAppAndBuild); // var runtimeApp = result.app; @@ -130,7 +146,7 @@ request.open("GET", url, true); request.responseType = "json"; request.send(); -request.onload = function(){ +request.onload = function() { let res = request.response; // session details @@ -145,14 +161,15 @@ request.onload = function(){ details.users = res.users; let assets_response = res.assetList; - for (idx = 0; idx < assets_response.length; idx++) - { + + for (idx = 0; idx < assets_response.length; idx++) { asset = new Object; asset.id = assets_response[idx].asset_id; asset.name = assets_response[idx].asset_name; asset.url = assets_response[idx].path; asset.isWholeObject = Boolean(assets_response[idx].is_whole_object); asset.scale = assets_response[idx].scale || 1; + details.assets.push(asset); } }; diff --git a/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/relay.js b/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/relay.js index 8046623..3f46ff4 100644 --- a/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/relay.js +++ b/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/relay.js @@ -1,8 +1,15 @@ // 'esversion: 6' -// Remember: also change Assets\Packages\KomodoCore\Hidden~\WebGLTemplates\KomodoWebXRFullView2020\relay.js if you intend for the changes to be reflected in projects that use the package. If you are reading this from inside a build folder, you can change this file as you please. +// Remember: also change +// Assets\Packages\KomodoCore\Hidden~\WebGLTemplates\KomodoWebXRFullView2020\relay.js +// if you intend for the changes to be reflected in projects that use the package. +// If you are reading this from inside a build folder, you can change this file as +// you please. -// Tip: if you need to change this on-the-fly, you can edit this file without rebuilding. It's also possible to use the inspector to inspect the VR frame and call `window.RELAY_API_BASE_URL=""`, if for some reason you need to do that in real time. +// Tip: if you need to change this on-the-fly, you can edit this file without +// rebuilding. It's also possible to use the inspector to inspect the VR frame and +// call `window.RELAY_API_BASE_URL=""`, if for some reason you need +// to do that in real time. /* * --------------------------------------------------------------------------------- @@ -11,14 +18,22 @@ */ // Replace these with your own server's URLs. - -var RELAY_BASE_URL = "http://localhost:3000"; -var API_BASE_URL = "http://localhost:4040"; -var VR_BASE_URL = "http://localhost:8123"; //TODO -- change this to a better default - -// init globals which Unity will assign when setup is done. -var sync = null; -var chat = null; +// +// If running each of these without Docker: +// - RELAY_BASE_URL: Look in komodo-relay > serve.js or config.js for the port number +// - API_BASE_URL: Look in komodo-portal > config.js > web.port for the port number +// - VR_BASE_URL: This will be unused for local builds +// +// If running each of these with Docker: +// - RELAY_BASE_URL: Look in komodo-relay > docker-compose.yml > +// services.komodo-relay.labels > traefik.frontend.rule +// - API_BASE_URL: Look in komodo-portal > docker-compose.yml > +// services.backend.labels > traefik.frontend.rule +// - VR_BASE_URL: Look in komodo-portal > .env.* > VUE_APP_VR_CLIENT_BASE_URL + +var RELAY_BASE_URL = "http://localhost:3000"; +var API_BASE_URL = "http://localhost:4040"; +var VR_BASE_URL = "http://localhost:8123"; /* * --------------------------------------------------------------------------------- @@ -26,6 +41,10 @@ var chat = null; * --------------------------------------------------------------------------------- */ +// init globals which Unity will assign when setup is done. +var sync = null; +var chat = null; + /** * Get the URL parameters * source: https://css-tricks.com/snippets/javascript/get-url-variables/ @@ -92,8 +111,6 @@ var splitAppAndBuild = function (appAndBuild) { var runtimeAppAndBuild = removeVRBaseUrl(removeQuery(window.location.href)); -//console.log(runtimeAppAndBuild); - // TODO(Brandon): in the future, pass app and build as separate details like this: // var result = splitAppAndBuild(runtimeAppAndBuild); // var runtimeApp = result.app; @@ -130,7 +147,7 @@ request.open("GET", url, true); request.responseType = "json"; request.send(); -request.onload = function(){ +request.onload = function() { let res = request.response; // session details @@ -145,14 +162,15 @@ request.onload = function(){ details.users = res.users; let assets_response = res.assetList; - for (idx = 0; idx < assets_response.length; idx++) - { + + for (idx = 0; idx < assets_response.length; idx++) { asset = new Object; asset.id = assets_response[idx].asset_id; asset.name = assets_response[idx].asset_name; asset.url = assets_response[idx].path; asset.isWholeObject = Boolean(assets_response[idx].is_whole_object); asset.scale = assets_response[idx].scale || 1; + details.assets.push(asset); } }; diff --git a/Komodo/ProjectSettings/ProjectSettings.asset b/Komodo/ProjectSettings/ProjectSettings.asset index 9b9f28a..48f26e1 100644 --- a/Komodo/ProjectSettings/ProjectSettings.asset +++ b/Komodo/ProjectSettings/ProjectSettings.asset @@ -211,6 +211,7 @@ PlayerSettings: - {fileID: 11400000, guid: a5e5b7605fb48984988490688c2a74e2, type: 2} - {fileID: 11400000, guid: 8fed9c7708c5a6b46bbde22d82990e10, type: 2} - {fileID: 2478256764130162806, guid: 552445d583cb06c4eaf9d56596dd45c2, type: 2} + - {fileID: 0} metroInputSource: 0 wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1 @@ -727,7 +728,6 @@ PlayerSettings: metroSplashScreenUseBackgroundColor: 0 platformCapabilities: WindowsStoreApps: - EnterpriseAuthentication: False OfflineMapsManagement: False HumanInterfaceDevice: False Location: False @@ -740,6 +740,7 @@ PlayerSettings: InternetClientServer: False VideosLibrary: False Objects3D: False + InternetClient: False RemoteSystem: False BlockedChatMessages: False PhoneCall: False @@ -760,10 +761,10 @@ PlayerSettings: PointOfService: False RecordedCallsFolder: False Contacts: False - InternetClient: False + Proximity: False CodeGeneration: False BackgroundMediaPlayback: False - Proximity: False + EnterpriseAuthentication: False metroTargetDeviceFamilies: Desktop: False Holographic: False From 4266589da347a6bcb7b0e32ece87f8a3438467f3 Mon Sep 17 00:00:00 2001 From: Brandon Dang <8165314+parseccentric@users.noreply.github.com> Date: Mon, 7 Feb 2022 17:48:29 -0600 Subject: [PATCH 03/15] fixed whitespace, removed stale comments and regions --- .../Managers/DrawingInstanceManager.cs | 132 ++++++++++-------- 1 file changed, 75 insertions(+), 57 deletions(-) diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs index 6f84ed0..ee2a313 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs @@ -3,16 +3,15 @@ using System.Collections.Generic; using System; using Komodo.Utilities; -//using static Komodo.Runtime.NetworkUpdateHandler; namespace Komodo.Runtime { - //may need to rename this if we are including primitive shapes to our list public class DrawingInstanceManager : SingletonComponent { public static DrawingInstanceManager Instance { - get { return ((DrawingInstanceManager)_Instance); } + get { return (DrawingInstanceManager) _Instance; } + set { _Instance = value; } } @@ -21,8 +20,13 @@ public static DrawingInstanceManager Instance public EntityManager entityManager; [HideInInspector] public Transform userStrokeParent; + [HideInInspector] public Transform externalStrokeParent; + private Dictionary lineRenderersInQueue = new Dictionary(); + + private Dictionary allStrokeIDValidator = new Dictionary(); + public void Awake() { //used to set our managers alive state to true to detect if it exist within scene @@ -34,18 +38,19 @@ public void Awake() //parent for our stored lines userStrokeParent = new GameObject("UserStrokeParent").transform; + externalStrokeParent = new GameObject("ExternalClientStrokeParent").transform; userStrokeParent.SetParent(transform); + externalStrokeParent.SetParent(transform); - //register our message type with the funcion GlobalMessageManager.Instance.Subscribe("draw", (str) => Draw_Refresh(str)); } public void CreateUserStrokeInstance(int strokeID, LineRenderer lineRenderer, bool sendNetworkCall) { - //used to set correct pivot point when scalling object by grabbing + //set correct pivot point when scaling object by grabbing GameObject pivot = new GameObject("LineRender:" + strokeID, typeof(BoxCollider)); if (lineRendererContainerPrefab == null) @@ -54,69 +59,84 @@ public void CreateUserStrokeInstance(int strokeID, LineRenderer lineRenderer, bo } GameObject lineRendCopy = Instantiate(lineRendererContainerPrefab).gameObject; + lineRendCopy.name = "LineR:" + strokeID; //Create a reference to use in network var nAGO = NetworkedObjectsManager.Instance.CreateNetworkedGameObject(pivot, strokeID, strokeID); - //tag it as a drawing for ECS + // Make own client's draw strokes grabbable pivot.tag = TagList.interactable; + entityManager.AddComponentData(nAGO.Entity, new DrawingTag { }); var bColl = pivot.GetComponent(); + LineRenderer copiedLR = lineRendCopy.GetComponent(); var color = lineRenderer.startColor; + copiedLR.startColor = color; + copiedLR.endColor = color; copiedLR.widthMultiplier = lineRenderer.widthMultiplier; Bounds newBounds = new Bounds(lineRenderer.GetPosition(0), Vector3.one * 0.01f); + copiedLR.positionCount = 0; for (int i = 0; i < lineRenderer.positionCount; i++) { copiedLR.positionCount++; + copiedLR.SetPosition(i, lineRenderer.GetPosition(i)); - newBounds.Encapsulate(new Bounds(lineRenderer.GetPosition(i), Vector3.one * 0.01f));//lineRenderer.GetPosition(i)); + newBounds.Encapsulate(new Bounds(lineRenderer.GetPosition(i), Vector3.one * 0.01f)); } pivot.transform.position = newBounds.center; - bColl.center = lineRendCopy.transform.position; //newBounds.center;//averageLoc / lr.positionCount;//lr.GetPosition(0)/2; + + bColl.center = lineRendCopy.transform.position; + bColl.size = newBounds.size; lineRendCopy.transform.SetParent(pivot.transform, true); if (sendNetworkCall) { - SendStrokeNetworkUpdate(strokeID, Entity_Type.LineEnd, copiedLR.widthMultiplier, lineRenderer.GetPosition(lineRenderer.positionCount - 1), new Vector4(lineRenderer.startColor.r, lineRenderer.startColor.g, lineRenderer.startColor.b, lineRenderer.startColor.a)); + SendStrokeNetworkUpdate( + strokeID, + Entity_Type.LineEnd, + copiedLR.widthMultiplier, + lineRenderer.GetPosition(lineRenderer.positionCount - 1), + new Vector4(lineRenderer.startColor.r, lineRenderer.startColor.g, lineRenderer.startColor.b, lineRenderer.startColor.a) + ); } pivot.transform.SetParent(userStrokeParent, true); if (UndoRedoManager.IsAlive) + { //save undoing process for ourselves and others UndoRedoManager.Instance.savedStrokeActions.Push(() => { pivot.SetActive(false); - //send network update call for everyone else SendStrokeNetworkUpdate(strokeID, Entity_Type.LineNotRender); }); - + } } - public void CreateExternalClientStrokeInstance(int strokeID, LineRenderer currentLineRenderer) { GameObject pivot = new GameObject("LineRender:" + strokeID, typeof(BoxCollider)); NetworkedGameObject nAGO = NetworkedObjectsManager.Instance.CreateNetworkedGameObject(pivot, strokeID, strokeID, true); - //overide interactable tag when creatingNetworkGameObject since we are not moving drawings only deleting them + // Make other clients' draw strokes grabbable pivot.tag = TagList.interactable; + //tag created drawing object will be useful in the future for having items with multiple tags entityManager.AddComponentData(nAGO.Entity, new DrawingTag { }); @@ -125,10 +145,14 @@ public void CreateExternalClientStrokeInstance(int strokeID, LineRenderer curren Bounds newBounds = new Bounds(currentLineRenderer.GetPosition(0), Vector3.one * 0.01f); for (int i = 0; i < currentLineRenderer.positionCount; i++) + { newBounds.Encapsulate(new Bounds(currentLineRenderer.GetPosition(i), Vector3.one * 0.01f)); + } pivot.transform.position = newBounds.center; + bColl.center = currentLineRenderer.transform.position; + bColl.size = newBounds.size; currentLineRenderer.transform.SetParent(pivot.transform, true); @@ -136,120 +160,114 @@ public void CreateExternalClientStrokeInstance(int strokeID, LineRenderer curren pivot.transform.SetParent(externalStrokeParent, true); } - public void SendStrokeNetworkUpdate(int sID, Entity_Type entityType, float lineWidth = 1, Vector3 curPos = default, Vector4 color = default) { - var drawUpdate = new Draw((int)NetworkUpdateHandler.Instance.client_id, sID - , (int)entityType, lineWidth, curPos, - color); + var drawUpdate = new Draw((int) NetworkUpdateHandler.Instance.client_id, sID, (int) entityType, lineWidth, curPos, color); var drawSer = JsonUtility.ToJson(drawUpdate); KomodoMessage komodoMessage = new KomodoMessage("draw", drawSer); + komodoMessage.Send(); } - - - #region Draw Receive Calls - //Setting up Line Rendering Calls - private Dictionary lineRenderersInQueue = new Dictionary(); - private Dictionary allStrokeIDValidator = new Dictionary(); - - //To avoid duplicating stroke ids because sending different ids states ma - public void Draw_Refresh(string stringData)//Draw newData) + public void Draw_Refresh (string stringData) { Draw newData = JsonUtility.FromJson(stringData); - LineRenderer currentLineRenderer = default; //we start a new line if there is no ID already corresponding to one in the scene if (!allStrokeIDValidator.ContainsKey(newData.strokeId)) { GameObject lineRendCopy = Instantiate(DrawingInstanceManager.Instance.lineRendererContainerPrefab).gameObject; + lineRendCopy.name = "LineR:" + newData.strokeId; lineRendCopy.transform.SetParent(DrawingInstanceManager.Instance.externalStrokeParent, true); + currentLineRenderer = lineRendCopy.GetComponent(); currentLineRenderer.positionCount = 0; allStrokeIDValidator.Add(newData.strokeId, newData.strokeId); + lineRenderersInQueue.Add(newData.strokeId, currentLineRenderer); } - //we get reference to the linenderer we are supposed to be working with + // get reference to the line renderer we are supposed to be working with if (lineRenderersInQueue.ContainsKey(newData.strokeId)) + { currentLineRenderer = lineRenderersInQueue[newData.strokeId]; + } switch (newData.strokeType) { - //Continues A Line - case (int)Entity_Type.Line: - + // Continues a Line + case (int) Entity_Type.Line: + { var brushColor = new Vector4(newData.curColor.x, newData.curColor.y, newData.curColor.z, newData.curColor.w); + currentLineRenderer.startColor = brushColor; + currentLineRenderer.endColor = brushColor; + currentLineRenderer.widthMultiplier = newData.lineWidth; ++currentLineRenderer.positionCount; + currentLineRenderer.SetPosition(currentLineRenderer.positionCount - 1, newData.curStrokePos); break; + } - //Ends A Line A completes its setup - case (int)Entity_Type.LineEnd: - + case (int) Entity_Type.LineEnd: + { ++currentLineRenderer.positionCount; + currentLineRenderer.SetPosition(currentLineRenderer.positionCount - 1, newData.curStrokePos); - //Create external client stroke instance - DrawingInstanceManager.Instance.CreateExternalClientStrokeInstance(newData.strokeId, currentLineRenderer); //new GameObject("LineRender:" + (newData.strokeId), typeof(BoxCollider//; + DrawingInstanceManager.Instance.CreateExternalClientStrokeInstance(newData.strokeId, currentLineRenderer); break; + } - //Deletes a Line - case (int)Entity_Type.LineDelete: - + case (int) Entity_Type.LineDelete: + { if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId)) { if (lineRenderersInQueue.ContainsKey(newData.strokeId)) + { lineRenderersInQueue.Remove(newData.strokeId); + } Destroy(NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject); + NetworkedObjectsManager.Instance.networkedObjectFromEntityId.Remove(newData.strokeId); } break; + } - case (int)Entity_Type.LineRender: - + case (int) Entity_Type.LineRender: + { if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId)) + { NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject.SetActive(true); + } break; + } - case (int)Entity_Type.LineNotRender: - + case (int) Entity_Type.LineNotRender: + { if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId)) + { NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject.SetActive(false); + } break; + } } } - - #endregion - - - - - - - - - - } - - } From 1d4f2861093bd954c7771aee8865420b40128342 Mon Sep 17 00:00:00 2001 From: Brandon Dang <8165314+parseccentric@users.noreply.github.com> Date: Tue, 8 Feb 2022 13:27:57 -0600 Subject: [PATCH 04/15] add handlers for applying look and look end interactions --- .../Network/NetworkedObjectsManager.cs | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/NetworkedObjectsManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/NetworkedObjectsManager.cs index 2b5148c..358bfed 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/NetworkedObjectsManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/NetworkedObjectsManager.cs @@ -143,7 +143,7 @@ public void ApplyInteraction (Interaction interactionData) switch (interactionData.interactionType) { - case (int)INTERACTIONS.SHOW: + case (int) INTERACTIONS.SHOW: if (UIManager.IsAlive) { @@ -152,7 +152,7 @@ public void ApplyInteraction (Interaction interactionData) break; - case (int)INTERACTIONS.HIDE: + case (int) INTERACTIONS.HIDE: if (UIManager.IsAlive) { @@ -161,19 +161,19 @@ public void ApplyInteraction (Interaction interactionData) break; - case (int)INTERACTIONS.GRAB: + case (int) INTERACTIONS.GRAB: Instance.ApplyGrabStartInteraction(interactionData); break; - case (int)INTERACTIONS.DROP: + case (int) INTERACTIONS.DROP: Instance.ApplyGrabEndInteraction(interactionData); break; - case (int)INTERACTIONS.CHANGE_SCENE: + case (int) INTERACTIONS.CHANGE_SCENE: if (SceneManagerExtensions.IsAlive) { @@ -183,18 +183,30 @@ public void ApplyInteraction (Interaction interactionData) break; - case (int)INTERACTIONS.LOCK: + case (int) INTERACTIONS.LOCK: Instance.ApplyLockInteraction(interactionData); break; - case (int)INTERACTIONS.UNLOCK: + case (int) INTERACTIONS.UNLOCK: Instance.ApplyUnlockInteraction(interactionData); break; + case (int) INTERACTIONS.LOOK: + + // Do nothing + + break; + + case (int) INTERACTIONS.LOOK_END: + + // Do nothing + + break; + default: Debug.LogWarning ($"Tried to ApplyInteraction, but interaction type {interactionData.interactionType} was unknown. Skipping"); From a681d893f6bf1222277a7eb516bf156ff4da34ce Mon Sep 17 00:00:00 2001 From: Brandon Dang <8165314+parseccentric@users.noreply.github.com> Date: Tue, 8 Feb 2022 13:48:44 -0600 Subject: [PATCH 05/15] moved enums and structs into own files --- .../RuntimeSession/ClientSpawnManager.cs | 73 +------------------ .../Scripts/RuntimeSession/EntityState.cs | 15 ++++ .../RuntimeSession/EntityState.cs.meta | 11 +++ .../Scripts/RuntimeSession/EntityType.cs | 24 ++++++ .../Scripts/RuntimeSession/EntityType.cs.meta | 11 +++ .../Scripts/RuntimeSession/InteractionType.cs | 29 ++++++++ .../RuntimeSession/InteractionType.cs.meta | 11 +++ .../Scripts/RuntimeSession/SessionState.cs | 15 ++++ .../RuntimeSession/SessionState.cs.meta | 11 +++ .../RuntimeSession/SessionStateManager.cs | 18 ----- .../Scripts/RuntimeSession/SpeechToText.cs | 30 ++++++++ .../RuntimeSession/SpeechToText.cs.meta | 11 +++ 12 files changed, 170 insertions(+), 89 deletions(-) create mode 100644 Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityState.cs create mode 100644 Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityState.cs.meta create mode 100644 Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs create mode 100644 Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs.meta create mode 100644 Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/InteractionType.cs create mode 100644 Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/InteractionType.cs.meta create mode 100644 Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionState.cs create mode 100644 Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionState.cs.meta create mode 100644 Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SpeechToText.cs create mode 100644 Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SpeechToText.cs.meta diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs index c6a631f..c4edb66 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs @@ -52,61 +52,6 @@ namespace Komodo.Runtime [System.Serializable] public class UnityEvent_Int : UnityEvent { } [System.Serializable] public class UnityEvent_String : UnityEvent { } - //For handling different type of text between clients - public enum STRINGTYPE - { - TUTORIAL, - CLIENT_NAME, - SPEECH_TO_TEXT, - } - public struct SpeechToTextSnippet - { - public int target; - public int stringType; - public string text; - } - //types of data in scene - public enum Entity_Type - { - none = -1, - users_head = 0, - users_Lhand = 1, - users_Rhand = 2, - objects = 3, - physicsObject = 4, - main_Player = 5, - physicsEnd = 8, - Line = 10, - LineEnd = 11, - LineDelete = 12, - LineRender = 13, - LineNotRender = 14, - } - - #region INTERACTION TYPES - public enum INTERACTIONS - { - LOOK = 0, - LOOK_END = 1, - SHOW = 2, - HIDE = 3, - GRAB = 4, - DROP = 5, - CHANGE_SCENE = 6, - SLICE_OBJECT = 7, - LOCK = 8, - UNLOCK = 9, - LINE = 10, - LINE_END = 11, - SHOW_MENU = 12, - HIDE_MENU = 13, - - SETTING_TAB = 14, - PEOPLE_TAB = 15, - INTERACTION_TAB = 16, - CREATE_TAB = 17, - } - #endregion /// /// This class is meant to: /// --- set up main player @@ -941,16 +886,8 @@ public void ApplyPositionToRightHand(Position positionData) } #region Text Receive Calls - - public struct SpeechToText - { - public int session_id; - public int client_id; - public string text; - public string type; - public int ts; - } - + // TODO: as much as possible, move these functions to static functions + // in SpeechToText.cs public void OnReceiveSpeechToTextSnippet(string data) { var deserializedData = JsonUtility.FromJson(data); @@ -989,13 +926,9 @@ public void ProcessSpeechToTextSnippet(SpeechToTextSnippet newText) clientIndex = avatarIndexFromClientId[newText.target]; clientUsernameDisplays[clientIndex].text = newText.text; break; - } - } - - private static string SplitWordsByLength(string str, int maxLength) { List chunks = new List(); @@ -1057,10 +990,8 @@ public IEnumerator SetTextTimer(int textIndex, string textD, float seconds = 5) } - public IEnumerator ShutOffText(int textIndex, float seconds) { - clientSpeechToTextDisplays[textIndex].transform.parent.gameObject.SetActive(true); // secondsToWaitDic[index] -= seconds; diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityState.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityState.cs new file mode 100644 index 0000000..fa484c5 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityState.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Komodo.Runtime +{ + [System.Serializable] + public struct EntityState + { + public int id; + public Position latest; + public bool render; + public bool locked; + } +} diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityState.cs.meta b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityState.cs.meta new file mode 100644 index 0000000..b470494 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c28255cb2cf4a9d489bbee5f880787ac +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs new file mode 100644 index 0000000..1b0c950 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Komodo.Runtime +{ + //types of data in scene + public enum Entity_Type + { + none = -1, + users_head = 0, + users_Lhand = 1, + users_Rhand = 2, + objects = 3, + physicsObject = 4, + main_Player = 5, + physicsEnd = 8, + Line = 10, + LineEnd = 11, + LineDelete = 12, + LineRender = 13, + LineNotRender = 14, + } +} diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs.meta b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs.meta new file mode 100644 index 0000000..5328995 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 553819b7d55679f4c9783217f1282e16 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/InteractionType.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/InteractionType.cs new file mode 100644 index 0000000..7305c72 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/InteractionType.cs @@ -0,0 +1,29 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Komodo.Runtime +{ + public enum INTERACTIONS + { + LOOK = 0, + LOOK_END = 1, + SHOW = 2, + HIDE = 3, + GRAB = 4, + DROP = 5, + CHANGE_SCENE = 6, + SLICE_OBJECT = 7, + LOCK = 8, + UNLOCK = 9, + LINE = 10, + LINE_END = 11, + SHOW_MENU = 12, + HIDE_MENU = 13, + + SETTING_TAB = 14, + PEOPLE_TAB = 15, + INTERACTION_TAB = 16, + CREATE_TAB = 17, + } +} diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/InteractionType.cs.meta b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/InteractionType.cs.meta new file mode 100644 index 0000000..e828052 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/InteractionType.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5ecb7ba8a86c8d94cb4c7064cc5ae17f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionState.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionState.cs new file mode 100644 index 0000000..093e342 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionState.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Komodo.Runtime +{ + [System.Serializable] + public class SessionState + { + public int[] clients; + public EntityState[] entities; + public int scene; + public bool isRecording; + } +} diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionState.cs.meta b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionState.cs.meta new file mode 100644 index 0000000..c5fba2a --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionState.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ccbf976550777ce4b9dfdb9dfe8290f2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionStateManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionStateManager.cs index 5651fb7..0ae7652 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionStateManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SessionStateManager.cs @@ -205,22 +205,4 @@ public void ApplyInteraction(Interaction interactionData) NetworkedObjectsManager.Instance.ApplyInteraction(interactionData); } } - - [System.Serializable] - public struct EntityState - { - public int id; - public Position latest; - public bool render; - public bool locked; - } - - [System.Serializable] - public class SessionState - { - public int[] clients; - public EntityState[] entities; - public int scene; - public bool isRecording; - } } diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SpeechToText.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SpeechToText.cs new file mode 100644 index 0000000..7f1a809 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SpeechToText.cs @@ -0,0 +1,30 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Komodo.Runtime +{ + //For handling different type of text between clients + public enum STRINGTYPE + { + TUTORIAL, + CLIENT_NAME, + SPEECH_TO_TEXT, + } + + public struct SpeechToTextSnippet + { + public int target; + public int stringType; + public string text; + } + + public struct SpeechToText + { + public int session_id; + public int client_id; + public string text; + public string type; + public int ts; + } +} diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SpeechToText.cs.meta b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SpeechToText.cs.meta new file mode 100644 index 0000000..5b7c448 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/SpeechToText.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a2f972960dd2da247b6706c5ee5773ac +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From e6c2129a611d8c8018ba1af5116d99c56e91c868 Mon Sep 17 00:00:00 2001 From: Brandon Dang <8165314+parseccentric@users.noreply.github.com> Date: Tue, 8 Feb 2022 13:50:51 -0600 Subject: [PATCH 06/15] added comment about hand rotation --- .../Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs index c4edb66..e326091 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs @@ -505,7 +505,9 @@ public void AddNewClient(int clientID, bool isMainPlayer = false) var ROT = entityManager.GetComponentData(avatarEntityGroupFromClientId[clientID].rootEntity).Value.value;//.entity_data.rot; - //To prevent offset issues when working with editor + + // TODO -- investigate whether this area is a cause of the + // hand position and rotation being wrong in the browser #if UNITY_WEBGL && !UNITY_EDITOR || TESTING_BEFORE_BUILDING mainPlayer.transform.position = temp.position; From aea5ae9a16bae054a733240e31bb3109cc2a74f8 Mon Sep 17 00:00:00 2001 From: Brandon Dang <8165314+parseccentric@users.noreply.github.com> Date: Tue, 8 Feb 2022 14:25:04 -0600 Subject: [PATCH 07/15] remove unused code --- .../RuntimeSession/ClientSpawnManager.cs | 94 ------------------- 1 file changed, 94 deletions(-) diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs index e326091..3bbd7a7 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/ClientSpawnManager.cs @@ -666,100 +666,6 @@ public async void DestroyClient(int clientID) } #endregion - #region Create A Network Managed Objects - - - #endregion - - #region Draw Receive Calls - //Setting up Line Rendering Calls - private Dictionary lineRenderersInQueue = new Dictionary(); - private Dictionary allStrokeIDValidator = new Dictionary(); - - //To avoid duplicating stroke ids because sending different ids states ma - public void Draw_Refresh(string stringData)//Draw newData) - { - Draw newData = JsonUtility.FromJson(stringData); - - - LineRenderer currentLineRenderer = default; - - //we start a new line if there is no ID already corresponding to one in the scene - if (!allStrokeIDValidator.ContainsKey(newData.strokeId)) - { - GameObject lineRendCopy = Instantiate(DrawingInstanceManager.Instance.lineRendererContainerPrefab).gameObject; - lineRendCopy.name = "LineR:" + newData.strokeId; - - lineRendCopy.transform.SetParent(DrawingInstanceManager.Instance.externalStrokeParent, true); - currentLineRenderer = lineRendCopy.GetComponent(); - - currentLineRenderer.positionCount = 0; - - allStrokeIDValidator.Add(newData.strokeId, newData.strokeId); - lineRenderersInQueue.Add(newData.strokeId, currentLineRenderer); - } - - //we get reference to the linenderer we are supposed to be working with - if (lineRenderersInQueue.ContainsKey(newData.strokeId)) - currentLineRenderer = lineRenderersInQueue[newData.strokeId]; - - switch (newData.strokeType) - { - //Continues A Line - case (int)Entity_Type.Line: - - var brushColor = new Vector4(newData.curColor.x, newData.curColor.y, newData.curColor.z, newData.curColor.w); - currentLineRenderer.startColor = brushColor; - currentLineRenderer.endColor = brushColor; - currentLineRenderer.widthMultiplier = newData.lineWidth; - - ++currentLineRenderer.positionCount; - currentLineRenderer.SetPosition(currentLineRenderer.positionCount - 1, newData.curStrokePos); - - break; - - //Ends A Line A completes its setup - case (int)Entity_Type.LineEnd: - - ++currentLineRenderer.positionCount; - currentLineRenderer.SetPosition(currentLineRenderer.positionCount - 1, newData.curStrokePos); - - //Create external client stroke instance - DrawingInstanceManager.Instance.CreateExternalClientStrokeInstance(newData.strokeId, currentLineRenderer); //new GameObject("LineRender:" + (newData.strokeId), typeof(BoxCollider//; - - break; - - //Deletes a Line - case (int)Entity_Type.LineDelete: - - if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId)) - { - if (lineRenderersInQueue.ContainsKey(newData.strokeId)) - lineRenderersInQueue.Remove(newData.strokeId); - - Destroy(NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject); - NetworkedObjectsManager.Instance.networkedObjectFromEntityId.Remove(newData.strokeId); - } - break; - - case (int)Entity_Type.LineRender: - - if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId)) - NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject.SetActive(true); - - break; - - case (int)Entity_Type.LineNotRender: - - if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId)) - NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject.SetActive(false); - - break; - } - } - - #endregion - public void AddClientIfNeeded (int id) { if (NetworkUpdateHandler.Instance.client_id == id) From 2b46a609601bc5f6293abf1de86fff7213f7fcd9 Mon Sep 17 00:00:00 2001 From: Brandon Dang <8165314+parseccentric@users.noreply.github.com> Date: Tue, 8 Feb 2022 15:40:11 -0600 Subject: [PATCH 08/15] refactored into functions; renamed variables; adjusted whitespace --- .../RuntimeSession/EventSystem/TriggerDraw.cs | 62 ++--- .../Managers/DrawingInstanceManager.cs | 213 ++++++++++++------ .../Network/NetworkedObjectsManager.cs | 47 ++++ 3 files changed, 229 insertions(+), 93 deletions(-) diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs index ab6aa7e..8aa1890 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs @@ -1,6 +1,5 @@ using UnityEngine; using Unity.Entities; -using static Komodo.Runtime.NetworkUpdateHandler; namespace Komodo.Runtime { @@ -9,14 +8,17 @@ namespace Komodo.Runtime public class TriggerDraw : MonoBehaviour { private Transform thisTransform; + private LineRenderer lineRenderer; public float distanceThreshold = 0.5f; public float timeToCheckNewStrokeIndex; + private float timePass; private int curLineIndex = 0; + private int strokeID = 0; private int strokeIndex; @@ -24,24 +26,19 @@ public class TriggerDraw : MonoBehaviour [Header("IDENTIFY INTERACTION ID, PLACE A UNIQUE NUMBER EXCEPT 0")] public int handID; - - //to disable drawing during color picker selection through unity events; // color+picker.cs adjust this + //to disable drawing during color picker selection through unity events; [HideInInspector] public bool isSelectingColorPicker; private EntityManager entityManager; - //to disable drawing during erassing funcionality + //to disable drawing during erasing funcionality private bool isEraserOn = false; - - public void Set_DRAW_UPDATE(bool active) { isEraserOn = active; } - - public virtual void Start() { entityManager = World.DefaultGameObjectInjectionWorld.EntityManager; @@ -54,7 +51,6 @@ public virtual void Start() thisTransform = transform; } - public void Update() { if (lineRenderer == null || thisTransform == null || isEraserOn || isSelectingColorPicker) @@ -68,30 +64,40 @@ public void Update() float curDistance = 0; - if (lineRenderer.positionCount == 0) { ++lineRenderer.positionCount; lineRenderer.SetPosition(0, thisTransform.position); - curDistance = Vector3.Distance(thisTransform.position, lineRenderer.GetPosition(0)); + curDistance = Vector3.Distance(thisTransform.position, lineRenderer.GetPosition(0)); } else + { curDistance = Vector3.Distance(thisTransform.position, lineRenderer.GetPosition(curLineIndex)); - + } if (curDistance > distanceThreshold) { //update visuals per stroke - ////offset: 5000 + clientid + child render count - /// - - DrawingInstanceManager.Instance.SendStrokeNetworkUpdate(strokeID, Entity_Type.Line, lineRenderer.widthMultiplier, lineRenderer.GetPosition(curLineIndex), - new Vector4(lineRenderer.startColor.r, lineRenderer.startColor.g, lineRenderer.startColor.b, lineRenderer.startColor.a)); - + //offset: 5000 + clientid + child render count + + DrawingInstanceManager.Instance.SendStrokeNetworkUpdate( + strokeID, + Entity_Type.Line, + lineRenderer.widthMultiplier, + lineRenderer.GetPosition(curLineIndex), + new Vector4 + ( + lineRenderer.startColor.r, + lineRenderer.startColor.g, + lineRenderer.startColor.b, + lineRenderer.startColor.a + ) + ); ++lineRenderer.positionCount; + curLineIndex++; lineRenderer.SetPosition(curLineIndex, thisTransform.position); @@ -99,39 +105,43 @@ public void Update() } } - //THIS IS WHERE FUNCTIONS ARE INVOKED (ON RELEASE OF TRIGGER BUTTON WHICH DEACTIVATES PARENT OBJECT public virtual void OnDisable() { //get rid of uncompleted stroke saved up locations if (lineRenderer.positionCount == 1) + { lineRenderer.positionCount = 0; + } if (lineRenderer == null || lineRenderer.positionCount <= 1) + { return; + } //make strokeID identical based on left or right hand add an offset *100 strokeID * 10000 //ALL STROKE IDS HAVE TO BE UNIQUE TO REFERENCE THROGH THE NETWORK if (NetworkUpdateHandler.IsAlive) + { strokeID = handID * 1000000 + 100000 + NetworkUpdateHandler.Instance.client_id * 10000 + strokeIndex; + } else + { return; + } - //GameObject pivot = - DrawingInstanceManager.Instance.CreateUserStrokeInstance(strokeID, lineRenderer, true); + DrawingInstanceManager.Instance.InitializeFinishedLineFromOwnClient(strokeID, lineRenderer, true); curLineIndex = 0; - //pivot.transform.SetParent(lineRendererSharedContainer); - strokeIndex++; - //updateID + if (NetworkUpdateHandler.IsAlive) + { strokeID = handID * 1000000 + 100000 + NetworkUpdateHandler.Instance.client_id * 10000 + strokeIndex; + } lineRenderer.positionCount = 0; - } - } } \ No newline at end of file diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs index ee2a313..e2d6766 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs @@ -23,9 +23,7 @@ public static DrawingInstanceManager Instance [HideInInspector] public Transform externalStrokeParent; - private Dictionary lineRenderersInQueue = new Dictionary(); - - private Dictionary allStrokeIDValidator = new Dictionary(); + private Dictionary lineRendererFromId = new Dictionary(); public void Awake() { @@ -45,10 +43,10 @@ public void Awake() externalStrokeParent.SetParent(transform); - GlobalMessageManager.Instance.Subscribe("draw", (str) => Draw_Refresh(str)); + GlobalMessageManager.Instance.Subscribe("draw", (str) => ReceiveDrawUpdate(str)); } - public void CreateUserStrokeInstance(int strokeID, LineRenderer lineRenderer, bool sendNetworkCall) + public void InitializeFinishedLineFromOwnClient(int strokeID, LineRenderer lineRenderer, bool doSendNetworkUpdate) { //set correct pivot point when scaling object by grabbing GameObject pivot = new GameObject("LineRender:" + strokeID, typeof(BoxCollider)); @@ -63,7 +61,7 @@ public void CreateUserStrokeInstance(int strokeID, LineRenderer lineRenderer, bo lineRendCopy.name = "LineR:" + strokeID; //Create a reference to use in network - var nAGO = NetworkedObjectsManager.Instance.CreateNetworkedGameObject(pivot, strokeID, strokeID); + NetworkedGameObject nAGO = NetworkedObjectsManager.Instance.CreateNetworkedGameObject(pivot, strokeID, strokeID); // Make own client's draw strokes grabbable pivot.tag = TagList.interactable; @@ -103,7 +101,7 @@ public void CreateUserStrokeInstance(int strokeID, LineRenderer lineRenderer, bo lineRendCopy.transform.SetParent(pivot.transform, true); - if (sendNetworkCall) + if (doSendNetworkUpdate) { SendStrokeNetworkUpdate( strokeID, @@ -128,41 +126,49 @@ public void CreateUserStrokeInstance(int strokeID, LineRenderer lineRenderer, bo } } - public void CreateExternalClientStrokeInstance(int strokeID, LineRenderer currentLineRenderer) + public void InitializeFinishedLineFromOtherClient(int strokeID, LineRenderer renderer) { GameObject pivot = new GameObject("LineRender:" + strokeID, typeof(BoxCollider)); - NetworkedGameObject nAGO = NetworkedObjectsManager.Instance.CreateNetworkedGameObject(pivot, strokeID, strokeID, true); + NetworkedGameObject netObject = NetworkedObjectsManager.Instance.CreateNetworkedGameObject(pivot, strokeID, strokeID, true); // Make other clients' draw strokes grabbable pivot.tag = TagList.interactable; //tag created drawing object will be useful in the future for having items with multiple tags - entityManager.AddComponentData(nAGO.Entity, new DrawingTag { }); + entityManager.AddComponentData(netObject.Entity, new DrawingTag { }); - var bColl = pivot.GetComponent(); + var collider = pivot.GetComponent(); - Bounds newBounds = new Bounds(currentLineRenderer.GetPosition(0), Vector3.one * 0.01f); + Bounds newBounds = new Bounds(renderer.GetPosition(0), Vector3.one * 0.01f); - for (int i = 0; i < currentLineRenderer.positionCount; i++) + for (int i = 0; i < renderer.positionCount; i++) { - newBounds.Encapsulate(new Bounds(currentLineRenderer.GetPosition(i), Vector3.one * 0.01f)); + newBounds.Encapsulate(new Bounds(renderer.GetPosition(i), Vector3.one * 0.01f)); } pivot.transform.position = newBounds.center; - bColl.center = currentLineRenderer.transform.position; + collider.center = renderer.transform.position; - bColl.size = newBounds.size; + collider.size = newBounds.size; - currentLineRenderer.transform.SetParent(pivot.transform, true); + renderer.transform.SetParent(pivot.transform, true); pivot.transform.SetParent(externalStrokeParent, true); } - public void SendStrokeNetworkUpdate(int sID, Entity_Type entityType, float lineWidth = 1, Vector3 curPos = default, Vector4 color = default) + public void SendStrokeNetworkUpdate(int id, Entity_Type entityType, float lineWidth = 1, Vector3 curPos = default, Vector4 color = default) { - var drawUpdate = new Draw((int) NetworkUpdateHandler.Instance.client_id, sID, (int) entityType, lineWidth, curPos, color); + var drawUpdate = new Draw + ( + (int) NetworkUpdateHandler.Instance.client_id, + id, + (int) entityType, + lineWidth, + curPos, + color + ); var drawSer = JsonUtility.ToJson(drawUpdate); @@ -171,99 +177,172 @@ public void SendStrokeNetworkUpdate(int sID, Entity_Type entityType, float lineW komodoMessage.Send(); } - public void Draw_Refresh (string stringData) + protected bool IsLineRendererRegistered (int id) + { + return lineRendererFromId.ContainsKey(id); + } + + protected void RegisterLineRenderer (int id, LineRenderer renderer) + { + lineRendererFromId.Add(id, renderer); + } + + protected LineRenderer GetLineRenderer (int id) { - Draw newData = JsonUtility.FromJson(stringData); + return lineRendererFromId[id]; + } + + protected void UnregisterLineRenderer (int id) + { + lineRendererFromId.Remove(id); + } + + protected LineRenderer CreateLineRendererContainer (Draw data) + { + GameObject lineRendCopy = Instantiate(lineRendererContainerPrefab).gameObject; + + lineRendCopy.name = "LineR:" + data.strokeId; - LineRenderer currentLineRenderer = default; + lineRendCopy.transform.SetParent(externalStrokeParent, true); - //we start a new line if there is no ID already corresponding to one in the scene - if (!allStrokeIDValidator.ContainsKey(newData.strokeId)) + return lineRendCopy.GetComponent(); + } + + protected void ContinueLine (Draw data) + { + if (!IsLineRendererRegistered(data.strokeId)) { - GameObject lineRendCopy = Instantiate(DrawingInstanceManager.Instance.lineRendererContainerPrefab).gameObject; + Debug.LogWarning($"Line renderer {data.strokeId} will not be started or continued, because it was never registered."); + + return; + } - lineRendCopy.name = "LineR:" + newData.strokeId; + LineRenderer renderer = GetLineRenderer(data.strokeId); - lineRendCopy.transform.SetParent(DrawingInstanceManager.Instance.externalStrokeParent, true); + var brushColor = new Vector4(data.curColor.x, data.curColor.y, data.curColor.z, data.curColor.w); - currentLineRenderer = lineRendCopy.GetComponent(); + renderer.startColor = brushColor; - currentLineRenderer.positionCount = 0; + renderer.endColor = brushColor; - allStrokeIDValidator.Add(newData.strokeId, newData.strokeId); + renderer.widthMultiplier = data.lineWidth; - lineRenderersInQueue.Add(newData.strokeId, currentLineRenderer); + ++renderer.positionCount; + + renderer.SetPosition(renderer.positionCount - 1, data.curStrokePos); + } + + protected void EndLine (Draw data) + { + if (!IsLineRendererRegistered(data.strokeId)) + { + Debug.LogWarning($"Line renderer {data.strokeId} will not be ended, because it was never registered."); + + return; } - // get reference to the line renderer we are supposed to be working with - if (lineRenderersInQueue.ContainsKey(newData.strokeId)) + LineRenderer renderer = GetLineRenderer(data.strokeId); + + renderer.positionCount += 1; + + renderer.SetPosition(renderer.positionCount - 1, data.curStrokePos); + + InitializeFinishedLineFromOtherClient(data.strokeId, renderer); + } + + protected void DeleteLine (Draw data) + { + if (!IsLineRendererRegistered(data.strokeId)) { - currentLineRenderer = lineRenderersInQueue[newData.strokeId]; + Debug.LogWarning($"Line renderer {data.strokeId} will not be deleted, because it was never registered."); + + return; } - switch (newData.strokeType) + bool success = NetworkedObjectsManager.Instance.DestroyAndUnregisterEntity(data.strokeId); + + if (!success) { - // Continues a Line - case (int) Entity_Type.Line: - { - var brushColor = new Vector4(newData.curColor.x, newData.curColor.y, newData.curColor.z, newData.curColor.w); + Debug.LogWarning($"Could not delete line {data.strokeId}'s networked object."); + + return; + } + + UnregisterLineRenderer(data.strokeId); + } + + protected void ShowLine (Draw data) + { + bool success = NetworkedObjectsManager.Instance.ShowEntity(data.strokeId); + + if (!success) + { + Debug.LogWarning($"Could not show line {data.strokeId}."); + } + } + + protected void HideLine (Draw data) + { + bool success = NetworkedObjectsManager.Instance.HideEntity(data.strokeId); - currentLineRenderer.startColor = brushColor; + if (!success) + { + Debug.LogWarning($"Could not hide line {data.strokeId}."); + } + } - currentLineRenderer.endColor = brushColor; + protected void StartLineAndRegisterLineRenderer (Draw data) + { + LineRenderer currentLineRenderer = CreateLineRendererContainer(data); - currentLineRenderer.widthMultiplier = newData.lineWidth; + currentLineRenderer.positionCount = 0; - ++currentLineRenderer.positionCount; + RegisterLineRenderer(data.strokeId, currentLineRenderer); + } - currentLineRenderer.SetPosition(currentLineRenderer.positionCount - 1, newData.curStrokePos); + public void ReceiveDrawUpdate (string stringData) + { + Draw data = JsonUtility.FromJson(stringData); + + if (!IsLineRendererRegistered(data.strokeId)) + { + StartLineAndRegisterLineRenderer(data); + } + + switch (data.strokeType) + { + // Continues a Line + case (int) Entity_Type.Line: + { + ContinueLine(data); break; } case (int) Entity_Type.LineEnd: { - ++currentLineRenderer.positionCount; - - currentLineRenderer.SetPosition(currentLineRenderer.positionCount - 1, newData.curStrokePos); - - DrawingInstanceManager.Instance.CreateExternalClientStrokeInstance(newData.strokeId, currentLineRenderer); + EndLine(data); break; } case (int) Entity_Type.LineDelete: { - if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId)) - { - if (lineRenderersInQueue.ContainsKey(newData.strokeId)) - { - lineRenderersInQueue.Remove(newData.strokeId); - } - - Destroy(NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject); + DeleteLine(data); - NetworkedObjectsManager.Instance.networkedObjectFromEntityId.Remove(newData.strokeId); - } break; } case (int) Entity_Type.LineRender: { - if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId)) - { - NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject.SetActive(true); - } + ShowLine(data); break; } case (int) Entity_Type.LineNotRender: { - if (NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(newData.strokeId)) - { - NetworkedObjectsManager.Instance.networkedObjectFromEntityId[newData.strokeId].gameObject.SetActive(false); - } + HideLine(data); break; } diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/NetworkedObjectsManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/NetworkedObjectsManager.cs index 358bfed..62bb5c3 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/NetworkedObjectsManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/NetworkedObjectsManager.cs @@ -377,5 +377,52 @@ public void LinkNetObjectToButton(int entityID, NetworkedGameObject netObject) ModelImportInitializer.Instance.networkedGameObjects[buttonID] = netObject; } } + + // Returns true for success and false for failure + public bool DestroyAndUnregisterEntity (int id) + { + if (!networkedObjectFromEntityId.ContainsKey(id)) + { + Debug.LogWarning($"Networked Object with key {id} will not be destroyed or unregistered, because it was never registered."); + + return false; + } + + Destroy(networkedObjectFromEntityId[id].gameObject); + + networkedObjectFromEntityId.Remove(id); + + return true; + } + + // Returns true for success and false for failure + public bool ShowEntity (int id) + { + if (!NetworkedObjectsManager.Instance.networkedObjectFromEntityId.ContainsKey(id)) + { + Debug.LogWarning($"Networked Object {id} will not be shown, because it was never registered."); + + return false; + } + + NetworkedObjectsManager.Instance.networkedObjectFromEntityId[id].gameObject.SetActive(true); + + return true; + } + + // Returns true for success and false for failure + public bool HideEntity (int id) + { + if (!networkedObjectFromEntityId.ContainsKey(id)) + { + Debug.LogWarning($"Networked Object {id} will not be hidden, because it was never registered."); + + return false; + } + + networkedObjectFromEntityId[id].gameObject.SetActive(false); + + return true; + } } } From 4dc9c8384996650104c2873622e3567810e102ed Mon Sep 17 00:00:00 2001 From: Brandon Dang <8165314+parseccentric@users.noreply.github.com> Date: Tue, 8 Feb 2022 15:52:17 -0600 Subject: [PATCH 09/15] renaming --- .../RuntimeSession/EventSystem/TriggerDraw.cs | 2 +- .../Managers/DrawingInstanceManager.cs | 10 ++++---- .../RuntimeSession/Managers/EraseManager.cs | 24 ++++++++++++------- .../Network/NetworkedObjectsManager.cs | 1 - .../Network/SocketIOEditorSimulator.cs | 10 +++++++- 5 files changed, 30 insertions(+), 17 deletions(-) diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs index 8aa1890..fb4b96d 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs @@ -82,7 +82,7 @@ public void Update() //update visuals per stroke //offset: 5000 + clientid + child render count - DrawingInstanceManager.Instance.SendStrokeNetworkUpdate( + DrawingInstanceManager.Instance.SendDrawUpdate( strokeID, Entity_Type.Line, lineRenderer.widthMultiplier, diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs index e2d6766..ddbdd7a 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs @@ -103,7 +103,7 @@ public void InitializeFinishedLineFromOwnClient(int strokeID, LineRenderer lineR if (doSendNetworkUpdate) { - SendStrokeNetworkUpdate( + SendDrawUpdate( strokeID, Entity_Type.LineEnd, copiedLR.widthMultiplier, @@ -121,7 +121,7 @@ public void InitializeFinishedLineFromOwnClient(int strokeID, LineRenderer lineR { pivot.SetActive(false); - SendStrokeNetworkUpdate(strokeID, Entity_Type.LineNotRender); + SendDrawUpdate(strokeID, Entity_Type.LineNotRender); }); } } @@ -158,7 +158,7 @@ public void InitializeFinishedLineFromOtherClient(int strokeID, LineRenderer ren pivot.transform.SetParent(externalStrokeParent, true); } - public void SendStrokeNetworkUpdate(int id, Entity_Type entityType, float lineWidth = 1, Vector3 curPos = default, Vector4 color = default) + public void SendDrawUpdate(int id, Entity_Type entityType, float lineWidth = 1, Vector3 curPos = default, Vector4 color = default) { var drawUpdate = new Draw ( @@ -170,9 +170,9 @@ public void SendStrokeNetworkUpdate(int id, Entity_Type entityType, float lineWi color ); - var drawSer = JsonUtility.ToJson(drawUpdate); + var serializedUpdate = JsonUtility.ToJson(drawUpdate); - KomodoMessage komodoMessage = new KomodoMessage("draw", drawSer); + KomodoMessage komodoMessage = new KomodoMessage("draw", serializedUpdate); komodoMessage.Send(); } diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/EraseManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/EraseManager.cs index 4b39efb..6fdfc74 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/EraseManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/EraseManager.cs @@ -13,6 +13,7 @@ public static EraseManager Instance } TriggerEraseDraw leftHandErase; + TriggerEraseDraw rightHandErase; public EntityManager entityManager; @@ -37,19 +38,24 @@ public virtual void TryAndErase(NetworkedGameObject netObj) netObj.gameObject.SetActive(false); // when actions of erasing are being captured, the curStrokepos and curColor will both be set to 0. - DrawingInstanceManager.Instance.SendStrokeNetworkUpdate(entityID, Entity_Type.LineNotRender); + DrawingInstanceManager.Instance.SendDrawUpdate(entityID, Entity_Type.LineNotRender); //save our reverted action for undoing the process with the undo button if (UndoRedoManager.IsAlive) - UndoRedoManager.Instance.savedStrokeActions.Push(() => - { - - netObj.gameObject.SetActive(true); - - DrawingInstanceManager.Instance.SendStrokeNetworkUpdate(entityID, Entity_Type.LineRender); - } + { + UndoRedoManager.Instance.savedStrokeActions.Push + ( + (System.Action) + ( + () => + { + netObj.gameObject.SetActive(true); + + DrawingInstanceManager.Instance.SendDrawUpdate(entityID, Entity_Type.LineRender); + } + ) ); - + } } } diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/NetworkedObjectsManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/NetworkedObjectsManager.cs index 62bb5c3..b5fad73 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/NetworkedObjectsManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/NetworkedObjectsManager.cs @@ -73,7 +73,6 @@ public List GetNetworkedSubObjectList(int index) return result; } - public int GenerateEntityIDBase () { return (999 * 1000) + ((int) Entity_Type.objects * 100); diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/SocketIOEditorSimulator.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/SocketIOEditorSimulator.cs index d95e2b2..7b57aeb 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/SocketIOEditorSimulator.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/SocketIOEditorSimulator.cs @@ -13,8 +13,11 @@ public static SocketIOEditorSimulator Instance } public bool isVerbose = false; + public bool doLogClientEvents = true; + public bool doLogCustomInteractions = true; + public bool doLogPositionEvents = false; public bool setSocketIOAdapterNameFails; @@ -48,18 +51,23 @@ public static SocketIOEditorSimulator Instance public int clientId; public int sessionId; - + public int isTeacher; public string sessionDetails = @"{""assets"":[{""id"":111550,""name"":""GraceGremer"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/8f5fef97-a735-4c2e-8d28-fc3badfe09a3/model.glb"",""isWholeObject"":true,""scale"":1},{""id"":111576,""name"":""GarmentSetup1"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/1843c37c-dc40-4520-91cb-ad1cdc70d72e/model.glb"",""isWholeObject"":false,""scale"":1},{""id"":111577,""name"":""GarmentSetup2"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/cb3464eb-f96e-48c6-b774-e4dfbdc8ab78/model.glb"",""isWholeObject"":false,""scale"":1},{""id"":111578,""name"":""GarmentSetup3"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/e8567627-ade7-493e-a017-e8b1b61e71af/model.glb"",""isWholeObject"":false,""scale"":1},{""id"":111579,""name"":""GarmentSetup4"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/9a133a69-c8ba-4cf8-9539-a9a2b2827226/model.glb"",""isWholeObject"":false,""scale"":1},{""id"":111580,""name"":""GarmentSetup5"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/0529709a-803e-4f61-86d1-092dabf0c2cb/model.glb"",""isWholeObject"":false,""scale"":1},{""id"":111589,""name"":""ShanenHaigler"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/7bb5d74d-39f3-4b3d-aa56-4708b62bda95/model.glb"",""isWholeObject"":true,""scale"":1},{""id"":111597,""name"":""Garment O'Donnell"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/ee63a354-b427-4ca3-a2a0-6e230efabe55/model.glb"",""isWholeObject"":true,""scale"":1},{""id"":111602,""name"":""GraceGremer"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/14bacabd-7f09-4120-b420-ccfa09b23e03/model.glb"",""isWholeObject"":true,""scale"":1},{""id"":111604,""name"":""CarleeIhde"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/de622ac8-eabd-4d3a-ab8f-ab56ee415813/model.glb"",""isWholeObject"":true,""scale"":1},{""id"":111605,""name"":""CarleeI"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/29394a64-0e31-4824-86f8-133297f9f84c/model.glb"",""isWholeObject"":true,""scale"":1},{""id"":111607,""name"":""G-SarahMiranda"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/f3f1442c-f9cc-454b-8b32-8f3597d79272/model.glb"",""isWholeObject"":true,""scale"":1},{""id"":111608,""name"":""SarahMirandaMood"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/0b5036d8-37f0-4c32-b65a-7030cef4718d/model.glb"",""isWholeObject"":true,""scale"":1},{""id"":111609,""name"":""G-ShanenHaigleer"",""url"":""https://s3.us-east-2.amazonaws.com/vrcat-assets/5539b18d-ed67-48cb-8a87-164fc161319a/model.glb"",""isWholeObject"":true,""scale"":1}],""build"":""/test/Brandon-develop-2021-10-19-15xx/"",""course_id"":3,""create_at"":""2021-03-26T01:00:58.000Z"",""description"":""(No description added)"",""end_time"":""2021-03-31T19:03:00.000Z"",""session_id"":141,""session_name"":""SP21 - Critique Group C"",""start_time"":""2021-03-31T18:03:00.000Z"",""users"":[]}"; private float[] _arrayPointer; + private int _relayUpdateSize; + private int _posCursor; public string InstantiationManagerName = "InstantiationManager"; + public string NetworkManagerName = "NetworkManager"; + private ClientSpawnManager _ClientSpawnManager; + private NetworkUpdateHandler _NetworkUpdateHandler; public void Awake() From 34862edf596b7c24049f139600c8409cf49bef17 Mon Sep 17 00:00:00 2001 From: Brandon Dang <8165314+parseccentric@users.noreply.github.com> Date: Tue, 8 Feb 2022 16:03:29 -0600 Subject: [PATCH 10/15] moved draw action types out of entity type --- .../Scripts/RuntimeSession/DrawActionType.cs | 15 +++++++++++++++ .../RuntimeSession/DrawActionType.cs.meta | 11 +++++++++++ .../Scripts/RuntimeSession/EntityType.cs | 7 ++----- .../RuntimeSession/EventSystem/TriggerDraw.cs | 2 +- .../RuntimeSession/Managers/DoubleTapState.cs | 1 - .../Managers/DrawingInstanceManager.cs | 18 +++++++++--------- .../RuntimeSession/Managers/EraseManager.cs | 4 ++-- .../Network/MainClientUpdater.cs | 10 +++++----- 8 files changed, 45 insertions(+), 23 deletions(-) create mode 100644 Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/DrawActionType.cs create mode 100644 Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/DrawActionType.cs.meta diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/DrawActionType.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/DrawActionType.cs new file mode 100644 index 0000000..30b2b21 --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/DrawActionType.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace Komodo.Runtime +{ + public enum DrawActionType + { + Continue = 10, + End = 11, + Delete = 12, + Show = 13, + Hide = 14, + } +} diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/DrawActionType.cs.meta b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/DrawActionType.cs.meta new file mode 100644 index 0000000..49f4a5e --- /dev/null +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/DrawActionType.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a70f2f75517143f4e895456033deabd5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs index 1b0c950..3a978c8 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs @@ -15,10 +15,7 @@ public enum Entity_Type physicsObject = 4, main_Player = 5, physicsEnd = 8, - Line = 10, - LineEnd = 11, - LineDelete = 12, - LineRender = 13, - LineNotRender = 14, + + // Double-check when using 10, 11, 12, 13, 14 that you aren't accidentally triggering any draw actions. See DrawActionType } } diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs index fb4b96d..1756424 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs @@ -84,7 +84,7 @@ public void Update() DrawingInstanceManager.Instance.SendDrawUpdate( strokeID, - Entity_Type.Line, + DrawActionType.Continue, lineRenderer.widthMultiplier, lineRenderer.GetPosition(curLineIndex), new Vector4 diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DoubleTapState.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DoubleTapState.cs index ee48577..e92ae24 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DoubleTapState.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DoubleTapState.cs @@ -21,4 +21,3 @@ public static DoubleTapState Instance public UnityEvent OnDoubleTriggerStateOn; public UnityEvent OnDoubleTriggerStateOff; } - diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs index ddbdd7a..2e15477 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs @@ -105,7 +105,7 @@ public void InitializeFinishedLineFromOwnClient(int strokeID, LineRenderer lineR { SendDrawUpdate( strokeID, - Entity_Type.LineEnd, + DrawActionType.End, copiedLR.widthMultiplier, lineRenderer.GetPosition(lineRenderer.positionCount - 1), new Vector4(lineRenderer.startColor.r, lineRenderer.startColor.g, lineRenderer.startColor.b, lineRenderer.startColor.a) @@ -121,7 +121,7 @@ public void InitializeFinishedLineFromOwnClient(int strokeID, LineRenderer lineR { pivot.SetActive(false); - SendDrawUpdate(strokeID, Entity_Type.LineNotRender); + SendDrawUpdate(strokeID, DrawActionType.Hide); }); } } @@ -158,13 +158,13 @@ public void InitializeFinishedLineFromOtherClient(int strokeID, LineRenderer ren pivot.transform.SetParent(externalStrokeParent, true); } - public void SendDrawUpdate(int id, Entity_Type entityType, float lineWidth = 1, Vector3 curPos = default, Vector4 color = default) + public void SendDrawUpdate(int id, DrawActionType actionType, float lineWidth = 1, Vector3 curPos = default, Vector4 color = default) { var drawUpdate = new Draw ( (int) NetworkUpdateHandler.Instance.client_id, id, - (int) entityType, + (int) actionType, lineWidth, curPos, color @@ -312,35 +312,35 @@ public void ReceiveDrawUpdate (string stringData) switch (data.strokeType) { // Continues a Line - case (int) Entity_Type.Line: + case (int) DrawActionType.Continue: { ContinueLine(data); break; } - case (int) Entity_Type.LineEnd: + case (int) DrawActionType.End: { EndLine(data); break; } - case (int) Entity_Type.LineDelete: + case (int) DrawActionType.Delete: { DeleteLine(data); break; } - case (int) Entity_Type.LineRender: + case (int) DrawActionType.Show: { ShowLine(data); break; } - case (int) Entity_Type.LineNotRender: + case (int) DrawActionType.Hide: { HideLine(data); diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/EraseManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/EraseManager.cs index 6fdfc74..126edca 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/EraseManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/EraseManager.cs @@ -38,7 +38,7 @@ public virtual void TryAndErase(NetworkedGameObject netObj) netObj.gameObject.SetActive(false); // when actions of erasing are being captured, the curStrokepos and curColor will both be set to 0. - DrawingInstanceManager.Instance.SendDrawUpdate(entityID, Entity_Type.LineNotRender); + DrawingInstanceManager.Instance.SendDrawUpdate(entityID, DrawActionType.Hide); //save our reverted action for undoing the process with the undo button if (UndoRedoManager.IsAlive) @@ -51,7 +51,7 @@ public virtual void TryAndErase(NetworkedGameObject netObj) { netObj.gameObject.SetActive(true); - DrawingInstanceManager.Instance.SendDrawUpdate(entityID, Entity_Type.LineRender); + DrawingInstanceManager.Instance.SendDrawUpdate(entityID, DrawActionType.Show); } ) ); diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/MainClientUpdater.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/MainClientUpdater.cs index 146c739..4dea152 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/MainClientUpdater.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/MainClientUpdater.cs @@ -266,9 +266,9 @@ public void SendSyncPosition(Entity_Type entityType, Vector3 position, Quaternio netUpdateHandler.SendSyncPoseMessage(coords); } - public void SendSyncNetObject(NetworkedGameObject eContainer) + public void SendSyncNetObject(NetworkedGameObject netObject) { - var entityData = entityManager.GetComponentData(eContainer.Entity); + var entityData = entityManager.GetComponentData(netObject.Entity); Position position = new Position { @@ -278,12 +278,12 @@ public void SendSyncNetObject(NetworkedGameObject eContainer) entityType = (int)entityData.current_Entity_Type, - rot = eContainer.transform.rotation, + rot = netObject.transform.rotation, - pos = eContainer.transform.position, + pos = netObject.transform.position, //since using parenting for objects, we need to translate local to global scalling when having it in your hand, when releasing we need to return such objects scalling from global to local scale - scaleFactor = eContainer.transform.lossyScale.x, + scaleFactor = netObject.transform.lossyScale.x, }; netUpdateHandler.SendSyncPoseMessage(position); From 1a9f379c8a65de33f6fb805aa8cffc7d85d26695 Mon Sep 17 00:00:00 2001 From: Brandon Dang <8165314+parseccentric@users.noreply.github.com> Date: Tue, 8 Feb 2022 16:07:31 -0600 Subject: [PATCH 11/15] Revert "moved draw action types out of entity type" This reverts commit 34862edf596b7c24049f139600c8409cf49bef17. --- .../Scripts/RuntimeSession/DrawActionType.cs | 15 --------------- .../RuntimeSession/DrawActionType.cs.meta | 11 ----------- .../Scripts/RuntimeSession/EntityType.cs | 7 +++++-- .../RuntimeSession/EventSystem/TriggerDraw.cs | 2 +- .../RuntimeSession/Managers/DoubleTapState.cs | 1 + .../Managers/DrawingInstanceManager.cs | 18 +++++++++--------- .../RuntimeSession/Managers/EraseManager.cs | 4 ++-- .../Network/MainClientUpdater.cs | 10 +++++----- 8 files changed, 23 insertions(+), 45 deletions(-) delete mode 100644 Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/DrawActionType.cs delete mode 100644 Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/DrawActionType.cs.meta diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/DrawActionType.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/DrawActionType.cs deleted file mode 100644 index 30b2b21..0000000 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/DrawActionType.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace Komodo.Runtime -{ - public enum DrawActionType - { - Continue = 10, - End = 11, - Delete = 12, - Show = 13, - Hide = 14, - } -} diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/DrawActionType.cs.meta b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/DrawActionType.cs.meta deleted file mode 100644 index 49f4a5e..0000000 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/DrawActionType.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a70f2f75517143f4e895456033deabd5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs index 3a978c8..1b0c950 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EntityType.cs @@ -15,7 +15,10 @@ public enum Entity_Type physicsObject = 4, main_Player = 5, physicsEnd = 8, - - // Double-check when using 10, 11, 12, 13, 14 that you aren't accidentally triggering any draw actions. See DrawActionType + Line = 10, + LineEnd = 11, + LineDelete = 12, + LineRender = 13, + LineNotRender = 14, } } diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs index 1756424..fb4b96d 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs @@ -84,7 +84,7 @@ public void Update() DrawingInstanceManager.Instance.SendDrawUpdate( strokeID, - DrawActionType.Continue, + Entity_Type.Line, lineRenderer.widthMultiplier, lineRenderer.GetPosition(curLineIndex), new Vector4 diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DoubleTapState.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DoubleTapState.cs index e92ae24..ee48577 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DoubleTapState.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DoubleTapState.cs @@ -21,3 +21,4 @@ public static DoubleTapState Instance public UnityEvent OnDoubleTriggerStateOn; public UnityEvent OnDoubleTriggerStateOff; } + diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs index 2e15477..ddbdd7a 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/DrawingInstanceManager.cs @@ -105,7 +105,7 @@ public void InitializeFinishedLineFromOwnClient(int strokeID, LineRenderer lineR { SendDrawUpdate( strokeID, - DrawActionType.End, + Entity_Type.LineEnd, copiedLR.widthMultiplier, lineRenderer.GetPosition(lineRenderer.positionCount - 1), new Vector4(lineRenderer.startColor.r, lineRenderer.startColor.g, lineRenderer.startColor.b, lineRenderer.startColor.a) @@ -121,7 +121,7 @@ public void InitializeFinishedLineFromOwnClient(int strokeID, LineRenderer lineR { pivot.SetActive(false); - SendDrawUpdate(strokeID, DrawActionType.Hide); + SendDrawUpdate(strokeID, Entity_Type.LineNotRender); }); } } @@ -158,13 +158,13 @@ public void InitializeFinishedLineFromOtherClient(int strokeID, LineRenderer ren pivot.transform.SetParent(externalStrokeParent, true); } - public void SendDrawUpdate(int id, DrawActionType actionType, float lineWidth = 1, Vector3 curPos = default, Vector4 color = default) + public void SendDrawUpdate(int id, Entity_Type entityType, float lineWidth = 1, Vector3 curPos = default, Vector4 color = default) { var drawUpdate = new Draw ( (int) NetworkUpdateHandler.Instance.client_id, id, - (int) actionType, + (int) entityType, lineWidth, curPos, color @@ -312,35 +312,35 @@ public void ReceiveDrawUpdate (string stringData) switch (data.strokeType) { // Continues a Line - case (int) DrawActionType.Continue: + case (int) Entity_Type.Line: { ContinueLine(data); break; } - case (int) DrawActionType.End: + case (int) Entity_Type.LineEnd: { EndLine(data); break; } - case (int) DrawActionType.Delete: + case (int) Entity_Type.LineDelete: { DeleteLine(data); break; } - case (int) DrawActionType.Show: + case (int) Entity_Type.LineRender: { ShowLine(data); break; } - case (int) DrawActionType.Hide: + case (int) Entity_Type.LineNotRender: { HideLine(data); diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/EraseManager.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/EraseManager.cs index 126edca..6fdfc74 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/EraseManager.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Managers/EraseManager.cs @@ -38,7 +38,7 @@ public virtual void TryAndErase(NetworkedGameObject netObj) netObj.gameObject.SetActive(false); // when actions of erasing are being captured, the curStrokepos and curColor will both be set to 0. - DrawingInstanceManager.Instance.SendDrawUpdate(entityID, DrawActionType.Hide); + DrawingInstanceManager.Instance.SendDrawUpdate(entityID, Entity_Type.LineNotRender); //save our reverted action for undoing the process with the undo button if (UndoRedoManager.IsAlive) @@ -51,7 +51,7 @@ public virtual void TryAndErase(NetworkedGameObject netObj) { netObj.gameObject.SetActive(true); - DrawingInstanceManager.Instance.SendDrawUpdate(entityID, DrawActionType.Show); + DrawingInstanceManager.Instance.SendDrawUpdate(entityID, Entity_Type.LineRender); } ) ); diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/MainClientUpdater.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/MainClientUpdater.cs index 4dea152..146c739 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/MainClientUpdater.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/MainClientUpdater.cs @@ -266,9 +266,9 @@ public void SendSyncPosition(Entity_Type entityType, Vector3 position, Quaternio netUpdateHandler.SendSyncPoseMessage(coords); } - public void SendSyncNetObject(NetworkedGameObject netObject) + public void SendSyncNetObject(NetworkedGameObject eContainer) { - var entityData = entityManager.GetComponentData(netObject.Entity); + var entityData = entityManager.GetComponentData(eContainer.Entity); Position position = new Position { @@ -278,12 +278,12 @@ public void SendSyncNetObject(NetworkedGameObject netObject) entityType = (int)entityData.current_Entity_Type, - rot = netObject.transform.rotation, + rot = eContainer.transform.rotation, - pos = netObject.transform.position, + pos = eContainer.transform.position, //since using parenting for objects, we need to translate local to global scalling when having it in your hand, when releasing we need to return such objects scalling from global to local scale - scaleFactor = netObject.transform.lossyScale.x, + scaleFactor = eContainer.transform.lossyScale.x, }; netUpdateHandler.SendSyncPoseMessage(position); From eaec38f55a0b1ca2e78cc3e6e6aaa2348c6b32a2 Mon Sep 17 00:00:00 2001 From: Brandon Dang <8165314+parseccentric@users.noreply.github.com> Date: Wed, 9 Feb 2022 19:18:12 -0600 Subject: [PATCH 12/15] updated test results to match new features --- .../test-results-YYYY-MM-DD-HHMM.md | 15 +++++++++++++++ Komodo/ProjectSettings/ProjectSettings.asset | 6 ++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/test-results-YYYY-MM-DD-HHMM.md b/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/test-results-YYYY-MM-DD-HHMM.md index 391bfb5..fe5da6c 100644 --- a/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/test-results-YYYY-MM-DD-HHMM.md +++ b/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/test-results-YYYY-MM-DD-HHMM.md @@ -80,6 +80,12 @@ RESULT = … - strokes have correct z depth re:each other _RESULT_ - strokes have correct z depth while drawing _RESULT_ - strokes have correct z depth after drawing is done _RESULT_ +- move own drawings _RESULT_ +- rotate own drawings _RESULT_ +- scale own drawings _RESULT_ +- move others' drawings _RESULT_ +- rotate others' drawings _RESULT_ +- undo own drawings _RESULT_ **erase** - with left hand _RESULT_ @@ -148,7 +154,12 @@ RESULT = … **Catches Up State Upon (Re-)Entry** - Auto connect _RESULT_ +- Turn off network connection and turn back on _RESULT_ - Get Joined to Session _RESULT_ +- `[!]` when disconnected from server _RESULT_ +- `[!]` when disconnected from room (session) _RESULT_ +- Client disappears from others' _RESULT_ +- Client starts moving again on auto-reconnect _RESULT_ - Avatar names _RESULT_ - Avatar people _RESULT_ - Avatar poses _RESULT_ @@ -223,6 +234,10 @@ RESULT = … - pan (Middle Mouse Drag) _RESULT_ - right-click (no dragging yet) to teleport _RESULT_ +**Capture** +- capture button starts capture +- capture button stops capture + ## Bugs - STEPS_TO_REPRODUCE - EXPECTED_RESULT diff --git a/Komodo/ProjectSettings/ProjectSettings.asset b/Komodo/ProjectSettings/ProjectSettings.asset index 48f26e1..79119ca 100644 --- a/Komodo/ProjectSettings/ProjectSettings.asset +++ b/Komodo/ProjectSettings/ProjectSettings.asset @@ -207,6 +207,8 @@ PlayerSettings: - {fileID: 0} - {fileID: 0} - {fileID: 0} + - {fileID: 0} + - {fileID: 0} - {fileID: 2910771567588298596, guid: ac933aa07b1097d47a08984d469dccfc, type: 2} - {fileID: 11400000, guid: a5e5b7605fb48984988490688c2a74e2, type: 2} - {fileID: 11400000, guid: 8fed9c7708c5a6b46bbde22d82990e10, type: 2} @@ -728,6 +730,7 @@ PlayerSettings: metroSplashScreenUseBackgroundColor: 0 platformCapabilities: WindowsStoreApps: + EnterpriseAuthentication: False OfflineMapsManagement: False HumanInterfaceDevice: False Location: False @@ -740,7 +743,6 @@ PlayerSettings: InternetClientServer: False VideosLibrary: False Objects3D: False - InternetClient: False RemoteSystem: False BlockedChatMessages: False PhoneCall: False @@ -762,9 +764,9 @@ PlayerSettings: RecordedCallsFolder: False Contacts: False Proximity: False + InternetClient: False CodeGeneration: False BackgroundMediaPlayback: False - EnterpriseAuthentication: False metroTargetDeviceFamilies: Desktop: False Holographic: False From 49fd14ad4bebfb8abead83f2b78ddcf610268e4b Mon Sep 17 00:00:00 2001 From: Brandon Dang <8165314+parseccentric@users.noreply.github.com> Date: Tue, 22 Feb 2022 12:24:28 -0600 Subject: [PATCH 13/15] add comments explaining draw system --- .../RuntimeSession/EventSystem/TriggerDraw.cs | 13 +++++++++++++ .../Scripts/RuntimeSession/Network/Draw.cs | 16 ++++++++++++++++ Komodo/ProjectSettings/ProjectSettings.asset | 5 ++--- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs index fb4b96d..ce9efd8 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/EventSystem/TriggerDraw.cs @@ -124,6 +124,19 @@ public virtual void OnDisable() if (NetworkUpdateHandler.IsAlive) { strokeID = handID * 1000000 + 100000 + NetworkUpdateHandler.Instance.client_id * 10000 + strokeIndex; + + // TODO: refactor the multiple instances of this + // calculation into one method. + + // TODO: evaluate reduced human readability if there + // are 100 or more registered clients. + // Consider client 111. Then the equation would be + // 1000000 + 100000 + 1110000 + 1234 + // = 2210000 + 891234 + // = 3101234 + // The apparent hand is 3 and apparent client ID is 10, + // but the actual hand is 1 and the actual client ID is + // 111. } else { diff --git a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/Draw.cs b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/Draw.cs index da1fa4b..7df1d99 100644 --- a/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/Draw.cs +++ b/Komodo/Assets/Packages/KomodoCore/Runtime/Scripts/RuntimeSession/Network/Draw.cs @@ -4,11 +4,25 @@ namespace Komodo.Runtime { public struct Draw { + // Who is sending the draw update public int clientId; + + // An ID unique among all entities (draw strokes, models, model pack subobjects) public int strokeId; + + // The kind of action being performed. + // See Entity_Type.Line ... Entity_Type.LineNotRender public int strokeType; + + // Used for continue line. The visual thickness of the line. public float lineWidth; + + // Used for continue line and end line. + // The endpoint of the currently drawn line segment. public Vector3 curStrokePos; + + // Used for continue line. + // The color of the line segment. public Vector4 curColor; public Draw(int clientId, int strokeId, int strokeType, float lineWidth, Vector3 curStrokePos, Vector4 curColor) @@ -20,5 +34,7 @@ public Draw(int clientId, int strokeId, int strokeType, float lineWidth, Vector3 this.curStrokePos = curStrokePos; this.curColor = curColor; } + + // TODO: Add constructors for ContinueLine, EndLine, ShowLine, HideLIne } } \ No newline at end of file diff --git a/Komodo/ProjectSettings/ProjectSettings.asset b/Komodo/ProjectSettings/ProjectSettings.asset index 79119ca..e7b5776 100644 --- a/Komodo/ProjectSettings/ProjectSettings.asset +++ b/Komodo/ProjectSettings/ProjectSettings.asset @@ -213,7 +213,6 @@ PlayerSettings: - {fileID: 11400000, guid: a5e5b7605fb48984988490688c2a74e2, type: 2} - {fileID: 11400000, guid: 8fed9c7708c5a6b46bbde22d82990e10, type: 2} - {fileID: 2478256764130162806, guid: 552445d583cb06c4eaf9d56596dd45c2, type: 2} - - {fileID: 0} metroInputSource: 0 wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1 @@ -730,7 +729,6 @@ PlayerSettings: metroSplashScreenUseBackgroundColor: 0 platformCapabilities: WindowsStoreApps: - EnterpriseAuthentication: False OfflineMapsManagement: False HumanInterfaceDevice: False Location: False @@ -743,6 +741,7 @@ PlayerSettings: InternetClientServer: False VideosLibrary: False Objects3D: False + InternetClient: False RemoteSystem: False BlockedChatMessages: False PhoneCall: False @@ -764,9 +763,9 @@ PlayerSettings: RecordedCallsFolder: False Contacts: False Proximity: False - InternetClient: False CodeGeneration: False BackgroundMediaPlayback: False + EnterpriseAuthentication: False metroTargetDeviceFamilies: Desktop: False Holographic: False From 2286d89733b9b50d6d8d95d01680adf8fd83745e Mon Sep 17 00:00:00 2001 From: Brandon Dang <8165314+parseccentric@users.noreply.github.com> Date: Fri, 25 Feb 2022 16:17:46 -0600 Subject: [PATCH 14/15] version number --- Komodo/Assets/Packages/KomodoCore/package.json | 2 +- Komodo/ProjectSettings/ProjectSettings.asset | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Komodo/Assets/Packages/KomodoCore/package.json b/Komodo/Assets/Packages/KomodoCore/package.json index bdf9e60..486a617 100644 --- a/Komodo/Assets/Packages/KomodoCore/package.json +++ b/Komodo/Assets/Packages/KomodoCore/package.json @@ -1,7 +1,7 @@ { "name": "com.graingeridealab.komodo", "displayName": "KomodoCore", - "version": "0.5.7", + "version": "0.5.8", "unity": "2020.3", "keywords": [ "webxr", diff --git a/Komodo/ProjectSettings/ProjectSettings.asset b/Komodo/ProjectSettings/ProjectSettings.asset index e7b5776..a9139d2 100644 --- a/Komodo/ProjectSettings/ProjectSettings.asset +++ b/Komodo/ProjectSettings/ProjectSettings.asset @@ -209,10 +209,12 @@ PlayerSettings: - {fileID: 0} - {fileID: 0} - {fileID: 0} + - {fileID: 0} - {fileID: 2910771567588298596, guid: ac933aa07b1097d47a08984d469dccfc, type: 2} - {fileID: 11400000, guid: a5e5b7605fb48984988490688c2a74e2, type: 2} - {fileID: 11400000, guid: 8fed9c7708c5a6b46bbde22d82990e10, type: 2} - {fileID: 2478256764130162806, guid: 552445d583cb06c4eaf9d56596dd45c2, type: 2} + - {fileID: 0} metroInputSource: 0 wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1 @@ -740,8 +742,8 @@ PlayerSettings: PrivateNetworkClientServer: False InternetClientServer: False VideosLibrary: False + BackgroundMediaPlayback: False Objects3D: False - InternetClient: False RemoteSystem: False BlockedChatMessages: False PhoneCall: False @@ -762,9 +764,9 @@ PlayerSettings: PointOfService: False RecordedCallsFolder: False Contacts: False + InternetClient: False Proximity: False CodeGeneration: False - BackgroundMediaPlayback: False EnterpriseAuthentication: False metroTargetDeviceFamilies: Desktop: False From c71188b81588b9af88a9fee31411df979471297f Mon Sep 17 00:00:00 2001 From: Brandon Dang <8165314+parseccentric@users.noreply.github.com> Date: Fri, 25 Feb 2022 16:32:42 -0600 Subject: [PATCH 15/15] update test template --- .../test-results-YYYY-MM-DD-HHMM.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/test-results-YYYY-MM-DD-HHMM.md b/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/test-results-YYYY-MM-DD-HHMM.md index c62a230..0f4e6d2 100644 --- a/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/test-results-YYYY-MM-DD-HHMM.md +++ b/Komodo/Assets/WebGLTemplates/KomodoWebXRFullView2020/test-results-YYYY-MM-DD-HHMM.md @@ -108,15 +108,12 @@ _vX_Y_Z-RC_NUM-[NON_DEV]_ ### Model Interactions - Can Grab model _RESULT_ - Grab model pack _RESULT_ -- Grab synchronizes _RESULT_ - Grabbing locks for others _RESULT_ - Can Scale model _RESULT_ - Scale model pack _RESULT_ -- Scale synchronizes _RESULT_ - Scaling locks for others _RESULT_ - Can Show / Hide _RESULT_ -- Synced show / hide _RESULT_ -- Synced show / hide for model packs _RESULT_ +- Show / Hide for model packs _RESULT_ - Can lock model _RESULT_ - Can lock model pack _RESULT_ - Grab lock vs UI lock _RESULT_ @@ -148,7 +145,9 @@ _vX_Y_Z-RC_NUM-[NON_DEV]_ - “You just left” own _RESULT_ - “Someone just left” others _RESULT_ - Close Connection and Rejoin simulated offline _RESULT_ -- Drawing poses, color _RESULT_ +- Pre-disconnection drawing poses _RESULT_ +- During-disconnection drawings _RESULT_ +- During-disconnection drawing poses _RESULT_ # Spectator Tests @@ -206,9 +205,10 @@ _vX_Y_Z-RC_NUM-[NON_DEV]_ - pan (Middle Mouse Drag) _RESULT_ - right-click (no dragging yet) to teleport _RESULT_ -**Capture** +## Captures - capture button starts capture _RESULT_ - capture button stops capture _RESULT_ + ### Capture file - Capture file includes events for pressing settings, people, interact, create tabs _RESULT_ - Capture file includes events for calling out the VR menu _RESULT_ @@ -256,7 +256,7 @@ ___ ## Transferring new and deleted tests to the template -* Use a text editor with a diff or compare function to easily copy the new tests (or delete tests) without copying the test results. +* Use a text editor with a diff or compare function to easily copy the new tests (or delete tests) to the template without copying the test results. * Keep the test name to one line, and write details on how to execute the test in the Komodo Manual ## Template