Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion away3d/animators/ParticleAnimationSet.hx
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ class ParticleAnimationSet extends AnimationSetBase implements IAnimationSet
animationSubGeometry.createVertexData(subGeometry.numVertices, _totalLenOfOneVertex);
}

calculateParticleOffsets(mesh);

if (newAnimationSubGeometry == false)
return;

Expand Down Expand Up @@ -344,6 +346,12 @@ class ParticleAnimationSet extends AnimationSetBase implements IAnimationSet
break;
}
}

if(j < animationSubGeometry.animationParticleOffset + animationSubGeometry.animationParticles.length) {
j++;
continue;
}

numVertices = particle.numVertices;
vertexData = animationSubGeometry.vertexData;
vertexLength = numVertices*_totalLenOfOneVertex;
Expand All @@ -366,7 +374,6 @@ class ParticleAnimationSet extends AnimationSetBase implements IAnimationSet

counterForVertex += _totalLenOfOneVertex;
}

}

//store particle properties if they need to be retreived for dynamic local nodes
Expand All @@ -382,5 +389,24 @@ class ParticleAnimationSet extends AnimationSetBase implements IAnimationSet
//next particle
i++;
}

calculateParticleOffsets(mesh);
}

/**
* Will throw an error if a sub-mesh lacks an AnimationSubGeometry; only
* call this after creating them all.
*/
private function calculateParticleOffsets(mesh:Mesh):Void
{
var particleOffset:Int = 0;
for (subMesh in mesh.subMeshes) {
var subGeometry:AnimationSubGeometry = mesh.shareAnimationGeometry
? _animationSubGeometries[subMesh.subGeometry]
: subMesh.animationSubGeometry;

subGeometry.animationParticleOffset = particleOffset;
particleOffset += subGeometry.animationParticles.length;
}
}
}
1 change: 1 addition & 0 deletions away3d/animators/ParticleAnimator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class ParticleAnimator extends AnimatorBase implements IAnimator
animatorSubGeometry.createVertexData(subGeometry.numVertices, _totalLenOfOneVertex);

//pass the particles data to the animator subGeometry
animatorSubGeometry.animationParticleOffset = subMesh.animationSubGeometry.animationParticleOffset;
animatorSubGeometry.animationParticles = subMesh.animationSubGeometry.animationParticles;
}
}
1 change: 1 addition & 0 deletions away3d/animators/data/AnimationSubGeometry.hx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class AnimationSubGeometry

public var previousTime:Float = Math.NEGATIVE_INFINITY;

public var animationParticleOffset:Int = 0;
public var animationParticles:Vector<ParticleAnimationData> = new Vector<ParticleAnimationData>();

public function new()
Expand Down
12 changes: 9 additions & 3 deletions away3d/animators/states/ParticleStateBase.hx
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,19 @@ class ParticleStateBase extends AnimationStateBase
var animationParticle:ParticleAnimationData = null;

// var numParticles:uint = _positions.length/dataLength;
var numParticles:Int = _dynamicProperties.length;
var i:Int = 0;
var particleOffset:Int = animationSubGeometry.animationParticleOffset;
var numParticles:Int = animationParticles.length;
if(numParticles > _dynamicProperties.length - particleOffset) {
numParticles = _dynamicProperties.length - particleOffset;
}

var i:Int = particleOffset;
var j:Int = 0;
var k:Int = 0;

//loop through all particles
while (i < numParticles) {
while (i < particleOffset + numParticles) {
data = _dynamicProperties[i];
//loop through each particle data for the current particle
while (j < numParticles && (animationParticle = animationParticles[j]).index == i) {
data = _dynamicProperties[i];
Expand Down
Loading