From 40fbd13c26c874caf2edc77341e8f91c64593832 Mon Sep 17 00:00:00 2001 From: AlvaroHG Date: Wed, 14 Aug 2024 15:50:18 -0700 Subject: [PATCH 1/7] Fixes --- unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs b/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs index a827d8200a..c5f73d8cd3 100644 --- a/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs +++ b/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs @@ -6115,7 +6115,9 @@ public void RotateUniverseAroundAgent(ServerAction action) { public void ChangeFOV(float fieldOfView, string camera = "") { if (fieldOfView > 0 && fieldOfView < 180) { if (string.IsNullOrEmpty(camera)) { - m_Camera.fieldOfView = fieldOfView; + agentManager.UpdateMainCamera( + fieldOfView: fieldOfView + ); actionFinished(true); } else { var cameraTuples = new List<(Camera camera, bool isThirdPartyCamera, int id)>() @@ -6143,7 +6145,9 @@ public void ChangeFOV(float fieldOfView, string camera = "") { fieldOfView: fieldOfView ); } else { - tuple.camera.fieldOfView = fieldOfView; + agentManager.UpdateMainCamera( + fieldOfView: fieldOfView + ); } } actionFinished(true); From 424620967943cd2c9e8c26e25ecf9d003722b29b Mon Sep 17 00:00:00 2001 From: AlvaroHG Date: Wed, 14 Aug 2024 16:19:44 -0700 Subject: [PATCH 2/7] Fixes double action finish calls, change modern action type --- unity/Assets/Scripts/AgentManager.cs | 12 +- unity/Assets/Scripts/FpinAgentController.cs | 419 ++++++------------ .../PhysicsRemoteFPSAgentController.cs | 49 +- 3 files changed, 168 insertions(+), 312 deletions(-) diff --git a/unity/Assets/Scripts/AgentManager.cs b/unity/Assets/Scripts/AgentManager.cs index 6dc119e148..98df2b116a 100644 --- a/unity/Assets/Scripts/AgentManager.cs +++ b/unity/Assets/Scripts/AgentManager.cs @@ -571,7 +571,7 @@ public void updateThirdPartyCameraImageSynthesis(bool status) { } } - private void updateCameraProperties( + private ActionFinished updateCameraProperties( Camera camera, Vector3? position, Vector3? rotation, @@ -693,7 +693,7 @@ private void updateCameraProperties( imageSynthesis.OnCameraChange(); } - this.activeAgent().actionFinished(success: true); + return ActionFinished.Success; } private void assertFovInBounds(float fov) { @@ -821,7 +821,7 @@ public OptionalVector3(float? x = null, float? y = null, float? z = null) { //allows repositioning and changing of values of agent's primary camera //note this does not support changing the main camera of multiple agents beyond the primary for now - public void UpdateMainCamera( + public ActionFinished UpdateMainCamera( OptionalVector3 position = null, OptionalVector3 rotation = null, float? fieldOfView = null, @@ -855,7 +855,7 @@ public void UpdateMainCamera( optionalVector3: rotation, defaultsOnNull: oldRotation ); - updateCameraProperties( + return updateCameraProperties( camera: agentMainCam, position: targetPosition, rotation: targetRotation, @@ -873,7 +873,7 @@ public void UpdateMainCamera( } // Updates third party cameras, including secondary camera of stretch agent - public void UpdateThirdPartyCamera( + public ActionFinished UpdateThirdPartyCamera( int thirdPartyCameraId = 0, OptionalVector3 position = null, OptionalVector3 rotation = null, @@ -922,7 +922,7 @@ public void UpdateThirdPartyCamera( optionalVector3: rotation, defaultsOnNull: oldRotation ); - updateCameraProperties( + return updateCameraProperties( camera: thirdPartyCamera, position: targetPosition, rotation: targetRotation, diff --git a/unity/Assets/Scripts/FpinAgentController.cs b/unity/Assets/Scripts/FpinAgentController.cs index f35e3696f7..9571325c7e 100644 --- a/unity/Assets/Scripts/FpinAgentController.cs +++ b/unity/Assets/Scripts/FpinAgentController.cs @@ -11,10 +11,8 @@ using UnityEngine.Rendering.PostProcessing; using UnityEngine.UIElements; -namespace UnityStandardAssets.Characters.FirstPerson -{ - public class BoxBounds - { +namespace UnityStandardAssets.Characters.FirstPerson { + public class BoxBounds { public Vector3 worldCenter; public Vector3 agentRelativeCenter; public Vector3 size; @@ -22,8 +20,7 @@ public class BoxBounds [Serializable] [MessagePackObject(keyAsPropertyName: true)] - public class LoadInUnityProceduralAsset - { + public class LoadInUnityProceduralAsset { public string id; public string dir; public string extension = ".msgpack.gz"; @@ -33,8 +30,7 @@ public class LoadInUnityProceduralAsset #nullable enable [Serializable] [MessagePackObject(keyAsPropertyName: true)] - public class BodyAsset - { + public class BodyAsset { public string? assetId = null; public LoadInUnityProceduralAsset? dynamicAsset = null; public ProceduralAsset? asset = null; @@ -44,8 +40,7 @@ public class BodyAsset [Serializable] [MessagePackObject(keyAsPropertyName: true)] - public class BackwardsCompatibleInitializeParams - { + public class BackwardsCompatibleInitializeParams { // Make what parameters it uses explicit public float maxUpwardLookAngle = 0.0f; public float maxDownwardLookAngle = 0.0f; @@ -69,8 +64,7 @@ public class BackwardsCompatibleInitializeParams public string visibilityScheme = VisibilityScheme.Collider.ToString(); } - public class FpinAgentController : PhysicsRemoteFPSAgentController - { + public class FpinAgentController : PhysicsRemoteFPSAgentController { private static readonly Vector3 agentSpawnOffset = new Vector3(100.0f, 100.0f, 100.0f); private FpinMovableContinuous fpinMovable; public BoxCollider spawnedBoxCollider = null; @@ -79,12 +73,9 @@ public class FpinAgentController : PhysicsRemoteFPSAgentController private Transform topMeshTransform = null; private Bounds? agentBounds = null; public BoxBounds boxBounds = null; - public BoxBounds BoxBounds - { - get - { - if (spawnedBoxCollider != null) - { + public BoxBounds BoxBounds { + get { + if (spawnedBoxCollider != null) { BoxBounds currentBounds = new BoxBounds(); currentBounds.worldCenter = spawnedBoxCollider.transform.TransformPoint( @@ -100,9 +91,7 @@ public BoxBounds BoxBounds // Debug.Log($"world center: {boxBounds.worldCenter}"); // Debug.Log($"size: {boxBounds.size}"); // Debug.Log($"agentRelativeCenter: {boxBounds.agentRelativeCenter}"); - } - else - { + } else { // Debug.Log("why is it nullll"); return null; } @@ -117,8 +106,7 @@ public BoxBounds BoxBounds public FpinAgentController(BaseAgentComponent baseAgentComponent, AgentManager agentManager) : base(baseAgentComponent, agentManager) { } - public void Start() - { + public void Start() { //put stuff we need here when we need it maybe } @@ -129,8 +117,7 @@ public override RaycastHit[] CastBodyTrayectory( float moveMagnitude, int layerMask, CapsuleData cachedCapsule - ) - { + ) { Vector3 startPositionBoxCenter = startPosition + this.transform.TransformDirection(this.boxBounds.agentRelativeCenter); @@ -148,16 +135,14 @@ CapsuleData cachedCapsule //since the size returned by the box collider only reflects its size in local space DISREGARDING ANY TRANSFORM SCALES //IN ITS PARENTS OR ITSELF here we go - public Vector3 GetTrueSizeOfBoxCollider(BoxCollider collider) - { + public Vector3 GetTrueSizeOfBoxCollider(BoxCollider collider) { Vector3 trueSize = collider.size; // get the transform of the collider itself Transform currentTransform = collider.transform; // Apply the scale from the collider's transform and all parent transforms - while (currentTransform != null) - { + while (currentTransform != null) { trueSize.x *= currentTransform.localScale.x; trueSize.y *= currentTransform.localScale.y; trueSize.z *= currentTransform.localScale.z; @@ -170,29 +155,24 @@ public Vector3 GetTrueSizeOfBoxCollider(BoxCollider collider) } //override so we can access to fpin specific stuff - public override MetadataWrapper generateMetadataWrapper() - { + public override MetadataWrapper generateMetadataWrapper() { //get all the usual stuff from base agent's implementation MetadataWrapper metaWrap = base.generateMetadataWrapper(); //here's the fpin specific stuff - if (boxBounds != null) - { + if (boxBounds != null) { //get from BoxBounds as box world center will update as agent moves so we can't cache it metaWrap.agent.fpinColliderSize = BoxBounds.size; metaWrap.agent.fpinColliderWorldCenter = BoxBounds.worldCenter; metaWrap.agent.fpinColliderAgentRelativeCenter = BoxBounds.agentRelativeCenter; - } - else - { + } else { metaWrap.agent.fpinColliderSize = new Vector3(0, 0, 0); } return metaWrap; } - public List SamplePointsOnNavMesh(int sampleCount, float maxDistance) - { + public List SamplePointsOnNavMesh(int sampleCount, float maxDistance) { float minX = agentManager.SceneBounds.min.x; float minZ = agentManager.SceneBounds.min.z; float maxX = agentManager.SceneBounds.max.x; @@ -203,10 +183,8 @@ public List SamplePointsOnNavMesh(int sampleCount, float maxDistance) int n = (int)Mathf.Ceil(Mathf.Sqrt(sampleCount)); List initPoints = new List(); - for (int i = 0; i < n; i++) - { - for (int j = 0; j < n; j++) - { + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { initPoints.Add( new Vector3( Mathf.Lerp(minX, maxX, (i + 0.5f) / n), @@ -219,17 +197,14 @@ public List SamplePointsOnNavMesh(int sampleCount, float maxDistance) initPoints.Shuffle_(); List pointsOnMesh = new List(); - for (int i = 0; i < initPoints.Count; i++) - { - if (pointsOnMesh.Count >= sampleCount) - { + for (int i = 0; i < initPoints.Count; i++) { + if (pointsOnMesh.Count >= sampleCount) { break; } NavMeshHit hit; Vector3 randomPoint = initPoints[i]; - if (NavMesh.SamplePosition(randomPoint, out hit, maxDistance, NavMesh.AllAreas)) - { + if (NavMesh.SamplePosition(randomPoint, out hit, maxDistance, NavMesh.AllAreas)) { # if UNITY_EDITOR Debug.DrawLine( hit.position, @@ -247,17 +222,14 @@ public List SamplePointsOnNavMesh(int sampleCount, float maxDistance) return pointsOnMesh; } - public void RandomlyPlaceAgentOnNavMesh(int n = 200, float maxDistance = 0.1f) - { + public void RandomlyPlaceAgentOnNavMesh(int n = 200, float maxDistance = 0.1f) { List pointsOnMesh = SamplePointsOnNavMesh(n, maxDistance: maxDistance); - if (pointsOnMesh.Count == 0) - { + if (pointsOnMesh.Count == 0) { throw new InvalidOperationException("No points on the navmesh"); } Bounds b = UtilityFunctions.CreateEmptyBounds(); - foreach (Collider c in GetComponentsInChildren()) - { + foreach (Collider c in GetComponentsInChildren()) { b.Encapsulate(c.bounds); } @@ -266,10 +238,8 @@ public void RandomlyPlaceAgentOnNavMesh(int n = 200, float maxDistance = 0.1f) //Debug.Log($"yOffset is: {yOffset}"); bool success = false; - foreach (Vector3 point in pointsOnMesh) - { - try - { + foreach (Vector3 point in pointsOnMesh) { + try { //Debug.Log($"what is the point we are trying from the pointsOnMesh? {point:F8}"); teleportFull( position: point + new Vector3(0, yOffset, 0), @@ -279,9 +249,7 @@ public void RandomlyPlaceAgentOnNavMesh(int n = 200, float maxDistance = 0.1f) ); success = true; break; - } - catch (InvalidOperationException) - { + } catch (InvalidOperationException) { continue; } } @@ -296,8 +264,7 @@ public void spawnAgentBoxCollider( Bounds agentBounds, bool useVisibleColliderBase = false, bool spawnCollidersWithoutMesh = false - ) - { + ) { //create colliders based on the agent bounds var col = new GameObject("fpinCollider", typeof(BoxCollider)); col.layer = LayerMask.NameToLayer("Agent"); @@ -332,27 +299,22 @@ public void spawnAgentBoxCollider( //helper function to remove the currently generated agent box collider //make sure to follow this up with a subsequent generation so BoxBounds isn't left null - public void destroyAgentBoxCollider() - { + public void destroyAgentBoxCollider() { GameObject visibleBox = GameObject.Find("VisibleBox"); - if (spawnedBoxCollider != null) - { + if (spawnedBoxCollider != null) { UnityEngine.Object.DestroyImmediate(spawnedBoxCollider.transform.gameObject); spawnedBoxCollider = null; } - if (spawnedTriggerBoxCollider != null) - { + if (spawnedTriggerBoxCollider != null) { UnityEngine.Object.DestroyImmediate(spawnedTriggerBoxCollider.transform.gameObject); spawnedTriggerBoxCollider = null; } - if (visibleBox != null) - { + if (visibleBox != null) { UnityEngine.Object.DestroyImmediate(visibleBox); } #if UNITY_EDITOR GameObject visualizedBoxCollider = GameObject.Find("VisualizedBoxCollider"); - if (visualizedBoxCollider != null) - { + if (visualizedBoxCollider != null) { UnityEngine.Object.DestroyImmediate(visualizedBoxCollider); } #endif @@ -368,36 +330,30 @@ private Transform CopyMeshChildrenRecursive( Transform sourceTransform, Transform targetTransform, bool isTopMost = true - ) - { + ) { Transform thisTransform = null; - foreach (Transform child in sourceTransform) - { + foreach (Transform child in sourceTransform) { GameObject copiedChild = null; // Check if the child has a MeshFilter component MeshFilter meshFilter = child.GetComponent(); - if (meshFilter != null) - { + if (meshFilter != null) { copiedChild = CopyMeshToTarget(child, targetTransform); } // Process children only if necessary (i.e., they contain MeshFilters) - if (HasMeshInChildrenOrSelf(child)) - { + if (HasMeshInChildrenOrSelf(child)) { Transform parentForChildren = (copiedChild != null) ? copiedChild.transform : CreateContainerForHierarchy(child, targetTransform).transform; CopyMeshChildrenRecursive(child, parentForChildren, false); - if (isTopMost) - { + if (isTopMost) { thisTransform = parentForChildren; } } } - if (isTopMost) - { + if (isTopMost) { // Set up intermediate object for scaling the mesh in agent-space (since the top-level mesh could be rotated, potentially introducing a complex matrix of scales) GameObject agentScaleObject = new GameObject("AgentScaleObject"); agentScaleObject.transform.position = thisTransform.position; @@ -409,8 +365,7 @@ private Transform CopyMeshChildrenRecursive( return null; } - private GameObject CopyMeshToTarget(Transform child, Transform targetParent) - { + private GameObject CopyMeshToTarget(Transform child, Transform targetParent) { // Create a new GameObject and copy components GameObject copiedChild = new GameObject(child.name); copiedChild.transform.SetParent(targetParent); @@ -420,8 +375,7 @@ private GameObject CopyMeshToTarget(Transform child, Transform targetParent) copiedMeshFilter.mesh = meshFilter.mesh; MeshRenderer sourceMeshRenderer = child.GetComponent(); - if (sourceMeshRenderer != null) - { + if (sourceMeshRenderer != null) { MeshRenderer copiedMeshRenderer = copiedChild.AddComponent(); copiedMeshRenderer.sharedMaterials = sourceMeshRenderer.sharedMaterials; } @@ -433,26 +387,21 @@ private GameObject CopyMeshToTarget(Transform child, Transform targetParent) return copiedChild; } - private bool HasMeshInChildrenOrSelf(Transform transform) - { - foreach (Transform child in transform) - { - if (child.GetComponent() != null || HasMeshInChildrenOrSelf(child)) - { + private bool HasMeshInChildrenOrSelf(Transform transform) { + foreach (Transform child in transform) { + if (child.GetComponent() != null || HasMeshInChildrenOrSelf(child)) { return true; } } - if (transform.GetComponent() != null) - { + if (transform.GetComponent() != null) { return true; } return false; } - private GameObject CreateContainerForHierarchy(Transform child, Transform targetParent) - { + private GameObject CreateContainerForHierarchy(Transform child, Transform targetParent) { GameObject container = new GameObject(child.name + "_Container"); container.transform.SetParent(targetParent); container.transform.localPosition = child.localPosition; @@ -464,26 +413,22 @@ private GameObject CreateContainerForHierarchy(Transform child, Transform target private HashSet TransformedMeshRendererVertices( MeshRenderer mr, bool returnFirstVertexOnly = false - ) - { + ) { MeshFilter mf = mr.gameObject.GetComponent(); Matrix4x4 localToWorld = mr.transform.localToWorldMatrix; HashSet vertices = new HashSet(mf.sharedMesh.vertices); HashSet transformedVertices = new HashSet(); - foreach (Vector3 vertex in vertices) - { + foreach (Vector3 vertex in vertices) { transformedVertices.Add(localToWorld.MultiplyPoint3x4(vertex)); } return transformedVertices; } - public ActionFinished GetBoxBounds() - { + public ActionFinished GetBoxBounds() { return new ActionFinished() { success = true, actionReturn = this.BoxBounds }; } - public Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 angles) - { + public Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 angles) { // Move the point to the pivot's origin Vector3 dir = point - pivot; // Rotate it @@ -495,31 +440,23 @@ public Vector3 RotatePointAroundPivot(Vector3 point, Vector3 pivot, Vector3 angl public ActionFinished BackwardsCompatibleInitialize( BackwardsCompatibleInitializeParams args - ) - { + ) { Debug.Log("RUNNING BackCompatInitialize from FpinAgentController.cs"); // limit camera from looking too far down/up //default max are 30 up and 60 down, different agent types may overwrite this - if (Mathf.Approximately(args.maxUpwardLookAngle, 0.0f)) - { + if (Mathf.Approximately(args.maxUpwardLookAngle, 0.0f)) { this.maxUpwardLookAngle = 30f; - } - else - { + } else { this.maxUpwardLookAngle = args.maxUpwardLookAngle; } - if (Mathf.Approximately(args.maxDownwardLookAngle, 0.0f)) - { + if (Mathf.Approximately(args.maxDownwardLookAngle, 0.0f)) { this.maxDownwardLookAngle = 60f; - } - else - { + } else { this.maxDownwardLookAngle = args.maxDownwardLookAngle; } - if (args.antiAliasing != null) - { + if (args.antiAliasing != null) { agentManager.updateAntiAliasing( postProcessLayer: m_Camera.gameObject.GetComponentInChildren(), antiAliasing: args.antiAliasing @@ -527,77 +464,62 @@ BackwardsCompatibleInitializeParams args } // m_Camera.GetComponent().SwitchRenderersToHide(this.VisibilityCapsule); - if (args.gridSize == 0) - { + if (args.gridSize == 0) { args.gridSize = 0.25f; } // note: this overrides the default FOV values set in InitializeBody() - if (args.fieldOfView > 0 && args.fieldOfView < 180) - { + if (args.fieldOfView > 0 && args.fieldOfView < 180) { m_Camera.fieldOfView = args.fieldOfView; - } - else if (args.fieldOfView < 0 || args.fieldOfView >= 180) - { + } else if (args.fieldOfView < 0 || args.fieldOfView >= 180) { errorMessage = "fov must be set to (0, 180) noninclusive."; Debug.Log(errorMessage); return new ActionFinished(success: false, errorMessage: errorMessage); } - if (args.cameraNearPlane > 0) - { + if (args.cameraNearPlane > 0) { m_Camera.nearClipPlane = args.cameraNearPlane; } - if (args.cameraFarPlane > 0) - { + if (args.cameraFarPlane > 0) { m_Camera.farClipPlane = args.cameraFarPlane; } - if (args.timeScale > 0) - { - if (Time.timeScale != args.timeScale) - { + if (args.timeScale > 0) { + if (Time.timeScale != args.timeScale) { Time.timeScale = args.timeScale; } - } - else - { + } else { errorMessage = "Time scale must be > 0"; Debug.Log(errorMessage); return new ActionFinished(success: false, errorMessage: errorMessage); } - if (args.rotateStepDegrees <= 0.0) - { + if (args.rotateStepDegrees <= 0.0) { errorMessage = "rotateStepDegrees must be a non-zero, non-negative float"; Debug.Log(errorMessage); return new ActionFinished(success: false, errorMessage: errorMessage); } // default is 90 defined in the ServerAction class, specify whatever you want the default to be - if (args.rotateStepDegrees > 0.0) - { + if (args.rotateStepDegrees > 0.0) { this.rotateStepDegrees = args.rotateStepDegrees; } - if (args.snapToGrid && !ValidRotateStepDegreesWithSnapToGrid(args.rotateStepDegrees)) - { + if (args.snapToGrid && !ValidRotateStepDegreesWithSnapToGrid(args.rotateStepDegrees)) { errorMessage = $"Invalid values 'rotateStepDegrees': ${args.rotateStepDegrees} and 'snapToGrid':${args.snapToGrid}. 'snapToGrid': 'True' is not supported when 'rotateStepDegrees' is different from grid rotation steps of 0, 90, 180, 270 or 360."; Debug.Log(errorMessage); return new ActionFinished(success: false, errorMessage: errorMessage); } - if (args.maxDownwardLookAngle < 0) - { + if (args.maxDownwardLookAngle < 0) { errorMessage = "maxDownwardLookAngle must be a non-negative float"; Debug.Log(errorMessage); return new ActionFinished(success: false, errorMessage: errorMessage); } - if (args.maxUpwardLookAngle < 0) - { + if (args.maxUpwardLookAngle < 0) { errorMessage = "maxUpwardLookAngle must be a non-negative float"; Debug.Log(errorMessage); return new ActionFinished(success: false, errorMessage: errorMessage); @@ -610,21 +532,18 @@ BackwardsCompatibleInitializeParams args || args.renderSemanticSegmentation || args.renderInstanceSegmentation || args.renderNormalsImage - ) - { + ) { this.updateImageSynthesis(true); } - if (args.visibilityDistance > 0.0f) - { + if (args.visibilityDistance > 0.0f) { this.maxVisibleDistance = args.visibilityDistance; } var navmeshAgent = this.GetComponentInChildren(); var collider = this.GetComponent(); - if (collider != null && navmeshAgent != null) - { + if (collider != null && navmeshAgent != null) { navmeshAgent.radius = collider.radius; navmeshAgent.height = collider.height; navmeshAgent.transform.localPosition = new Vector3( @@ -636,14 +555,11 @@ BackwardsCompatibleInitializeParams args // navmeshAgent.radius = - if (args.gridSize <= 0 || args.gridSize > 5) - { + if (args.gridSize <= 0 || args.gridSize > 5) { errorMessage = "grid size must be in the range (0,5]"; Debug.Log(errorMessage); return new ActionFinished(success: false, errorMessage: errorMessage); - } - else - { + } else { gridSize = args.gridSize; // Don't know what this was for @@ -666,8 +582,7 @@ BackwardsCompatibleInitializeParams args return new ActionFinished( success: true, - actionReturn: new InitializeReturn - { + actionReturn: new InitializeReturn { cameraNearPlane = m_Camera.nearClipPlane, cameraFarPlane = m_Camera.farClipPlane } @@ -682,8 +597,7 @@ public ActionFinished Initialize( Vector3? colliderScaleRatio = null, bool useAbsoluteSize = false, bool useVisibleColliderBase = false - ) - { + ) { this.visibilityScheme = VisibilityScheme.Distance; var actionFinished = this.InitializeBody( bodyAsset: bodyAsset, @@ -705,16 +619,14 @@ public ActionFinished InitializeBody( Vector3? colliderScaleRatio = null, bool useAbsoluteSize = false, bool useVisibleColliderBase = false - ) - { + ) { // if using no source body mesh, we default to using absolute size via the colliderScaleRatio // since a non absolute size doesn't make sense if we have no default mesh size to base the scale // ratio on Vector3 meshScaleRatio = colliderScaleRatio.GetValueOrDefault(Vector3.one); bool noMesh = false; - if (bodyAsset == null) - { + if (bodyAsset == null) { useAbsoluteSize = true; noMesh = true; } @@ -729,21 +641,18 @@ public ActionFinished InitializeBody( //remove any old copied meshes or generated colliders from previous fpin agent now destroyAgentBoxCollider(); - if (fpinVisibilityCapsule != null) - { + if (fpinVisibilityCapsule != null) { UnityEngine.Object.DestroyImmediate(fpinVisibilityCapsule); } var spawnAssetActionFinished = new ActionFinished(); Bounds meshBoundsWorld = new Bounds(this.transform.position, Vector3.zero); - if (bodyAsset != null) - { + if (bodyAsset != null) { //spawn in a default mesh in an out-of-the-way location (currently 200,200,200) to base the new bounds on spawnAssetActionFinished = spawnBodyAsset(bodyAsset, out GameObject spawnedMesh); // Return early if spawn failed - if (!spawnAssetActionFinished.success) - { + if (!spawnAssetActionFinished.success) { return spawnAssetActionFinished; } @@ -759,18 +668,13 @@ public ActionFinished InitializeBody( // so we'll take the bounds-center of the first meshRenderer MeshRenderer[] meshRenderers = topMeshTransform.gameObject.GetComponentsInChildren(); - foreach (MeshRenderer mr in meshRenderers) - { + foreach (MeshRenderer mr in meshRenderers) { // No need to run TransformedMeshRendererVertices if the meshRenderer's GameObject isn't rotated - if (mr.transform.eulerAngles.magnitude < 1e-4f) - { + if (mr.transform.eulerAngles.magnitude < 1e-4f) { meshBoundsWorld.Encapsulate(mr.bounds); - } - else - { + } else { HashSet vertices = TransformedMeshRendererVertices(mr); - foreach (Vector3 vertex in vertices) - { + foreach (Vector3 vertex in vertices) { meshBoundsWorld.Encapsulate(vertex); } } @@ -781,17 +685,14 @@ public ActionFinished InitializeBody( topMeshTransform.position = meshBoundsWorld.center; topMeshTransform.GetChild(0).position = currentTopMeshTransformChildPos; - if (useAbsoluteSize) - { + if (useAbsoluteSize) { topMeshTransform.localScale = new Vector3( meshScaleRatio.x / meshBoundsWorld.size.x, meshScaleRatio.y / meshBoundsWorld.size.y, meshScaleRatio.z / meshBoundsWorld.size.z ); meshBoundsWorld.size = meshScaleRatio; - } - else - { + } else { topMeshTransform.localScale = meshScaleRatio; meshBoundsWorld.size = new Vector3( meshScaleRatio.x * meshBoundsWorld.size.x, @@ -810,18 +711,14 @@ public ActionFinished InitializeBody( this.transform.position + Vector3.up * meshBoundsWorld.extents.y; // remove the spawned mesh cause we are done with it - foreach (var sop in spawnedMesh.GetComponentsInChildren()) - { + foreach (var sop in spawnedMesh.GetComponentsInChildren()) { agentManager.physicsSceneManager.RemoveFromObjectsInScene(sop); } - if (spawnedMesh.activeInHierarchy) - { + if (spawnedMesh.activeInHierarchy) { UnityEngine.Object.DestroyImmediate(spawnedMesh); } - } - else - { + } else { meshBoundsWorld = new Bounds( this.transform.position + (Vector3.up * meshScaleRatio.y / 2), meshScaleRatio @@ -836,8 +733,7 @@ public ActionFinished InitializeBody( // set reference to the meshes so the base agent and fpin agent are happy VisibilityCapsule = fpinVisibilityCapsule = viscap; - if (topMeshTransform != null) - { + if (topMeshTransform != null) { topMeshTransform.SetParent(viscap.transform); } @@ -853,8 +749,7 @@ public ActionFinished InitializeBody( ); // spawn the visible collider base if we need to - if (useVisibleColliderBase) - { + if (useVisibleColliderBase) { GameObject visibleBase = GameObject.CreatePrimitive(PrimitiveType.Cube); visibleBase.name = "visibleBase"; visibleBase.GetComponent().enabled = false; @@ -966,8 +861,7 @@ public ActionFinished InitializeBody( originalRotation, checkBoxLayerMask ) - ) - { + ) { this.transform.position = originalPosition; this.transform.rotation = originalRotation; string error = @@ -989,10 +883,8 @@ public ActionFinished InitializeBody( fpinMovable = new FpinMovableContinuous(this.GetComponentInParent()); // we had a body asset used, so actionFinished returns info related to that - if (bodyAsset != null) - { - return new ActionFinished(spawnAssetActionFinished) - { + if (bodyAsset != null) { + return new ActionFinished(spawnAssetActionFinished) { // TODO: change to a proper class once metadata return is defined actionReturn = new Dictionary() { @@ -1006,11 +898,8 @@ spawnAssetActionFinished.actionReturn as ObjectSphereBounds { "cameraFarPlane", m_Camera.farClipPlane } } }; - } - else - { - return new ActionFinished() - { + } else { + return new ActionFinished() { // TODO: change to a proper class once metadata return is defined actionReturn = new Dictionary() { @@ -1022,18 +911,14 @@ spawnAssetActionFinished.actionReturn as ObjectSphereBounds } } - private ActionFinished spawnBodyAsset(BodyAsset bodyAsset, out GameObject spawnedMesh) - { - if (bodyAsset == null) - { + private ActionFinished spawnBodyAsset(BodyAsset bodyAsset, out GameObject spawnedMesh) { + if (bodyAsset == null) { throw new ArgumentNullException("bodyAsset is null"); - } - else if ( - bodyAsset.assetId == null - && bodyAsset.dynamicAsset == null - && bodyAsset.asset == null - ) - { + } else if ( + bodyAsset.assetId == null + && bodyAsset.dynamicAsset == null + && bodyAsset.asset == null + ) { throw new ArgumentNullException( "`bodyAsset.assetId`, `bodyAsset.dynamicAsset` or `bodyAsset.asset` must be provided all are null." ); @@ -1047,8 +932,7 @@ private ActionFinished spawnBodyAsset(BodyAsset bodyAsset, out GameObject spawne if ( (bodyAsset.dynamicAsset != null || bodyAsset.asset != null) && bodyAsset.assetId == null - ) - { + ) { var id = bodyAsset.dynamicAsset != null ? bodyAsset.dynamicAsset.id @@ -1056,24 +940,20 @@ private ActionFinished spawnBodyAsset(BodyAsset bodyAsset, out GameObject spawne var assetMap = ProceduralTools.getAssetMap(); // Check if asset is in AssetDatabase already - if (assetMap.ContainsKey(id)) - { + if (assetMap.ContainsKey(id)) { Debug.Log("------- Already contains key"); bodyAsset.assetId = id; } } - if (bodyAsset.assetId != null) - { + if (bodyAsset.assetId != null) { actionFinished = SpawnAsset( bodyAsset.assetId, "agentMesh", new Vector3(200f, 200f, 200f) ); spawnedMesh = GameObject.Find("agentMesh"); - } - else if (bodyAsset.dynamicAsset != null) - { + } else if (bodyAsset.dynamicAsset != null) { actionFinished = this.CreateRuntimeAsset( id: bodyAsset.dynamicAsset.id, dir: bodyAsset.dynamicAsset.dir, @@ -1082,9 +962,7 @@ private ActionFinished spawnBodyAsset(BodyAsset bodyAsset, out GameObject spawne serializable: true ); spawnedMesh = GameObject.Find("mesh"); - } - else if (bodyAsset.asset != null) - { + } else if (bodyAsset.asset != null) { bodyAsset.asset.serializable = true; actionFinished = this.CreateRuntimeAsset(asset: bodyAsset.asset); } @@ -1092,8 +970,7 @@ private ActionFinished spawnBodyAsset(BodyAsset bodyAsset, out GameObject spawne if ( bodyAsset.assetId == null && (bodyAsset.dynamicAsset != null || bodyAsset.asset != null) - ) - { + ) { var id = bodyAsset.dynamicAsset != null ? bodyAsset.dynamicAsset.id @@ -1101,8 +978,7 @@ private ActionFinished spawnBodyAsset(BodyAsset bodyAsset, out GameObject spawne Debug.Log( $"-- checks {bodyAsset.assetId == null} {bodyAsset.dynamicAsset != null} {bodyAsset.asset != null} " ); - if (!actionFinished.success || actionFinished.actionReturn == null) - { + if (!actionFinished.success || actionFinished.actionReturn == null) { return new ActionFinished( success: false, errorMessage: $"Could not create asset `{bodyAsset.dynamicAsset}` error: {actionFinished.errorMessage}" @@ -1115,8 +991,7 @@ private ActionFinished spawnBodyAsset(BodyAsset bodyAsset, out GameObject spawne return actionFinished; } - protected override LayerMask GetVisibilityRaycastLayerMask(bool withSimObjInvisible = false) - { + protected override LayerMask GetVisibilityRaycastLayerMask(bool withSimObjInvisible = false) { // No agent because camera can be in the path of colliders string[] layers = new string[] { @@ -1126,8 +1001,7 @@ protected override LayerMask GetVisibilityRaycastLayerMask(bool withSimObjInvisi "Procedural3", "Procedural0" //, "Agent" }; - if (withSimObjInvisible) - { + if (withSimObjInvisible) { layers = layers.Append("SimObjInvisible").ToArray(); } return LayerMask.GetMask(layers); @@ -1140,8 +1014,7 @@ public override void TeleportFull( float? horizon = null, bool? standing = null, bool forceAction = false - ) - { + ) { teleportFull( position: position, rotation: rotation, @@ -1155,8 +1028,7 @@ protected override void teleportFull( Vector3? rotation, float? horizon, bool forceAction - ) - { + ) { //Debug.Log($"what even is the position passed in at the start? {position:F8}"); if ( rotation.HasValue @@ -1164,8 +1036,7 @@ bool forceAction !Mathf.Approximately(rotation.Value.x, 0f) || !Mathf.Approximately(rotation.Value.z, 0f) ) - ) - { + ) { throw new ArgumentOutOfRangeException( "No agents currently can change in pitch or roll. So, you must set rotation(x=0, y=yaw, z=0)." + $" You gave {rotation.Value.ToString("F6")}." @@ -1177,8 +1048,7 @@ bool forceAction !forceAction && horizon.HasValue && (horizon.Value > maxDownwardLookAngle || horizon.Value < -maxUpwardLookAngle) - ) - { + ) { throw new ArgumentOutOfRangeException( $"Each horizon must be in [{-maxUpwardLookAngle}:{maxDownwardLookAngle}]. You gave {horizon}." ); @@ -1188,15 +1058,13 @@ bool forceAction !forceAction && position.HasValue && !agentManager.SceneBounds.Contains(position.Value) - ) - { + ) { throw new ArgumentOutOfRangeException( $"Teleport position {position.Value.ToString("F6")} out of scene bounds! Ignore this by setting forceAction=true." ); } - if (!forceAction && position.HasValue && !isPositionOnGrid(position.Value)) - { + if (!forceAction && position.HasValue && !isPositionOnGrid(position.Value)) { throw new ArgumentOutOfRangeException( $"Teleport position {position.Value.ToString("F6")} is not on the grid of size {gridSize}." ); @@ -1225,15 +1093,13 @@ bool forceAction targetPosition: position.GetValueOrDefault(transform.position) ); - if (!forceAction) - { + if (!forceAction) { if ( isAgentCapsuleColliding( collidersToIgnore: collidersToIgnoreDuringMovement, includeErrorMessage: true ) - ) - { + ) { transform.position = oldPosition; transform.rotation = oldRotation; autoSyncTransforms(); @@ -1247,8 +1113,7 @@ bool forceAction collidersToIgnore: collidersToIgnoreDuringMovement, includeErrorMessage: true ) - ) - { + ) { transform.position = oldPosition; transform.rotation = oldRotation; autoSyncTransforms(); @@ -1260,11 +1125,9 @@ bool forceAction actionFinished(success: true); } - protected override void assertTeleportedNearGround(Vector3? targetPosition) - { + protected override void assertTeleportedNearGround(Vector3? targetPosition) { // position should not change if it's null. - if (targetPosition == null) - { + if (targetPosition == null) { return; } @@ -1279,8 +1142,7 @@ protected override void assertTeleportedNearGround(Vector3? targetPosition) autoSyncTransforms(); // perhaps like y=2 was specified, with an agent's standing height of 0.9 - if (Mathf.Abs(transform.position.y - pos.y) > 1.0f) - { + if (Mathf.Abs(transform.position.y - pos.y) > 1.0f) { throw new InvalidOperationException( "After teleporting and adjusting agent position to floor, there was too large a change." + " This may be due to the target teleport coordinates causing the agent to fall through the floor." @@ -1294,10 +1156,8 @@ public IEnumerator MoveAgent( float ahead = 0, float right = 0, float speed = 1 - ) - { - if (ahead == 0 && right == 0) - { + ) { + if (ahead == 0 && right == 0) { throw new ArgumentException("Must specify ahead or right!"); } Vector3 direction = new Vector3(x: right, y: 0, z: ahead); @@ -1325,8 +1185,7 @@ public IEnumerator MoveAhead( float? moveMagnitude = null, float speed = 1, bool returnToStart = true - ) - { + ) { return MoveAgent( ahead: moveMagnitude.GetValueOrDefault(gridSize), speed: speed, @@ -1338,8 +1197,7 @@ public IEnumerator MoveBack( float? moveMagnitude = null, float speed = 1, bool returnToStart = true - ) - { + ) { return MoveAgent( ahead: -moveMagnitude.GetValueOrDefault(gridSize), speed: speed, @@ -1351,8 +1209,7 @@ public IEnumerator MoveRight( float? moveMagnitude = null, float speed = 1, bool returnToStart = true - ) - { + ) { return MoveAgent( right: moveMagnitude.GetValueOrDefault(gridSize), speed: speed, @@ -1364,8 +1221,7 @@ public IEnumerator MoveLeft( float? moveMagnitude = null, float speed = 1, bool returnToStart = true - ) - { + ) { return MoveAgent( right: -moveMagnitude.GetValueOrDefault(gridSize), speed: speed, @@ -1377,8 +1233,7 @@ public IEnumerator RotateRight( float? degrees = null, float speed = 1.0f, bool returnToStart = true - ) - { + ) { return RotateAgent( degrees: degrees.GetValueOrDefault(rotateStepDegrees), speed: speed, @@ -1390,8 +1245,7 @@ public IEnumerator RotateLeft( float? degrees = null, float speed = 1.0f, bool returnToStart = true - ) - { + ) { return RotateAgent( degrees: -degrees.GetValueOrDefault(rotateStepDegrees), speed: speed, @@ -1403,8 +1257,7 @@ public virtual IEnumerator RotateAgent( float degrees, float speed = 1.0f, bool returnToStart = true - ) - { + ) { CollisionListener collisionListener = fpinMovable.collisionListener; collisionListener.Reset(); diff --git a/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs b/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs index c5f73d8cd3..1a5094233a 100644 --- a/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs +++ b/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs @@ -6112,13 +6112,11 @@ public void RotateUniverseAroundAgent(ServerAction action) { actionFinished(true); } - public void ChangeFOV(float fieldOfView, string camera = "") { + public ActionFinished ChangeFOV(float fieldOfView, string camera = "") { if (fieldOfView > 0 && fieldOfView < 180) { if (string.IsNullOrEmpty(camera)) { - agentManager.UpdateMainCamera( - fieldOfView: fieldOfView - ); - actionFinished(true); + agentManager.UpdateMainCamera(fieldOfView: fieldOfView); + return ActionFinished.Success; } else { var cameraTuples = new List<(Camera camera, bool isThirdPartyCamera, int id)>() { @@ -6136,28 +6134,33 @@ public void ChangeFOV(float fieldOfView, string camera = "") { if (matches.Count() == 0) { errorMessage = $"Camera '{camera}' is not present in the agent, make sure the agent was initialized correctly or camera was added via 'AddThirdPartyCamera'."; - actionFinished(false); + return ActionFinished.Fail; } else { - foreach (var tuple in matches) { - if (tuple.isThirdPartyCamera) { - agentManager.UpdateThirdPartyCamera( - tuple.id, - fieldOfView: fieldOfView - ); - } else { - agentManager.UpdateMainCamera( - fieldOfView: fieldOfView - ); - } - } - actionFinished(true); + return matches + .Select(tuple => + tuple.isThirdPartyCamera + ? agentManager.UpdateThirdPartyCamera( + tuple.id, + fieldOfView: fieldOfView + ) + : agentManager.UpdateMainCamera(fieldOfView: fieldOfView) + ) + .Where(actionFinish => actionFinish.success) + .Aggregate( + ActionFinished.Success, + (aggregateActionFinished, singleActionFinish) => + new ActionFinished( + success: aggregateActionFinished.success + && singleActionFinish.success, + errorMessage: $"{aggregateActionFinished.errorMessage}\n{singleActionFinish}" + ) + ); } } - } else { - errorMessage = "fov must be in (0, 180) noninclusive."; - Debug.Log(errorMessage); - actionFinished(false); } + errorMessage = "fov must be in (0, 180) noninclusive."; + Debug.Log(errorMessage); + return new ActionFinished(success: false, errorMessage: errorMessage); } // in case you want to change the timescale From 57aa216686d215f75abe572ea0c42aa844c5f28f Mon Sep 17 00:00:00 2001 From: AlvaroHG Date: Wed, 14 Aug 2024 16:55:40 -0700 Subject: [PATCH 3/7] Action finish fix --- unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs b/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs index 1a5094233a..2931007aa2 100644 --- a/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs +++ b/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs @@ -6145,7 +6145,6 @@ public ActionFinished ChangeFOV(float fieldOfView, string camera = "") { ) : agentManager.UpdateMainCamera(fieldOfView: fieldOfView) ) - .Where(actionFinish => actionFinish.success) .Aggregate( ActionFinished.Success, (aggregateActionFinished, singleActionFinish) => From 2486b9e3c44d0cf07431acb012a987fb4c7f835f Mon Sep 17 00:00:00 2001 From: AlvaroHG Date: Wed, 14 Aug 2024 16:56:46 -0700 Subject: [PATCH 4/7] message fix --- unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs b/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs index 2931007aa2..9e1efafb8c 100644 --- a/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs +++ b/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs @@ -6151,7 +6151,7 @@ public ActionFinished ChangeFOV(float fieldOfView, string camera = "") { new ActionFinished( success: aggregateActionFinished.success && singleActionFinish.success, - errorMessage: $"{aggregateActionFinished.errorMessage}\n{singleActionFinish}" + errorMessage: $"{aggregateActionFinished.errorMessage}\n{singleActionFinish.errorMessage}" ) ); } From afa8a3328009a4e346db6ac8a0b772fa1021ce82 Mon Sep 17 00:00:00 2001 From: AlvaroHG Date: Tue, 20 Aug 2024 15:07:00 -0700 Subject: [PATCH 5/7] Making ChangeFOV deprecated --- unity/Assets/Scripts/DebugInputField.cs | 36 ++++++++----- .../PhysicsRemoteFPSAgentController.cs | 54 +++---------------- 2 files changed, 31 insertions(+), 59 deletions(-) diff --git a/unity/Assets/Scripts/DebugInputField.cs b/unity/Assets/Scripts/DebugInputField.cs index 0fc77e4c08..da23929c0c 100644 --- a/unity/Assets/Scripts/DebugInputField.cs +++ b/unity/Assets/Scripts/DebugInputField.cs @@ -619,6 +619,30 @@ public void Execute(string command) { ActionDispatcher.Dispatch(AManager, new DynamicServerAction(action)); //CurrentActiveController().ProcessControlCommand(new DynamicServerAction(action), AManager); + break; + } + case "initpinnobody2": { + Dictionary action = new Dictionary(); + + action["action"] = "Initialize"; + action["agentMode"] = "fpin"; + action["visibilityScheme"] = "Distance"; + action["renderInstanceSegmentation"] = true; + action["renderDepth"] = true; + + action[DynamicServerAction.agentInitializationParamsVariable] = new Dictionary< + string, + object + >() + { + { "originOffsetX", 0.2f }, + { "originOffsetZ", 0.4f }, + { "colliderScaleRatio", new Vector3(0.8f, 1.2f, 0.5f) }, + { "useVisibleColliderBase", true }, + { "useAbsoluteSize", true } + }; + AManager.Initialize((new DynamicServerAction(action)).ToObject()); + break; } @@ -3165,18 +3189,6 @@ IEnumerator executeBatch(JArray jActions) { CurrentActiveController().ProcessControlCommand(action); break; } - - case "fov": { - Dictionary comm = new Dictionary(); - comm["action"] = "ChangeFOV"; - comm["fieldOfView"] = float.Parse(splitcommand[1]); - if (splitcommand.Length > 2) { - comm["camera"] = splitcommand[2]; - } - - CurrentActiveController().ProcessControlCommand(comm); - break; - } case "teles": { ServerAction action = new ServerAction(); action.action = "TeleportFull"; diff --git a/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs b/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs index 9e1efafb8c..ab0d615f5d 100644 --- a/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs +++ b/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs @@ -6112,54 +6112,14 @@ public void RotateUniverseAroundAgent(ServerAction action) { actionFinished(true); } + [ObsoleteAttribute( + message: "This action is deprecated. Use `UpdateMainCamera` or `UpdateThirdPartyCamera` instead.", + error: true + )] public ActionFinished ChangeFOV(float fieldOfView, string camera = "") { - if (fieldOfView > 0 && fieldOfView < 180) { - if (string.IsNullOrEmpty(camera)) { - agentManager.UpdateMainCamera(fieldOfView: fieldOfView); - return ActionFinished.Success; - } else { - var cameraTuples = new List<(Camera camera, bool isThirdPartyCamera, int id)>() - { - (camera: m_Camera, isThirdPartyCamera: false, id: -1) - }.Concat( - this.agentManager.thirdPartyCameras.Select( - (c, i) => (camera: c, isThirdPartyCamera: true, id: i) - ) - ); - var matches = cameraTuples; - if (camera != "*") { - matches = cameraTuples.Where(t => t.camera.name == camera); - } - // Debug.Log($"Camera matches: {matches.Count()} {string.Join(", ", matches.Select(m => m.camera.name))}"); - if (matches.Count() == 0) { - errorMessage = - $"Camera '{camera}' is not present in the agent, make sure the agent was initialized correctly or camera was added via 'AddThirdPartyCamera'."; - return ActionFinished.Fail; - } else { - return matches - .Select(tuple => - tuple.isThirdPartyCamera - ? agentManager.UpdateThirdPartyCamera( - tuple.id, - fieldOfView: fieldOfView - ) - : agentManager.UpdateMainCamera(fieldOfView: fieldOfView) - ) - .Aggregate( - ActionFinished.Success, - (aggregateActionFinished, singleActionFinish) => - new ActionFinished( - success: aggregateActionFinished.success - && singleActionFinish.success, - errorMessage: $"{aggregateActionFinished.errorMessage}\n{singleActionFinish.errorMessage}" - ) - ); - } - } - } - errorMessage = "fov must be in (0, 180) noninclusive."; - Debug.Log(errorMessage); - return new ActionFinished(success: false, errorMessage: errorMessage); + throw new InvalidOperationException( + "This action is deprecated. Use `UpdateMainCamera` or `UpdateThirdPartyCamera` instead." + ); } // in case you want to change the timescale From 8416a09c0a6b97eb1abd5e99f32e1ba5159cee8a Mon Sep 17 00:00:00 2001 From: AlvaroHG Date: Tue, 20 Aug 2024 15:09:02 -0700 Subject: [PATCH 6/7] Removes extra debug action --- unity/Assets/Scripts/DebugInputField.cs | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/unity/Assets/Scripts/DebugInputField.cs b/unity/Assets/Scripts/DebugInputField.cs index da23929c0c..c751d407e3 100644 --- a/unity/Assets/Scripts/DebugInputField.cs +++ b/unity/Assets/Scripts/DebugInputField.cs @@ -621,31 +621,6 @@ public void Execute(string command) { break; } - case "initpinnobody2": { - Dictionary action = new Dictionary(); - - action["action"] = "Initialize"; - action["agentMode"] = "fpin"; - action["visibilityScheme"] = "Distance"; - action["renderInstanceSegmentation"] = true; - action["renderDepth"] = true; - - action[DynamicServerAction.agentInitializationParamsVariable] = new Dictionary< - string, - object - >() - { - { "originOffsetX", 0.2f }, - { "originOffsetZ", 0.4f }, - { "colliderScaleRatio", new Vector3(0.8f, 1.2f, 0.5f) }, - { "useVisibleColliderBase", true }, - { "useAbsoluteSize", true } - }; - AManager.Initialize((new DynamicServerAction(action)).ToObject()); - - break; - } - //fpin using stretch bot as source mesh case "initpins": { Dictionary action = new Dictionary(); From e20479ab7ad9920bc2e72a95f5846a592c434e10 Mon Sep 17 00:00:00 2001 From: AlvaroHG Date: Tue, 20 Aug 2024 18:50:12 -0700 Subject: [PATCH 7/7] Fpin ffrom main --- unity/Assets/Scripts/FpinAgentController.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/unity/Assets/Scripts/FpinAgentController.cs b/unity/Assets/Scripts/FpinAgentController.cs index fef0ebaef1..c97ac47e5c 100644 --- a/unity/Assets/Scripts/FpinAgentController.cs +++ b/unity/Assets/Scripts/FpinAgentController.cs @@ -885,6 +885,7 @@ public ActionFinished InitializeBody( // we had a body asset used, so actionFinished returns info related to that if (bodyAsset != null) { return new ActionFinished(spawnAssetActionFinished) { + success = true, // TODO: change to a proper class once metadata return is defined actionReturn = new Dictionary() { @@ -899,8 +900,8 @@ spawnAssetActionFinished.actionReturn as ObjectSphereBounds } }; } else { - return new ActionFinished() - { + return new ActionFinished( + success: true, // TODO: change to a proper class once metadata return is defined actionReturn: new Dictionary() {