Skip to content

Commit

Permalink
Merge pull request #12878 from carolhmj/fixSPSInvisibleParticles
Browse files Browse the repository at this point in the history
Fix invisible particles being visible again after a call of buildMesh
  • Loading branch information
sebavan committed Aug 16, 2022
2 parents 4fd6b73 + 3630e99 commit c8e4142
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/dev/core/src/Particles/solidParticleSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export class SolidParticleSystem implements IDisposable {
private _defaultMaterial: Material;
private _autoUpdateSubMeshes: boolean = false;
private _tmpVertex: SolidParticleVertex;
private _recomputeInvisibles: boolean = false;

/**
* Creates a SPS (Solid Particle System) object.
Expand Down Expand Up @@ -314,6 +315,7 @@ export class SolidParticleSystem implements IDisposable {
}
this._isNotBuilt = false;
this.recomputeNormals = false;
this._recomputeInvisibles = true;
return this.mesh;
}

Expand Down Expand Up @@ -1174,7 +1176,7 @@ export class SolidParticleSystem implements IDisposable {
}

// skip the computations for inactive or already invisible particles
if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
if (!particle.alive || (particle._stillInvisible && !particle.isVisible && !this._recomputeInvisibles)) {
// increment indexes for the next particle
pt = shape.length;
index += pt * 3;
Expand Down Expand Up @@ -1487,6 +1489,7 @@ export class SolidParticleSystem implements IDisposable {
if (this._autoUpdateSubMeshes) {
this.computeSubMeshes();
}
this._recomputeInvisibles = false;
this.afterUpdateParticles(start, end, update);
return this;
}
Expand Down

0 comments on commit c8e4142

Please sign in to comment.