forked from LeenkxTeam/LNXSDK
Update
This commit is contained in:
@ -139,11 +139,6 @@ class ParticleSystemCPU {
|
||||
scaleElementsCount = getRampElementsLength();
|
||||
scaleRampSizeFactor = getRampSizeFactor();
|
||||
|
||||
Scene.active.notifyOnInit(function () {
|
||||
var i: Int;
|
||||
for (i in 0...count) addToPool();
|
||||
});
|
||||
|
||||
switch (type) {
|
||||
case 0: // Emission
|
||||
loopAnim = {
|
||||
@ -163,16 +158,19 @@ class ParticleSystemCPU {
|
||||
if (loop) start();
|
||||
}
|
||||
}
|
||||
|
||||
Scene.active.notifyOnInit(function () {
|
||||
if (autoStart) start();
|
||||
});
|
||||
case 1: // Hair
|
||||
Scene.active.notifyOnInit(function () {
|
||||
var i: Int;
|
||||
for (i in 0...count) spawnParticle();
|
||||
});
|
||||
default:
|
||||
}
|
||||
|
||||
Scene.active.notifyOnInit(function () {
|
||||
if (autoStart) start();
|
||||
for (i in 0...count) addToPool();
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -370,17 +368,6 @@ class ParticleSystemCPU {
|
||||
particlePhysics.set(o, physics);
|
||||
o.transform.buildMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
function setVelocityHair(object: Object, velocity: Vec4, randQuat: Quat, phaseQuat: Quat) {
|
||||
var dir: Vec4 = velocity.clone().normalize();
|
||||
var yaw: FastFloat = Math.atan2(-dir.x, dir.y);
|
||||
var pitch: FastFloat = Math.asin(dir.z);
|
||||
var targetRot: Quat = new Quat().fromEuler(pitch, 0, yaw);
|
||||
|
||||
targetRot.mult(randQuat);
|
||||
object.transform.rot.setFrom(targetRot.mult(phaseQuat));
|
||||
}
|
||||
|
||||
function updateParticles() {
|
||||
for (particle => physics in particlePhysics) {
|
||||
@ -415,13 +402,22 @@ class ParticleSystemCPU {
|
||||
}
|
||||
}
|
||||
|
||||
function setVelocityHair(object: Object, velocity: Vec4, randQuat: Quat, phaseQuat: Quat) {
|
||||
var dir: Vec4 = velocity.clone().normalize();
|
||||
var yaw: FastFloat = Math.atan2(-dir.x, dir.y);
|
||||
var pitch: FastFloat = Math.asin(dir.z);
|
||||
var targetRot: Quat = new Quat().fromEuler(pitch, 0, yaw);
|
||||
|
||||
targetRot.mult(randQuat);
|
||||
object.transform.rot.setFrom(targetRot.mult(phaseQuat));
|
||||
}
|
||||
|
||||
// Linear interpolation
|
||||
function interpolateRampValue(normalizedAge: FastFloat, positions: Array<FastFloat>, colors: Array<FastFloat>): FastFloat {
|
||||
if (positions.length == 0) return 1.0;
|
||||
if (normalizedAge <= positions[0]) return colors[0];
|
||||
if (normalizedAge >= positions[positions.length - 1]) return colors[colors.length - 1];
|
||||
|
||||
var i: Int;
|
||||
for (i in 0...(positions.length - 1)) {
|
||||
if (normalizedAge >= positions[i] && normalizedAge <= positions[i + 1]) {
|
||||
var t: FastFloat = (normalizedAge - positions[i]) / (positions[i + 1] - positions[i]);
|
||||
@ -535,6 +531,7 @@ class ParticleSystemCPU {
|
||||
var v = c.sub(a);
|
||||
return a.add(u.mult(x).add(v.mult(y)));
|
||||
}
|
||||
}
|
||||
|
||||
typedef TParticlePhysics = {
|
||||
var velocity: Vec4;
|
||||
@ -547,5 +544,4 @@ class ParticleSystemCPU {
|
||||
var rampColors: Array<FastFloat>;
|
||||
var scaleRampSizeFactor: FastFloat;
|
||||
}
|
||||
}
|
||||
#end
|
||||
|
||||
Reference in New Issue
Block a user