diff --git a/unity/Assets/Scripts/AgentManager.cs b/unity/Assets/Scripts/AgentManager.cs index 36d2070205..b3dc6c1a97 100644 --- a/unity/Assets/Scripts/AgentManager.cs +++ b/unity/Assets/Scripts/AgentManager.cs @@ -1310,17 +1310,22 @@ bool shouldRenderImageSynthesis if (camera.transform.parent != null) { cMetadata.parentObjectName = camera.transform.parent.name; - cMetadata.parentRelativeThirdPartyCameraPosition = - camera.transform.localPosition; + cMetadata.parentRelativeThirdPartyCameraPosition = camera + .transform + .localPosition; //get third party camera rotation as quaternion in parent space - cMetadata.parentRelativeThirdPartyCameraRotation = - camera.transform.localEulerAngles; + cMetadata.parentRelativeThirdPartyCameraRotation = camera + .transform + .localEulerAngles; } else { //if not parented, default position and rotation to world coordinate space cMetadata.parentObjectName = ""; cMetadata.parentRelativeThirdPartyCameraPosition = camera.transform.position; - cMetadata.parentRelativeThirdPartyCameraRotation = camera.transform.rotation.eulerAngles; + cMetadata.parentRelativeThirdPartyCameraRotation = camera + .transform + .rotation + .eulerAngles; } //if this camera is part of the agent's hierarchy at all, get agent relative info @@ -1337,7 +1342,7 @@ bool shouldRenderImageSynthesis agentSpaceCameraRotationAsQuaternion.eulerAngles; } else { //if this third party camera is not a child of the agent, we don't need agent-relative coordinates - //Note: We don't default this to world space because in the case of a multi-agent scenario, the agent + //Note: We don't default this to world space because in the case of a multi-agent scenario, the agent //to be relative to is ambiguous and UHHHHH cMetadata.agentRelativeThirdPartyCameraPosition = null; cMetadata.agentRelativeThirdPartyCameraRotation = null; diff --git a/unity/Assets/Scripts/ArmAgentController.cs b/unity/Assets/Scripts/ArmAgentController.cs index f851d2caf9..de21938e37 100644 --- a/unity/Assets/Scripts/ArmAgentController.cs +++ b/unity/Assets/Scripts/ArmAgentController.cs @@ -274,9 +274,9 @@ public override void Teleport( bool forceAction = false ) { //non-high level agents cannot set standing - if(standing != null) { + if (standing != null) { errorMessage = "Cannot set standing for arm/stretch agent"; - actionFinishedEmit(success:false, actionReturn:null, errorMessage:errorMessage); + actionFinishedEmit(success: false, actionReturn: null, errorMessage: errorMessage); return; } @@ -290,19 +290,19 @@ public override void Teleport( } public override void TeleportFull( - Vector3? position = null, - Vector3? rotation = null, - float? horizon = null, - bool? standing = null, + Vector3? position = null, + Vector3? rotation = null, + float? horizon = null, + bool? standing = null, bool forceAction = false ) { //non-high level agents cannot set standing - if(standing != null) { + if (standing != null) { errorMessage = "Cannot set standing for arm/stretch agent"; - actionFinishedEmit(success:false, actionReturn:null, errorMessage:errorMessage); + actionFinishedEmit(success: false, actionReturn: null, errorMessage: errorMessage); return; } - + //cache old values in case there is a failure Vector3 oldPosition = transform.position; Quaternion oldRotation = transform.rotation; @@ -315,7 +315,7 @@ public override void TeleportFull( horizon: horizon, forceAction: forceAction ); - + // add arm value cases if (!forceAction) { if (Arm != null && Arm.IsArmColliding()) { @@ -329,7 +329,6 @@ public override void TeleportFull( } base.assertTeleportedNearGround(targetPosition: position); } - } catch (InvalidOperationException e) { transform.position = oldPosition; transform.rotation = oldRotation; diff --git a/unity/Assets/Scripts/DiscreteHidenSeekAgentController.cs b/unity/Assets/Scripts/DiscreteHidenSeekAgentController.cs index 43c4f575da..6d4deb2c37 100644 --- a/unity/Assets/Scripts/DiscreteHidenSeekAgentController.cs +++ b/unity/Assets/Scripts/DiscreteHidenSeekAgentController.cs @@ -268,7 +268,7 @@ void Update() { if (wasStanding == true) { action.action = "Crouch"; PhysicsController.ProcessControlCommand(action); - } else if(wasStanding == false) { + } else if (wasStanding == false) { action.action = "Stand"; PhysicsController.ProcessControlCommand(action); } diff --git a/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs b/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs index ff3a92003c..8f91afd3b5 100644 --- a/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs +++ b/unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs @@ -174,27 +174,30 @@ public void SetMassProperties(string objectId, float mass, float drag, float ang } public bool? isStanding() { - //default to not standing if this isn't literally the PhysicsRemoteFPSAgentController //this means the metadat for isStanding should always be false for all derived classes - if (this.GetType() != typeof(PhysicsRemoteFPSAgentController)) - { + if (this.GetType() != typeof(PhysicsRemoteFPSAgentController)) { return null; } //if camera is in neither the standing or crouching predetermined locations, return null - if(UtilityFunctions.ArePositionsApproximatelyEqual(m_Camera.transform.localPosition, standingLocalCameraPosition) == true) { + if ( + UtilityFunctions.ArePositionsApproximatelyEqual( + m_Camera.transform.localPosition, + standingLocalCameraPosition + ) == true + ) { return true; - } - - else if(UtilityFunctions.ArePositionsApproximatelyEqual(m_Camera.transform.localPosition, crouchingLocalCameraPosition) == true) { + } else if ( + UtilityFunctions.ArePositionsApproximatelyEqual( + m_Camera.transform.localPosition, + crouchingLocalCameraPosition + ) == true + ) { return false; - } - - else { + } else { return null; } - } public override MetadataWrapper generateMetadataWrapper() { @@ -2343,7 +2346,7 @@ public bool CheckIfItemBlocksAgentStandOrCrouch() { bool? standState = isStanding(); if (standState == true) { dir = new Vector3(0.0f, -1f, 0.0f); - } else if (standState == false){ + } else if (standState == false) { dir = new Vector3(0.0f, 1f, 0.0f); } @@ -6374,7 +6377,7 @@ SimObjPhysics sop in GetAllVisibleSimObjPhysics( if (wasStanding == true) { stand(); - } else if(wasStanding == false){ + } else if (wasStanding == false) { crouch(); } transform.position = oldPosition; @@ -6638,7 +6641,7 @@ public virtual List> getInteractablePoses( // restore old agent pose if (wasStanding == true) { stand(); - } else if(wasStanding == false) { + } else if (wasStanding == false) { crouch(); } SetTransform( diff --git a/unity/Assets/UnitTests/TestThirdPartyCameraAndMainCamera.cs b/unity/Assets/UnitTests/TestThirdPartyCameraAndMainCamera.cs index 0332d494b0..098a25c202 100644 --- a/unity/Assets/UnitTests/TestThirdPartyCameraAndMainCamera.cs +++ b/unity/Assets/UnitTests/TestThirdPartyCameraAndMainCamera.cs @@ -524,7 +524,7 @@ public IEnumerator TestThirdPartyCameraMetadataReturn() metadata.thirdPartyCameras[0].parentRelativeThirdPartyCameraRotation.z, 30.0000000000f ); - Assert.AreEqual(result, true); + Assert.AreEqual(result, true); Assert.AreEqual(metadata.thirdPartyCameras[0].parentObjectName, ""); action.Clear(); @@ -611,50 +611,32 @@ public IEnumerator TestThirdPartyCameraMetadataReturn() ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata - .thirdPartyCameras[0] - .parentRelativeThirdPartyCameraPosition - .x, + metadata.thirdPartyCameras[0].parentRelativeThirdPartyCameraPosition.x, 1.0000000000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata - .thirdPartyCameras[0] - .parentRelativeThirdPartyCameraPosition - .y, + metadata.thirdPartyCameras[0].parentRelativeThirdPartyCameraPosition.y, 2.0000000000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata - .thirdPartyCameras[0] - .parentRelativeThirdPartyCameraPosition - .z, + metadata.thirdPartyCameras[0].parentRelativeThirdPartyCameraPosition.z, 3.0000020000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata - .thirdPartyCameras[0] - .parentRelativeThirdPartyCameraRotation - .x, + metadata.thirdPartyCameras[0].parentRelativeThirdPartyCameraRotation.x, 20.0000000000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata - .thirdPartyCameras[0] - .parentRelativeThirdPartyCameraRotation - .y, + metadata.thirdPartyCameras[0].parentRelativeThirdPartyCameraRotation.y, 20.0000000000f ); Assert.AreEqual(result, true); result = Mathf.Approximately( - metadata - .thirdPartyCameras[0] - .parentRelativeThirdPartyCameraRotation - .z, + metadata.thirdPartyCameras[0].parentRelativeThirdPartyCameraRotation.z, 20.0000000000f ); Assert.AreEqual(result, true);