Skip to content

Commit 3fc07e6

Browse files
committed
fix(SDK): ensure simulator returns valid play area vertices array
The Simulator was returning a vertices array that was too small and therefore caused anything that required those vertices to crash. Also, all SDKs need to return null if a valid vertices array cannot be obtained so the consuming script can do a null check and prevent attempting to build something with an invalid vertice array.
1 parent 43d2953 commit 3fc07e6

File tree

4 files changed

+17
-32
lines changed

4 files changed

+17
-32
lines changed

Assets/VRTK/SDK/Daydream/SDK_DaydreamBoundaries.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,6 @@ public override Transform GetPlayArea()
5555
/// <returns>A Vector3 array of the points in the scene that represent the play area boundaries.</returns>
5656
public override Vector3[] GetPlayAreaVertices(GameObject playArea)
5757
{
58-
if (area)
59-
{
60-
// taken from SDK_Simulator, is this a valid size? does bounds even make sense in non-positionaly tracked HMD?
61-
Vector3[] vertices = new Vector3[4];
62-
vertices[0] = new Vector3(1, 0, 1);
63-
vertices[1] = new Vector3(-1, 0, 1);
64-
vertices[2] = new Vector3(1, 0, -1);
65-
vertices[3] = new Vector3(-1, 0, -1);
66-
return vertices;
67-
}
6858
return null;
6959
}
7060

Assets/VRTK/SDK/Fallback/SDK_FallbackBoundaries.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,7 @@ public override Transform GetPlayArea()
3434
/// <returns>A Vector3 array of the points in the scene that represent the play area boundaries.</returns>
3535
public override Vector3[] GetPlayAreaVertices(GameObject playArea)
3636
{
37-
return new Vector3[8]
38-
{
39-
Vector3.zero,
40-
Vector3.zero,
41-
Vector3.zero,
42-
Vector3.zero,
43-
Vector3.zero,
44-
Vector3.zero,
45-
Vector3.zero,
46-
Vector3.zero
47-
};
37+
return null;
4838
}
4939

5040
/// <summary>

Assets/VRTK/SDK/OculusVR/SDK_OculusVRBoundaries.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public override Vector3[] GetPlayAreaVertices(GameObject playArea)
7373

7474
return vertices;
7575
}
76-
return new Vector3[0];
76+
return null;
7777
}
7878

7979
/// <summary>

Assets/VRTK/SDK/Simulator/SDK_SimBoundaries.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,21 @@ public override Transform GetPlayArea()
4343
/// <returns>A Vector3 array of the points in the scene that represent the play area boundaries.</returns>
4444
public override Vector3[] GetPlayAreaVertices(GameObject playArea)
4545
{
46-
if (area)
47-
{
48-
Vector3[] vertices = new Vector3[4];
49-
vertices[0] = new Vector3(1, 0, 1);
50-
vertices[1] = new Vector3(-1, 0, 1);
51-
vertices[2] = new Vector3(1, 0, -1);
52-
vertices[3] = new Vector3(-1, 0, -1);
53-
return vertices;
54-
}
55-
return null;
46+
float inner = 0.9f;
47+
float outer = 1f;
48+
49+
Vector3[] vertices = new Vector3[8];
50+
vertices[0] = new Vector3(inner, 0f, -inner);
51+
vertices[1] = new Vector3(-inner, 0f, -inner);
52+
vertices[2] = new Vector3(-inner, 0f, inner);
53+
vertices[3] = new Vector3(inner, 0f, inner);
54+
55+
vertices[4] = new Vector3(outer, 0f, -outer);
56+
vertices[5] = new Vector3(-outer, 0f, -outer);
57+
vertices[6] = new Vector3(-outer, 0f, outer);
58+
vertices[7] = new Vector3(outer, 0f, outer);
59+
60+
return vertices;
5661
}
5762

5863
/// <summary>

0 commit comments

Comments
 (0)