Skip to content

Commit 618dae7

Browse files
authored
IParticleSystem: add doNotSerialize (#17342)
This commit adds an optional doNotSerialize to IParticleSystem, makes it possible to control if a particle system should be serialized. The `doNotSerialize` is also added to `ParticleSystem` and `GPUParticleSystem`, but not added to `SubEmitter`, `SubEmitter.particleSystem.doNotSerialize` is checked instead.
1 parent 62472d9 commit 618dae7

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

packages/dev/core/src/Misc/sceneSerializer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,10 @@ export class SceneSerializer {
338338
// Particles Systems
339339
serializationObject.particleSystems = [];
340340
for (index = 0; index < scene.particleSystems.length; index++) {
341-
serializationObject.particleSystems.push(scene.particleSystems[index].serialize(false));
341+
const particleSystem = scene.particleSystems[index];
342+
if (!particleSystem.doNotSerialize) {
343+
serializationObject.particleSystems.push(particleSystem.serialize(false));
344+
}
342345
}
343346

344347
// Post processes

packages/dev/core/src/Particles/IParticleSystem.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@ export interface IParticleSystem {
299299
*/
300300
isNodeGenerated: boolean;
301301

302+
/**
303+
* Specifies if the particle system should be serialized
304+
*/
305+
doNotSerialize?: boolean;
306+
302307
/**
303308
* Gets the maximum number of particles active at the same time.
304309
* @returns The max number of active particles.

packages/dev/core/src/Particles/gpuParticleSystem.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ export class GPUParticleSystem extends BaseParticleSystem implements IDisposable
109109
private _platform: IGPUParticleSystemPlatform;
110110
private _rebuildingAfterContextLost = false;
111111

112+
/**
113+
* Specifies if the particle system should be serialized
114+
*/
115+
public doNotSerialize = false;
116+
112117
/**
113118
* Gets a boolean indicating if the GPU particles can be rendered on current browser
114119
*/

packages/dev/core/src/Particles/particleSystem.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ export class ParticleSystem extends ThinParticleSystem {
8282
* The current active Sub-systems, this property is used by the root particle system only.
8383
*/
8484
public activeSubSystems: Array<ParticleSystem>;
85+
86+
/**
87+
* Specifies if the particle system should be serialized
88+
*/
89+
public doNotSerialize = false;
90+
8591
/**
8692
* Creates a Point Emitter for the particle system (emits directly from the emitter position)
8793
* @param direction1 Particles are emitted between the direction1 and direction2 from within the box
@@ -878,7 +884,9 @@ export class ParticleSystem extends ThinParticleSystem {
878884
for (const subs of this._subEmitters) {
879885
const cell = [];
880886
for (const sub of subs) {
881-
cell.push(sub.serialize(serializeTexture));
887+
if (!sub.particleSystem.doNotSerialize) {
888+
cell.push(sub.serialize(serializeTexture));
889+
}
882890
}
883891

884892
serializationObject.subEmitters.push(cell);

packages/dev/core/src/Particles/particleSystemSet.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ export class ParticleSystemSet implements IDisposable {
137137

138138
result.systems = [];
139139
for (const system of this.systems) {
140-
result.systems.push(system.serialize(serializeTexture));
140+
if (!system.doNotSerialize) {
141+
result.systems.push(system.serialize(serializeTexture));
142+
}
141143
}
142144

143145
if (this._emitterNode) {

0 commit comments

Comments
 (0)