Skip to content

Commit

Permalink
formatting for collider scheme removal changes
Browse files Browse the repository at this point in the history
  • Loading branch information
winthos committed Aug 12, 2024
1 parent f4cd5da commit 5bb0c63
Show file tree
Hide file tree
Showing 5 changed files with 176 additions and 343 deletions.
9 changes: 3 additions & 6 deletions unity/Assets/Scripts/AgentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2677,11 +2677,9 @@ public SimObjType ReceptableSimObjType() {
return (SimObjType)Enum.Parse(typeof(SimObjType), receptacleObjectType);
}

public static VisibilityScheme GetVisibilitySchemeFromString(string visibilityScheme)
{
public static VisibilityScheme GetVisibilitySchemeFromString(string visibilityScheme) {
VisibilityScheme result = VisibilityScheme.Distance;
try
{
try {
result = (VisibilityScheme)Enum.Parse(typeof(VisibilityScheme), visibilityScheme, true);
}
// including this pragma so the "ex variable declared but not used" warning stops yelling
Expand Down Expand Up @@ -2789,8 +2787,7 @@ public enum ServerActionErrorCode {
UnhandledException
}

public enum VisibilityScheme
{
public enum VisibilityScheme {
Collider, //deprecated, scheme is now Distance based only
Distance
}
Expand Down
51 changes: 19 additions & 32 deletions unity/Assets/Scripts/BaseFPSAgentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4537,8 +4537,7 @@ protected SimObjPhysics[] GetAllVisibleSimObjPhysics(
float maxDistance,
out SimObjPhysics[] interactable,
IEnumerable<SimObjPhysics> filterSimObjs = null
)
{
) {
return GetAllVisibleSimObjPhysicsDistance(
camera,
maxDistance,
Expand All @@ -4556,29 +4555,23 @@ public void GetVisibleObjectsFromCamera(
float? maxDistance = null, //max distance from the camera origin to consider objects visible
int? thirdPartyCameraId = null, //leave null to query main camera, otherwise pass in the index of the third party camera
List<string> filterObjectIds = null //only return objects with these ids
)
{
) {
//if thirdPartyCameraId not specified, default to main camera
Camera camera = m_Camera;
if (thirdPartyCameraId.HasValue)
{
if (thirdPartyCameraId.HasValue) {
camera = agentManager.thirdPartyCameras[thirdPartyCameraId.Value];
if (this.visibilityScheme != VisibilityScheme.Distance)
{
if (this.visibilityScheme != VisibilityScheme.Distance) {
throw new System.NotImplementedException(
$"Visibility scheme {this.visibilityScheme} is not implemented for third party cameras. Default visibility scheme should be 'Distance'."
);
}
}
}

//only check visibility for objects with these ids otherwise check them all
List<SimObjPhysics> filterSimObjs = null;
if (filterObjectIds != null)
{
foreach (string objectId in filterObjectIds)
{
if (!physicsSceneManager.ObjectIdToSimObjPhysics.ContainsKey(objectId))
{
if (filterObjectIds != null) {
foreach (string objectId in filterObjectIds) {
if (!physicsSceneManager.ObjectIdToSimObjPhysics.ContainsKey(objectId)) {
throw new ArgumentException(
$"Object with id {objectId} does not exist in scene."
);
Expand All @@ -4597,12 +4590,12 @@ public void GetVisibleObjectsFromCamera(
interactable: out interactable
);

// #if UNITY_EDITOR
// foreach (SimObjPhysics sop in visible)
// {
// Debug.Log("Visible: " + sop.name);
// }
// #endif
// #if UNITY_EDITOR
// foreach (SimObjPhysics sop in visible)
// {
// Debug.Log("Visible: " + sop.name);
// }
// #endif

actionFinishedEmit(true, visible.Select(sop => sop.ObjectID).ToList());
}
Expand All @@ -4617,23 +4610,18 @@ public void GetVisibleObjects(
string visibilityScheme = null,
int? thirdPartyCameraIndex = null,
List<string> objectIds = null
)
{
) {
Camera camera; //which camera are we checking visibility from?
if (thirdPartyCameraIndex.HasValue)
{
if (thirdPartyCameraIndex.HasValue) {
camera = agentManager.thirdPartyCameras[thirdPartyCameraIndex.Value];
if (this.visibilityScheme != VisibilityScheme.Distance)
{
if (this.visibilityScheme != VisibilityScheme.Distance) {
throw new System.NotImplementedException(
$"Visibility scheme {this.visibilityScheme} is not implemented for third party cameras. Default visibility scheme should be 'Distance'."
);
}
}

//can also be used to query main camera
else
{
else {
camera = m_Camera;
}

Expand Down Expand Up @@ -4725,8 +4713,7 @@ out SimObjPhysics[] interactable
return visible.ToArray();
}

protected virtual LayerMask GetVisibilityRaycastLayerMask(bool withSimObjInvisible = false)
{
protected virtual LayerMask GetVisibilityRaycastLayerMask(bool withSimObjInvisible = false) {
string[] layers = new string[]
{
"SimObjVisible",
Expand Down
22 changes: 10 additions & 12 deletions unity/Assets/Scripts/DebugInputField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2760,20 +2760,18 @@ IEnumerator executeBatch(JArray jActions) {
action["objectId"] = splitcommand[1];
}

break;
}
break;
}

case "gvo":
{
Dictionary<string, object> action = new Dictionary<string, object>()
{
["action"] = "GetVisibleObjects",
["thirdPartyCameraIndex"] = 0,
};
case "gvo": {
Dictionary<string, object> action = new Dictionary<string, object>() {
["action"] = "GetVisibleObjects",
["thirdPartyCameraIndex"] = 0,
};

CurrentActiveController().ProcessControlCommand(action);
break;
}
CurrentActiveController().ProcessControlCommand(action);
break;
}

case "putxy": {
Dictionary<string, object> action = new Dictionary<string, object>();
Expand Down
Loading

0 comments on commit 5bb0c63

Please sign in to comment.