Skip to content

Commit

Permalink
ARCore Extensions SDK v1.42.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Fine committed Mar 15, 2024
1 parent 7984b17 commit a7adcde
Show file tree
Hide file tree
Showing 37 changed files with 1,089 additions and 191 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<dependencies>
<iosPods>
<iosPod name="ARCore/CloudAnchors" version="~> 1.41.0" minTargetSdk="12.0">
<iosPod name="ARCore/CloudAnchors" version="~> 1.42.0" minTargetSdk="12.0">
</iosPod>
</iosPods>
</dependencies>
2 changes: 1 addition & 1 deletion Editor/BuildResources/ARCoreiOSDependencies.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<dependencies>
<iosPods>
<iosPod name="ARCore/GARSession" version="~> 1.41.0" minTargetSdk="12.0">
<iosPod name="ARCore/GARSession" version="~> 1.42.0" minTargetSdk="12.0">
</iosPod>
</iosPods>
</dependencies>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<dependencies>
<iosPods>
<iosPod name="ARCore/Geospatial" version="~> 1.41.0" minTargetSdk="12.0">
<iosPod name="ARCore/Geospatial" version="~> 1.42.0" minTargetSdk="12.0">
</iosPod>
</iosPods>
</dependencies>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<dependencies>
<iosPods>
<iosPod name="ARCore/Semantics" version="~> 1.41.0" minTargetSdk="12.0">
<iosPod name="ARCore/Semantics" version="~> 1.42.0" minTargetSdk="12.0">
</iosPod>
</iosPods>
</dependencies>
116 changes: 116 additions & 0 deletions Editor/GeospatialCreator/Scripts/GeospatialCreatorCesiumAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,122 @@ internal static bool SetMapTileApiKeyForCesium3DTileset(
EditorUtility.SetDirty(tileset);
return true;
}

internal class Origin3DTilesetCesiumAdapter : Origin3DTilesetAdapter
{
// The parent ARGeospatialCreatorOrigin object that owns this instance of the Adapter
private readonly ARGeospatialCreatorOrigin _origin;

internal Origin3DTilesetCesiumAdapter(ARGeospatialCreatorOrigin origin)
{
_origin = origin;
}

/// <summary> Gets the parent ARGeospatialCreatorOrigin object.</summary>
public override ARGeospatialCreatorOrigin Origin
{
get
{
return _origin;
}
}

/// <summary> Sets the Cesium tileset's "Create Physics Meshes" setting.</summary>
/// <param name="enable"> Specifies whether to enable the setting or not.</param>
public override void SetPhysicsMeshesEnabled(bool enable)
{
Cesium3DTileset tileset = GetTilesetComponent(Origin);
if (tileset == null)
{
Debug.LogError(
"No Cesium3DTileset component associated with Origin " + Origin.name);
return;
}

if (tileset.createPhysicsMeshes != enable)
{
tileset.createPhysicsMeshes = enable;
}
}

/// <summary> Gets the Cesium tileset's "Create Physics Meshes" setting.</summary>
public override bool GetPhysicsMeshesEnabled()
{
Cesium3DTileset tileset = GetTilesetComponent(Origin);
if (tileset == null)
{
Debug.LogError(
"No Cesium3DTileset component associated with Origin " + Origin.name);
return false;
}

return tileset.createPhysicsMeshes;
}

/// <summary> Retrieves percentage of tiles loaded for current view.</summary>
/// <returns> Percentage (0.0 to 100.0) of tiles loaded for current view.</returns>
public override float ComputeTilesetLoadProgress()
{
Cesium3DTileset tileset = GetTilesetComponent(Origin);
if (tileset == null)
{
Debug.LogError(
"No Cesium3DTileset component associated with Origin " + Origin.name);
return 0;
}
return tileset.ComputeLoadProgress();
}

/// <summary> Returns true if the collider belongs to a tile in this tileset.</summary>
/// <param name="collider"> The collider to be checked.</param>
public override bool IsTileCollider(Collider collider)
{
if ((collider != null) &&
(collider.gameObject.GetComponent<CesiumGlobeAnchor>() != null))
{
return true;
}
return false;
}
}

