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

Class Initializer_RotationRandom

src/SourceEngine/ParticleSystem.ts:503–530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

501}
502
503class Initializer_RotationRandom extends ModuleBase {
504 private readonly initial: number;
505 private readonly min: number;
506 private readonly max: number;
507 private readonly randomExponent: number;
508
509 constructor(elem: DMX.DMXElement) {
510 super(elem);
511 this.initial = getAttribValue(elem, `rotation_initial`, DMX.DMXAttributeType.Float, 0) * MathConstants.DEG_TO_RAD;
512 this.min = getAttribValue(elem, `rotation_offset_min`, DMX.DMXAttributeType.Float, 0) * MathConstants.DEG_TO_RAD;
513 this.max = getAttribValue(elem, `rotation_offset_max`, DMX.DMXAttributeType.Float, 360) * MathConstants.DEG_TO_RAD;
514 this.randomExponent = getAttribValue(elem, `rotation_random_exponent`, DMX.DMXAttributeType.Float, 1);
515 }
516
517 public override streamWrite(): StreamMask {
518 return StreamMask.Rotation;
519 }
520
521 public init(system: ParticleSystemInstance, p: number): void {
522 if (!system.hasStream(StreamMask.Rotation))
523 return;
524
525 const rotation = this.initial + randRangeExp(system, this.min, this.max, this.randomExponent);
526
527 const data = system.particleDataF32;
528 data[system.getStreamOffs(StreamMask.Rotation, p)] = rotation;
529 }
530}
531
532class Initializer_SequenceRandom extends ModuleBase {
533 private readonly min: number;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected