From dc718637d975897e7b584bcea6dc5771f3e6913a Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Sat, 19 Jun 2021 11:27:21 +0200 Subject: [PATCH] Add support for Point and DepthPoint when searching for a default Pose --- app/src/main/java/fr/smarquis/ar_toolbox/Nodes.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/fr/smarquis/ar_toolbox/Nodes.kt b/app/src/main/java/fr/smarquis/ar_toolbox/Nodes.kt index c58d4e6..29e8e88 100644 --- a/app/src/main/java/fr/smarquis/ar_toolbox/Nodes.kt +++ b/app/src/main/java/fr/smarquis/ar_toolbox/Nodes.kt @@ -63,7 +63,11 @@ sealed class Nodes( val centerY = ar.height / 2F val hits = ar.arFrame?.hitTest(centerX, centerY) val planeHitPose = hits?.firstOrNull { - (it.trackable as? Plane)?.isPoseInPolygon(it.hitPose) == true && it.distance <= PLANE_ANCHORING_DISTANCE + when (val trackable = it.trackable) { + is Plane -> trackable.isPoseInPolygon(it.hitPose) && it.distance <= PLANE_ANCHORING_DISTANCE + is DepthPoint, is Point -> it.distance <= DEFAULT_POSE_DISTANCE + else -> false + } }?.hitPose if (planeHitPose != null) return planeHitPose val ray = ar.scene.camera.screenPointToRay(centerX, centerY)