Skip to content

Commit

Permalink
shortening variable names
Browse files Browse the repository at this point in the history
shortening the following:
- agentPositionRelativeThirdPartyCameraPosition -> agentRelativeThirdPartyCameraPosition
- agentRotationRelativeThirdPartyCameraRotation -> agentRelativeThirdPartyCameraRotation
- parentPositionRelativeThirdPartyCameraPosition -> parentRelativeThirdPartyCameraPosition
- parentRotationRelativeThirdPartyCameraRotation -> parentRelativeThirdPartyCameraRotation
  • Loading branch information
winthos committed Sep 16, 2024
1 parent b861218 commit 12d8e05
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
24 changes: 12 additions & 12 deletions unity/Assets/Scripts/AgentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1310,34 +1310,34 @@ bool shouldRenderImageSynthesis
if (camera.transform.parent != null) {
cMetadata.parentObjectName = camera.transform.parent.name;

cMetadata.parentPositionRelativeThirdPartyCameraPosition =
cMetadata.parentRelativeThirdPartyCameraPosition =
camera.transform.localPosition;

//get third party camera rotation as quaternion in parent space
cMetadata.parentPositionRelativeThirdPartyCameraRotation =
cMetadata.parentRelativeThirdPartyCameraRotation =
camera.transform.localEulerAngles;
} else {
cMetadata.parentObjectName = "";
cMetadata.parentPositionRelativeThirdPartyCameraPosition = null;
cMetadata.parentPositionRelativeThirdPartyCameraRotation = null;
cMetadata.parentRelativeThirdPartyCameraPosition = null;
cMetadata.parentRelativeThirdPartyCameraRotation = null;
}

//if this camera is part of the agent's hierarchy at all, get agent relative info
if (camera.GetComponentInParent<BaseAgentComponent>() != null) {
GameObject agent = camera.GetComponentInParent<BaseAgentComponent>().gameObject;

cMetadata.agentPositionRelativeThirdPartyCameraPosition =
cMetadata.agentRelativeThirdPartyCameraPosition =
agent.transform.InverseTransformPoint(camera.transform.position);

var agentSpaceCameraRotationAsQuaternion =
Quaternion.Inverse(agent.transform.rotation)
* worldSpaceCameraRotationAsQuaternion;
cMetadata.agentRotationRelativeThirdPartyCameraRotation =
cMetadata.agentRelativeThirdPartyCameraRotation =
agentSpaceCameraRotationAsQuaternion.eulerAngles;
} else {
//if this third party camera is not a child of the agent, we don't need agent-relative coordinates
cMetadata.agentPositionRelativeThirdPartyCameraPosition = null;
cMetadata.agentRotationRelativeThirdPartyCameraRotation = null;
cMetadata.agentRelativeThirdPartyCameraPosition = null;
cMetadata.agentRelativeThirdPartyCameraRotation = null;
}

cMetadata.fieldOfView = camera.fieldOfView;
Expand Down Expand Up @@ -1872,12 +1872,12 @@ public class ThirdPartyCameraMetadata {

//note these should only be returned with values
//if the third party camera is a child of the agent
public Vector3? agentPositionRelativeThirdPartyCameraPosition;
public Vector3? agentRotationRelativeThirdPartyCameraRotation;
public Vector3? agentRelativeThirdPartyCameraPosition;
public Vector3? agentRelativeThirdPartyCameraRotation;

//return the local space coordinates if this third party camera has a parent object, this may be the same as agentPositionRelative depending on how things are parented
public Vector3? parentPositionRelativeThirdPartyCameraPosition;
public Vector3? parentPositionRelativeThirdPartyCameraRotation;
public Vector3? parentRelativeThirdPartyCameraPosition;
public Vector3? parentRelativeThirdPartyCameraRotation;
public string parentObjectName; //if this third party camera is in a hierarchy, return the name of the parent object
}

