Skip to content
Snippets Groups Projects
Commit 733a633f authored by MaZiFAU's avatar MaZiFAU
Browse files

Fixed Bugs; Added PluginAssembly;

Fixed Bugs:
+multiple hits logic/highlight/remover

Added PluginAssembly:
+should help with compile time
parent cc85781e
No related branches found
No related tags found
No related merge requests found
{
"name": "PluginAssembly",
"rootNamespace": "",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
\ No newline at end of file
fileFormatVersion: 2
guid: 4db3019411610f640ae53ea9ba8dab0a
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
...@@ -493,7 +493,7 @@ RectTransform: ...@@ -493,7 +493,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -33793.79} m_AnchoredPosition: {x: 0, y: -41183.812}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 1} m_Pivot: {x: 0.5, y: 1}
--- !u!114 &8823539307371861913 --- !u!114 &8823539307371861913
......
...@@ -20,7 +20,7 @@ MonoBehaviour: ...@@ -20,7 +20,7 @@ MonoBehaviour:
ButtonIndx: 1 ButtonIndx: 1
LayerHitMask: LayerHitMask:
serializedVersion: 2 serializedVersion: 2
m_Bits: 1572913 m_Bits: 1581105
SecondaryLayerMask: SecondaryLayerMask:
serializedVersion: 2 serializedVersion: 2
m_Bits: 0 m_Bits: 0
...@@ -162,7 +162,7 @@ public void CoroutineCascadeForMeAndChildrenAllRenderer(Func<FactObject, Rendere ...@@ -162,7 +162,7 @@ public void CoroutineCascadeForMeAndChildrenAllRenderer(Func<FactObject, Rendere
CascadeForMeAndChildren((FactObject fo) => CascadeForMeAndChildren((FactObject fo) =>
fo.ForAllRenderer((Renderer ren) => fo.ForAllRenderer((Renderer ren) =>
StartCoroutine(func(fo, ren)) this.StartCoroutine(func(fo, ren))
)); ));
} }
} }
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using UnityEngine; using UnityEngine;
using static CommunicationEvents; using static CommunicationEvents;
...@@ -12,13 +13,17 @@ public class Remover : Gadget ...@@ -12,13 +13,17 @@ public class Remover : Gadget
public override void _Hit(RaycastHit[] hit) public override void _Hit(RaycastHit[] hit)
{ {
// It's probably better to keep this only on the first hit and not multiple hits bool samestep = false;
string hid = hit[0].transform.GetComponent<FactObject>()?.URI; foreach (string uri in hit.Select(h => h.transform.GetComponent<FactObject>()?.URI))
if (hid == null) {
return; if(uri == null)
continue;
Workflow.Add(hid); Workflow.Add(uri);
StageStatic.stage.factState.Remove(Workflow[0], samestep: false, gadget: this); StageStatic.stage.factState.Remove(Workflow.Last(), samestep, gadget: this);
samestep = true;
}
ResetGadget(); ResetGadget();
} }
......
...@@ -7,7 +7,7 @@ public class ShinyThings : MonoBehaviour ...@@ -7,7 +7,7 @@ public class ShinyThings : MonoBehaviour
{ {
public WorldCursor Cursor; public WorldCursor Cursor;
//Attributes for Highlighting of Facts when Mouse-Over //Attributes for Highlighting of Facts when Mouse-Over
private FactObject lastFactSelection; private List<FactObject> LastFactSelection = new();
//Variables for Pushout-Highlighting //Variables for Pushout-Highlighting
private static float timerDuration = 2.5f; private static float timerDuration = 2.5f;
...@@ -34,10 +34,7 @@ private void Awake() ...@@ -34,10 +34,7 @@ private void Awake()
CommunicationEvents.AnimateExistingAsSolutionEvent.AddListener(HighlightWithFireworks); CommunicationEvents.AnimateExistingAsSolutionEvent.AddListener(HighlightWithFireworks);
rain = rain_wait = IEnumeratorExtensions.yield_break; rain = rain_wait = IEnumeratorExtensions.yield_break;
}
public void Start()
{
if (Cursor == null) if (Cursor == null)
Cursor = GetComponent<WorldCursor>(); Cursor = GetComponent<WorldCursor>();
...@@ -49,30 +46,30 @@ public void Start() ...@@ -49,30 +46,30 @@ public void Start()
public void Update() public void Update()
{ {
foreach(var hit in Cursor.Hits) if (Cursor?.Hits != null)
HighlightCurserHit(hit); HighlightCurserHit(Cursor.Hits);
} }
private void HighlightCurserHit(RaycastHit hit) private void HighlightCurserHit(RaycastHit[] hits)
{ {
FactObject selected_fact_obj = hit.transform?.GetComponentInChildren<FactObject>(); List<FactObject> selected_fact_objs = hits
.Select(h => h.transform?.GetComponentInChildren<FactObject>())
.Where(f => f != null)
.ToList();
//Set the last Fact unselected //Set the last Facts unselected
if (this.lastFactSelection != null foreach (var lastFact in LastFactSelection)
&& (selected_fact_obj == null || this.lastFactSelection != selected_fact_obj)) if (lastFact != null
{ && !selected_fact_objs.Contains(lastFact))
ApplyMaterial(lastFactSelection, lastFactSelection.Default); ApplyMaterial(lastFact, lastFact.Default);
this.lastFactSelection = null;
}
//Set the Fact that was Hit as selected //Set the Facts that were Hit as selected
if (selected_fact_obj != null && hit.transform != null foreach (var fact_obj in selected_fact_objs)
&& (hit.transform.CompareTag("Selectable") || hit.transform.CompareTag("SnapZone")) if (!LastFactSelection.Contains(fact_obj))
&& (this.lastFactSelection == null || this.lastFactSelection != selected_fact_obj)) ApplyMaterial(fact_obj, fact_obj.Selected);
{
ApplyMaterial(selected_fact_obj, selected_fact_obj.Selected); LastFactSelection = selected_fact_objs;
this.lastFactSelection = selected_fact_obj; return;
}
void ApplyMaterial(FactObject root, Material new_mat) => void ApplyMaterial(FactObject root, Material new_mat) =>
root.CoroutineCascadeForMeAndChildrenAllRenderer( root.CoroutineCascadeForMeAndChildrenAllRenderer(
...@@ -109,7 +106,7 @@ public void HighlightWithFireworks(Fact fact, FactObject.FactMaterials mat) ...@@ -109,7 +106,7 @@ public void HighlightWithFireworks(Fact fact, FactObject.FactMaterials mat)
IEnumerator BlossomAndDie() IEnumerator BlossomAndDie()
{ {
GameObject firework = GameObject.Instantiate GameObject firework = GameObject.Instantiate
( Fireworks_Animation (Fireworks_Animation
, fact.Representation.transform , fact.Representation.transform
); );
......
...@@ -11,7 +11,7 @@ public class WorldCursor : MonoBehaviour ...@@ -11,7 +11,7 @@ public class WorldCursor : MonoBehaviour
// TODO experimentell for multiple hits // TODO experimentell for multiple hits
public RaycastHit[] Hits; public RaycastHit[] Hits;
public float CollisionDistance = 0.1f; public float IntersectionDistance = 0.1f;
public string deactivateSnapKey; public string deactivateSnapKey;
private Camera Cam; private Camera Cam;
...@@ -118,9 +118,15 @@ void Update() ...@@ -118,9 +118,15 @@ void Update()
break; // we had at least 1 succesfull case break; // we had at least 1 succesfull case
} }
if (i + 1 < Hits.Length if (i == Hits.Length)
&& Hits[i + 1].distance - Hits[i + 0].distance < CollisionDistance) return; // no valid Hit
{ // we have two objects intersecting
Hits = Hits.Skip(i)
.TakeWhile(h => h.distance - Hits[i].distance < IntersectionDistance)
.ToArray();
if (Hits.Length > 1)
{ // we have two or more objects intersecting
if (facts[i + 0] is RayFact rayFact1 if (facts[i + 0] is RayFact rayFact1
&& facts[i + 1] is RayFact rayFact2) && facts[i + 1] is RayFact rayFact2)
{ {
...@@ -128,21 +134,14 @@ void Update() ...@@ -128,21 +134,14 @@ void Update()
, rayFact2.Point1.Point, rayFact2.Dir , rayFact2.Point1.Point, rayFact2.Dir
, rayFact1.Point1.Point, rayFact1.Dir)) , rayFact1.Point1.Point, rayFact1.Dir))
{ {
Hits[i].point = intersectionPoint; Hits[i + 0].point = intersectionPoint;
Hits[i + 1].point = intersectionPoint;
} }
} }
//TODO: check for other types of intersection. Future Work //TODO: check for other types of intersection. Future Work
} }
int nr_hits = Hits.Length - i;
if (i == Hits.Length)
{
i = 0;
nr_hits = 1;
}
Hits = Hits.Slice(i, nr_hits).ToArray();
transform.up = Hits[0].normal; transform.up = Hits[0].normal;
transform.position = Hits[0].point + .01f * Hits[0].normal; transform.position = Hits[0].point + .01f * Hits[0].normal;
......
...@@ -33,7 +33,7 @@ public void RevertMode() ...@@ -33,7 +33,7 @@ public void RevertMode()
/// <param name="select">Page to switch to</param> /// <param name="select">Page to switch to</param>
public void SetMode(int select) public void SetMode(int select)
{ {
gameObject.SetActiveAllChildren(false); Pages.SetActiveAllChildren(false);
mode_last = mode; mode_last = mode;
mode = select; mode = select;
......
...@@ -30,10 +30,10 @@ EditorUserSettings: ...@@ -30,10 +30,10 @@ EditorUserSettings:
value: 00540c020302515f0b0f5f2711265c44171519797e7c7463787d4d63e1b8303c value: 00540c020302515f0b0f5f2711265c44171519797e7c7463787d4d63e1b8303c
flags: 0 flags: 0
RecentlyUsedSceneGuid-8: RecentlyUsedSceneGuid-8:
value: 57505505560608585a56557116730644404e4d7b7c7b7562787e4f66e4b1313e value: 0709560454055c0d0c5e5c2444740b4413154a72792d22627c714963e0b6373d
flags: 0 flags: 0
RecentlyUsedSceneGuid-9: RecentlyUsedSceneGuid-9:
value: 0709560454055c0d0c5e5c2444740b4413154a72792d22627c714963e0b6373d value: 57505505560608585a56557116730644404e4d7b7c7b7562787e4f66e4b1313e
flags: 0 flags: 0
RecentlyUsedScenePath-0: RecentlyUsedScenePath-0:
value: 22424703114646680e0b0227036c681f041b1c39631c3435281e1221eee47a2decee22f0 value: 22424703114646680e0b0227036c681f041b1c39631c3435281e1221eee47a2decee22f0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment