From 7675df8eb9829501a3bcf42dc00d447be1943e56 Mon Sep 17 00:00:00 2001 From: Eli VanderBilt Date: Tue, 7 Dec 2021 14:51:41 -0800 Subject: [PATCH 1/5] Changed Stretch Agent's secondary camera to update its imagesynthesis without caching anything --- unity/Assets/Scripts/BaseFPSAgentController.cs | 2 -- unity/Assets/Scripts/StretchAgentController.cs | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/unity/Assets/Scripts/BaseFPSAgentController.cs b/unity/Assets/Scripts/BaseFPSAgentController.cs index edeaa51229..d5bc6b682c 100644 --- a/unity/Assets/Scripts/BaseFPSAgentController.cs +++ b/unity/Assets/Scripts/BaseFPSAgentController.cs @@ -142,7 +142,6 @@ public GameObject[] TargetCircles { protected bool snapToGrid; protected bool continuousMode;// deprecated, use snapToGrid instead public ImageSynthesis imageSynthesis; - // public bool enableImageSynthesis; private bool isVisible = true; public bool inHighFrictionArea = false; // outbound object filter @@ -619,7 +618,6 @@ public void Initialize(ServerAction action) { if (action.renderDepthImage || action.renderSemanticSegmentation || action.renderInstanceSegmentation || action.renderNormalsImage) { this.updateImageSynthesis(true); - // enableImageSynthesis = true; } if (action.visibilityDistance > 0.0f) { diff --git a/unity/Assets/Scripts/StretchAgentController.cs b/unity/Assets/Scripts/StretchAgentController.cs index b348984e77..048c3fdb23 100644 --- a/unity/Assets/Scripts/StretchAgentController.cs +++ b/unity/Assets/Scripts/StretchAgentController.cs @@ -44,9 +44,9 @@ public override void InitializeBody() { fp_camera_2.transform.localEulerAngles = new Vector3(45f, 90f, 0f); fp_camera_2.fieldOfView = 60f; agentManager.registerAsThirdPartyCamera(fp_camera_2); - // if (enableImageSynthesis) { + if (imageSynthesis.enabled) { agentManager.updateThirdPartyCameraImageSynthesis(true); - // } + } // limit camera from looking too far down this.maxDownwardLookAngle = 90f; From 37bc4dc41f8fa140507e5281a8817f61f38709bf Mon Sep 17 00:00:00 2001 From: Eli VanderBilt Date: Tue, 7 Dec 2021 15:20:35 -0800 Subject: [PATCH 2/5] More direct reference to main camera's image-synthesis activation --- unity/Assets/Scripts/StretchAgentController.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unity/Assets/Scripts/StretchAgentController.cs b/unity/Assets/Scripts/StretchAgentController.cs index 048c3fdb23..e0bcccaed8 100644 --- a/unity/Assets/Scripts/StretchAgentController.cs +++ b/unity/Assets/Scripts/StretchAgentController.cs @@ -44,7 +44,8 @@ public override void InitializeBody() { fp_camera_2.transform.localEulerAngles = new Vector3(45f, 90f, 0f); fp_camera_2.fieldOfView = 60f; agentManager.registerAsThirdPartyCamera(fp_camera_2); - if (imageSynthesis.enabled) { + + if (this.gameObject.GetComponentInChildren().enabled) { agentManager.updateThirdPartyCameraImageSynthesis(true); } From 54353b9b55d38c2d5b8f95972b6f306c1c632d3b Mon Sep 17 00:00:00 2001 From: Eli VanderBilt Date: Tue, 7 Dec 2021 16:41:32 -0800 Subject: [PATCH 3/5] Using override method instead --- unity/Assets/Scripts/BaseFPSAgentController.cs | 2 +- unity/Assets/Scripts/StretchAgentController.cs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/unity/Assets/Scripts/BaseFPSAgentController.cs b/unity/Assets/Scripts/BaseFPSAgentController.cs index d5bc6b682c..d3614a6de4 100644 --- a/unity/Assets/Scripts/BaseFPSAgentController.cs +++ b/unity/Assets/Scripts/BaseFPSAgentController.cs @@ -1787,7 +1787,7 @@ public virtual MetadataWrapper generateMetadataWrapper() { } - public void updateImageSynthesis(bool status) { + public virtual void updateImageSynthesis(bool status) { if (this.imageSynthesis == null) { imageSynthesis = this.gameObject.GetComponentInChildren() as ImageSynthesis; } diff --git a/unity/Assets/Scripts/StretchAgentController.cs b/unity/Assets/Scripts/StretchAgentController.cs index e0bcccaed8..f140d1cea6 100644 --- a/unity/Assets/Scripts/StretchAgentController.cs +++ b/unity/Assets/Scripts/StretchAgentController.cs @@ -13,6 +13,11 @@ public partial class StretchAgentController : PhysicsRemoteFPSAgentController { public StretchAgentController(BaseAgentComponent baseAgentComponent, AgentManager agentManager) : base(baseAgentComponent, agentManager) { } + public override void updateImageSynthesis(bool status) { + base.updateImageSynthesis(status); + agentManager.updateThirdPartyCameraImageSynthesis(true); + } + public override void InitializeBody() { VisibilityCapsule = StretchVisCap; m_CharacterController.center = new Vector3(0, -0.1934924f, -0.1247f); @@ -44,10 +49,6 @@ public override void InitializeBody() { fp_camera_2.transform.localEulerAngles = new Vector3(45f, 90f, 0f); fp_camera_2.fieldOfView = 60f; agentManager.registerAsThirdPartyCamera(fp_camera_2); - - if (this.gameObject.GetComponentInChildren().enabled) { - agentManager.updateThirdPartyCameraImageSynthesis(true); - } // limit camera from looking too far down this.maxDownwardLookAngle = 90f; From 03b26e96a43c83f955386b8cac925d4d2b550837 Mon Sep 17 00:00:00 2001 From: Eli VanderBilt Date: Wed, 8 Dec 2021 11:31:05 -0800 Subject: [PATCH 4/5] Added context to updateThirdPartyCameraImageSynthesis, and made it parameter-dependent --- unity/Assets/Scripts/StretchAgentController.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/unity/Assets/Scripts/StretchAgentController.cs b/unity/Assets/Scripts/StretchAgentController.cs index f140d1cea6..470f03a553 100644 --- a/unity/Assets/Scripts/StretchAgentController.cs +++ b/unity/Assets/Scripts/StretchAgentController.cs @@ -15,7 +15,13 @@ public StretchAgentController(BaseAgentComponent baseAgentComponent, AgentManage public override void updateImageSynthesis(bool status) { base.updateImageSynthesis(status); - agentManager.updateThirdPartyCameraImageSynthesis(true); + + // updateImageSynthesis is run in BaseFPSController's Initialize method after the + // Stretch Agent's unique secondary camera has been added to the list of third party + // cameras in InitializeBody, so a third-party camera image synthesis update is + // necessary if we want the secondary camera's image synthesis componenent to match + // the primary camera's + agentManager.updateThirdPartyCameraImageSynthesis(status); } public override void InitializeBody() { From 7184aa455bc21cc38406487a3d8e2d65ceba2571 Mon Sep 17 00:00:00 2001 From: Eli VanderBilt Date: Mon, 13 Dec 2021 16:08:13 -0800 Subject: [PATCH 5/5] Corrected visibility point conditions to include Stretch Arm edge case --- unity/Assets/Scripts/BaseFPSAgentController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unity/Assets/Scripts/BaseFPSAgentController.cs b/unity/Assets/Scripts/BaseFPSAgentController.cs index d3614a6de4..e77a541b3a 100644 --- a/unity/Assets/Scripts/BaseFPSAgentController.cs +++ b/unity/Assets/Scripts/BaseFPSAgentController.cs @@ -2998,7 +2998,7 @@ bool includeInvisible if (Physics.Raycast(camera.transform.position, point.position - camera.transform.position, out hit, raycastDistance, (1 << 8) | (1 << 10))) { if ( hit.transform == sop.transform - || (isSopHeldByArm && Arm.heldObjects[sop].Contains(hit.collider)) + || ( isSopHeldByArm && ((Arm != null && Arm.heldObjects[sop].Contains(hit.collider)) || (SArm != null && SArm.heldObjects[sop].Contains(hit.collider))) ) ) { // if this line is drawn, then this visibility point is in camera frame and not occluded // might want to use this for a targeting check as well at some point....