Skip to content

Commit eee7a55

Browse files
authored
Merge pull request #6863 from Troy-Ferrell/users/trferrel/line-pointer-refactor-v2
Line pointer refactor for performance
2 parents cd0098f + 5d4260b commit eee7a55

File tree

18 files changed

+553
-482
lines changed

18 files changed

+553
-482
lines changed

Assets/MixedRealityToolkit.SDK/Features/UX/Prefabs/Pointers/DefaultControllerPointer.prefab

Lines changed: 62 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ GameObject:
1212
- component: {fileID: 8090720277987393429}
1313
- component: {fileID: 120690711267243118}
1414
- component: {fileID: 114903794112201558}
15-
- component: {fileID: 7488119136884840896}
1615
- component: {fileID: 114269887534944512}
1716
- component: {fileID: 3980487836371375048}
1817
m_Layer: 0
@@ -135,28 +134,14 @@ LineRenderer:
135134
m_SortingOrder: 0
136135
m_Positions:
137136
- {x: 0, y: 0, z: 0.00009899999}
138-
- {x: 0, y: 0, z: 0.0431347}
139-
- {x: 0, y: 0, z: 0.08617534}
140-
- {x: 0, y: 0, z: 0.12922585}
141-
- {x: 0, y: 0, z: 0.17229114}
142-
- {x: 0, y: 0, z: 0.21537617}
143-
- {x: 0, y: 0, z: 0.25848585}
144-
- {x: 0, y: 0, z: 0.30162507}
145-
- {x: 0, y: 0, z: 0.3447989}
146-
- {x: 0, y: 0, z: 0.3880121}
147-
- {x: 0, y: 0, z: 0.43126965}
148-
- {x: 0, y: 0, z: 0.47457656}
149-
- {x: 0, y: 0, z: 0.5179376}
150-
- {x: 0, y: 0, z: 0.56135786}
151-
- {x: 0, y: 0, z: 0.6048422}
152-
- {x: 0, y: 0, z: 0.64839554}
153-
- {x: 0, y: 0, z: 0.6920228}
154-
- {x: 0, y: 0, z: 0.735729}
155-
- {x: 0, y: 0, z: 0.77951896}
156-
- {x: 0, y: 0, z: 0.82339764}
157-
- {x: 0, y: 0, z: 0.86736983}
158-
- {x: 0, y: 0, z: 0.9114408}
159-
- {x: 0, y: 0, z: 0.95561516}
137+
- {x: 0, y: 0, z: 0.110090755}
138+
- {x: 0, y: 0, z: 0.22016485}
139+
- {x: 0, y: 0, z: 0.3304035}
140+
- {x: 0, y: 0, z: 0.440889}
141+
- {x: 0, y: 0, z: 0.5517036}
142+
- {x: 0, y: 0, z: 0.66292953}
143+
- {x: 0, y: 0, z: 0.77464914}
144+
- {x: 0, y: 0, z: 0.8869445}
160145
- {x: 0, y: 0, z: 0.999898}
161146
m_Parameters:
162147
serializedVersion: 3
@@ -188,32 +173,32 @@ LineRenderer:
188173
colorGradient:
189174
serializedVersion: 2
190175
key0: {r: 1, g: 1, b: 1, a: 0}
191-
key1: {r: 0.8018868, g: 0.8018868, b: 0.8018868, a: 1}
192-
key2: {r: 0, g: 0, b: 0, a: 1}
193-
key3: {r: 0, g: 0, b: 0, a: 0.49803922}
176+
key1: {r: 0.8113208, g: 0.8113208, b: 0.8113208, a: 0}
177+
key2: {r: 0, g: 0, b: 0, a: 0.087757625}
178+
key3: {r: 0, g: 0, b: 0, a: 0.087757625}
194179
key4: {r: 0, g: 0, b: 0, a: 0}
195180
key5: {r: 0, g: 0, b: 0, a: 0}
196-
key6: {r: 0, g: 0, b: 0, a: 0.9411765}
181+
key6: {r: 0, g: 0, b: 0, a: 0}
197182
key7: {r: 0, g: 0, b: 0, a: 0}
198-
ctime0: 32768
183+
ctime0: 0
199184
ctime1: 65535
200185
ctime2: 0
201186
ctime3: 0
202187
ctime4: 0
203188
ctime5: 0
204189
ctime6: 0
205190
ctime7: 0
206-
atime0: 4587
207-
atime1: 11141
208-
atime2: 13762
209-
atime3: 16384
210-
atime4: 22937
211-
atime5: 49151
212-
atime6: 58982
213-
atime7: 65535
191+
atime0: 0
192+
atime1: 4587
193+
atime2: 11141
194+
atime3: 65535
195+
atime4: 0
196+
atime5: 0
197+
atime6: 0
198+
atime7: 0
214199
m_Mode: 0
215200
m_NumColorKeys: 2
216-
m_NumAlphaKeys: 8
201+
m_NumAlphaKeys: 4
217202
numCornerVertices: 8
218203
numCapVertices: 8
219204
alignment: 0
@@ -229,7 +214,7 @@ MonoBehaviour:
229214
m_PrefabInstance: {fileID: 0}
230215
m_PrefabAsset: {fileID: 0}
231216
m_GameObject: {fileID: 1247086986094436}
232-
m_Enabled: 0
217+
m_Enabled: 1
233218
m_EditorHideFlags: 0
234219
m_Script: {fileID: 11500000, guid: 1287d4d138a242f794bcfc01354d3ae2, type: 3}
235220
m_Name:
@@ -239,8 +224,8 @@ MonoBehaviour:
239224
serializedVersion: 2
240225
key0: {r: 1, g: 1, b: 1, a: 0}
241226
key1: {r: 0.8113208, g: 0.8113208, b: 0.8113208, a: 0}
242-
key2: {r: 0, g: 0, b: 0, a: 1}
243-
key3: {r: 0, g: 0, b: 0, a: 1}
227+
key2: {r: 0, g: 0, b: 0, a: 0.087757625}
228+
key3: {r: 0, g: 0, b: 0, a: 0.087757625}
244229
key4: {r: 0, g: 0, b: 0, a: 0}
245230
key5: {r: 0, g: 0, b: 0, a: 0}
246231
key6: {r: 0, g: 0, b: 0, a: 0}
@@ -292,113 +277,7 @@ MonoBehaviour:
292277
colorOffset: 0
293278
widthOffset: 0
294279
stepMode: 0
295-
lineStepCount: 16
296-
pointDistributionMode: 1
297-
customPointDistributionLength: 0.2
298-
customPointDistributionCurve:
299-
serializedVersion: 2
300-
m_Curve:
301-
- serializedVersion: 3
302-
time: 0
303-
value: 0
304-
inSlope: 0
305-
outSlope: 1
306-
tangentMode: 0
307-
weightedMode: 0
308-
inWeight: 0
309-
outWeight: 0
310-
- serializedVersion: 3
311-
time: 1
312-
value: 1
313-
inSlope: 1
314-
outSlope: 0
315-
tangentMode: 0
316-
weightedMode: 0
317-
inWeight: 0
318-
outWeight: 0
319-
m_PreInfinity: 2
320-
m_PostInfinity: 2
321-
m_RotationOrder: 4
322-
lineMaterial: {fileID: 2100000, guid: 11727442de02c1d4b8d37a063c748aec, type: 2}
323-
roundedEdges: 1
324-
roundedCaps: 1
325-
fadeLineBrightnessOnEnable: 1
326-
fadeLinePercentage: 0.55
327-
fadeLineAnimationTime: 0.65
328-
lineRenderer: {fileID: 120690711267243118}
329-
tileMaterialByWorldLength: 0
330-
tileMaterialScale: 1
331-
--- !u!114 &7488119136884840896
332-
MonoBehaviour:
333-
m_ObjectHideFlags: 0
334-
m_CorrespondingSourceObject: {fileID: 0}
335-
m_PrefabInstance: {fileID: 0}
336-
m_PrefabAsset: {fileID: 0}
337-
m_GameObject: {fileID: 1247086986094436}
338-
m_Enabled: 1
339-
m_EditorHideFlags: 0
340-
m_Script: {fileID: 11500000, guid: 1287d4d138a242f794bcfc01354d3ae2, type: 3}
341-
m_Name:
342-
m_EditorClassIdentifier:
343-
lineDataSource: {fileID: 8090720277987393429}
344-
lineColor:
345-
serializedVersion: 2
346-
key0: {r: 1, g: 1, b: 1, a: 0}
347-
key1: {r: 0.8018868, g: 0.8018868, b: 0.8018868, a: 1}
348-
key2: {r: 0, g: 0, b: 0, a: 1}
349-
key3: {r: 0, g: 0, b: 0, a: 0.49803922}
350-
key4: {r: 0, g: 0, b: 0, a: 0}
351-
key5: {r: 0, g: 0, b: 0, a: 0}
352-
key6: {r: 0, g: 0, b: 0, a: 0.9411765}
353-
key7: {r: 0, g: 0, b: 0, a: 0}
354-
ctime0: 32768
355-
ctime1: 65535
356-
ctime2: 0
357-
ctime3: 0
358-
ctime4: 0
359-
ctime5: 0
360-
ctime6: 0
361-
ctime7: 0
362-
atime0: 4587
363-
atime1: 11141
364-
atime2: 13762
365-
atime3: 16384
366-
atime4: 22937
367-
atime5: 49151
368-
atime6: 58982
369-
atime7: 65535
370-
m_Mode: 0
371-
m_NumColorKeys: 2
372-
m_NumAlphaKeys: 8
373-
lineWidth:
374-
serializedVersion: 2
375-
m_Curve:
376-
- serializedVersion: 3
377-
time: 0
378-
value: 0.15
379-
inSlope: 0
380-
outSlope: 0
381-
tangentMode: 0
382-
weightedMode: 0
383-
inWeight: 0
384-
outWeight: 0
385-
- serializedVersion: 3
386-
time: 1
387-
value: 0.15
388-
inSlope: 0
389-
outSlope: 0
390-
tangentMode: 0
391-
weightedMode: 0
392-
inWeight: 0
393-
outWeight: 0
394-
m_PreInfinity: 2
395-
m_PostInfinity: 2
396-
m_RotationOrder: 4
397-
widthMultiplier: 0.01
398-
colorOffset: 0
399-
widthOffset: 0
400-
stepMode: 0
401-
lineStepCount: 36
280+
lineStepCount: 10
402281
pointDistributionMode: 1
403282
customPointDistributionLength: 0.1
404283
customPointDistributionCurve:
@@ -428,7 +307,7 @@ MonoBehaviour:
428307
lineMaterial: {fileID: 2100000, guid: 876c7e981edab3a44918b5c51482a286, type: 2}
429308
roundedEdges: 1
430309
roundedCaps: 1
431-
fadeLineBrightnessOnEnable: 1
310+
fadeLineBrightnessOnEnable: 0
432311
fadeLinePercentage: 0.55
433312
fadeLineAnimationTime: 0.65
434313
lineRenderer: {fileID: 120690711267243118}
@@ -472,7 +351,6 @@ MonoBehaviour:
472351
pointerExtent: 10
473352
defaultPointerExtent: 5.5
474353
sphereCastRadius: 0.1
475-
LineCastResolution: 2
476354
LineColorSelected:
477355
serializedVersion: 2
478356
key0: {r: 0.990566, g: 0.990566, b: 0.990566, a: 0}
@@ -505,32 +383,32 @@ MonoBehaviour:
505383
LineColorValid:
506384
serializedVersion: 2
507385
key0: {r: 1, g: 1, b: 1, a: 0}
508-
key1: {r: 0.9056604, g: 0.9056604, b: 0.9056604, a: 0}
509-
key2: {r: 0, g: 0, b: 0, a: 1}
510-
key3: {r: 0, g: 0, b: 0, a: 1}
386+
key1: {r: 0.8018868, g: 0.8018868, b: 0.8018868, a: 0.55}
387+
key2: {r: 0, g: 0, b: 0, a: 0.55}
388+
key3: {r: 0, g: 0, b: 0, a: 0.27392158}
511389
key4: {r: 0, g: 0, b: 0, a: 0}
512390
key5: {r: 0, g: 0, b: 0, a: 0}
513-
key6: {r: 0, g: 0, b: 0, a: 0}
391+
key6: {r: 0, g: 0, b: 0, a: 0.5176471}
514392
key7: {r: 0, g: 0, b: 0, a: 0}
515-
ctime0: 0
393+
ctime0: 32768
516394
ctime1: 65535
517395
ctime2: 0
518396
ctime3: 0
519397
ctime4: 0
520398
ctime5: 0
521399
ctime6: 0
522400
ctime7: 0
523-
atime0: 0
524-
atime1: 4587
525-
atime2: 11141
526-
atime3: 65535
527-
atime4: 63222
528-
atime5: 0
529-
atime6: 0
530-
atime7: 0
401+
atime0: 4587
402+
atime1: 11141
403+
atime2: 13762
404+
atime3: 16384
405+
atime4: 22937
406+
atime5: 49151
407+
atime6: 58982
408+
atime7: 65535
531409
m_Mode: 0
532410
m_NumColorKeys: 2
533-
m_NumAlphaKeys: 4
411+
m_NumAlphaKeys: 8
534412
LineColorInvalid:
535413
serializedVersion: 2
536414
key0: {r: 1, g: 0.7971698, b: 0.7971698, a: 0}
@@ -562,33 +440,33 @@ MonoBehaviour:
562440
m_NumAlphaKeys: 3
563441
LineColorNoTarget:
564442
serializedVersion: 2
565-
key0: {r: 0.8113208, g: 0.8113208, b: 0.8113208, a: 0}
566-
key1: {r: 0.6132076, g: 0.6132076, b: 0.6132076, a: 1}
567-
key2: {r: 0, g: 0, b: 0, a: 0.43137255}
568-
key3: {r: 0, g: 0, b: 0, a: 0}
443+
key0: {r: 1, g: 1, b: 1, a: 0}
444+
key1: {r: 0.8018868, g: 0.8018868, b: 0.8018868, a: 0.55}
445+
key2: {r: 0, g: 0, b: 0, a: 0.627451}
446+
key3: {r: 0, g: 0, b: 0, a: 0.27392158}
569447
key4: {r: 0, g: 0, b: 0, a: 0}
570448
key5: {r: 0, g: 0, b: 0, a: 0}
571-
key6: {r: 0, g: 0, b: 0, a: 0}
449+
key6: {r: 0, g: 0, b: 0, a: 0.69411767}
572450
key7: {r: 0, g: 0, b: 0, a: 0}
573-
ctime0: 0
451+
ctime0: 32768
574452
ctime1: 65535
575453
ctime2: 0
576454
ctime3: 0
577455
ctime4: 0
578456
ctime5: 0
579457
ctime6: 0
580458
ctime7: 0
581-
atime0: 0
582-
atime1: 1735
583-
atime2: 50115
584-
atime3: 65535
585-
atime4: 0
586-
atime5: 0
587-
atime6: 0
588-
atime7: 0
459+
atime0: 4587
460+
atime1: 11141
461+
atime2: 13762
462+
atime3: 16384
463+
atime4: 22937
464+
atime5: 49151
465+
atime6: 59385
466+
atime7: 65535
589467
m_Mode: 0
590468
m_NumColorKeys: 2
591-
m_NumAlphaKeys: 4
469+
m_NumAlphaKeys: 8
592470
LineColorLockFocus:
593471
serializedVersion: 2
594472
key0: {r: 1, g: 1, b: 1, a: 0}
@@ -621,11 +499,15 @@ MonoBehaviour:
621499
lineBase: {fileID: 8090720277987393429}
622500
lineRenderers:
623501
- {fileID: 114903794112201558}
624-
lineRendererSelected: {fileID: 114903794112201558}
625-
lineRendererNoTarget: {fileID: 7488119136884840896}
502+
lineMaterialSelected: {fileID: 2100000, guid: 11727442de02c1d4b8d37a063c748aec,
503+
type: 2}
504+
lineMaterialNoTarget: {fileID: 2100000, guid: 876c7e981edab3a44918b5c51482a286,
505+
type: 2}
626506
inertia: {fileID: 3980487836371375048}
627507
startPointLerp: 0.267
628508
endPointLerp: 0.637
509+
lineRendererSelected: {fileID: 0}
510+
lineRendererNoTarget: {fileID: 0}
629511
--- !u!114 &3980487836371375048
630512
MonoBehaviour:
631513
m_ObjectHideFlags: 0
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
using Microsoft.MixedReality.Toolkit.Physics;
5+
using UnityEngine;
6+
7+
namespace Microsoft.MixedReality.Toolkit.Input
8+
{
9+
/// <summary>
10+
/// Extends line pointer to support curves. Useful for teleportation or other situations where multiple raysteps need to be tested along a spline
11+
/// </summary>
12+
[AddComponentMenu("Scripts/MRTK/SDK/CurvePointer")]
13+
public class CurvePointer : LinePointer
14+
{
15+
[Range(1, 50)]
16+
[SerializeField]
17+
[Tooltip("Number of ray steps to utilize in raycast operation along curve defined in LineBase. This setting has a high performance cost. Values above 20 are not recommended.")]
18+
protected int LineCastResolution = 10;
19+
20+
/// <inheritdoc />
21+
protected override void UpdateRays()
22+
{
23+
// Make sure our array will hold
24+
if (Rays == null || Rays.Length != LineCastResolution)
25+
{
26+
Rays = new RayStep[LineCastResolution];
27+
}
28+
29+
float stepSize = 1f / Rays.Length;
30+
Vector3 lastPoint = LineBase.GetUnClampedPoint(0f);
31+
for (int i = 0; i < Rays.Length; i++)
32+
{
33+
Vector3 currentPoint = LineBase.GetUnClampedPoint(stepSize * (i + 1));
34+
Rays[i].UpdateRayStep(ref lastPoint, ref currentPoint);
35+
lastPoint = currentPoint;
36+
}
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)