Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export class BasicPositionUpdateBlock extends NodeParticleBlock {
const processPosition = (particle: Particle) => {
state.particleContext = particle;
state.systemContext = system;
particle.direction.scaleToRef(system._directionScale, system._scaledDirection);
particle.position.addInPlace(system._scaledDirection);
particle.direction.scaleToRef(particle._directionScale, particle._scaledDirection);
particle.position.addInPlace(particle._scaledDirection);
};

const positionProcessing = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ export class NodeParticleBuildState {
case NodeParticleContextualSources.Direction:
return this.particleContext.direction;
case NodeParticleContextualSources.ScaledDirection:
this.particleContext.direction.scaleToRef(this.systemContext._directionScale, this.systemContext._scaledDirection);
return this.systemContext._scaledDirection;
this.particleContext.direction.scaleToRef(this.particleContext._directionScale, this.particleContext._scaledDirection);
return this.particleContext._scaledDirection;
case NodeParticleContextualSources.Color:
return this.particleContext.color;
case NodeParticleContextualSources.InitialColor:
Expand Down Expand Up @@ -149,8 +149,8 @@ export class NodeParticleBuildState {
this.particleContext.colorStep.scaleToRef(this.systemContext._scaledUpdateSpeed, this.systemContext._scaledColorStep);
return this.systemContext._scaledColorStep;
case NodeParticleContextualSources.LocalPositionUpdated:
this.particleContext.direction.scaleToRef(this.systemContext._directionScale, this.systemContext._scaledDirection);
this.particleContext._localPosition!.addInPlace(this.systemContext._scaledDirection);
this.particleContext.direction.scaleToRef(this.particleContext._directionScale, this.particleContext._scaledDirection);
this.particleContext._localPosition!.addInPlace(this.particleContext._scaledDirection);
Vector3.TransformCoordinatesToRef(this.particleContext._localPosition!, this.systemContext._emitterWorldMatrix, this.particleContext.position);
return this.particleContext.position;
}
Expand Down
6 changes: 6 additions & 0 deletions packages/dev/core/src/Particles/particle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ export class Particle {
/** @internal */
public _currentVelocity2 = 0;

/** @internal */
public _directionScale: number;

/** @internal */
public _scaledDirection = Vector3.Zero();

/** @internal */
public _currentLimitVelocityGradient: Nullable<FactorGradient>;
/** @internal */
Expand Down
12 changes: 6 additions & 6 deletions packages/dev/core/src/Particles/thinParticleSystem.function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function _ProcessVelocityGradients(particle: Particle, system: ThinPartic
particle._currentVelocity2 = (<FactorGradient>nextGradient).getFactor();
particle._currentVelocityGradient = <FactorGradient>currentGradient;
}
system._directionScale *= Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
particle._directionScale *= Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
});
}

Expand All @@ -143,8 +143,8 @@ export function _ProcessLimitVelocityGradients(particle: Particle, system: ThinP
}

/** @internal */
export function _ProcessDirection(particle: Particle, system: ThinParticleSystem) {
particle.direction.scaleToRef(system._directionScale, system._scaledDirection);
export function _ProcessDirection(particle: Particle) {
particle.direction.scaleToRef(particle._directionScale, particle._scaledDirection);
}

/** Position */
Expand Down Expand Up @@ -172,10 +172,10 @@ export function _CreateIsLocalData(particle: Particle, system: ThinParticleSyste
/** @internal */
export function _ProcessPosition(particle: Particle, system: ThinParticleSystem) {
if (system.isLocal && particle._localPosition) {
particle._localPosition!.addInPlace(system._scaledDirection);
particle._localPosition!.addInPlace(particle._scaledDirection);
Vector3.TransformCoordinatesToRef(particle._localPosition!, system._emitterWorldMatrix, particle.position);
} else {
particle.position.addInPlace(system._scaledDirection);
particle.position.addInPlace(particle._scaledDirection);
}
}

Expand Down Expand Up @@ -204,7 +204,7 @@ export function _ProcessDragGradients(particle: Particle, system: ThinParticleSy

const drag = Lerp(particle._currentDrag1, particle._currentDrag2, scale);

system._scaledDirection.scaleInPlace(1.0 - drag);
particle._scaledDirection.scaleInPlace(1.0 - drag);
});
}

Expand Down
6 changes: 1 addition & 5 deletions packages/dev/core/src/Particles/thinParticleSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,6 @@ export class ThinParticleSystem extends BaseParticleSystem implements IDisposabl
/** @internal */
public _colorDiff = new Color4(0, 0, 0, 0);
/** @internal */
public _scaledDirection = Vector3.Zero();
/** @internal */
public _scaledGravity = Vector3.Zero();
private _currentRenderId = -1;
private _alive: boolean;
Expand Down Expand Up @@ -283,8 +281,6 @@ export class ThinParticleSystem extends BaseParticleSystem implements IDisposabl
private _noiseCreation: _IExecutionQueueItem;
private _createQueueStart: Nullable<_IExecutionQueueItem> = null;

/** @internal */
public _directionScale: number;
/** @internal */
public _tempScaledUpdateSpeed: number;
/** @internal */
Expand Down Expand Up @@ -716,7 +712,7 @@ export class ThinParticleSystem extends BaseParticleSystem implements IDisposabl
}

this._ratio = particle.age / particle.lifeTime;
this._directionScale = this._tempScaledUpdateSpeed;
particle._directionScale = this._tempScaledUpdateSpeed;

// Processing queue
let currentQueueItem = this._updateQueueStart;
Expand Down