internal class OriginComponentCesiumAdapter : IOriginComponentAdapter
{
// The parent ARGeospatialCreatorOrigin object that owns this instance of the Adapter
private readonly ARGeospatialCreatorOrigin _origin;

public OriginComponentCesiumAdapter(ARGeospatialCreatorOrigin origin)
{
_origin = origin;
}

public GeoCoordinate GetOriginFromComponent()
{
CesiumForUnity.CesiumGeoreference geoRef = GetCesiumGeoreference();
return (geoRef == null) ? null :
new GeoCoordinate(geoRef.latitude, geoRef.longitude, geoRef.height);
}

public void SetComponentOrigin(GeoCoordinate newOrigin)
{
CesiumForUnity.CesiumGeoreference geoRef = GetCesiumGeoreference();
if (geoRef == null)
{
Debug.LogWarning("Origin location updated for " + _origin.gameObject.name +
", but there is no Cesium Georeference subcomponent.");
return;
}

geoRef.latitude = newOrigin.Latitude;
geoRef.longitude = newOrigin.Longitude;
geoRef.height = newOrigin.Altitude;
}

private CesiumForUnity.CesiumGeoreference GetCesiumGeoreference()
{
return _origin.gameObject.GetComponent<CesiumForUnity.CesiumGeoreference>();
}
}
}
}
#endif // ARCORE_INTERNAL_USE_CESIUM
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,52 @@ public override void OnInspectorGUI()
}
}

private void GUIForSnapToTile()
{
string snapToTileTooltip = "Visually position the anchor within the editor so it " +
"aligns with the top of the tile. This override in the editor does not impact " +
"the position at runtime.";

if (GUILayout.Button(new GUIContent("Snap to Tile", snapToTileTooltip)))
{
ARGeospatialCreatorOrigin origin =
_origin.objectReferenceValue as ARGeospatialCreatorOrigin;
if (origin == null)
{
Debug.LogError("An ARGeospatialCreatorOrigin object must be present in the " +
"scene and assigned to the anchor to use the Snap to Tile feature.");
return;
}

var tileset = origin._origin3DTilesetAdapter;
if (tileset.GetPhysicsMeshesEnabled() == false)
{
#if ARCORE_INTERNAL_USE_CESIUM
Debug.LogError("Physics Meshes must be enabled on the tileset to use " +
"the Snap to Tile feature. Please enable the \"Create Physics Meshes\" " +
"setting in the Cesium3DTileset component owned by the Origin.",
GeospatialCreatorCesiumAdapter.GetTilesetComponent(origin));
#else
Debug.LogError("Physics Meshes must be enabled on the tileset to use " +
"the Snap to Tile feature.");
#endif
return;
}

(bool success, double tileAltitude) =
tileset.CalcTileAltitudeWGS84(_latitude.doubleValue, _longitude.doubleValue);
if (success)
{
_editorAltitudeOverride.doubleValue = tileAltitude;
}
else
{
Debug.LogWarning("Could not Snap to Tile at Latitude: " +
_latitude.doubleValue + " and Longitude: " + _longitude.doubleValue);
}
}
}

