Skip to content

Commit d7c3642

Browse files
author
lawwong
committed
Update to v1.7.3
* Bug fix - [VRModule] Fix compile error in OculusVRModule.cs #14 - [Pointer3D] Fix **IPointerExit** not handled correctly when disabling a raycaster #16 - [Pointer3D] Fix **IPointerExit**/**IPointerPressExit**/**IPointerUp** doesn't execute in some cases - Add **Pointer3DEventData.pressProcessed** flag to ensure Down/Up processed correctly * Improvement - Add new struct type **HTC.UnityPlugin.Utility.RigidPose** to replace **HTC.UnityPlugin.PoseTracker.Pose** - Utility.RigidPose inherit all members in PoseTracker.Pose - Add forward, up, right property getter - Obsolete struct **HTC.UnityPlugin.PoseTracker.Pose** (will be removed in future version) to avoid type ambiguous with UnityEngine.Pose (new type in Unity 2017.2) - If you somehow want to using HTC.UnityPlugin.PoseTracker and UnityEngine.Pose in your script at the same time, please use full type name or add type alias to avoid ambiguous compile error ``` csharp using HTC.UnityPlugin.PoseTracker; using UnityEngine; using Pose = UnityEngine.Pose; public class MyPoseTracker : BasePoseTracker { public Pose m_pose; ... } ``` - Change some recommended setting value - Now binding interface switch is recommended as enable only if Steam VR plugin is imported - Now external camera interface switch is recommended as enable only if Steam VR plugin is imported - Now VIU system game object will be auto generated only if nessary
2 parents bae8c18 + 5680ea9 commit d7c3642

33 files changed

+534
-234
lines changed

Assets/HTC.UnityPlugin/Pointer3D/Pointer3DEventData.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public class Pointer3DEventData : PointerEventData
6666

6767
public float pressDistance;
6868
public GameObject pressEnter;
69+
public bool pressPrecessed;
6970

