File tree Expand file tree Collapse file tree
OSVR-Unity/Assets/OSVRUnity/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,9 +102,22 @@ void OnEnable()
102102 void FixedUpdate ( )
103103 {
104104 EnsureStarted ( ) ;
105+ //Debug.Log("ClientKit FixedUpdate: frame # " + Time.frameCount + " " + Time.time);
106+ contextObject . update ( ) ;
107+ }
108+
109+ //may seem superfluous. the goal here is to update the client more often to make sure we have the most recent tracker data
110+ //this helps reduce latency
111+ void Update ( )
112+ {
113+ contextObject . update ( ) ;
114+ }
115+ //may seem superfluous. the goal here is to update the client more often to make sure we have the most recent tracker data
116+ //this helps reduce latency
117+ void LateUpdate ( )
118+ {
105119 contextObject . update ( ) ;
106120 }
107-
108121 void Stop ( )
109122 {
110123 if ( null != contextObject )
Original file line number Diff line number Diff line change @@ -32,15 +32,30 @@ namespace Unity
3232 /// </summary>
3333 public class PoseInterface : InterfaceGameObject
3434 {
35+ //private int currentFrame = 0;
36+ //private int frameCount = 0;
3537 new void Start ( )
3638 {
3739 osvrInterface . RegisterCallback ( callback ) ;
40+ //currentFrame = Time.frameCount;
41+ //frameCount = 0;
3842 }
3943
4044 private void callback ( string source , Vector3 position , Quaternion rotation )
4145 {
4246 transform . localPosition = position ;
4347 transform . localRotation = rotation ;
48+ //keeping this here for now for debugging purposes
49+ /*if(currentFrame != Time.frameCount)
50+ {
51+ Debug.Log("Time.frameCount = " + currentFrame + ", Time.time = " + Time.time + ". Callbacks per frame = " + frameCount);
52+ frameCount = 0;
53+ currentFrame = Time.frameCount;
54+ }
55+ else
56+ {
57+ frameCount++;
58+ }*/
4459 }
4560 }
4661 }
Original file line number Diff line number Diff line change @@ -37,12 +37,14 @@ public class VREye : MonoBehaviour
3737 {
3838 #region Private Variables
3939 private Camera _camera ;
40+ private ClientKit clientKit ;
4041 #endregion
4142 #region Public Variables
4243 public Eye eye ;
4344 public Camera Camera { get { return _camera ; } set { _camera = value ; } }
4445 [ HideInInspector ]
4546 public Transform cachedTransform ;
47+
4648 #endregion
4749
4850 #region Init
@@ -90,6 +92,10 @@ public void SetEyeRoll(float rollAmount)
9092 #region Private Methods
9193 void Init ( )
9294 {
95+ if ( clientKit == null )
96+ {
97+ clientKit = GameObject . FindObjectOfType < ClientKit > ( ) ;
98+ }
9399 //cache:
94100 cachedTransform = transform ;
95101
@@ -122,6 +128,14 @@ private void SetViewportRects()
122128 break ;
123129 }
124130 }
131+
132+ //Called after a camera finishes rendering the scene.
133+ //the goal here is to update the client often to make sure we have the most recent tracker data
134+ //this helps reduce latency
135+ void OnPostRender ( )
136+ {
137+ clientKit . context . update ( ) ;
138+ }
125139 #endregion
126140
127141
You can’t perform that action at this time.
0 commit comments