private void GUIForAltitude(AnchorAltitudeType altitudeType)
{
using (new EditorGUI.IndentLevelScope())
Expand All @@ -112,22 +158,24 @@ private void GUIForAltitude(AnchorAltitudeType altitudeType)

GUILayout.BeginHorizontal();

string overrideAltitudeLabel = "Override altitude in Editor Scene View";
_useEditorAltitudeOverride.boolValue = EditorGUILayout.Toggle(
"Override altitude in Editor Scene View",
overrideAltitudeLabel,
_useEditorAltitudeOverride.boolValue);

// Allow the override value to be edited only if the flag is enabled.
EditorGUI.BeginDisabledGroup(!_useEditorAltitudeOverride.boolValue);
_editorAltitudeOverride.doubleValue = EditorGUILayout.DoubleField(
_editorAltitudeOverride.doubleValue);
GUIForSnapToTile();
EditorGUI.EndDisabledGroup();

GUILayout.EndHorizontal();

if (_useEditorAltitudeOverride.boolValue)
{
EditorGUILayout.HelpBox(
"The Editor-only altitude override sets the altitude used in the Scene " +
"\"" + overrideAltitudeLabel + "\" sets the altitude used in the Scene " +
"View to position the anchor, in meters according to WGS84. This is " +
"useful to vizualize the anchor relative to the scene geometry in cases " +
"where the scene geometry altitude is not fully aligned with the real " +
Expand All @@ -136,7 +184,6 @@ private void GUIForAltitude(AnchorAltitudeType altitudeType)
MessageType.Info,
wide: true);
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
namespace Google.XR.ARCoreExtensions.GeospatialCreator.Editor.Internal
{
using System;
using Google.XR.ARCoreExtensions.Editor.Internal;
using Google.XR.ARCoreExtensions.GeospatialCreator;
using Google.XR.ARCoreExtensions.GeospatialCreator.Internal;
#if ARCORE_INTERNAL_USE_UNITY_MATH
Expand Down Expand Up @@ -62,6 +63,8 @@ static GeospatialAnchorUpdater()

var tracker = new GeospatialObjectTracker<ARGeospatialCreatorAnchor>(actionFactory);
tracker.StartTracking();
GeospatialCreatorHelper.CountGeospatialCreatorAnchorsDelegate =
tracker.GetTrackedObjectsCount;
}

public GeospatialAnchorUpdater(ARGeospatialCreatorAnchor anchor)
Expand Down Expand Up @@ -139,6 +142,7 @@ private bool HasGeodeticPositionChanged()
{
return true;
}

return false;
}

Expand Down Expand Up @@ -211,7 +215,6 @@ private void UpdateUnityPosition()
// EditorAltitudeOverride value, if it is used.
double alt = _anchor.UseEditorAltitudeOverride ?
_anchor.EditorAltitudeOverride : _anchor.Altitude;

GeoCoordinate coor = new GeoCoordinate(
_anchor.Latitude,
_anchor.Longitude,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public void StopTracking()
_trackedObjects.Clear();
}

public uint GetTrackedObjectsCount()
{
return Convert.ToUInt32(_trackedObjects.Count);
}

/// <summary>
/// Handles EditorApplication.Update() events to check if GameObjects of type T have been
/// added to or removed from the scene. For new objects, a a new update Action is created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ public GeospatialOriginUpdater(ARGeospatialCreatorOrigin origin)
{
_origin = origin;
#if ARCORE_INTERNAL_USE_CESIUM
_origin._originComponentAdapter = new CesiumOriginAdapter(origin);
_origin._originComponentAdapter =
new GeospatialCreatorCesiumAdapter.OriginComponentCesiumAdapter(origin);
_origin.UpdateOriginFromComponent();
_origin._origin3DTilesetAdapter =
new GeospatialCreatorCesiumAdapter.Origin3DTilesetCesiumAdapter(origin);
#endif
}

Expand All @@ -66,44 +69,6 @@ private void EditorUpdate()
_origin.UpdateOriginFromComponent();
}

#if ARCORE_INTERNAL_USE_CESIUM
private class CesiumOriginAdapter : IOriginComponentAdapter
{
private readonly ARGeospatialCreatorOrigin _origin;

public CesiumOriginAdapter(ARGeospatialCreatorOrigin origin)
{
_origin = origin;
}

public GeoCoordinate GetOriginFromComponent()
{
CesiumForUnity.CesiumGeoreference geoRef = GetCesiumGeoreference();
return (geoRef == null) ? null :
new GeoCoordinate(geoRef.latitude, geoRef.longitude, geoRef.height);
}

public void SetComponentOrigin(GeoCoordinate newOrigin)
{
CesiumForUnity.CesiumGeoreference geoRef = GetCesiumGeoreference();
if (geoRef == null)
{
Debug.LogWarning("Origin location updated for " + _origin.gameObject.name +
", but there is no Cesium Georeference subcomponent.");
return;
}

geoRef.latitude = newOrigin.Latitude;
geoRef.longitude = newOrigin.Longitude;
geoRef.height = newOrigin.Altitude;
}

private CesiumForUnity.CesiumGeoreference GetCesiumGeoreference()
{
return _origin.gameObject.GetComponent<CesiumForUnity.CesiumGeoreference>();
}
}
#endif //ARCORE_INTERNAL_USE_CESIUM
}
}
#endif // ARCORE_INTERNAL_GEOSPATIAL_CREATOR_ENABLED
Loading

0 comments on commit a7adcde

Please sign in to comment.