Skip to content

Commit

Permalink
Making ChangeFOV deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroHG committed Aug 20, 2024
1 parent 2486b9e commit afa8a33
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 59 deletions.
36 changes: 24 additions & 12 deletions unity/Assets/Scripts/DebugInputField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, object> action = new Dictionary<string, object>();

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<ServerAction>());

break;
}

Expand Down Expand Up @@ -3165,18 +3189,6 @@ IEnumerator executeBatch(JArray jActions) {
CurrentActiveController().ProcessControlCommand(action);
break;
}

case "fov": {
Dictionary<string, object> comm = new Dictionary<string, object>();
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";
Expand Down
54 changes: 7 additions & 47 deletions unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit afa8a33

Please sign in to comment.