forked from cgvr/DeltaVR
reduced shape scanner conf count, fix bug with HUD
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -68,8 +68,8 @@ public class ShapeScanner : MonoBehaviour
|
||||
private float raySpawnDistanceX;
|
||||
private float raySpawnDistanceZ;
|
||||
private int currentConfiguration;
|
||||
private int rayCount;
|
||||
private int correctRayStates;
|
||||
private int totalRayCount;
|
||||
private int correctRayCount;
|
||||
private bool isCompleted;
|
||||
|
||||
|
||||
@@ -109,11 +109,10 @@ public class ShapeScanner : MonoBehaviour
|
||||
int rayRowCount = configuration.rows.Count;
|
||||
for (int i = 0; i < rayRowCount; i++)
|
||||
{
|
||||
float rayPosX = raySpawnCorner1.localPosition.x + i * raySpawnDistanceX / (rayRowCount - 1);
|
||||
float rayPosZ = raySpawnCorner1.localPosition.z + i * raySpawnDistanceZ / (rayRowCount - 1);
|
||||
for (int j = 0; j < rayRowCount; j++)
|
||||
{
|
||||
// Local position
|
||||
float rayPosZ = raySpawnCorner1.localPosition.z + j * raySpawnDistanceZ / (rayRowCount - 1);
|
||||
float rayPosX = raySpawnCorner1.localPosition.x + j * raySpawnDistanceX / (rayRowCount - 1);
|
||||
Vector3 rayPos = new Vector3(rayPosX, 0, rayPosZ);
|
||||
ShapeScannerRay ray = Instantiate(rayPrefab, rayParent);
|
||||
ray.transform.localPosition = rayPos;
|
||||
@@ -131,9 +130,11 @@ public class ShapeScanner : MonoBehaviour
|
||||
}
|
||||
}
|
||||
// Count total rays and required collision rays
|
||||
rayCount = configuration.rows.SelectMany(row => row.cells).Count();
|
||||
correctRayStates = configuration.rows.SelectMany(row => row.cells).Count(cell => !cell);
|
||||
UpdateDisplay(calculateCorrectPercentage());
|
||||
totalRayCount = configuration.rows.SelectMany(row => row.cells).Count();
|
||||
correctRayCount = configuration.rows.SelectMany(row => row.cells).Count(cell => !cell);
|
||||
|
||||
float percentage = calculateCorrectPercentage();
|
||||
UpdateDisplay(percentage);
|
||||
}
|
||||
|
||||
private void OnConfigurationComplete()
|
||||
@@ -167,12 +168,12 @@ public class ShapeScanner : MonoBehaviour
|
||||
|
||||
private float calculateCorrectPercentage()
|
||||
{
|
||||
return (float) correctRayStates / rayCount * 100;
|
||||
return (float) correctRayCount / totalRayCount * 100;
|
||||
}
|
||||
|
||||
public void IncrementCorrectRayCount()
|
||||
{
|
||||
correctRayStates++;
|
||||
correctRayCount++;
|
||||
float correctPercentage = calculateCorrectPercentage();
|
||||
UpdateDisplay(correctPercentage);
|
||||
if (isCompleted)
|
||||
@@ -182,14 +183,14 @@ public class ShapeScanner : MonoBehaviour
|
||||
if (correctPercentage >= configurations[currentConfiguration].requiredCorrectPercentage)
|
||||
{
|
||||
OnConfigurationComplete();
|
||||
UpdateCurrentConfigurationDisplay(currentConfiguration + 1);
|
||||
if (currentConfiguration + 1 < configurations.Count)
|
||||
{
|
||||
currentConfiguration++;
|
||||
InitializeConfiguration(configurations[currentConfiguration]);
|
||||
UpdateCurrentConfigurationDisplay(currentConfiguration);
|
||||
} else
|
||||
{
|
||||
// Initialize configuration with all rays requiring collision
|
||||
// Initialize configuration with no rays requiring collision
|
||||
List<BoolRow> rows = Enumerable.Repeat(new BoolRow(Enumerable.Repeat(false, 6).ToList()), 6).ToList();
|
||||
ShapeScannerConfiguration configuration = new ShapeScannerConfiguration(6, 100, rows);
|
||||
InitializeConfiguration(configuration);
|
||||
@@ -200,12 +201,13 @@ public class ShapeScanner : MonoBehaviour
|
||||
|
||||
public void DecrementCorrectRayCount()
|
||||
{
|
||||
correctRayStates--;
|
||||
correctRayCount--;
|
||||
UpdateDisplay(calculateCorrectPercentage());
|
||||
}
|
||||
|
||||
private void UpdateDisplay(float percentage)
|
||||
{
|
||||
Debug.Log("updating display to: " + percentage);
|
||||
correctPercentageDisplay.text = Mathf.Round(percentage).ToString() + " %";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user