Expand Down
40 changes: 20 additions & 20 deletions unity/Assets/UnitTests/TestThirdPartyCameraAndMainCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -479,19 +479,19 @@ public IEnumerator TestThirdPartyCameraMetadataReturn()
);
Assert.AreEqual(result, true);
Assert.AreEqual(
metadata.thirdPartyCameras[0].agentPositionRelativeThirdPartyCameraPosition,
metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraPosition,
null
);
Assert.AreEqual(
metadata.thirdPartyCameras[0].agentRotationRelativeThirdPartyCameraRotation,
metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraRotation,
null
);
Assert.AreEqual(
metadata.thirdPartyCameras[0].parentPositionRelativeThirdPartyCameraPosition,
metadata.thirdPartyCameras[0].parentRelativeThirdPartyCameraPosition,
null
);
Assert.AreEqual(
metadata.thirdPartyCameras[0].parentPositionRelativeThirdPartyCameraRotation,
metadata.thirdPartyCameras[0].parentRelativeThirdPartyCameraRotation,
null
);
Assert.AreEqual(metadata.thirdPartyCameras[0].parentObjectName, "");
Expand All @@ -513,11 +513,11 @@ public IEnumerator TestThirdPartyCameraMetadataReturn()
// Debug.Log($"world relative camera pos: {metadata.thirdPartyCameras[0].worldRelativeThirdPartyCameraPosition:F10}");
// Debug.Log($"world relative camera rot: {metadata.thirdPartyCameras[0].worldRelativeThirdPartyCameraRotation:F10}");
// //agent relative
// Debug.Log($"agent relative camera pos: {metadata.thirdPartyCameras[0].agentPositionRelativeThirdPartyCameraPosition:F10}");
// Debug.Log($"agent relative camera rot: {metadata.thirdPartyCameras[0].agentRotationRelativeThirdPartyCameraRotation:F10}");
// Debug.Log($"agent relative camera pos: {metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraPosition:F10}");
// Debug.Log($"agent relative camera rot: {metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraRotation:F10}");
// //parent relative
// Debug.Log($"parent relative camera rot: {metadata.thirdPartyCameras[0].parentPositionRelativeThirdPartyCameraPosition:F10}");
// Debug.Log($"parent relative camera rot: {metadata.thirdPartyCameras[0].parentPositionRelativeThirdPartyCameraRotation:F10}");
// Debug.Log($"parent relative camera rot: {metadata.thirdPartyCameras[0].parentRelativeThirdPartyCameraPosition:F10}");
// Debug.Log($"parent relative camera rot: {metadata.thirdPartyCameras[0].parentRelativeThirdPartyCameraRotation:F10}");
// Debug.Log($"parent object name: {metadata.thirdPartyCameras[0].parentObjectName}");

result = Mathf.Approximately(
Expand Down Expand Up @@ -551,39 +551,39 @@ public IEnumerator TestThirdPartyCameraMetadataReturn()
);
Assert.AreEqual(result, true);
result = Mathf.Approximately(
metadata.thirdPartyCameras[0].agentPositionRelativeThirdPartyCameraPosition.Value.x,
metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraPosition.Value.x,
1.0000000000f
);
Assert.AreEqual(result, true);
result = Mathf.Approximately(
metadata.thirdPartyCameras[0].agentPositionRelativeThirdPartyCameraPosition.Value.y,
metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraPosition.Value.y,
2.0000000000f
);
Assert.AreEqual(result, true);
result = Mathf.Approximately(
metadata.thirdPartyCameras[0].agentPositionRelativeThirdPartyCameraPosition.Value.z,
metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraPosition.Value.z,
3.0000020000f
);
Assert.AreEqual(result, true);
result = Mathf.Approximately(
metadata.thirdPartyCameras[0].agentRotationRelativeThirdPartyCameraRotation.Value.x,
metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraRotation.Value.x,
20.0000000000f
);
Assert.AreEqual(result, true);
result = Mathf.Approximately(
metadata.thirdPartyCameras[0].agentRotationRelativeThirdPartyCameraRotation.Value.y,
metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraRotation.Value.y,
20.0000000000f
);
Assert.AreEqual(result, true);
result = Mathf.Approximately(
metadata.thirdPartyCameras[0].agentRotationRelativeThirdPartyCameraRotation.Value.z,
metadata.thirdPartyCameras[0].agentRelativeThirdPartyCameraRotation.Value.z,
20.0000000000f
);
Assert.AreEqual(result, true);
result = Mathf.Approximately(
metadata
.thirdPartyCameras[0]
.parentPositionRelativeThirdPartyCameraPosition
.parentRelativeThirdPartyCameraPosition
.Value
.x,
1.0000000000f
Expand All @@ -592,7 +592,7 @@ public IEnumerator TestThirdPartyCameraMetadataReturn()
result = Mathf.Approximately(
metadata
.thirdPartyCameras[0]
.parentPositionRelativeThirdPartyCameraPosition
.parentRelativeThirdPartyCameraPosition
.Value
.y,
2.0000000000f
Expand All @@ -601,7 +601,7 @@ public IEnumerator TestThirdPartyCameraMetadataReturn()
result = Mathf.Approximately(
metadata
.thirdPartyCameras[0]
.parentPositionRelativeThirdPartyCameraPosition
.parentRelativeThirdPartyCameraPosition
.Value
.z,
3.0000020000f
Expand All @@ -610,7 +610,7 @@ public IEnumerator TestThirdPartyCameraMetadataReturn()
result = Mathf.Approximately(
metadata
.thirdPartyCameras[0]
.parentPositionRelativeThirdPartyCameraRotation
.parentRelativeThirdPartyCameraRotation
.Value
.x,
20.0000000000f
Expand All @@ -619,7 +619,7 @@ public IEnumerator TestThirdPartyCameraMetadataReturn()
result = Mathf.Approximately(
metadata
.thirdPartyCameras[0]
.parentPositionRelativeThirdPartyCameraRotation
.parentRelativeThirdPartyCameraRotation
.Value
.y,
20.0000000000f
Expand All @@ -628,7 +628,7 @@ public IEnumerator TestThirdPartyCameraMetadataReturn()
result = Mathf.Approximately(
metadata
.thirdPartyCameras[0]
.parentPositionRelativeThirdPartyCameraRotation
.parentRelativeThirdPartyCameraRotation
.Value
.z,
20.0000000000f
Expand Down

0 comments on commit 12d8e05

Please sign in to comment.