7071
public Pointer3DEventData(Pointer3DRaycaster ownerRaycaster, EventSystem eventSystem) : base(eventSystem)
7172
{

Assets/HTC.UnityPlugin/Pointer3D/Pointer3DInputModule.cs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -223,29 +223,26 @@ protected void CleanUpRaycaster(Pointer3DRaycaster raycaster)
223223
if (raycaster == null) { return; }
224224

225225
var hoverEventData = raycaster.HoverEventData;
226-
if (hoverEventData == null || raycaster.ButtonEventDataList.Count == 0) { return; }
227-
228-
hoverEventData.Reset();
229226

230227
// buttons event
231228
for (int i = 0, imax = raycaster.ButtonEventDataList.Count; i < imax; ++i)
232229
{
233230
var buttonEventData = raycaster.ButtonEventDataList[i];
234-
if (buttonEventData == null || buttonEventData == hoverEventData) { continue; }
231+
if (buttonEventData == null) { continue; }
235232

236233
buttonEventData.Reset();
237234

238-
if (buttonEventData.eligibleForClick)
235+
if (buttonEventData.pressPrecessed)
239236
{
240237
ProcessPressUp(buttonEventData);
241238
HandlePressExitAndEnter(buttonEventData, null);
242239
}
243240

244241
if (buttonEventData.pointerEnter != null)
245242
{
246-
if (i == 0)
243+
if (buttonEventData == hoverEventData)
247244
{
248-
// perform exit event for hover event data
245+
// perform exit event only for hover event data
249246
HandlePointerExitAndEnter(buttonEventData, null);
250247
}
251248
else
@@ -286,9 +283,6 @@ protected virtual void ProcessRaycast()
286283
var raycaster = processingRaycasters[i];
287284
if (raycaster == null) { continue; }
288285

289-
var hoverEventData = raycaster.HoverEventData;
290-
if(hoverEventData == null || raycaster.ButtonEventDataList.Count == 0) { continue; }
291-
292286
raycaster.Raycast();
293287
var result = raycaster.FirstRaycastResult();
294288

@@ -297,6 +291,9 @@ protected virtual void ProcessRaycast()
297291
var raycasterPos = raycaster.transform.position;
298292
var raycasterRot = raycaster.transform.rotation;
299293

294+
var hoverEventData = raycaster.HoverEventData;
295+
if (hoverEventData == null) { continue; }
296+
300297
// gen shared data and put in hover event
301298
hoverEventData.Reset();
302299
hoverEventData.delta = Vector2.zero;
@@ -384,17 +381,16 @@ protected virtual void ProcessMove(PointerEventData eventData)
384381

385382
protected virtual void ProcessPress(Pointer3DEventData eventData)
386383
{
387-
if (eventData.GetPressDown())
388-
{
389-
ProcessPressDown(eventData);
390-
}
391-
392384
if (eventData.GetPress())
393385
{
386+
if (!eventData.pressPrecessed)
387+
{
388+
ProcessPressDown(eventData);
389+
}
390+
394391
HandlePressExitAndEnter(eventData, eventData.pointerCurrentRaycast.gameObject);
395392
}
396-
397-
if (eventData.GetPressUp())
393+
else if (eventData.pressPrecessed)
398394
{
399395
ProcessPressUp(eventData);
400396
HandlePressExitAndEnter(eventData, null);
@@ -405,6 +401,7 @@ protected void ProcessPressDown(Pointer3DEventData eventData)
405401
{
406402
var currentOverGo = eventData.pointerCurrentRaycast.gameObject;
407403

404+
eventData.pressPrecessed = true;
408405
eventData.eligibleForClick = true;
409406
eventData.delta = Vector2.zero;
410407
eventData.dragging = false;
@@ -481,6 +478,7 @@ protected void ProcessPressUp(Pointer3DEventData eventData)
481478
ExecuteEvents.ExecuteHierarchy(currentOverGo, eventData, ExecuteEvents.dropHandler);
482479
}
483480

481+
eventData.pressPrecessed = false;
484482
eventData.eligibleForClick = false;
485483
eventData.pointerPress = null;
486484
eventData.rawPointerPress = null;

Assets/HTC.UnityPlugin/PoseTracker/Base/BasePoseModifier.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//========= Copyright 2016-2017, HTC Corporation. All rights reserved. ===========
22

3+
using HTC.UnityPlugin.Utility;
4+
using System;
35
using UnityEngine;
46

57
namespace HTC.UnityPlugin.PoseTracker
@@ -49,6 +51,9 @@ protected virtual void OnDestroy()
4951
baseTracker.RemoveModifier(this);
5052
}
5153

52-
public abstract void ModifyPose(ref Pose pose, Transform origin);
54+
[Obsolete]
55+
public virtual void ModifyPose(ref Pose pose, Transform origin) { }
56+
57+
public virtual void ModifyPose(ref RigidPose pose, Transform origin) { }
5358
}
5459
}

Assets/HTC.UnityPlugin/PoseTracker/Base/BasePoseTracker.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//========= Copyright 2016-2017, HTC Corporation. All rights reserved. ===========
22

33
using HTC.UnityPlugin.Utility;
4+
using System;
45
using UnityEngine;
56

67
namespace HTC.UnityPlugin.PoseTracker
@@ -38,14 +39,28 @@ public bool RemoveModifier(IPoseModifier obj)
3839
return modifierSet == null ? false : modifierSet.Remove(obj);
3940
}
4041

42+
[Obsolete]
4143
protected void TrackPose(Pose pose, Transform origin = null)
4244
{
43-
pose = pose * new Pose(posOffset, Quaternion.Euler(rotOffset));
45+
TrackPose((RigidPose)pose, origin);
46+
}
47+
48+
protected void TrackPose(RigidPose pose, Transform origin = null)
49+
{
50+
pose = pose * new RigidPose(posOffset, Quaternion.Euler(rotOffset));
4451
ModifyPose(ref pose, origin);
45-
Pose.SetPose(transform, pose, origin);
52+
RigidPose.SetPose(transform, pose, origin);
4653
}
4754

55+
[Obsolete]
4856
protected void ModifyPose(ref Pose pose, Transform origin)
57+
{
58+
var rigidPose = (RigidPose)pose;
59+
ModifyPose(ref rigidPose, origin);
60+
pose = rigidPose;
61+
}
62+
63+
protected void ModifyPose(ref RigidPose pose, Transform origin)
4964
{
5065
if (modifierSet == null) { return; }
5166

Assets/HTC.UnityPlugin/PoseTracker/Base/IPoseModifier.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//========= Copyright 2016-2017, HTC Corporation. All rights reserved. ===========
22

3+
using HTC.UnityPlugin.Utility;
4+
using System;
35
using UnityEngine;
46

57
namespace HTC.UnityPlugin.PoseTracker
@@ -8,6 +10,8 @@ public interface IPoseModifier
810
{
911
bool enabled { get; }
1012
int priority { get; set; }
13+
[Obsolete]
1114
void ModifyPose(ref Pose pose, Transform origin);
15+
void ModifyPose(ref RigidPose pose, Transform origin);
1216
}
1317
}

Assets/HTC.UnityPlugin/PoseTracker/Pose.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//========= Copyright 2016-2017, HTC Corporation. All rights reserved. ===========
22

3+
using HTC.UnityPlugin.Utility;
34
using System;
45
using UnityEngine;
56

@@ -8,6 +9,7 @@ namespace HTC.UnityPlugin.PoseTracker
89
/// <summary>
910
/// Describe a pose by position and rotation
1011
/// </summary>
12+
[Obsolete("Use HTC.UnityPlugin.Utility.RigidPose instead")]
1113
[Serializable]
1214
public struct Pose
1315
{
@@ -192,6 +194,16 @@ public static Pose FromToPose(Pose from, Pose to)
192194
return new Pose(invRot * (to.pos - from.pos), invRot * to.rot);
193195
}
194196

197+
public static implicit operator RigidPose(Pose v)
198+
{
199+
return new RigidPose(v.pos, v.rot);
200+
}
201+
202+
public static implicit operator Pose(RigidPose v)
203+
{
204+
return new Pose(v.pos, v.rot);
205+
}
206+
195207
public override string ToString()
196208
{
197209
return "p" + pos.ToString() + "r" + rot.ToString();

Assets/HTC.UnityPlugin/PoseTracker/PoseModifiers/PoseEaser.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//========= Copyright 2016-2017, HTC Corporation. All rights reserved. ===========
22

3+
using HTC.UnityPlugin.Utility;
34
using UnityEngine;
45

56
namespace HTC.UnityPlugin.PoseTracker
@@ -18,7 +19,7 @@ public class PoseEaser : BasePoseModifier
1819
public float duration = 0.15f;
1920

2021
private bool firstPose = true;
21-
private Pose prevPose;
22+
private RigidPose prevPose;
2223

2324
public bool easePositionX = true;
2425
public bool easePositionY = true;
@@ -34,7 +35,7 @@ protected override void OnEnable()
3435
ResetFirstPose();
3536
}
3637

37-
public override void ModifyPose(ref Pose pose, Transform origin)
38+
public override void ModifyPose(ref RigidPose pose, Transform origin)
3839
{
3940
if (firstPose)
4041
{
@@ -45,7 +46,7 @@ public override void ModifyPose(ref Pose pose, Transform origin)
4546
var deltaTime = Time.unscaledDeltaTime;
4647
if (deltaTime < duration)
4748
{
48-
var easedPose = Pose.Lerp(prevPose, pose, curve.Evaluate(deltaTime / duration));
49+
var easedPose = RigidPose.Lerp(prevPose, pose, curve.Evaluate(deltaTime / duration));
4950

5051
if (!easePositionX || !easePositionY || !easePositionZ)
5152
{

Assets/HTC.UnityPlugin/PoseTracker/PoseModifiers/PoseFreezer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//========= Copyright 2016-2017, HTC Corporation. All rights reserved. ===========
22

3+
using HTC.UnityPlugin.Utility;
34
using UnityEngine;
45

56
namespace HTC.UnityPlugin.PoseTracker
@@ -15,7 +16,7 @@ public class PoseFreezer : BasePoseModifier
1516
public bool freezeRotationY = false;
1617
public bool freezeRotationZ = true;
1718

18-
public override void ModifyPose(ref Pose pose, Transform origin)
19+
public override void ModifyPose(ref RigidPose pose, Transform origin)
1920
{
2021
Vector3 freezePos;
2122
Vector3 freezeEuler;

Assets/HTC.UnityPlugin/PoseTracker/PoseModifiers/PoseStablizer.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//========= Copyright 2016-2017, HTC Corporation. All rights reserved. ===========
22

3+
using HTC.UnityPlugin.Utility;
34
using UnityEngine;
45

56
namespace HTC.UnityPlugin.PoseTracker
@@ -11,15 +12,15 @@ public class PoseStablizer : BasePoseModifier
1112
public float rotationThreshold = 0.5f; // degree
1213

1314
private bool firstPose = true;
14-
private Pose prevPose;
15+
private RigidPose prevPose;
1516

1617
protected override void OnEnable()
1718
{
1819
base.OnEnable();
1920
ResetFirstPose();
2021
}
2122

22-
public override void ModifyPose(ref Pose pose, Transform origin)
23+
public override void ModifyPose(ref RigidPose pose, Transform origin)
2324
{
2425
if (firstPose)
2526
{

Assets/HTC.UnityPlugin/PoseTracker/PoseTracker.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//========= Copyright 2016-2017, HTC Corporation. All rights reserved. ===========
22

3+
using HTC.UnityPlugin.Utility;
34
using UnityEngine;
45

56
namespace HTC.UnityPlugin.PoseTracker
@@ -11,7 +12,7 @@ public class PoseTracker : BasePoseTracker
1112

1213
protected virtual void LateUpdate()
1314
{
14-
TrackPose(new Pose(target, true), target.parent);
15+
TrackPose(new RigidPose(target, true), target.parent);
1516
}
1617
}
1718
}

0 commit comments

Comments
 (0)