forked from cgvr/DeltaVR
fix shapescanner incorrect ray counting and make asynchronous
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
### TODO
|
||||
* teha build kus archery range'is spawnitud objektid
|
||||
* FMOD ChannelControl errorid
|
||||
* glTF-StableFramerate, Parent-GeneratedModel eemaldada?
|
||||
* speech-to-text:
|
||||
* uurida miks buildis Whisper halvemini töötab
|
||||
* proovida suuremat Whisperi mudelit, äkki töötab mürases keskkonnas paremini
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
@@ -99,13 +99,7 @@ public class ShapeScanner : MonoBehaviour
|
||||
|
||||
private void InitializeConfiguration(ShapeScannerConfiguration configuration)
|
||||
{
|
||||
// Recreate all existing rays
|
||||
foreach (ShapeScannerRay ray in existingRays)
|
||||
{
|
||||
Destroy(ray.gameObject);
|
||||
}
|
||||
existingRays.Clear();
|
||||
|
||||
// Create rays
|
||||
int rayRowCount = configuration.rows.Count;
|
||||
for (int i = 0; i < rayRowCount; i++)
|
||||
{
|
||||
@@ -133,13 +127,14 @@ public class ShapeScanner : MonoBehaviour
|
||||
totalRayCount = configuration.rows.SelectMany(row => row.cells).Count();
|
||||
correctRayCount = configuration.rows.SelectMany(row => row.cells).Count(cell => !cell);
|
||||
|
||||
float percentage = calculateCorrectPercentage();
|
||||
float percentage = CalculateCorrectPercentage();
|
||||
UpdateDisplay(percentage);
|
||||
}
|
||||
|
||||
private void OnConfigurationComplete()
|
||||
{
|
||||
HashSet<GameObject> allCollidingObjects = new HashSet<GameObject>();
|
||||
// Destroy colliding scannable objects
|
||||
HashSet<GameObject> allCollidingObjects = new();
|
||||
foreach (ShapeScannerRay ray in existingRays)
|
||||
{
|
||||
allCollidingObjects.UnionWith(ray.GetCollidingObjects());
|
||||
@@ -161,20 +156,28 @@ public class ShapeScanner : MonoBehaviour
|
||||
Destroy(collidingObject);
|
||||
}
|
||||
|
||||
// Destroy all existing rays
|
||||
foreach (ShapeScannerRay ray in existingRays)
|
||||
{
|
||||
Destroy(ray.gameObject);
|
||||
}
|
||||
existingRays.Clear();
|
||||
|
||||
// Play sound effect and emit particles
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.ShapeScannerSuccess, gameObject);
|
||||
if (!particles.isPlaying) particles.Play();
|
||||
particles.Emit(100);
|
||||
}
|
||||
|
||||
private float calculateCorrectPercentage()
|
||||
private float CalculateCorrectPercentage()
|
||||
{
|
||||
return (float) correctRayCount / totalRayCount * 100;
|
||||
}
|
||||
|
||||
public void IncrementCorrectRayCount()
|
||||
public async void IncrementCorrectRayCount()
|
||||
{
|
||||
correctRayCount++;
|
||||
float correctPercentage = calculateCorrectPercentage();
|
||||
float correctPercentage = CalculateCorrectPercentage();
|
||||
UpdateDisplay(correctPercentage);
|
||||
if (isCompleted)
|
||||
{
|
||||
@@ -183,6 +186,8 @@ public class ShapeScanner : MonoBehaviour
|
||||
if (correctPercentage >= configurations[currentConfiguration].requiredCorrectPercentage)
|
||||
{
|
||||
OnConfigurationComplete();
|
||||
await Task.Delay(1000);
|
||||
|
||||
UpdateCurrentConfigurationDisplay(currentConfiguration + 1);
|
||||
if (currentConfiguration + 1 < configurations.Count)
|
||||
{
|
||||
@@ -202,12 +207,11 @@ public class ShapeScanner : MonoBehaviour
|
||||
public void DecrementCorrectRayCount()
|
||||
{
|
||||
correctRayCount--;
|
||||
UpdateDisplay(calculateCorrectPercentage());
|
||||
UpdateDisplay(CalculateCorrectPercentage());
|
||||
}
|
||||
|
||||
private void UpdateDisplay(float percentage)
|
||||
{
|
||||
Debug.Log("updating display to: " + percentage);
|
||||
correctPercentageDisplay.text = Mathf.Round(percentage).ToString() + " %";
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
"name": "Perfoon",
|
||||
"score": 416.0
|
||||
},
|
||||
{
|
||||
"name": "jjkujkkg",
|
||||
"score": 194.0
|
||||
},
|
||||
{
|
||||
"name": "h",
|
||||
"score": 138.0
|
||||
@@ -11,6 +15,18 @@
|
||||
{
|
||||
"name": "raimps",
|
||||
"score": 115.0
|
||||
},
|
||||
{
|
||||
"name": "k",
|
||||
"score": 58.0
|
||||
},
|
||||
{
|
||||
"name": "kr",
|
||||
"score": 53.0
|
||||
},
|
||||
{
|
||||
"name": "krr",
|
||||
"score": 34.0
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user