Skip to content

Commit

Permalink
Remove ARPosition and ARSize
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Dec 9, 2023
1 parent 71ab475 commit f8162fd
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import com.kylecorry.trail_sense.tools.augmented_reality.position.GeographicPosi
import com.kylecorry.trail_sense.tools.augmented_reality.position.SphericalPositionStrategy
import kotlin.math.hypot

// TODO: Is the interface even needed?
// TODO: Use ARPosition and ARSize
// TODO: Are the helper methods needed, or can the constructor be called directly?
class ARMarkerImpl private constructor(
private val positionStrategy: ARPositionStrategy,
private val canvasObject: CanvasObject,
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.kylecorry.trail_sense.shared.permissions.alertNoCameraPermission
import com.kylecorry.trail_sense.shared.permissions.requestCamera
import com.kylecorry.trail_sense.shared.sensors.LocationSubsystem
import com.kylecorry.andromeda.fragments.observeFlow
import com.kylecorry.trail_sense.tools.augmented_reality.position.GeographicPositionStrategy
import kotlinx.coroutines.Dispatchers
import java.time.Duration
import java.time.LocalDate
Expand All @@ -61,6 +62,7 @@ class AugmentedRealityFragment : BoundFragment<FragmentAugmentedRealityBinding>(
Distance.meters(userPrefs.navigation.maxBeaconDistance),
onFocus = this::onBeaconFocused
) {
println(it)
if (navigator.getDestinationId() != it.id) {
navigator.navigateTo(it)
} else {
Expand Down Expand Up @@ -102,7 +104,7 @@ class AugmentedRealityFragment : BoundFragment<FragmentAugmentedRealityBinding>(
if (it == null) {
binding.arView.clearGuide()
} else {
binding.arView.guideTo(ARPosition.geographic(it.coordinate, it.elevation)) {
binding.arView.guideTo(GeographicPositionStrategy(it.coordinate, it.elevation)) {
// Do nothing when reached
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.kylecorry.trail_sense.shared.declination.DeclinationUtils
import com.kylecorry.trail_sense.shared.sensors.SensorService
import com.kylecorry.trail_sense.shared.text
import com.kylecorry.trail_sense.shared.textDimensions
import com.kylecorry.trail_sense.tools.augmented_reality.position.ARPositionStrategy
import java.time.Duration
import kotlin.math.atan2

Expand Down Expand Up @@ -108,7 +109,7 @@ class AugmentedRealityView : CanvasView {
private val layerLock = Any()

// Guidance
private var guideLocation: ARPosition? = null
private var guideStrategy: ARPositionStrategy? = null
private var guideThreshold: Float? = null
private var onGuideReached: (() -> Unit)? = null

Expand Down Expand Up @@ -155,17 +156,17 @@ class AugmentedRealityView : CanvasView {
}

fun guideTo(
location: ARPosition,
guideStrategy: ARPositionStrategy,
thresholdDegrees: Float? = null,
onReached: () -> Unit = { clearGuide() }
) {
guideLocation = location
this.guideStrategy = guideStrategy
guideThreshold = thresholdDegrees
onGuideReached = onReached
}

fun clearGuide() {
guideLocation = null
guideStrategy = null
guideThreshold = null
onGuideReached = null
}
Expand Down Expand Up @@ -224,7 +225,7 @@ class AugmentedRealityView : CanvasView {

private fun drawGuidance() {
// Draw an arrow around the reticle that points to the desired location
val coordinate = guideLocation?.getHorizonCoordinate(location, altitude) ?: return
val coordinate = guideStrategy?.getHorizonCoordinate(this) ?: return
val threshold = guideThreshold
val point = toPixel(coordinate)
val center = PixelCoordinate(width / 2f, height / 2f)
Expand Down

0 comments on commit f8162fd

Please sign in to comment.