From 8a17cd03497a4037067f9c1714d69a8975090189 Mon Sep 17 00:00:00 2001 From: Mikkel Bybjerg Date: Sat, 27 Apr 2019 09:09:57 +0200 Subject: optimize dragon transformations --- nGJ2019/Assets/Scripts/SwarmSystem.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'nGJ2019/Assets/Scripts/SwarmSystem.cs') diff --git a/nGJ2019/Assets/Scripts/SwarmSystem.cs b/nGJ2019/Assets/Scripts/SwarmSystem.cs index 9f19dd0..9658a92 100644 --- a/nGJ2019/Assets/Scripts/SwarmSystem.cs +++ b/nGJ2019/Assets/Scripts/SwarmSystem.cs @@ -26,6 +26,7 @@ public class SwarmSystem : MonoBehaviour private List> triGraph; public float Noise {get; set;} + public float Collapse {get; set;} private Mesh getCurrentMesh() { @@ -365,11 +366,15 @@ public class SwarmSystem : MonoBehaviour Vector3 boneCenter = findBoneCenter(u, out boneDirec); - anchors[u].position = boneCenter + (Quaternion.AngleAxis(1f, boneDirec) * (anchors[u].position - boneCenter)); + anchors[u].position = boneCenter + (Quaternion.AngleAxis(3f, boneDirec) * (anchors[u].position - boneCenter)); anchors[u].position = meshIntersection(u, vertices, triangles, boneCenter); unit.position = anchors[u].position + Noise*noiseDirecs[u]; + + Vector3 collapsedPos = Vector3.Project(unit.position - transform.position, Vector3.right) + transform.position; + + unit.position = (1-Collapse)*unit.position + Collapse*collapsedPos; } } -- cgit v1.2.3