MCPcopy
hub / github.com/magcius/noclip.website / Initializer_AlphaRandom

Class Initializer_AlphaRandom

src/SourceEngine/ParticleSystem.ts:330–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328}
329
330class Initializer_AlphaRandom extends ModuleBase {
331 private readonly min: number;
332 private readonly max: number;
333 private readonly randomExponent: number;
334
335 constructor(elem: DMX.DMXElement) {
336 super(elem);
337 this.min = getAttribValue(elem, `alpha_min`, DMX.DMXAttributeType.Int, 0xFF) / 0xFF;
338 this.max = getAttribValue(elem, `alpha_max`, DMX.DMXAttributeType.Int, 0xFF) / 0xFF;
339 this.randomExponent = getAttribValue(elem, `alpha_random_exponent`, DMX.DMXAttributeType.Float, 1);
340 }
341
342 public override streamWrite(): StreamMask {
343 return StreamMask.Alpha;
344 }
345
346 public init(system: ParticleSystemInstance, p: number): void {
347 if (!system.hasStream(StreamMask.Alpha))
348 return;
349
350 const alpha = randRangeExp(system, this.min, this.max, this.randomExponent);
351
352 const data = system.particleDataF32;
353 data[system.getStreamOffs(StreamMask.Alpha, p)] = alpha;
354 }
355}
356
357class Initializer_ColorRandom extends ModuleBase {
358 private readonly color1: Readonly<Color>;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected