An open source Danmaku development kit for Unity3D.
0
fork

Configure Feed

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

Fixed bug with inaccurate rendering/processing

Previously either inactive or random stray bullets would get rendered or
skip processing for a frame or become doubly processed. This has now been
fixed.

james713 923afe97 5deb3918

+40 -10
+10
Assets/Dependencies/DanmakU/_Core_/Danmaku.cs
··· 226 226 if (!IsActive) 227 227 return; 228 228 Type.Return(this); 229 + DestroyImpl(); 230 + } 231 + 232 + /// <summary> 233 + /// What actually destroys 234 + /// Note that this does not return the Danmaku to the pool. 235 + /// This is used for 236 + /// </summary> 237 + internal void DestroyImpl() 238 + { 229 239 if (OnDestroy != null) 230 240 OnDestroy(this); 231 241
+29 -9
Assets/Dependencies/DanmakU/_Core_/DanmakuPrefab.cs
··· 16 16 17 17 namespace Hourai.DanmakU { 18 18 19 + /// <summary> 20 + /// 21 + /// </summary> 19 22 [RequireComponent(typeof(ParticleSystem))] 20 23 public abstract class DanmakuType : MonoBehaviour, IEnumerable<Danmaku> 21 24 { ··· 48 51 internal int sortingOrder; 49 52 50 53 private int updateIndex; 54 + private ParticleSystem.Particle particle; 51 55 52 56 Action PostUpdate; 53 57 ··· 207 211 danmakuSystem.GetParticles(particles); 208 212 209 213 // For some reason, new ParticleSystem.Particle breaks bullet systems 210 - // but accessing a 211 - ParticleSystem.Particle particle = particles[0]; 214 + // but accessing the first element like this and reusing it for each is OK. 215 + particle = particles[0]; 212 216 particle.axisOfRotation = Vector3.forward; 213 217 updateIndex = 0; 214 218 if (prefab.fixedAngle) { ··· 234 238 particles[updateIndex++] = particle; 235 239 } 236 240 } 241 + 237 242 updateIndex = -1; 238 243 239 244 danmakuSystem.SetParticles(particles, _activeCount); ··· 259 264 PostUpdate += delegate() 260 265 { 261 266 for (int i = 0; i < _activeCount; i++) 262 - all[i].Destroy(); 267 + all[i].DestroyImpl(); 263 268 _activeCount = 0; 264 269 _releasedCount = 0; 265 270 }; ··· 317 322 _releasedCount--; 318 323 319 324 Danmaku active = all[_activeCount]; // Last active Danmaku 320 - Danmaku released = all[_releasedCount]; // Last released Danmaku 321 - 322 - all[danmaku.PoolIndex = _releasedCount] = danmaku; 323 - all[released.PoolIndex = _activeCount] = released; 324 - all[active.PoolIndex = index] = active; 325 + if(_activeCount == _releasedCount) 326 + { 327 + all[danmaku.PoolIndex = _activeCount] = danmaku; 328 + all[active.PoolIndex = index] = active; 329 + } 330 + else 331 + { 332 + Danmaku released = all[_releasedCount]; // Last released Danmaku 333 + all[danmaku.PoolIndex = _releasedCount] = danmaku; 334 + all[released.PoolIndex = _activeCount] = released; 335 + all[active.PoolIndex = index] = active; 336 + } 337 + if (index <= updateIndex) 338 + { 339 + active.Update(); 340 + particle.position = active.position; 341 + particle.rotation = active.rotation; 342 + particle.size = active.Size; 343 + particle.color = active.Color; 344 + particles[index] = particle; 345 + } 325 346 } 326 347 #endregion 327 348 ··· 392 413 color = Color.white; 393 414 394 415 MeshFilter filter = mr.GetComponent<MeshFilter>(); 395 - Debug.Log(filter); 396 416 if (filter == null) 397 417 { 398 418 Debug.LogError("Danmaku Prefab (" + name +
+1 -1
Assets/Dependencies/DanmakU/_Core_/Editor/DanmakuInspector.cs
··· 35 35 Vector3 forward = Vector3.forward; 36 36 using (HandleUtil.With(Color.green)) { 37 37 foreach (Danmaku danmaku in Danmaku.All) { 38 - if(danmaku == null || !danmaku.IsActive) 38 + if(danmaku == null) 39 39 continue; 40 40 selectedDanmaku = danmaku; 41 41 Handles.matrix = Matrix4x4.TRS(danmaku.Position, Quaternion.Euler(0f, 0f, danmaku.Rotation), danmaku.Size * Vector3.one);