1 /*
2  * Copyright 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.xr.arcore
18 
19 import androidx.annotation.RestrictTo
20 import kotlin.time.ComparableTimeMark
21 
22 /**
23  * Represents the state of ARCore for Jetpack XR at an specific point in time.
24  *
25  * Can be obtained from [CoreState.perceptionState].
26  *
27  * @property timeMark the time at which the state was computed.
28  * @property trackables the trackables that are currently being tracked.
29  * @property leftHand the left hand, or null when not supported by the current platform.
30  * @property rightHand the right hand, or null when not supported by the current platform.
31  */
32 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
33 public class PerceptionState
34 internal constructor(
35     public val timeMark: ComparableTimeMark,
36     public val trackables: Collection<Trackable<Trackable.State>>,
37     public val leftHand: Hand?,
38     public val rightHand: Hand?,
39 ) {
equalsnull40     override fun equals(other: Any?): Boolean {
41         if (this === other) return true
42         if (other !is PerceptionState) return false
43         if (timeMark != other.timeMark) return false
44         if (trackables != other.trackables) return false
45         if (leftHand != other.leftHand) return false
46         if (rightHand != other.rightHand) return false
47         return true
48     }
49 
hashCodenull50     override fun hashCode(): Int {
51         var result = timeMark.hashCode()
52         result = 31 * result + trackables.hashCode()
53         result = 31 * result + leftHand.hashCode()
54         result = 31 * result + rightHand.hashCode()
55         return result
56     }
57 }
58