恶搞更新

Signed-off-by: TRAfoer <lhf190@outlook.com>
This commit is contained in:
2025-07-22 15:38:48 +08:00
parent 551d9c2b86
commit 2dae60d368
48 changed files with 35847 additions and 59531 deletions

View File

@@ -11,7 +11,8 @@ namespace Dreamteck.Splines
public ParticleSystem particleSystemComponent
{
get { return _particleSystem; }
set {
set
{
_particleSystem = value;
_renderer = _particleSystem.GetComponent<ParticleSystemRenderer>();
}
@@ -51,7 +52,7 @@ namespace Dreamteck.Splines
public float minCycles = 1f;
[HideInInspector]
public float maxCycles = 1f;
private Dictionary<uint, Particle> _particleDataMap = new Dictionary<uint, Particle>();
private ParticleSystem.Particle[] _particles = new ParticleSystem.Particle[0];
//private float[] _initialOffset = new float[0];
@@ -82,10 +83,10 @@ namespace Dreamteck.Splines
_particleDataMap = new Dictionary<uint, Particle>(maxParticles);
}
}
_particleCount = _particleSystem.GetParticles(_particles);
_particleSystem.GetCustomParticleData(_customParticleData, ParticleSystemCustomData.Custom1);
HashSet<uint> activeSeeds = new HashSet<uint>();
bool isLocal = _particleSystem.main.simulationSpace == ParticleSystemSimulationSpace.Local;
Transform particleSystemTransform = _particleSystem.transform;
@@ -107,7 +108,7 @@ namespace Dreamteck.Splines
if (isLocal) InverseTransformParticle(ref _particles[i], particleSystemTransform);
}
// 清理字典中已经死亡的粒子数据,防止内存无限增长
if (activeSeeds.Count < _particleDataMap.Count)
{
@@ -142,8 +143,8 @@ namespace Dreamteck.Splines
particle.velocity = trs.InverseTransformDirection(particle.velocity);
}
protected override void Reset()
{
base.Reset();
@@ -168,7 +169,7 @@ namespace Dreamteck.Splines
{
_particles[index].position = evalResult.position + particleData.threeDOffset;
}
if (apply3DRotation)
{
_particles[index].rotation3D = evalResult.rotation.eulerAngles;
@@ -182,12 +183,13 @@ namespace Dreamteck.Splines
finalOffset += Vector2.Lerp(particleData.startOffset, particleData.endOffset, 1f - lifePercent);
finalOffset.x *= scale.x;
finalOffset.y *= scale.y;
} else
}
else
{
finalOffset += particleData.startOffset;
}
}
_particles[index].position += resultRight * (finalOffset.x * evalResult.size)
_particles[index].position += resultRight * (finalOffset.x * evalResult.size)
+ evalResult.up * (finalOffset.y * evalResult.size);
_particles[index].velocity = evalResult.forward;
_particles[index].startColor = particleData.startColor * evalResult.color;
@@ -197,7 +199,7 @@ namespace Dreamteck.Splines
private void OnParticleBorn(int index, uint seed)
{
Particle newParticleData = new Particle();
Vector4 custom = _customParticleData[index];
custom.w = 1;
_customParticleData[index] = custom;
@@ -215,7 +217,7 @@ namespace Dreamteck.Splines
case EmitPoint.Beginning: percent = 0f; break;
case EmitPoint.Ending: percent = 1f; break;
case EmitPoint.Random: percent = Random.Range(0f, 1f); break;
case EmitPoint.Ordered: percent = expectedParticleCount > 0 ? (float)_birthIndex / expectedParticleCount : 0f; break;
case EmitPoint.Ordered: percent = expectedParticleCount > 0 ? (float)_birthIndex / expectedParticleCount : 0f; break;
}
Evaluate(percent, ref evalResult);
newParticleData.startColor = _particles[index].startColor;
@@ -237,11 +239,11 @@ namespace Dreamteck.Splines
{
newParticleData.threeDOffset = new Vector3(Random.Range(-width, width), Random.Range(-width, width), 0);
}
newParticleData.startOffset = circle * 0.5f;
newParticleData.endOffset = Random.insideUnitCircle * 0.5f;
_particleDataMap.Add(seed, newParticleData);
_particleDataMap.Add(seed, newParticleData);
if (!(motionType == MotionType.FollowForward || motionType == MotionType.FollowBackward))
{
Vector3 right = Vector3.Cross(evalResult.forward, evalResult.up);
@@ -283,7 +285,7 @@ namespace Dreamteck.Splines
public class Particle
{
internal float initialOffset;
internal float initialOffset;
internal Vector3 threeDOffset = Vector3.zero;
internal Vector2 startOffset = Vector2.zero;
internal Vector2 endOffset = Vector2.zero;
@@ -294,7 +296,7 @@ namespace Dreamteck.Splines
internal double GetSplinePercent(Wrap wrap, ParticleSystem.Particle particle, MotionType motionType)
{
float lifePercent = particle.remainingLifetime / particle.startLifetime;
if(motionType == MotionType.FollowBackward)
if (motionType == MotionType.FollowBackward)
{
lifePercent = 1f - lifePercent;
}
@@ -303,7 +305,7 @@ namespace Dreamteck.Splines
case Wrap.Default: return DMath.Clamp01(startPercent + (1f - lifePercent) * cycleSpeed);
case Wrap.Loop:
double loopPoint = startPercent + (1.0 - lifePercent) * cycleSpeed;
if(loopPoint > 1.0) loopPoint -= Mathf.FloorToInt((float)loopPoint);
if (loopPoint > 1.0) loopPoint -= Mathf.FloorToInt((float)loopPoint);
return loopPoint;
}
return 0.0;