An open source Danmaku development kit for Unity3D.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Removed FastTrig

It wasn't fast, in fact it was slower by almost a factor of 10.

james713 0a52ee14 cfe7d0fe

+9 -123
+4 -3
Assets/Dependencies/DanmakU/_Core_/Danmaku.cs
··· 97 97 if (AngularSpeed != 0f) { 98 98 float rotationChange = AngularSpeed * dt; 99 99 rotation += rotationChange; 100 - direction = FastTrig.UnitCircle(rotation); 100 + direction = Util.OnUnitCircle(rotation); 101 101 } 102 102 103 103 if (Speed != 0) { ··· 206 206 } 207 207 } 208 208 209 - if (!_isActive) { 209 + if (!_isActive || to_deactivate) { 210 210 DeactivateImmediate(); 211 211 return; 212 212 } ··· 319 319 /// If Danmaku needs to be deactivated in a moment when it is not being updated (i.e. when the game is paused), use <see cref="DeactivateImmediate"/> instead. 320 320 /// </remarks> 321 321 public void Deactivate() { 322 + Debug.Log("Hello"); 322 323 to_deactivate = true; 323 324 } 324 325 ··· 454 455 get { return rotation; } 455 456 set { 456 457 rotation = value; 457 - direction = FastTrig.UnitCircle(value); 458 + direction = Util.OnUnitCircle(rotation); 458 459 } 459 460 } 460 461
-23
Assets/Dependencies/DanmakU/_Core_/DanmakuBehavior.cs
··· 16 16 protected static float Dt { 17 17 get { return TimeUtil.DeltaTime; } 18 18 } 19 - 20 - /// <summary> 21 - /// Calculates the cosine of the 22 - /// </summary> 23 - /// <remarks> 24 - /// This function has much better performance than Mathf.Cos; however it can have much lower accuracy. 25 - /// </remarks> 26 - /// <param name="degree">Degree.</param> 27 - protected static float Cos(float degree) { 28 - return FastTrig.Cos(degree); 29 - } 30 - 31 - protected static float Sin(float degree) { 32 - return FastTrig.Sin(degree); 33 - } 34 - 35 - protected static float Tan(float degree) { 36 - return FastTrig.Tan(degree); 37 - } 38 - 39 - protected static Vector2 UnitCircle(float degree) { 40 - return FastTrig.UnitCircle(degree); 41 - } 42 19 } 43 20 44 21 }
+1 -1
Assets/Dependencies/DanmakU/_Core_/Util/Extensions/DanmakuCollectionExtensions.cs
··· 18 18 if (action == null) 19 19 throw new ArgumentNullException("action"); 20 20 foreach (Danmaku danmaku in danmakus) { 21 - if (danmaku && (filter == null || filter(danmaku))) 21 + if (danmaku != null && (filter == null || filter(danmaku))) 22 22 action(danmaku); 23 23 } 24 24 return danmakus;
-79
Assets/Dependencies/HouraiLib/Util/FastTrig.cs
··· 1 - using UnityEngine; 2 - using System.Collections; 3 - 4 - namespace Hourai 5 - { 6 - 7 - public static class FastTrig 8 - { 9 - /// <summary> 10 - /// A set of 2D vectors corresponding to unit circle coordinates 11 - /// Precalculated since Cosine and Sine calculations are expensive when called thousands of times per frame. 12 - /// An array access on an array of structs is much cheaper than calling both Mathf.Cos, and Mathf.Sin. 13 - /// </summary> 14 - internal static Vector2[] unitCircle; 15 - 16 - private const float DefaultAngleResolution = 0.01f; 17 - 18 - private static float _angRes = DefaultAngleResolution; 19 - private static float invAngRes; 20 - private static int unitCircleMax; 21 - 22 - public static float AngleResolution 23 - { 24 - get { return _angRes; } 25 - set 26 - { 27 - value = Mathf.Abs(value); 28 - bool changed = _angRes != value; 29 - _angRes = value; 30 - if (changed) 31 - Calculate(); 32 - } 33 - } 34 - 35 - static FastTrig() 36 - { 37 - Calculate(); 38 - } 39 - 40 - static void Calculate() 41 - { 42 - invAngRes = 1f / _angRes; 43 - unitCircleMax = Mathf.CeilToInt(360f / _angRes); 44 - float angle = 90f; 45 - unitCircle = new Vector2[unitCircleMax]; 46 - for (int i = 0; i < unitCircleMax; i++) 47 - { 48 - angle += _angRes; 49 - unitCircle[i] = Util.OnUnitCircle(angle); 50 - } 51 - } 52 - 53 - 54 - public static Vector2 UnitCircle(float angle) 55 - { 56 - //Clamp the angle to the range [0,360] 57 - angle = (angle % 360f + 360f) % 360f; 58 - return unitCircle[(int)(angle * invAngRes)]; 59 - } 60 - 61 - public static float Cos(float angle) 62 - { 63 - return UnitCircle(angle).x; 64 - } 65 - 66 - public static float Sin(float angle) 67 - { 68 - return UnitCircle(angle).y; 69 - } 70 - 71 - public static float Tan(float angle) 72 - { 73 - Vector2 uc = UnitCircle(angle); 74 - if (uc.x == 0f) 75 - return float.NaN; 76 - return uc.y / uc.x; 77 - } 78 - } 79 - }
-12
Assets/Dependencies/HouraiLib/Util/FastTrig.cs.meta
··· 1 - fileFormatVersion: 2 2 - guid: 4dc31966bd67ac347bab516c068a3eac 3 - timeCreated: 1441318393 4 - licenseType: Free 5 - MonoImporter: 6 - serializedVersion: 2 7 - defaultReferences: [] 8 - executionOrder: 0 9 - icon: {instanceID: 0} 10 - userData: 11 - assetBundleName: 12 - assetBundleVariant:
+3 -4
Assets/Test/BasicFireTest.cs
··· 25 25 FireData data = prefab; 26 26 group.Bind(data); 27 27 test = data.Infinite(Modifier.Rotate(2.5f)) 28 - .From(gameObject.Descendants()) 28 + //.From(gameObject.Descendants()) 29 29 .WithSpeed(2) 30 30 .Delay(delay) 31 31 .RadialBurst(100) ··· 33 33 Invoke("Test", 10); 34 34 } 35 35 36 - void Test() { 37 - Debug.Log(group.Count); 38 - group.Color(grad); 36 + void Test() { 37 + group.Deactivate(); 39 38 test.Stop(); 40 39 } 41 40
+1 -1
Assets/Test/Test Scene.unity
··· 329 329 m_Script: {fileID: 11500000, guid: 42f54d3639c02544385383898827713d, type: 3} 330 330 m_Name: 331 331 m_EditorClassIdentifier: 332 - delay: .00999999978 332 + delay: 0 333 333 prefab: {fileID: 11409350, guid: 5c0c5bf0c434853449fa68def8d34e65, type: 2} 334 334 grad: 335 335 key0: